Commit e876df1f authored by Ajay Joshi's avatar Ajay Joshi Committed by Jens Axboe

block: add zone open, close and finish ioctl support

Introduce three new ioctl commands BLKOPENZONE, BLKCLOSEZONE and
BLKFINISHZONE to allow applications to control the condition of zones
on a zoned block device through the execution of the REQ_OP_ZONE_OPEN,
REQ_OP_ZONE_CLOSE and REQ_OP_ZONE_FINISH operations.

Contains contributions from Matias Bjorling, Hans Holmberg,
Dmitry Fomichev, Keith Busch, Damien Le Moal and Christoph Hellwig.
Reviewed-by: default avatarJavier González <javier@javigon.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAjay Joshi <ajay.joshi@wdc.com>
Signed-off-by: default avatarMatias Bjorling <matias.bjorling@wdc.com>
Signed-off-by: default avatarHans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: default avatarDmitry Fomichev <dmitry.fomichev@wdc.com>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 6c1b1da5
...@@ -357,15 +357,16 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -357,15 +357,16 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
} }
/* /*
* BLKRESETZONE ioctl processing. * BLKRESETZONE, BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctl processing.
* Called from blkdev_ioctl. * Called from blkdev_ioctl.
*/ */
int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode, int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
void __user *argp = (void __user *)arg; void __user *argp = (void __user *)arg;
struct request_queue *q; struct request_queue *q;
struct blk_zone_range zrange; struct blk_zone_range zrange;
enum req_opf op;
if (!argp) if (!argp)
return -EINVAL; return -EINVAL;
...@@ -386,8 +387,25 @@ int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -386,8 +387,25 @@ int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
if (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range))) if (copy_from_user(&zrange, argp, sizeof(struct blk_zone_range)))
return -EFAULT; return -EFAULT;
return blkdev_zone_mgmt(bdev, REQ_OP_ZONE_RESET, switch (cmd) {
zrange.sector, zrange.nr_sectors, GFP_KERNEL); case BLKRESETZONE:
op = REQ_OP_ZONE_RESET;
break;
case BLKOPENZONE:
op = REQ_OP_ZONE_OPEN;
break;
case BLKCLOSEZONE:
op = REQ_OP_ZONE_CLOSE;
break;
case BLKFINISHZONE:
op = REQ_OP_ZONE_FINISH;
break;
default:
return -ENOTTY;
}
return blkdev_zone_mgmt(bdev, op, zrange.sector, zrange.nr_sectors,
GFP_KERNEL);
} }
static inline unsigned long *blk_alloc_zone_bitmap(int node, static inline unsigned long *blk_alloc_zone_bitmap(int node,
......
...@@ -532,7 +532,10 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd, ...@@ -532,7 +532,10 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
case BLKREPORTZONE: case BLKREPORTZONE:
return blkdev_report_zones_ioctl(bdev, mode, cmd, arg); return blkdev_report_zones_ioctl(bdev, mode, cmd, arg);
case BLKRESETZONE: case BLKRESETZONE:
return blkdev_reset_zones_ioctl(bdev, mode, cmd, arg); case BLKOPENZONE:
case BLKCLOSEZONE:
case BLKFINISHZONE:
return blkdev_zone_mgmt_ioctl(bdev, mode, cmd, arg);
case BLKGETZONESZ: case BLKGETZONESZ:
return put_uint(arg, bdev_zone_sectors(bdev)); return put_uint(arg, bdev_zone_sectors(bdev));
case BLKGETNRZONES: case BLKGETNRZONES:
......
...@@ -367,7 +367,7 @@ extern int blk_revalidate_disk_zones(struct gendisk *disk); ...@@ -367,7 +367,7 @@ extern int blk_revalidate_disk_zones(struct gendisk *disk);
extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
extern int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode, extern int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
#else /* CONFIG_BLK_DEV_ZONED */ #else /* CONFIG_BLK_DEV_ZONED */
...@@ -389,7 +389,7 @@ static inline int blkdev_report_zones_ioctl(struct block_device *bdev, ...@@ -389,7 +389,7 @@ static inline int blkdev_report_zones_ioctl(struct block_device *bdev,
return -ENOTTY; return -ENOTTY;
} }
static inline int blkdev_reset_zones_ioctl(struct block_device *bdev, static inline int blkdev_zone_mgmt_ioctl(struct block_device *bdev,
fmode_t mode, unsigned int cmd, fmode_t mode, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
......
...@@ -120,9 +120,11 @@ struct blk_zone_report { ...@@ -120,9 +120,11 @@ struct blk_zone_report {
}; };
/** /**
* struct blk_zone_range - BLKRESETZONE ioctl request * struct blk_zone_range - BLKRESETZONE/BLKOPENZONE/
* @sector: starting sector of the first zone to issue reset write pointer * BLKCLOSEZONE/BLKFINISHZONE ioctl
* @nr_sectors: Total number of sectors of 1 or more zones to reset * requests
* @sector: Starting sector of the first zone to operate on.
* @nr_sectors: Total number of sectors of all zones to operate on.
*/ */
struct blk_zone_range { struct blk_zone_range {
__u64 sector; __u64 sector;
...@@ -139,10 +141,19 @@ struct blk_zone_range { ...@@ -139,10 +141,19 @@ struct blk_zone_range {
* sector range. The sector range must be zone aligned. * sector range. The sector range must be zone aligned.
* @BLKGETZONESZ: Get the device zone size in number of 512 B sectors. * @BLKGETZONESZ: Get the device zone size in number of 512 B sectors.
* @BLKGETNRZONES: Get the total number of zones of the device. * @BLKGETNRZONES: Get the total number of zones of the device.
* @BLKOPENZONE: Open the zones in the specified sector range.
* The 512 B sector range must be zone aligned.
* @BLKCLOSEZONE: Close the zones in the specified sector range.
* The 512 B sector range must be zone aligned.
* @BLKFINISHZONE: Mark the zones as full in the specified sector range.
* The 512 B sector range must be zone aligned.
*/ */
#define BLKREPORTZONE _IOWR(0x12, 130, struct blk_zone_report) #define BLKREPORTZONE _IOWR(0x12, 130, struct blk_zone_report)
#define BLKRESETZONE _IOW(0x12, 131, struct blk_zone_range) #define BLKRESETZONE _IOW(0x12, 131, struct blk_zone_range)
#define BLKGETZONESZ _IOR(0x12, 132, __u32) #define BLKGETZONESZ _IOR(0x12, 132, __u32)
#define BLKGETNRZONES _IOR(0x12, 133, __u32) #define BLKGETNRZONES _IOR(0x12, 133, __u32)
#define BLKOPENZONE _IOW(0x12, 134, struct blk_zone_range)
#define BLKCLOSEZONE _IOW(0x12, 135, struct blk_zone_range)
#define BLKFINISHZONE _IOW(0x12, 136, struct blk_zone_range)
#endif /* _UAPI_BLKZONED_H */ #endif /* _UAPI_BLKZONED_H */
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