Skip to content

Commit f1569c4

Browse files
naotakdave
authored andcommitted
btrfs: disable fallocate in ZONED mode
fallocate() is implemented by reserving actual extent instead of reservations. This can result in exposing the sequential write constraint of host-managed zoned block devices to the application, which would break the POSIX semantic for the fallocated file. To avoid this, report fallocate() as not supported when in ZONED mode for now. In the future, we may be able to implement "in-memory" fallocate() in ZONED mode by utilizing space_info->bytes_may_use or similar, so this returns EOPNOTSUPP. Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent d206e9c commit f1569c4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/btrfs/file.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3308,6 +3308,10 @@ static long btrfs_fallocate(struct file *file, int mode,
33083308
int blocksize = btrfs_inode_sectorsize(BTRFS_I(inode));
33093309
int ret;
33103310

3311+
/* Do not allow fallocate in ZONED mode */
3312+
if (btrfs_is_zoned(btrfs_sb(inode->i_sb)))
3313+
return -EOPNOTSUPP;
3314+
33113315
alloc_start = round_down(offset, blocksize);
33123316
alloc_end = round_up(offset + len, blocksize);
33133317
cur_offset = alloc_start;

0 commit comments

Comments
 (0)