]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
zloop: advertise a volatile write cache
authorChristoph Hellwig <hch@lst.de>
Tue, 24 Feb 2026 14:21:44 +0000 (06:21 -0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 24 Feb 2026 21:50:18 +0000 (14:50 -0700)
Zloop is file system backed and thus needs to sync the underlying file
system to persist data.  Set BLK_FEAT_WRITE_CACHE so that the block
layer actually send flush commands, and fix the flush implementation
as sync_filesystem requires s_umount to be held and the code currently
misses that.

Fixes: eb0570c7df23 ("block: new zoned loop block device driver")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/zloop.c

index 8e334f5025fc0aedd1e6e28558941ab6fc7d6cd5..ae9bf2a85c21cbe484d4e4aca5f5114c55a1b635 100644 (file)
@@ -542,6 +542,21 @@ out:
        zloop_put_cmd(cmd);
 }
 
+/*
+ * Sync the entire FS containing the zone files instead of walking all files.
+ */
+static int zloop_flush(struct zloop_device *zlo)
+{
+       struct super_block *sb = file_inode(zlo->data_dir)->i_sb;
+       int ret;
+
+       down_read(&sb->s_umount);
+       ret = sync_filesystem(sb);
+       up_read(&sb->s_umount);
+
+       return ret;
+}
+
 static void zloop_handle_cmd(struct zloop_cmd *cmd)
 {
        struct request *rq = blk_mq_rq_from_pdu(cmd);
@@ -562,11 +577,7 @@ static void zloop_handle_cmd(struct zloop_cmd *cmd)
                zloop_rw(cmd);
                return;
        case REQ_OP_FLUSH:
-               /*
-                * Sync the entire FS containing the zone files instead of
-                * walking all files
-                */
-               cmd->ret = sync_filesystem(file_inode(zlo->data_dir)->i_sb);
+               cmd->ret = zloop_flush(zlo);
                break;
        case REQ_OP_ZONE_RESET:
                cmd->ret = zloop_reset_zone(zlo, rq_zone_no(rq));
@@ -981,7 +992,8 @@ static int zloop_ctl_add(struct zloop_options *opts)
        struct queue_limits lim = {
                .max_hw_sectors         = SZ_1M >> SECTOR_SHIFT,
                .chunk_sectors          = opts->zone_size,
-               .features               = BLK_FEAT_ZONED,
+               .features               = BLK_FEAT_ZONED | BLK_FEAT_WRITE_CACHE,
+
        };
        unsigned int nr_zones, i, j;
        struct zloop_device *zlo;