diff mbox series

btrfs-progs: use btrfs_pwrite in place of pwrite

Message ID 20211020065701.375186-1-naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: use btrfs_pwrite in place of pwrite | expand

Commit Message

Naohiro Aota Oct. 20, 2021, 6:57 a.m. UTC
We need to use btrfs_pwrite instead of pwrite to ensure the writing to
O_DIRECT file works.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 mkfs/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Josef Bacik Oct. 20, 2021, 1:48 p.m. UTC | #1
On Wed, Oct 20, 2021 at 03:57:01PM +0900, Naohiro Aota wrote:
> We need to use btrfs_pwrite instead of pwrite to ensure the writing to
> O_DIRECT file works.
> 
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef
David Sterba Oct. 20, 2021, 5:01 p.m. UTC | #2
On Wed, Oct 20, 2021 at 03:57:01PM +0900, Naohiro Aota wrote:
> We need to use btrfs_pwrite instead of pwrite to ensure the writing to
> O_DIRECT file works.
> 
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>

Added to devel, though it does not fix the problem with creating zoned
on a file image.
diff mbox series

Patch

diff --git a/mkfs/common.c b/mkfs/common.c
index 5c8d6ac13a3b..ca5393d56f3f 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -181,8 +181,8 @@  static int create_free_space_tree(int fd, struct btrfs_mkfs_config *cfg,
 	btrfs_set_header_nritems(buf, nritems);
 	csum_tree_block_size(buf, btrfs_csum_type_size(cfg->csum_type), 0,
 			     cfg->csum_type);
-	ret = pwrite(fd, buf->data, cfg->nodesize,
-		     cfg->blocks[MKFS_FREE_SPACE_TREE]);
+	ret = btrfs_pwrite(fd, buf->data, cfg->nodesize,
+			   cfg->blocks[MKFS_FREE_SPACE_TREE], cfg->zone_size);
 	if (ret != cfg->nodesize)
 		return ret < 0 ? -errno : -EIO;
 	return 0;