linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: drop dir i_size when adding new names on replay
@ 2013-09-11 18:18 Josef Bacik
  2013-09-11 18:56 ` Josef Bacik
  0 siblings, 1 reply; 2+ messages in thread
From: Josef Bacik @ 2013-09-11 18:18 UTC (permalink / raw)
  To: linux-btrfs

So if we have dir_index items in the log that means we also have the inode item
as well, which means that the inode's i_size is correct.  However when we
process dir_index'es we call btrfs_add_link() which will increase the
directory's i_size for the new entry.  So to fix this just drop the name len
size before we call btrfs_add_link() so the i_size ends out properly.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
---
 fs/btrfs/tree-log.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index c91309d..f0d34f5 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1497,6 +1497,12 @@ static noinline int insert_one_name(struct btrfs_trans_handle *trans,
 		iput(inode);
 		return -EIO;
 	}
+	/*
+	 * We need to drop the name_len since add_link we re-add the size.  If
+	 * we have the dir_index items then we had to have had the inode in the
+	 * log which means we have the correct i_size.
+	 */
+	btrfs_i_size_write(dir, dir->i_size - (name_len * 2));
 	ret = btrfs_add_link(trans, dir, inode, name, name_len, 1, index);
 
 	/* FIXME, put inode into FIXUP list */
-- 
1.7.7.6


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-11 18:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11 18:18 [PATCH] Btrfs: drop dir i_size when adding new names on replay Josef Bacik
2013-09-11 18:56 ` Josef Bacik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).