Commit 1a02f3a7 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe
Browse files

block: move the stable_writes flag to queue_limits



Move the stable_writes flag into the queue_limits feature field so that
it can be set atomically with the queue frozen.

The flag is now inherited by blk_stack_limits, which greatly simplifies
the code in dm, and fixed md which previously did not pass on the flag
set on lower devices.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20240617060532.127975-18-hch@lst.de


Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent cdb24979
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -88,7 +88,6 @@ static const char *const blk_queue_flag_name[] = {
	QUEUE_FLAG_NAME(SYNCHRONOUS),
	QUEUE_FLAG_NAME(SAME_FORCE),
	QUEUE_FLAG_NAME(INIT_DONE),
	QUEUE_FLAG_NAME(STABLE_WRITES),
	QUEUE_FLAG_NAME(POLL),
	QUEUE_FLAG_NAME(DAX),
	QUEUE_FLAG_NAME(STATS),
+1 −28
Original line number Diff line number Diff line
@@ -296,37 +296,10 @@ static ssize_t queue_##_name##_store(struct request_queue *q, \
	return queue_feature_store(q, page, count, _feature);		 \
}

#define QUEUE_SYSFS_BIT_FNS(name, flag, neg)				\
static ssize_t								\
queue_##name##_show(struct request_queue *q, char *page)		\
{									\
	int bit;							\
	bit = test_bit(QUEUE_FLAG_##flag, &q->queue_flags);		\
	return queue_var_show(neg ? !bit : bit, page);			\
}									\
static ssize_t								\
queue_##name##_store(struct request_queue *q, const char *page, size_t count) \
{									\
	unsigned long val;						\
	ssize_t ret;							\
	ret = queue_var_store(&val, page, count);			\
	if (ret < 0)							\
		 return ret;						\
	if (neg)							\
		val = !val;						\
									\
	if (val)							\
		blk_queue_flag_set(QUEUE_FLAG_##flag, q);		\
	else								\
		blk_queue_flag_clear(QUEUE_FLAG_##flag, q);		\
	return ret;							\
}

QUEUE_SYSFS_FEATURE(rotational, BLK_FEAT_ROTATIONAL)
QUEUE_SYSFS_FEATURE(add_random, BLK_FEAT_ADD_RANDOM)
QUEUE_SYSFS_FEATURE(iostats, BLK_FEAT_IO_STAT)
QUEUE_SYSFS_BIT_FNS(stable_writes, STABLE_WRITES, 0);
#undef QUEUE_SYSFS_BIT_FNS
QUEUE_SYSFS_FEATURE(stable_writes, BLK_FEAT_STABLE_WRITES);

static ssize_t queue_zoned_show(struct request_queue *q, char *page)
{
+2 −3
Original line number Diff line number Diff line
@@ -2698,7 +2698,8 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
		 */
		.max_hw_sectors		= DRBD_MAX_BIO_SIZE_SAFE >> 8,
		.features		= BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA |
					  BLK_FEAT_ROTATIONAL,
					  BLK_FEAT_ROTATIONAL |
					  BLK_FEAT_STABLE_WRITES,
	};

	device = minor_to_device(minor);
@@ -2737,8 +2738,6 @@ enum drbd_ret_code drbd_create_device(struct drbd_config_context *adm_ctx, unsig
	sprintf(disk->disk_name, "drbd%d", minor);
	disk->private_data = device;

	blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, disk->queue);

	device->md_io.page = alloc_page(GFP_KERNEL);
	if (!device->md_io.page)
		goto out_no_io_page;
+3 −6
Original line number Diff line number Diff line
@@ -4949,7 +4949,6 @@ static const struct blk_mq_ops rbd_mq_ops = {
static int rbd_init_disk(struct rbd_device *rbd_dev)
{
	struct gendisk *disk;
	struct request_queue *q;
	unsigned int objset_bytes =
	    rbd_dev->layout.object_size * rbd_dev->layout.stripe_count;
	struct queue_limits lim = {
@@ -4979,12 +4978,14 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
		lim.max_write_zeroes_sectors = objset_bytes >> SECTOR_SHIFT;
	}

	if (!ceph_test_opt(rbd_dev->rbd_client->client, NOCRC))
		lim.features |= BLK_FEAT_STABLE_WRITES;

	disk = blk_mq_alloc_disk(&rbd_dev->tag_set, &lim, rbd_dev);
	if (IS_ERR(disk)) {
		err = PTR_ERR(disk);
		goto out_tag_set;
	}
	q = disk->queue;

	snprintf(disk->disk_name, sizeof(disk->disk_name), RBD_DRV_NAME "%d",
		 rbd_dev->dev_id);
@@ -4996,10 +4997,6 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
		disk->minors = RBD_MINORS_PER_MAJOR;
	disk->fops = &rbd_bd_ops;
	disk->private_data = rbd_dev;

	if (!ceph_test_opt(rbd_dev->rbd_client->client, NOCRC))
		blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, q);

	rbd_dev->disk = disk;

	return 0;
+1 −1
Original line number Diff line number Diff line
@@ -2208,6 +2208,7 @@ static int zram_add(void)
#if ZRAM_LOGICAL_BLOCK_SIZE == PAGE_SIZE
		.max_write_zeroes_sectors	= UINT_MAX,
#endif
		.features			= BLK_FEAT_STABLE_WRITES,
	};
	struct zram *zram;
	int ret, device_id;
@@ -2246,7 +2247,6 @@ static int zram_add(void)
	/* Actual capacity set using sysfs (/sys/block/zram<id>/disksize */
	set_capacity(zram->disk, 0);
	blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, zram->disk->queue);
	blk_queue_flag_set(QUEUE_FLAG_STABLE_WRITES, zram->disk->queue);
	ret = device_add_disk(NULL, zram->disk, zram_disk_groups);
	if (ret)
		goto out_cleanup_disk;
Loading