Skip to content

Commit

Permalink
Btrfs: actually log directory we are fsync()'ing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Josef Bacik authored and Chris Mason committed Sep 21, 2013
1 parent 573aeca commit de2b530
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fs/btrfs/tree-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -3805,6 +3805,7 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans,
int ret = 0;
struct btrfs_root *root;
struct dentry *old_parent = NULL;
struct inode *orig_inode = inode;

/*
* for regular files, if its inode is already on disk, we don't
Expand All @@ -3824,7 +3825,14 @@ static noinline int check_parent_dirs_for_sync(struct btrfs_trans_handle *trans,
}

while (1) {
BTRFS_I(inode)->logged_trans = trans->transid;
/*
* If we are logging a directory then we start with our inode,
* not our parents inode, so we need to skipp setting the
* logged_trans so that further down in the log code we don't
* think this inode has already been logged.
*/
if (inode != orig_inode)
BTRFS_I(inode)->logged_trans = trans->transid;
smp_mb();

if (BTRFS_I(inode)->last_unlink_trans > last_committed) {
Expand Down

0 comments on commit de2b530

Please sign in to comment.