diff mbox

Btrfs: Allow creation of inline extent whose size is equal to blocksize.

Message ID 1429103787-21888-1-git-send-email-chandan@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Chandan Rajendra April 15, 2015, 1:16 p.m. UTC
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 mbox

Patch

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;