Skip to content

Commit 9acced3

Browse files
morbidrsamartinkpetersen
authored andcommitted
scsi: sd: sd_zbc: Don't pass GFP_NOIO to kvcalloc
Dan reported we're passing in GFP_NOIO to kvmalloc() which will then fallback to doing kmalloc() instead of an optional vmalloc() if the size exceeds kmalloc()s limits. This will break with drives that have zone numbers exceeding PAGE_SIZE/sizeof(u32). Instead of passing in GFP_NOIO, enter an implicit GFP_NOIO allocation scope. Link: https://lore.kernel.org/r/YCuvSfKw4qEQBr/t@mwanda Link: https://lore.kernel.org/r/5a6345e2989fd06c049ac4e4627f6acb492c15b8.1613569821.git.johannes.thumshirn@wdc.com Fixes: 5795eb4: ("scsi: sd_zbc: emulate ZONE_APPEND commands") Cc: Damien Le Moal <Damien.LeMoal@wdc.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent c2f23a9 commit 9acced3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/scsi/sd_zbc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
688688
unsigned int nr_zones = sdkp->rev_nr_zones;
689689
u32 max_append;
690690
int ret = 0;
691+
unsigned int flags;
691692

692693
/*
693694
* For all zoned disks, initialize zone append emulation data if not
@@ -720,16 +721,19 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
720721
disk->queue->nr_zones == nr_zones)
721722
goto unlock;
722723

724+
flags = memalloc_noio_save();
723725
sdkp->zone_blocks = zone_blocks;
724726
sdkp->nr_zones = nr_zones;
725-
sdkp->rev_wp_offset = kvcalloc(nr_zones, sizeof(u32), GFP_NOIO);
727+
sdkp->rev_wp_offset = kvcalloc(nr_zones, sizeof(u32), GFP_KERNEL);
726728
if (!sdkp->rev_wp_offset) {
727729
ret = -ENOMEM;
730+
memalloc_noio_restore(flags);
728731
goto unlock;
729732
}
730733

731734
ret = blk_revalidate_disk_zones(disk, sd_zbc_revalidate_zones_cb);
732735

736+
memalloc_noio_restore(flags);
733737
kvfree(sdkp->rev_wp_offset);
734738
sdkp->rev_wp_offset = NULL;
735739

0 commit comments

Comments
 (0)