]> git.hungrycats.org Git - linux/commitdiff
btrfs: do commit in sync_fs if there are pending changes
authorDavid Sterba <dsterba@suse.cz>
Fri, 28 Mar 2014 16:38:48 +0000 (17:38 +0100)
committerZygo Blaxell <zblaxell@serenity.furryterror.org>
Fri, 23 Jan 2015 02:50:01 +0000 (21:50 -0500)
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>
(cherry picked from commit 6b5fe46dfa52441f49c7432b1c1b1cb767834708)

fs/btrfs/super.c

index 889968ffbf5aa7a8683488f3a63f41d8a9b87827..60cde38deb924f406391ea9336237e85dea95ece 100644 (file)
@@ -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);
 }