linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Josef Bacik <jbacik@fb.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] Btrfs: deal with error on secondary log properly
Date: Tue, 25 Aug 2015 13:09:43 -0400	[thread overview]
Message-ID: <1440522583-32120-1-git-send-email-jbacik@fb.com> (raw)

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>
---
 fs/btrfs/file.c     | 4 ++++
 fs/btrfs/tree-log.c | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index b823fac..c8f49f5 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -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) {
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1bbaace..b4f15f5 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2857,6 +2857,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);
-- 
2.1.0


             reply	other threads:[~2015-08-25 17:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-25 17:09 Josef Bacik [this message]
2015-08-26  2:06 ` [PATCH] Btrfs: deal with error on secondary log properly Liu Bo
2015-08-26 19:06   ` Josef Bacik
2015-08-28 13:23     ` Filipe David Manana
2015-08-28 13:54       ` Josef Bacik
2015-08-28  2:45 ` Liu Bo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1440522583-32120-1-git-send-email-jbacik@fb.com \
    --to=jbacik@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).