Skip to contentSkip to conversation

zloop fixes

PATCH Applied Christoph Hellwig 4 participants 7 messages Feb 24

Subsystems (2)
lore
Share & tools
lore

Christoph Hellwig

author reviewer
#0 lore raw

Hi all,

two fixes for zloop found while writing new test cases using it.

author reviewer
#1 lore raw

PATCH 1/2 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 eb0570c7df23 ("block: new zoned loop block device driver")
---
 drivers/block/zloop.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/block/zloop.c +18 -6
index 65a40266437c..56e54d9791f1 100644
@@ -542,6 +542,21 @@ static void zloop_rw(struct zloop_cmd *cmd)
 	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;
Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] zloop: advertise a volatile write cache

Quoted 8 lines · Christoph Hellwig

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")

Thanks for fixing this.

Signature · 2 lines
Damien Le Moal
Western Digital Research
maintainer Applied
#3 lore raw

Re: [PATCH 1/2] zloop: advertise a volatile write cache

In reply to Christoph Hellwig
Quoted 8 lines · Christoph Hellwig

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.

[...]

Applied, thanks!

[1/2] zloop: advertise a volatile write cache

      commit: 6acf7860dcc79ed045cc9e6a79c8a8bb6959dba7
[2/2] zloop: check for spurious options passed to remove
      commit: 3c4617117a2b7682cf037be5e5533e379707f050

Best regards,

Signature · 1 line
Jens Axboe
author reviewer
#4 lore raw

PATCH 2/2 zloop: check for spurious options passed to remove

In reply to Christoph Hellwig

Zloop uses a command option parser for all control commands, but most options are only valid for adding a new device. Check for incorrectly specified options in the remove handler.

Fixes eb0570c7df23 ("block: new zoned loop block device driver")
---
 drivers/block/zloop.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/block/zloop.c +6 -1
index 56e54d9791f1..51c043342127 100644
@@ -1174,7 +1174,12 @@ static int zloop_ctl_remove(struct zloop_options *opts)
 	int ret;
 
 	if (!(opts->mask & ZLOOP_OPT_ID)) {
-		pr_err("No ID specified\n");
+		pr_err("No ID specified for remove\n");
+		return -EINVAL;
+	}
+
+	if (opts->mask & ~ZLOOP_OPT_ID) {
+		pr_err("Invalid option specified for remove\n");
 		return -EINVAL;
 	}
 
Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] zloop: check for spurious options passed to remove

Quoted 6 lines · Christoph Hellwig

Zloop uses a command option parser for all control commands, but most options are only valid for adding a new device. Check for incorrectly specified options in the remove handler.

Fixes eb0570c7df23 ("block: new zoned loop block device driver")
Signature · 2 lines
Damien Le Moal
Western Digital Research