linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Btrfs: Allow creation of inline extent whose size is equal to blocksize.
@ 2015-04-15 13:16 Chandan Rajendra
  0 siblings, 0 replies; only message in thread
From: Chandan Rajendra @ 2015-04-15 13:16 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Chandan Rajendra, chandan

With the current code, the following command (executed on a filesystem with 4k
as the block size) creates a file with a regular extent:
$ xfs_io -f -c "pwrite 0 4096" /mnt/file-0.bin; sync;

This commit fixes the issue by checking if 'actual_end - 1' is on a file
offset which is a multiple of block size.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
---
 fs/btrfs/inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 97bc1ff..b0925ba 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -259,8 +259,8 @@ static noinline int cow_file_range_inline(struct btrfs_root *root,
 	if (start > 0 ||
 	    actual_end > PAGE_CACHE_SIZE ||
 	    data_len > BTRFS_MAX_INLINE_DATA_SIZE(root) ||
-	    (!compressed_size &&
-	    (actual_end & (root->sectorsize - 1)) == 0) ||
+	    (!compressed_size && (actual_end > 1) &&
+		    ((actual_end - 1) & (root->sectorsize - 1)) == 0) ||
 	    end + 1 < isize ||
 	    data_len > root->fs_info->max_inline) {
 		return 1;
-- 
2.1.0


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

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

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-15 13:16 [PATCH] Btrfs: Allow creation of inline extent whose size is equal to blocksize Chandan Rajendra

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