]> git.hungrycats.org Git - linux/commitdiff
Btrfs: deal with error on secondary log properly
authorJosef Bacik <jbacik@fb.com>
Tue, 25 Aug 2015 17:01:40 +0000 (13:01 -0400)
committerZygo Blaxell <zblaxell@thirteen.furryterror.org>
Sat, 17 Oct 2015 03:10:59 +0000 (23:10 -0400)
If we have an fsync at the same time in two seperate subvolumes we could end up
with the tree log pointing at invalid blocks.  We need to notice if our writeout
failed in anyway, if it did then we need to do a full transaction commit and
return an error on the subvolume that gave us the io error.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
(cherry picked from commit d3e532cc080acaf30bac093998e4db4901cf690b)
(cherry picked from commit 6ebeedeb4589872bbae0c52b5981b3a87260543f)
(cherry picked from commit 30c498842353b0def31f5bca8934f9f23481119d)

fs/btrfs/file.c
fs/btrfs/tree-log.c

index b823fac91c9289bc67d3bb5191f4ce96e38294ac..c8f49f59814c9da5e2d10f2695d3e9b0527a480f 100644 (file)
@@ -2054,6 +2054,10 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
                        if (!ret) {
                                ret = btrfs_end_transaction(trans, root);
                                goto out;
+                       } else if (ctx.io_err) {
+                               btrfs_end_transaction(trans, root);
+                               ret = ctx.io_err;
+                               goto out;
                        }
                }
                if (!full_sync) {
index 448875b06d1ff2dbb676f4db24172965b07150fe..55443ce4c8794389c62ab50e52203eb4ca4519a7 100644 (file)
@@ -2859,6 +2859,10 @@ int btrfs_sync_log(struct btrfs_trans_handle *trans,
                ret = btrfs_wait_marked_extents(log, &log->dirty_log_pages,
                                                mark);
                btrfs_wait_logged_extents(trans, log, log_transid);
+               if (ret) {
+                       btrfs_set_log_full_commit(root->fs_info, trans);
+                       ctx->io_err = ret;
+               }
                wait_log_commit(log_root_tree,
                                root_log_ctx.log_transid);
                mutex_unlock(&log_root_tree->log_mutex);