Commit 6b377787 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Jens Axboe

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: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBart Van Assche <bvanassche@acm.org>
Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
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-11-hch@lst.deSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent bbe5c841
...@@ -342,6 +342,12 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize, ...@@ -342,6 +342,12 @@ static int __nbd_set_size(struct nbd_device *nbd, loff_t bytesize,
lim.max_hw_discard_sectors = UINT_MAX; lim.max_hw_discard_sectors = UINT_MAX;
else else
lim.max_hw_discard_sectors = 0; lim.max_hw_discard_sectors = 0;
if (!(nbd->config->flags & NBD_FLAG_SEND_FLUSH))
blk_queue_write_cache(nbd->disk->queue, false, false);
else if (nbd->config->flags & NBD_FLAG_SEND_FUA)
blk_queue_write_cache(nbd->disk->queue, true, true);
else
blk_queue_write_cache(nbd->disk->queue, true, false);
lim.logical_block_size = blksize; lim.logical_block_size = blksize;
lim.physical_block_size = blksize; lim.physical_block_size = blksize;
error = queue_limits_commit_update(nbd->disk->queue, &lim); error = queue_limits_commit_update(nbd->disk->queue, &lim);
...@@ -1286,19 +1292,10 @@ static void nbd_bdev_reset(struct nbd_device *nbd) ...@@ -1286,19 +1292,10 @@ static void nbd_bdev_reset(struct nbd_device *nbd)
static void nbd_parse_flags(struct nbd_device *nbd) static void nbd_parse_flags(struct nbd_device *nbd)
{ {
struct nbd_config *config = nbd->config; if (nbd->config->flags & NBD_FLAG_READ_ONLY)
if (config->flags & NBD_FLAG_READ_ONLY)
set_disk_ro(nbd->disk, true); set_disk_ro(nbd->disk, true);
else else
set_disk_ro(nbd->disk, false); set_disk_ro(nbd->disk, false);
if (config->flags & NBD_FLAG_SEND_FLUSH) {
if (config->flags & NBD_FLAG_SEND_FUA)
blk_queue_write_cache(nbd->disk->queue, true, true);
else
blk_queue_write_cache(nbd->disk->queue, true, false);
}
else
blk_queue_write_cache(nbd->disk->queue, false, false);
} }
static void send_disconnects(struct nbd_device *nbd) static void send_disconnects(struct nbd_device *nbd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment