Skip to content

Commit 6b37778

Browse files
Christoph Hellwigaxboe
Christoph Hellwig
authored andcommitted
nbd: move setting the cache control flags to __nbd_set_size
Move setting the cache control flags in nbd in preparation for moving these flags into the queue_limits structure. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Hannes Reinecke <hare@suse.de> Link: https://lore.kernel.org/r/20240617060532.127975-11-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent bbe5c84 commit 6b37778

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

drivers/block/nbd.c

+7-10
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,12 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
342342
lim.max_hw_discard_sectors = UINT_MAX;
343343
else
344344
lim.max_hw_discard_sectors = 0;
345+
if (!(nbd->config->flags & NBD_FLAG_SEND_FLUSH))
346+
blk_queue_write_cache(nbd->disk->queue, false, false);
347+
else if (nbd->config->flags & NBD_FLAG_SEND_FUA)
348+
blk_queue_write_cache(nbd->disk->queue, true, true);
349+
else
350+
blk_queue_write_cache(nbd->disk->queue, true, false);
345351
lim.logical_block_size = blksize;
346352
lim.physical_block_size = blksize;
347353
error = queue_limits_commit_update(nbd->disk->queue, &lim);
@@ -1286,19 +1292,10 @@ static void nbd_bdev_reset(struct nbd_device *nbd)
12861292

12871293
static void nbd_parse_flags(struct nbd_device *nbd)
12881294
{
1289-
struct nbd_config *config = nbd->config;
1290-
if (config->flags & NBD_FLAG_READ_ONLY)
1295+
if (nbd->config->flags & NBD_FLAG_READ_ONLY)
12911296
set_disk_ro(nbd->disk, true);
12921297
else
12931298
set_disk_ro(nbd->disk, false);
1294-
if (config->flags & NBD_FLAG_SEND_FLUSH) {
1295-
if (config->flags & NBD_FLAG_SEND_FUA)
1296-
blk_queue_write_cache(nbd->disk->queue, true, true);
1297-
else
1298-
blk_queue_write_cache(nbd->disk->queue, true, false);
1299-
}
1300-
else
1301-
blk_queue_write_cache(nbd->disk->queue, false, false);
13021299
}
13031300

13041301
static void send_disconnects(struct nbd_device *nbd)

0 commit comments

Comments
 (0)