Skip to content

Commit

Permalink
btrfs: do commit in sync_fs if there are pending changes
Browse files Browse the repository at this point in the history
If a pending change is requested, it's not processed unless there is a
transaction commit about to happen, not even after sync or SYNC_FS
ioctl. For example a remount that toggles the inode_cache option will
not take effect after sync on a quiescent filesystem.

Signed-off-by: David Sterba <dsterba@suse.cz>
  • Loading branch information
David Sterba committed Nov 12, 2014
1 parent 572d9ab commit 6b5fe46
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,9 +993,17 @@ int btrfs_sync_fs(struct super_block *sb, int wait)
trans = btrfs_attach_transaction_barrier(root);
if (IS_ERR(trans)) {
/* no transaction, don't bother */
if (PTR_ERR(trans) == -ENOENT)
return 0;
return PTR_ERR(trans);
if (PTR_ERR(trans) == -ENOENT) {
/*
* Exit unless we have some pending changes
* that need to go through commit
*/
if (fs_info->pending_changes == 0)
return 0;
trans = btrfs_start_transaction(root, 0);
} else {
return PTR_ERR(trans);
}
}
return btrfs_commit_transaction(trans, root);
}
Expand Down

0 comments on commit 6b5fe46

Please sign in to comment.