From: Josef Bacik <jbacik@fb.com>
To: <linux-btrfs@vger.kernel.org>
Subject: [PATCH] Btrfs: log entire range for FULL_SYNC
Date: Wed, 15 Apr 2015 14:33:21 -0400 [thread overview]
Message-ID: <1429122801-3096-1-git-send-email-jbacik@fb.com> (raw)
My log writes test uncovered a corruption that could happen with fsx'es mmap
write. It does an msync(MS_SYNC) after every mmap write, which turns into a
vfs_fsync_range() for the range we wrote. However if we've truncated before
this we will set FULL_SYNC on the inode, so if we've truncated up and then only
log up to the range we've inlcluded then fsck complains because i_size is > the
last extent in the flie. Fix this by making sure we log the entire file and not
just the range requested. With this patch we now pass the log writes test.
Thanks,
Signed-off-by: Josef Bacik <jbacik@fb.com>
---
fs/btrfs/file.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 23b6e03..46c7227 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1901,8 +1901,13 @@ int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
* start and finish before we start logging the inode, so that
* all extents are persisted and the respective file extent
* items are in the fs/subvol btree.
+ *
+ * We also need to do the whole range, we set FULL_SYNC if we
+ * truncated, and we could have some previous version of the
+ * inode in the log, so we need to write and log all the things.
*/
- ret = btrfs_wait_ordered_range(inode, start, end - start + 1);
+ end = (u64)-1;
+ ret = btrfs_wait_ordered_range(inode, start, end);
} else {
/*
* Start any new ordered operations before starting to log the
--
1.8.3.1
reply other threads:[~2015-04-15 18:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1429122801-3096-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).