Skip to content

Commit aadd5c5

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: move the synchronous flag to queue_limits
Move the synchronous flag into the queue_limits feature field so that it can be set atomically with the queue frozen. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20240617060532.127975-19-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 1a02f3a commit aadd5c5

File tree

6 files changed

+10
-11
lines changed

6 files changed

+10
-11
lines changed

block/blk-mq-debugfs.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ static const char *const blk_queue_flag_name[] = {
8585
QUEUE_FLAG_NAME(SAME_COMP),
8686
QUEUE_FLAG_NAME(FAIL_IO),
8787
QUEUE_FLAG_NAME(NOXMERGES),
88-
QUEUE_FLAG_NAME(SYNCHRONOUS),
8988
QUEUE_FLAG_NAME(SAME_FORCE),
9089
QUEUE_FLAG_NAME(INIT_DONE),
9190
QUEUE_FLAG_NAME(POLL),

drivers/block/brd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ static int brd_alloc(int i)
335335
.max_hw_discard_sectors = UINT_MAX,
336336
.max_discard_segments = 1,
337337
.discard_granularity = PAGE_SIZE,
338+
.features = BLK_FEAT_SYNCHRONOUS,
338339
};
339340

340341
list_for_each_entry(brd, &brd_devices, brd_list)
@@ -366,7 +367,6 @@ static int brd_alloc(int i)
366367
strscpy(disk->disk_name, buf, DISK_NAME_LEN);
367368
set_capacity(disk, rd_size * 2);
368369

369-
blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, disk->queue);
370370
blk_queue_flag_set(QUEUE_FLAG_NOWAIT, disk->queue);
371371
err = add_disk(disk);
372372
if (err)

drivers/block/zram/zram_drv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,7 +2208,8 @@ static int zram_add(void)
22082208
#if ZRAM_LOGICAL_BLOCK_SIZE == PAGE_SIZE
22092209
.max_write_zeroes_sectors = UINT_MAX,
22102210
#endif
2211-
.features = BLK_FEAT_STABLE_WRITES,
2211+
.features = BLK_FEAT_STABLE_WRITES |
2212+
BLK_FEAT_SYNCHRONOUS,
22122213
};
22132214
struct zram *zram;
22142215
int ret, device_id;
@@ -2246,7 +2247,6 @@ static int zram_add(void)
22462247

22472248
/* Actual capacity set using sysfs (/sys/block/zram<id>/disksize */
22482249
set_capacity(zram->disk, 0);
2249-
blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, zram->disk->queue);
22502250
ret = device_add_disk(NULL, zram->disk, zram_disk_groups);
22512251
if (ret)
22522252
goto out_cleanup_disk;

drivers/nvdimm/btt.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,7 @@ static int btt_blk_init(struct btt *btt)
15011501
.logical_block_size = btt->sector_size,
15021502
.max_hw_sectors = UINT_MAX,
15031503
.max_integrity_segments = 1,
1504+
.features = BLK_FEAT_SYNCHRONOUS,
15041505
};
15051506
int rc;
15061507

@@ -1518,8 +1519,6 @@ static int btt_blk_init(struct btt *btt)
15181519
btt->btt_disk->fops = &btt_fops;
15191520
btt->btt_disk->private_data = btt;
15201521

1521-
blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, btt->btt_disk->queue);
1522-
15231522
set_capacity(btt->btt_disk, btt->nlba * btt->sector_size >> 9);
15241523
rc = device_add_disk(&btt->nd_btt->dev, btt->btt_disk, NULL);
15251524
if (rc)

drivers/nvdimm/pmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ static int pmem_attach_disk(struct device *dev,
455455
.logical_block_size = pmem_sector_size(ndns),
456456
.physical_block_size = PAGE_SIZE,
457457
.max_hw_sectors = UINT_MAX,
458-
.features = BLK_FEAT_WRITE_CACHE,
458+
.features = BLK_FEAT_WRITE_CACHE |
459+
BLK_FEAT_SYNCHRONOUS,
459460
};
460461
int nid = dev_to_node(dev), fua;
461462
struct resource *res = &nsio->res;
@@ -546,7 +547,6 @@ static int pmem_attach_disk(struct device *dev,
546547
}
547548
pmem->virt_addr = addr;
548549

549-
blk_queue_flag_set(QUEUE_FLAG_SYNCHRONOUS, q);
550550
if (pmem->pfn_flags & PFN_MAP)
551551
blk_queue_flag_set(QUEUE_FLAG_DAX, q);
552552

include/linux/blkdev.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ enum {
301301

302302
/* don't modify data until writeback is done */
303303
BLK_FEAT_STABLE_WRITES = (1u << 5),
304+
305+
/* always completes in submit context */
306+
BLK_FEAT_SYNCHRONOUS = (1u << 6),
304307
};
305308

306309
/*
@@ -566,7 +569,6 @@ struct request_queue {
566569
#define QUEUE_FLAG_SAME_COMP 4 /* complete on same CPU-group */
567570
#define QUEUE_FLAG_FAIL_IO 5 /* fake timeout */
568571
#define QUEUE_FLAG_NOXMERGES 9 /* No extended merges */
569-
#define QUEUE_FLAG_SYNCHRONOUS 11 /* always completes in submit context */
570572
#define QUEUE_FLAG_SAME_FORCE 12 /* force complete on same CPU */
571573
#define QUEUE_FLAG_INIT_DONE 14 /* queue is initialized */
572574
#define QUEUE_FLAG_POLL 16 /* IO polling enabled if set */
@@ -1315,8 +1317,7 @@ static inline bool bdev_nonrot(struct block_device *bdev)
13151317

13161318
static inline bool bdev_synchronous(struct block_device *bdev)
13171319
{
1318-
return test_bit(QUEUE_FLAG_SYNCHRONOUS,
1319-
&bdev_get_queue(bdev)->queue_flags);
1320+
return bdev->bd_disk->queue->limits.features & BLK_FEAT_SYNCHRONOUS;
13201321
}
13211322

13221323
static inline bool bdev_stable_writes(struct block_device *bdev)

0 commit comments

Comments
 (0)