Re: [PATCH 2/4] Add bio/request flags for using ZBC/ZAC commands

2016-06-06 Thread Shaun Tancheff
On Mon, Jun 6, 2016 at 10:39 AM, Shaun Tancheff  wrote:
>
> T10 ZBC and T13 ZAC specify operations for Zoned devices.
>
> To be able to access the zone information and open and close zones
> adding flags for the report zones command (REQ_REPORT_ZONES) and for
> Open and Close zone (REQ_OPEN_ZONE and REQ_CLOSE_ZONE) can be added
> for use by struct bio's bi_rw and by struct request's cmd_flags.
>
> To reduce the number of additional flags needed REQ_RESET_ZONE shares
> the same flag as REQ_REPORT_ZONES and is differentiated by direction.
> Report zones is a device read that requires a buffer. Reset is a device
> command (WRITE) that has no associated data transfer.
>
> The Finish zone command is intentionally not implimented as there is no
> current use case for that operation.
>
> Report zones currently defaults to reporting on all zones. It expected
> that support for the zone option flag will piggy back on streamid
> support. The report option is useful as it can reduce the number of
> zones in each report, but not critical.
>
> Signed-off-by: Shaun Tancheff 
> ---
>  MAINTAINERS   |   9 ++
>  block/blk-lib.c   |  96 +
>  drivers/scsi/sd.c |  99 +-
>  drivers/scsi/sd.h |   1 +
>  include/linux/blk_types.h |  19 +++-
>  include/linux/blkzoned_api.h  |  25 +
>  include/uapi/linux/Kbuild |   1 +
>  include/uapi/linux/blkzoned_api.h | 215 
> ++
>  include/uapi/linux/fs.h   |   1 +
>  9 files changed, 461 insertions(+), 5 deletions(-)
>  create mode 100644 include/linux/blkzoned_api.h
>  create mode 100644 include/uapi/linux/blkzoned_api.h
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 7304d2e..0b71a3c 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -12660,6 +12660,15 @@ F: Documentation/networking/z8530drv.txt
>  F: drivers/net/hamradio/*scc.c
>  F: drivers/net/hamradio/z8530.h
>
> +ZBC AND ZBC BLOCK DEVICES
> +M: Shaun Tancheff 
> +W: http://seagate.com
> +W: 
> https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Seagate_ZDM-2DDevice-2DMapper=CwIBAg=IGDlg0lD0b-nebmJJ0Kp8A=Wg5NqlNlVTT7Ugl8V50qIHLe856QW0qfG3WVYGOrWzA=NgIOfWitaBWSqZoCVyVSkoMDm3cP1ofhQL7wPM1Z-xA=gEau_a22IpcIHd6A3J6ovk5P_nay7XAov8OoSfJdTXs=
> +L: linux-bl...@vger.kernel.org
> +S: Maintained
> +F: include/linux/blkzoned_api.h
> +F: include/uapi/linux/blkzoned_api.h
> +
>  ZBUD COMPRESSED PAGE ALLOCATOR
>  M: Seth Jennings 
>  L: linux...@kvack.org
> diff --git a/block/blk-lib.c b/block/blk-lib.c
> index 23d7f30..a7f047c 100644
> --- a/block/blk-lib.c
> +++ b/block/blk-lib.c
> @@ -6,6 +6,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>
>  #include "blk.h"
>
> @@ -249,3 +250,98 @@ int blkdev_issue_zeroout(struct block_device *bdev, 
> sector_t sector,
> return __blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask);
>  }
>  EXPORT_SYMBOL(blkdev_issue_zeroout);
> +
> +/**
> + * blkdev_issue_zone_report - queue a report zones operation
> + * @bdev:  target blockdev
> + * @bi_rw: extra bio rw flags. If unsure, use 0.
> + * @sector:starting sector (report will include this sector).

Missing:
  * @opt: See: zone_report_option, default is 0 (all zones)

> + * @page:  one or more contiguous pages.
> + * @pgsz:  up to size of page in bytes, size of report.
> + * @gfp_mask:  memory allocation flags (for bio_alloc)
> + *
> + * Description:
> + *Issue a zone report request for the sectors in question.
> + */
> +int blkdev_issue_zone_report(struct block_device *bdev, unsigned int bi_rw,
> +sector_t sector, u8 opt, struct page *page,
> +size_t pgsz, gfp_t gfp_mask)
> +{
> +   struct bdev_zone_report *conv = page_address(page);
> +   struct bio *bio;
> +   unsigned int nr_iovecs = 1;
> +   int ret = 0;
> +
> +   if (pgsz < (sizeof(struct bdev_zone_report) +
> +   sizeof(struct bdev_zone_descriptor)))
> +   return -EINVAL;
> +
> +   bio = bio_alloc(gfp_mask, nr_iovecs);
> +   if (!bio)
> +   return -ENOMEM;
> +
> +   conv->descriptor_count = 0;
> +   bio->bi_iter.bi_sector = sector;
> +   bio->bi_bdev = bdev;
> +   bio->bi_vcnt = 0;
> +   bio->bi_iter.bi_size = 0;
> +
> +   bi_rw |= REQ_REPORT_ZONES;
> +
> +   /* FUTURE ... when streamid is available: */
> +   /* bio_set_streamid(bio, opt); */
> +
> +   bio_add_page(bio, page, pgsz, 0);
> +   ret = submit_bio_wait(READ | bi_rw, bio);
> +
> +   /*
> +* When our request it nak'd the underlying device maybe conventional
> +* so ... report a single conventional zone the size of the device.
> +*/
> +   if (ret == -EIO && conv->descriptor_count) {
> +   

Re: [PATCH 2/4] Add bio/request flags for using ZBC/ZAC commands

2016-06-06 Thread kbuild test robot
Hi,

[auto build test WARNING on scsi/for-next]
[also build test WARNING on v4.7-rc2 next-20160606]
[cannot apply to block/for-next]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Shaun-Tancheff/Block-layer-support-ZAC-ZBC-commands/20160606-234756
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
reproduce: make htmldocs

All warnings (new ones prefixed by >>):

   lib/crc32.c:148: warning: No description found for parameter 'tab)[256]'
   lib/crc32.c:148: warning: Excess function parameter 'tab' description in 
'crc32_le_generic'
   lib/crc32.c:293: warning: No description found for parameter 'tab)[256]'
   lib/crc32.c:293: warning: Excess function parameter 'tab' description in 
'crc32_be_generic'
   lib/crc32.c:1: warning: no structured comments found
   mm/memory.c:2881: warning: No description found for parameter 'old'
>> block/blk-lib.c:269: warning: No description found for parameter 'opt'

vim +/opt +269 block/blk-lib.c

   253  
   254  /**
   255   * blkdev_issue_zone_report - queue a report zones operation
   256   * @bdev:   target blockdev
   257   * @bi_rw:  extra bio rw flags. If unsure, use 0.
   258   * @sector: starting sector (report will include this sector).
   259   * @page:   one or more contiguous pages.
   260   * @pgsz:   up to size of page in bytes, size of report.
   261   * @gfp_mask:   memory allocation flags (for bio_alloc)
   262   *
   263   * Description:
   264   *Issue a zone report request for the sectors in question.
   265   */
   266  int blkdev_issue_zone_report(struct block_device *bdev, unsigned int 
bi_rw,
   267   sector_t sector, u8 opt, struct page *page,
   268   size_t pgsz, gfp_t gfp_mask)
 > 269  {
   270  struct bdev_zone_report *conv = page_address(page);
   271  struct bio *bio;
   272  unsigned int nr_iovecs = 1;
   273  int ret = 0;
   274  
   275  if (pgsz < (sizeof(struct bdev_zone_report) +
   276  sizeof(struct bdev_zone_descriptor)))
   277  return -EINVAL;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: Binary data


[PATCH 2/4] Add bio/request flags for using ZBC/ZAC commands

2016-06-06 Thread Shaun Tancheff
T10 ZBC and T13 ZAC specify operations for Zoned devices.

To be able to access the zone information and open and close zones
adding flags for the report zones command (REQ_REPORT_ZONES) and for
Open and Close zone (REQ_OPEN_ZONE and REQ_CLOSE_ZONE) can be added
for use by struct bio's bi_rw and by struct request's cmd_flags.

To reduce the number of additional flags needed REQ_RESET_ZONE shares
the same flag as REQ_REPORT_ZONES and is differentiated by direction.
Report zones is a device read that requires a buffer. Reset is a device
command (WRITE) that has no associated data transfer.

The Finish zone command is intentionally not implimented as there is no
current use case for that operation.

Report zones currently defaults to reporting on all zones. It expected
that support for the zone option flag will piggy back on streamid
support. The report option is useful as it can reduce the number of
zones in each report, but not critical.

Signed-off-by: Shaun Tancheff 
---
 MAINTAINERS   |   9 ++
 block/blk-lib.c   |  96 +
 drivers/scsi/sd.c |  99 +-
 drivers/scsi/sd.h |   1 +
 include/linux/blk_types.h |  19 +++-
 include/linux/blkzoned_api.h  |  25 +
 include/uapi/linux/Kbuild |   1 +
 include/uapi/linux/blkzoned_api.h | 215 ++
 include/uapi/linux/fs.h   |   1 +
 9 files changed, 461 insertions(+), 5 deletions(-)
 create mode 100644 include/linux/blkzoned_api.h
 create mode 100644 include/uapi/linux/blkzoned_api.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 7304d2e..0b71a3c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -12660,6 +12660,15 @@ F: Documentation/networking/z8530drv.txt
 F: drivers/net/hamradio/*scc.c
 F: drivers/net/hamradio/z8530.h
 
+ZBC AND ZBC BLOCK DEVICES
+M: Shaun Tancheff 
+W: http://seagate.com
+W: https://github.com/Seagate/ZDM-Device-Mapper
+L: linux-bl...@vger.kernel.org
+S: Maintained
+F: include/linux/blkzoned_api.h
+F: include/uapi/linux/blkzoned_api.h
+
 ZBUD COMPRESSED PAGE ALLOCATOR
 M: Seth Jennings 
 L: linux...@kvack.org
diff --git a/block/blk-lib.c b/block/blk-lib.c
index 23d7f30..a7f047c 100644
--- a/block/blk-lib.c
+++ b/block/blk-lib.c
@@ -6,6 +6,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "blk.h"
 
@@ -249,3 +250,98 @@ int blkdev_issue_zeroout(struct block_device *bdev, 
sector_t sector,
return __blkdev_issue_zeroout(bdev, sector, nr_sects, gfp_mask);
 }
 EXPORT_SYMBOL(blkdev_issue_zeroout);
+
+/**
+ * blkdev_issue_zone_report - queue a report zones operation
+ * @bdev:  target blockdev
+ * @bi_rw: extra bio rw flags. If unsure, use 0.
+ * @sector:starting sector (report will include this sector).
+ * @page:  one or more contiguous pages.
+ * @pgsz:  up to size of page in bytes, size of report.
+ * @gfp_mask:  memory allocation flags (for bio_alloc)
+ *
+ * Description:
+ *Issue a zone report request for the sectors in question.
+ */
+int blkdev_issue_zone_report(struct block_device *bdev, unsigned int bi_rw,
+sector_t sector, u8 opt, struct page *page,
+size_t pgsz, gfp_t gfp_mask)
+{
+   struct bdev_zone_report *conv = page_address(page);
+   struct bio *bio;
+   unsigned int nr_iovecs = 1;
+   int ret = 0;
+
+   if (pgsz < (sizeof(struct bdev_zone_report) +
+   sizeof(struct bdev_zone_descriptor)))
+   return -EINVAL;
+
+   bio = bio_alloc(gfp_mask, nr_iovecs);
+   if (!bio)
+   return -ENOMEM;
+
+   conv->descriptor_count = 0;
+   bio->bi_iter.bi_sector = sector;
+   bio->bi_bdev = bdev;
+   bio->bi_vcnt = 0;
+   bio->bi_iter.bi_size = 0;
+
+   bi_rw |= REQ_REPORT_ZONES;
+
+   /* FUTURE ... when streamid is available: */
+   /* bio_set_streamid(bio, opt); */
+
+   bio_add_page(bio, page, pgsz, 0);
+   ret = submit_bio_wait(READ | bi_rw, bio);
+
+   /*
+* When our request it nak'd the underlying device maybe conventional
+* so ... report a single conventional zone the size of the device.
+*/
+   if (ret == -EIO && conv->descriptor_count) {
+   /* Adjust the conventional to the size of the partition ... */
+   __be64 blksz = cpu_to_be64(bdev->bd_part->nr_sects);
+
+   conv->maximum_lba = blksz;
+   conv->descriptors[0].type = ZTYP_CONVENTIONAL;
+   conv->descriptors[0].flags = ZCOND_CONVENTIONAL << 4;
+   conv->descriptors[0].length = blksz;
+   conv->descriptors[0].lba_start = 0;
+   conv->descriptors[0].lba_wptr = blksz;
+   return 0;
+   }
+   bio_put(bio);
+   return ret;
+}