aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-log.c
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@fusionio.com>2013-09-11 09:36:30 -0400
committerChris Mason <chris.mason@fusionio.com>2013-09-21 11:05:24 -0400
commitde2b530bfb683fd75c31ab65ec42949f5f7a5b58 (patch)
tree5b2b03e06b93c37472c18b161dcb0dd4e6c2f33b /fs/btrfs/tree-log.c
parent573aecafca1cf7a974231b759197a1aebcf39c2a (diff)
Btrfs: actually log directory we are fsync()'ing
If you just create a directory and then fsync that directory and then pull the power plug you will come back up and the directory will not be there. That is because we won't actually create directories if we've logged files inside of them since they will be created on replay, but in this check we will set our logged_trans of our current directory if it happens to be a directory, making us think it doesn't need to be logged. Fix the logic to only do this to parent directories. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/tree-log.c')
-rw-r--r--fs/btrfs/tree-log.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 0d9613c3f5e5..aaa2e2b67478 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -3805,6 +3805,7 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans,
3805 int ret = 0; 3805 int ret = 0;
3806 struct btrfs_root *root; 3806 struct btrfs_root *root;
3807 struct dentry *old_parent = NULL; 3807 struct dentry *old_parent = NULL;
3808 struct inode *orig_inode = inode;
3808 3809
3809 /* 3810 /*
3810 * for regular files, if its inode is already on disk, we don't 3811 * for regular files, if its inode is already on disk, we don't
@@ -3824,7 +3825,14 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans,
3824 } 3825 }
3825 3826
3826 while (1) { 3827 while (1) {
3827 BTRFS_I(inode)->logged_trans = trans->transid; 3828 /*
3829 * If we are logging a directory then we start with our inode,
3830 * not our parents inode, so we need to skipp setting the
3831 * logged_trans so that further down in the log code we don't
3832 * think this inode has already been logged.
3833 */
3834 if (inode != orig_inode)
3835 BTRFS_I(inode)->logged_trans = trans->transid;
3828 smp_mb(); 3836 smp_mb();
3829 3837
3830 if (BTRFS_I(inode)->last_unlink_trans > last_committed) { 3838 if (BTRFS_I(inode)->last_unlink_trans > last_committed) {