Skip to content

Commit 58ebe3e

Browse files
Christoph Hellwigaxboe
authored andcommitted
ubd: move setting the variable queue limits to ubd_add
No reason to delay this until open time. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Richard Weinberger <richard@nod.at> Link: https://lore.kernel.org/r/20240222072417.3773131-5-hch@lst.de Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent b8b364d commit 58ebe3e

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

arch/um/drivers/ubd_kern.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,6 @@ static int ubd_open_dev(struct ubd *ubd_dev)
772772
ubd_dev->fd = fd;
773773

774774
if(ubd_dev->cow.file != NULL){
775-
blk_queue_max_hw_sectors(ubd_dev->queue, 8 * sizeof(long));
776-
777775
err = -ENOMEM;
778776
ubd_dev->cow.bitmap = vmalloc(ubd_dev->cow.bitmap_len);
779777
if(ubd_dev->cow.bitmap == NULL){
@@ -795,10 +793,6 @@ static int ubd_open_dev(struct ubd *ubd_dev)
795793
if(err < 0) goto error;
796794
ubd_dev->cow.fd = err;
797795
}
798-
if (ubd_dev->no_trim == 0) {
799-
blk_queue_max_discard_sectors(ubd_dev->queue, UBD_MAX_REQUEST);
800-
blk_queue_max_write_zeroes_sectors(ubd_dev->queue, UBD_MAX_REQUEST);
801-
}
802796
return 0;
803797
error:
804798
os_close_file(ubd_dev->fd);
@@ -867,6 +861,13 @@ static int ubd_add(int n, char **error_out)
867861
if(ubd_dev->file == NULL)
868862
goto out;
869863

864+
if (ubd_dev->cow.file)
865+
lim.max_hw_sectors = 8 * sizeof(long);
866+
if (!ubd_dev->no_trim) {
867+
lim.max_hw_discard_sectors = UBD_MAX_REQUEST;
868+
lim.max_write_zeroes_sectors = UBD_MAX_REQUEST;
869+
}
870+
870871
err = ubd_file_size(ubd_dev, &ubd_dev->size);
871872
if(err < 0){
872873
*error_out = "Couldn't determine size of device's file";

0 commit comments

Comments
 (0)