From a29cb4b9f88af9905c0ab9497330eac64456dfdd Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Mon, 11 Jul 2022 23:06:17 -0400 Subject: [PATCH] cmd_device_set_state: use buffered IO for writing superblock The layout may be unaligned on 4k sector devices - but there's no reason we need to use direct IO here. Signed-off-by: Kent Overstreet --- cmd_device.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd_device.c b/cmd_device.c index 6a552af2..e3c5d513 100644 --- a/cmd_device.c +++ b/cmd_device.c @@ -418,9 +418,12 @@ int cmd_device_set_state(int argc, char *argv[]) le64_add_cpu(&sb.sb->seq, 1); - bch2_super_write(sb.bdev->bd_fd, sb.sb); + bch2_super_write(sb.bdev->bd_buffered_fd, sb.sb); + ret = fsync(sb.bdev->bd_buffered_fd); + if (ret) + fprintf(stderr, "error writing superblock: fsync error (%m)"); bch2_free_super(&sb); - return 0; + return ret; } char *fs_path = arg_pop();