mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2025-06-25 02:28:01 +03:00
linux/zvol_os: don't try to set disk ops if alloc fails
If the kernel fails to allocate the gendisk, zvo_disk will be NULL, and derefencing it will explode. So don't do that. Sponsored-by: Klara, Inc. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Rob Norris <rob.norris@klarasystems.com> Closes #17396
This commit is contained in:
parent
3084336ae4
commit
0c94d3838d
@ -1352,13 +1352,15 @@ zvol_alloc(dev_t dev, const char *name, uint64_t volblocksize)
|
|||||||
*/
|
*/
|
||||||
if (zv->zv_zso->use_blk_mq) {
|
if (zv->zv_zso->use_blk_mq) {
|
||||||
ret = zvol_alloc_blk_mq(zv, &limits);
|
ret = zvol_alloc_blk_mq(zv, &limits);
|
||||||
|
if (ret != 0)
|
||||||
|
goto out_kmem;
|
||||||
zso->zvo_disk->fops = &zvol_ops_blk_mq;
|
zso->zvo_disk->fops = &zvol_ops_blk_mq;
|
||||||
} else {
|
} else {
|
||||||
ret = zvol_alloc_non_blk_mq(zso, &limits);
|
ret = zvol_alloc_non_blk_mq(zso, &limits);
|
||||||
|
if (ret != 0)
|
||||||
|
goto out_kmem;
|
||||||
zso->zvo_disk->fops = &zvol_ops;
|
zso->zvo_disk->fops = &zvol_ops;
|
||||||
}
|
}
|
||||||
if (ret != 0)
|
|
||||||
goto out_kmem;
|
|
||||||
|
|
||||||
/* Limit read-ahead to a single page to prevent over-prefetching. */
|
/* Limit read-ahead to a single page to prevent over-prefetching. */
|
||||||
blk_queue_set_read_ahead(zso->zvo_queue, 1);
|
blk_queue_set_read_ahead(zso->zvo_queue, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user