linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: log entire range for FULL_SYNC
@ 2015-04-15 18:33 Josef Bacik
  0 siblings, 0 replies; only message in thread
From: Josef Bacik @ 2015-04-15 18:33 UTC (permalink / raw)
  To: linux-btrfs

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-15 18:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-15 18:33 [PATCH] Btrfs: log entire range for FULL_SYNC Josef Bacik

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).