Skip to content

Commit 6acf786

Browse files
Christoph Hellwigaxboe
authored andcommitted
zloop: advertise a volatile write cache
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: eb0570c ("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>
1 parent 0d195d3 commit 6acf786

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

drivers/block/zloop.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,21 @@ static void zloop_rw(struct zloop_cmd *cmd)
542542
zloop_put_cmd(cmd);
543543
}
544544

545+
/*
546+
* Sync the entire FS containing the zone files instead of walking all files.
547+
*/
548+
static int zloop_flush(struct zloop_device *zlo)
549+
{
550+
struct super_block *sb = file_inode(zlo->data_dir)->i_sb;
551+
int ret;
552+
553+
down_read(&sb->s_umount);
554+
ret = sync_filesystem(sb);
555+
up_read(&sb->s_umount);
556+
557+
return ret;
558+
}
559+
545560
static void zloop_handle_cmd(struct zloop_cmd *cmd)
546561
{
547562
struct request *rq = blk_mq_rq_from_pdu(cmd);
@@ -562,11 +577,7 @@ static void zloop_handle_cmd(struct zloop_cmd *cmd)
562577
zloop_rw(cmd);
563578
return;
564579
case REQ_OP_FLUSH:
565-
/*
566-
* Sync the entire FS containing the zone files instead of
567-
* walking all files
568-
*/
569-
cmd->ret = sync_filesystem(file_inode(zlo->data_dir)->i_sb);
580+
cmd->ret = zloop_flush(zlo);
570581
break;
571582
case REQ_OP_ZONE_RESET:
572583
cmd->ret = zloop_reset_zone(zlo, rq_zone_no(rq));
@@ -981,7 +992,8 @@ static int zloop_ctl_add(struct zloop_options *opts)
981992
struct queue_limits lim = {
982993
.max_hw_sectors = SZ_1M >> SECTOR_SHIFT,
983994
.chunk_sectors = opts->zone_size,
984-
.features = BLK_FEAT_ZONED,
995+
.features = BLK_FEAT_ZONED | BLK_FEAT_WRITE_CACHE,
996+
985997
};
986998
unsigned int nr_zones, i, j;
987999
struct zloop_device *zlo;

0 commit comments

Comments
 (0)