Commit 71f4ecdb authored by Johannes Thumshirn's avatar Johannes Thumshirn Committed by Jens Axboe

block: remove gfp_flags from blkdev_zone_mgmt

Now that all callers pass in GFP_KERNEL to blkdev_zone_mgmt() and use
memalloc_no{io,fs}_{save,restore}() to define the allocation scope, we can
drop the gfp_mask parameter from blkdev_zone_mgmt() as well as
blkdev_zone_reset_all() and blkdev_zone_reset_all_emulated().
Signed-off-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: default avatarDamien Le Moal <dlemoal@kernel.org>
Reviewed-by: default avatarMike Snitzer <snitzer@kernel.org>
Link: https://lore.kernel.org/r/20240128-zonefs_nofs-v3-5-ae3b7c8def61@wdc.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 147ec1c6
...@@ -177,8 +177,7 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx, ...@@ -177,8 +177,7 @@ static int blk_zone_need_reset_cb(struct blk_zone *zone, unsigned int idx,
} }
} }
static int blkdev_zone_reset_all_emulated(struct block_device *bdev, static int blkdev_zone_reset_all_emulated(struct block_device *bdev)
gfp_t gfp_mask)
{ {
struct gendisk *disk = bdev->bd_disk; struct gendisk *disk = bdev->bd_disk;
sector_t capacity = bdev_nr_sectors(bdev); sector_t capacity = bdev_nr_sectors(bdev);
...@@ -205,7 +204,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev, ...@@ -205,7 +204,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
} }
bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC, bio = blk_next_bio(bio, bdev, 0, REQ_OP_ZONE_RESET | REQ_SYNC,
gfp_mask); GFP_KERNEL);
bio->bi_iter.bi_sector = sector; bio->bi_iter.bi_sector = sector;
sector += zone_sectors; sector += zone_sectors;
...@@ -223,7 +222,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev, ...@@ -223,7 +222,7 @@ static int blkdev_zone_reset_all_emulated(struct block_device *bdev,
return ret; return ret;
} }
static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask) static int blkdev_zone_reset_all(struct block_device *bdev)
{ {
struct bio bio; struct bio bio;
...@@ -238,7 +237,6 @@ static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask) ...@@ -238,7 +237,6 @@ static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask)
* @sector: Start sector of the first zone to operate on * @sector: Start sector of the first zone to operate on
* @nr_sectors: Number of sectors, should be at least the length of one zone and * @nr_sectors: Number of sectors, should be at least the length of one zone and
* must be zone size aligned. * must be zone size aligned.
* @gfp_mask: Memory allocation flags (for bio_alloc)
* *
* Description: * Description:
* Perform the specified operation on the range of zones specified by * Perform the specified operation on the range of zones specified by
...@@ -248,7 +246,7 @@ static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask) ...@@ -248,7 +246,7 @@ static int blkdev_zone_reset_all(struct block_device *bdev, gfp_t gfp_mask)
* or finish request. * or finish request.
*/ */
int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op, int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
sector_t sector, sector_t nr_sectors, gfp_t gfp_mask) sector_t sector, sector_t nr_sectors)
{ {
struct request_queue *q = bdev_get_queue(bdev); struct request_queue *q = bdev_get_queue(bdev);
sector_t zone_sectors = bdev_zone_sectors(bdev); sector_t zone_sectors = bdev_zone_sectors(bdev);
...@@ -285,12 +283,12 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op, ...@@ -285,12 +283,12 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
*/ */
if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) { if (op == REQ_OP_ZONE_RESET && sector == 0 && nr_sectors == capacity) {
if (!blk_queue_zone_resetall(q)) if (!blk_queue_zone_resetall(q))
return blkdev_zone_reset_all_emulated(bdev, gfp_mask); return blkdev_zone_reset_all_emulated(bdev);
return blkdev_zone_reset_all(bdev, gfp_mask); return blkdev_zone_reset_all(bdev);
} }
while (sector < end_sector) { while (sector < end_sector) {
bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, gfp_mask); bio = blk_next_bio(bio, bdev, 0, op | REQ_SYNC, GFP_KERNEL);
bio->bi_iter.bi_sector = sector; bio->bi_iter.bi_sector = sector;
sector += zone_sectors; sector += zone_sectors;
...@@ -419,8 +417,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode, ...@@ -419,8 +417,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, blk_mode_t mode,
return -ENOTTY; return -ENOTTY;
} }
ret = blkdev_zone_mgmt(bdev, op, zrange.sector, zrange.nr_sectors, ret = blkdev_zone_mgmt(bdev, op, zrange.sector, zrange.nr_sectors);
GFP_KERNEL);
fail: fail:
if (cmd == BLKRESETZONE) if (cmd == BLKRESETZONE)
......
...@@ -1660,7 +1660,7 @@ static int dmz_reset_zone(struct dmz_metadata *zmd, struct dm_zone *zone) ...@@ -1660,7 +1660,7 @@ static int dmz_reset_zone(struct dmz_metadata *zmd, struct dm_zone *zone)
noio_flag = memalloc_noio_save(); noio_flag = memalloc_noio_save();
ret = blkdev_zone_mgmt(dev->bdev, REQ_OP_ZONE_RESET, ret = blkdev_zone_mgmt(dev->bdev, REQ_OP_ZONE_RESET,
dmz_start_sect(zmd, zone), dmz_start_sect(zmd, zone),
zmd->zone_nr_sectors, GFP_KERNEL); zmd->zone_nr_sectors);
memalloc_noio_restore(noio_flag); memalloc_noio_restore(noio_flag);
if (ret) { if (ret) {
dmz_dev_err(dev, "Reset zone %u failed %d", dmz_dev_err(dev, "Reset zone %u failed %d",
......
...@@ -456,8 +456,7 @@ static u16 nvmet_bdev_execute_zmgmt_send_all(struct nvmet_req *req) ...@@ -456,8 +456,7 @@ static u16 nvmet_bdev_execute_zmgmt_send_all(struct nvmet_req *req)
switch (zsa_req_op(req->cmd->zms.zsa)) { switch (zsa_req_op(req->cmd->zms.zsa)) {
case REQ_OP_ZONE_RESET: case REQ_OP_ZONE_RESET:
ret = blkdev_zone_mgmt(req->ns->bdev, REQ_OP_ZONE_RESET, 0, ret = blkdev_zone_mgmt(req->ns->bdev, REQ_OP_ZONE_RESET, 0,
get_capacity(req->ns->bdev->bd_disk), get_capacity(req->ns->bdev->bd_disk));
GFP_KERNEL);
if (ret < 0) if (ret < 0)
return blkdev_zone_mgmt_errno_to_nvme_status(ret); return blkdev_zone_mgmt_errno_to_nvme_status(ret);
break; break;
...@@ -508,7 +507,7 @@ static void nvmet_bdev_zmgmt_send_work(struct work_struct *w) ...@@ -508,7 +507,7 @@ static void nvmet_bdev_zmgmt_send_work(struct work_struct *w)
goto out; goto out;
} }
ret = blkdev_zone_mgmt(bdev, op, sect, zone_sectors, GFP_KERNEL); ret = blkdev_zone_mgmt(bdev, op, sect, zone_sectors);
if (ret < 0) if (ret < 0)
status = blkdev_zone_mgmt_errno_to_nvme_status(ret); status = blkdev_zone_mgmt_errno_to_nvme_status(ret);
......
...@@ -830,8 +830,7 @@ static int sb_log_location(struct block_device *bdev, struct blk_zone *zones, ...@@ -830,8 +830,7 @@ static int sb_log_location(struct block_device *bdev, struct blk_zone *zones,
nofs_flags = memalloc_nofs_save(); nofs_flags = memalloc_nofs_save();
ret = blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET, ret = blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET,
reset->start, reset->len, reset->start, reset->len);
GFP_KERNEL);
memalloc_nofs_restore(nofs_flags); memalloc_nofs_restore(nofs_flags);
if (ret) if (ret)
return ret; return ret;
...@@ -984,7 +983,7 @@ int btrfs_advance_sb_log(struct btrfs_device *device, int mirror) ...@@ -984,7 +983,7 @@ int btrfs_advance_sb_log(struct btrfs_device *device, int mirror)
nofs_flags = memalloc_nofs_save(); nofs_flags = memalloc_nofs_save();
ret = blkdev_zone_mgmt(device->bdev, ret = blkdev_zone_mgmt(device->bdev,
REQ_OP_ZONE_FINISH, zone->start, REQ_OP_ZONE_FINISH, zone->start,
zone->len, GFP_KERNEL); zone->len);
memalloc_nofs_restore(nofs_flags); memalloc_nofs_restore(nofs_flags);
if (ret) if (ret)
return ret; return ret;
...@@ -1023,8 +1022,7 @@ int btrfs_reset_sb_log_zones(struct block_device *bdev, int mirror) ...@@ -1023,8 +1022,7 @@ int btrfs_reset_sb_log_zones(struct block_device *bdev, int mirror)
nofs_flags = memalloc_nofs_save(); nofs_flags = memalloc_nofs_save();
ret = blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET, ret = blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET,
zone_start_sector(sb_zone, bdev), zone_start_sector(sb_zone, bdev),
zone_sectors * BTRFS_NR_SB_LOG_ZONES, zone_sectors * BTRFS_NR_SB_LOG_ZONES);
GFP_KERNEL);
memalloc_nofs_restore(nofs_flags); memalloc_nofs_restore(nofs_flags);
return ret; return ret;
} }
...@@ -1143,8 +1141,7 @@ int btrfs_reset_device_zone(struct btrfs_device *device, u64 physical, ...@@ -1143,8 +1141,7 @@ int btrfs_reset_device_zone(struct btrfs_device *device, u64 physical,
*bytes = 0; *bytes = 0;
nofs_flags = memalloc_nofs_save(); nofs_flags = memalloc_nofs_save();
ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_RESET, ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_RESET,
physical >> SECTOR_SHIFT, length >> SECTOR_SHIFT, physical >> SECTOR_SHIFT, length >> SECTOR_SHIFT);
GFP_KERNEL);
memalloc_nofs_restore(nofs_flags); memalloc_nofs_restore(nofs_flags);
if (ret) if (ret)
return ret; return ret;
...@@ -2258,8 +2255,7 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ ...@@ -2258,8 +2255,7 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ
nofs_flags = memalloc_nofs_save(); nofs_flags = memalloc_nofs_save();
ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH, ret = blkdev_zone_mgmt(device->bdev, REQ_OP_ZONE_FINISH,
physical >> SECTOR_SHIFT, physical >> SECTOR_SHIFT,
zinfo->zone_size >> SECTOR_SHIFT, zinfo->zone_size >> SECTOR_SHIFT);
GFP_KERNEL);
memalloc_nofs_restore(nofs_flags); memalloc_nofs_restore(nofs_flags);
if (ret) if (ret)
......
...@@ -1977,7 +1977,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi, ...@@ -1977,7 +1977,7 @@ static int __f2fs_issue_discard_zone(struct f2fs_sb_info *sbi,
trace_f2fs_issue_reset_zone(bdev, blkstart); trace_f2fs_issue_reset_zone(bdev, blkstart);
nofs_flags = memalloc_nofs_save(); nofs_flags = memalloc_nofs_save();
ret = blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET, ret = blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET,
sector, nr_sects, GFP_KERNEL); sector, nr_sects);
memalloc_nofs_restore(nofs_flags); memalloc_nofs_restore(nofs_flags);
return ret; return ret;
} }
...@@ -4921,7 +4921,7 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi, ...@@ -4921,7 +4921,7 @@ static int check_zone_write_pointer(struct f2fs_sb_info *sbi,
nofs_flags = memalloc_nofs_save(); nofs_flags = memalloc_nofs_save();
ret = blkdev_zone_mgmt(fdev->bdev, REQ_OP_ZONE_FINISH, ret = blkdev_zone_mgmt(fdev->bdev, REQ_OP_ZONE_FINISH,
zone->start, zone->len, GFP_KERNEL); zone->start, zone->len);
memalloc_nofs_restore(nofs_flags); memalloc_nofs_restore(nofs_flags);
if (ret == -EOPNOTSUPP) { if (ret == -EOPNOTSUPP) {
ret = blkdev_issue_zeroout(fdev->bdev, zone->wp, ret = blkdev_issue_zeroout(fdev->bdev, zone->wp,
......
...@@ -113,7 +113,7 @@ static int zonefs_zone_mgmt(struct super_block *sb, ...@@ -113,7 +113,7 @@ static int zonefs_zone_mgmt(struct super_block *sb,
trace_zonefs_zone_mgmt(sb, z, op); trace_zonefs_zone_mgmt(sb, z, op);
ret = blkdev_zone_mgmt(sb->s_bdev, op, z->z_sector, ret = blkdev_zone_mgmt(sb->s_bdev, op, z->z_sector,
z->z_size >> SECTOR_SHIFT, GFP_KERNEL); z->z_size >> SECTOR_SHIFT);
if (ret) { if (ret) {
zonefs_err(sb, zonefs_err(sb,
"Zone management operation %s at %llu failed %d\n", "Zone management operation %s at %llu failed %d\n",
......
...@@ -325,7 +325,7 @@ void disk_set_zoned(struct gendisk *disk); ...@@ -325,7 +325,7 @@ void disk_set_zoned(struct gendisk *disk);
int blkdev_report_zones(struct block_device *bdev, sector_t sector, int blkdev_report_zones(struct block_device *bdev, sector_t sector,
unsigned int nr_zones, report_zones_cb cb, void *data); unsigned int nr_zones, report_zones_cb cb, void *data);
int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op, int blkdev_zone_mgmt(struct block_device *bdev, enum req_op op,
sector_t sectors, sector_t nr_sectors, gfp_t gfp_mask); sector_t sectors, sector_t nr_sectors);
int blk_revalidate_disk_zones(struct gendisk *disk, int blk_revalidate_disk_zones(struct gendisk *disk,
void (*update_driver_data)(struct gendisk *disk)); void (*update_driver_data)(struct gendisk *disk));
......
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