commit libzbc for openSUSE:Factory
Hello community, here is the log from the commit of package libzbc for openSUSE:Factory checked in at 2016-12-08 00:31:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libzbc (Old) and /work/SRC/openSUSE:Factory/.libzbc.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "libzbc" Changes: -------- --- /work/SRC/openSUSE:Factory/libzbc/libzbc.changes 2016-10-10 16:21:46.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.libzbc.new/libzbc.changes 2016-12-08 00:31:13.000000000 +0100 @@ -1,0 +2,7 @@ +Tue Nov 29 10:31:02 UTC 2016 - jengelh@inai.de + +- Update to new upstream release 4.3.3 + * block backend driver: support latest "official" kernel + interface queued up for kernel 4.10 release. + +------------------------------------------------------------------- Old: ---- v4.3.0.tar.gz New: ---- v4.3.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libzbc.spec ++++++ --- /var/tmp/diff_new_pack.N3MIOt/_old 2016-12-08 00:31:14.000000000 +0100 +++ /var/tmp/diff_new_pack.N3MIOt/_new 2016-12-08 00:31:14.000000000 +0100 @@ -17,8 +17,8 @@ Name: libzbc -%define lname libzbc-4_3_0 -Version: 4.3.0 +%define lname libzbc-4_3_3 +Version: 4.3.3 Release: 0 Summary: Library for manipulating ZBC and ZAC disks License: BSD-2-Clause and LGPL-3.0+ ++++++ v4.3.0.tar.gz -> v4.3.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzbc-4.3.0/.gitignore new/libzbc-4.3.3/.gitignore --- old/libzbc-4.3.0/.gitignore 2016-08-18 04:04:10.000000000 +0200 +++ new/libzbc-4.3.3/.gitignore 2016-11-15 07:55:55.000000000 +0100 @@ -26,6 +26,7 @@ *.hex zbc_info +zbc_inquiry zbc_report_zones zbc_reset_write_ptr zbc_close_zone @@ -98,3 +99,8 @@ tools/lkvs/m4/ltversion.m4 tools/lkvs/m4/lt~obsolete.m4 +tools/lkvs/src/examples/lkvsfileput +tools/lkvs/src/examples/lkvsget +tools/lkvs/src/examples/lkvsmultiget +tools/lkvs/src/examples/lkvsmultiput +tools/lkvs/src/examples/lkvsput diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzbc-4.3.0/configure.ac new/libzbc-4.3.3/configure.ac --- old/libzbc-4.3.0/configure.ac 2016-08-18 04:04:10.000000000 +0200 +++ new/libzbc-4.3.3/configure.ac 2016-11-15 07:55:55.000000000 +0100 @@ -1,5 +1,5 @@ -AC_INIT([libzbc], [4.3.0], [damien.lemoal@hgst.com, adam.manzanares@hgst.com]) +AC_INIT([libzbc], [4.3.3], [damien.lemoal@wdc.com, adam.manzanares@wdc.com]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADER([include/config.h]) @@ -24,6 +24,12 @@ CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CC="$PTHREAD_CC" +# Checks for header files. +AC_CHECK_HEADER(scsi/scsi.h, [], [AC_MSG_ERROR([Couldn't find scsi/scsi.h])]) +AC_CHECK_HEADER(scsi/sg.h, [], [AC_MSG_ERROR([Couldn't find scsi/sg.h])]) +AC_CHECK_HEADER(libgen.h, [], [AC_MSG_ERROR([Couldn't find libgen.h])]) +AC_CHECK_HEADERS([linux/fs.h linux/blkzoned.h]) + # Conditionals # Build gzbc only if GTK3 is installed. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzbc-4.3.0/lib/zbc.h new/libzbc-4.3.3/lib/zbc.h --- old/libzbc-4.3.0/lib/zbc.h 2016-08-18 04:04:10.000000000 +0200 +++ new/libzbc-4.3.3/lib/zbc.h 2016-11-15 07:55:55.000000000 +0100 @@ -18,7 +18,8 @@ /***** Including files *****/ -#include <libzbc/zbc.h> +#include "config.h" +#include "libzbc/zbc.h" #include "zbc_log.h" #include <stdlib.h> @@ -199,22 +200,26 @@ extern int zbc_scsi_get_zbd_chars(zbc_device_t *dev); -extern int -zbc_scsi_report_zones(zbc_device_t *dev, - uint64_t start_lba, - enum zbc_reporting_options ro, - uint64_t *max_lba, - zbc_zone_t *zones, - unsigned int *nr_zones); - +/** + * SCSI backend driver open zone method. + * Used in block device backend too. + */ extern int zbc_scsi_open_zone(zbc_device_t *dev, uint64_t start_lba); +/** + * SCSI backend driver close zone method. + * Used in block device backend too. + */ extern int zbc_scsi_close_zone(zbc_device_t *dev, uint64_t start_lba); +/** + * SCSI backend driver finish zone method. + * Used in block device backend too. + */ extern int zbc_scsi_finish_zone(zbc_device_t *dev, uint64_t start_lba); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzbc-4.3.0/lib/zbc_block.c new/libzbc-4.3.3/lib/zbc_block.c --- old/libzbc-4.3.0/lib/zbc_block.c 2016-08-18 04:04:10.000000000 +0200 +++ new/libzbc-4.3.3/lib/zbc_block.c 2016-11-15 07:55:55.000000000 +0100 @@ -24,23 +24,41 @@ #include <sys/stat.h> #include <sys/types.h> #include <fcntl.h> +#include <limits.h> #include <linux/fs.h> #include "zbc.h" #include "zbc_sg.h" -/***** Macro and types definitions *****/ +#ifdef HAVE_LINUX_BLKZONED_H +#include <linux/blkzoned.h> +#endif -/** - * Block device descriptor data. - */ -typedef struct zbc_block_device { +/***** Inline functions *****/ + +static inline uint64_t zbc_block_lba2bytes(struct zbc_device *dev, + uint64_t lba) +{ + return lba * dev->zbd_info.zbd_logical_block_size; +} - struct zbc_device dev; +static inline uint64_t zbc_block_bytes2lba(struct zbc_device *dev, + uint64_t bytes) +{ + return bytes / dev->zbd_info.zbd_logical_block_size; +} - unsigned int zone_sectors; +static inline uint64_t zbc_block_lba2sector(struct zbc_device *dev, + uint64_t lba) +{ + return zbc_block_lba2bytes(dev, lba) >> 9; +} -} zbc_block_device_t; +static inline uint64_t zbc_block_sector2lba(struct zbc_device *dev, + uint64_t sector) +{ + return zbc_block_bytes2lba(dev, sector << 9); +} /***** Definition of private functions *****/ @@ -55,70 +73,34 @@ } /** - * Convert device address to block device handle address. - */ -static inline zbc_block_device_t * -zbc_dev_to_block_dev(struct zbc_device *dev) -{ - return container_of(dev, struct zbc_block_device, dev); -} - -/** * Test if the block device is zoned. */ static int zbc_block_device_is_zoned(struct zbc_device *dev) { - zbc_block_device_t *bdev = zbc_dev_to_block_dev(dev); - unsigned long long start, len; - unsigned int type, nr_zones; - int is_zoned = 0; char str[128]; - FILE *zoned; - int ret = 1; + FILE *file; - /* Check zoned attributes, if any */ + /* Check that this is a zoned block device */ snprintf(str, sizeof(str), "/sys/block/%s/queue/zoned", basename(dev->zbd_filename)); - zoned = fopen(str, "r"); - if ( ! zoned ) { - /* Not a zoned block device or no kernel support */ - return 0; + file = fopen(str, "r"); + if ( file ) { + memset(str, 0, sizeof(str)); + fscanf(file, "%s", str); } + fclose(file); - while( 1 ) { - - start = len = 0; - type = -1; - nr_zones = 0; - ret = fscanf(zoned, "%llu %llu %u %u", &start, &len, &type, &nr_zones); - if ( (ret == EOF) || (ret != 4) ) { - break; - } - - if ( nr_zones == 0 ) { - /* Not a zoned block device */ - ret = 0; - break; - } - - if ( type >= 2 ) { - if ( type == 2 ) { - dev->zbd_info.zbd_model = ZBC_DM_HOST_MANAGED; - } else { - dev->zbd_info.zbd_model = ZBC_DM_HOST_AWARE; - } - bdev->zone_sectors = len; - is_zoned = 1; - break; - } - + if ( strcmp(str, "host-aware") == 0 ) { + dev->zbd_info.zbd_model = ZBC_DM_HOST_AWARE; + return 1; + } else if ( strcmp(str, "host-managed") == 0 ) { + dev->zbd_info.zbd_model = ZBC_DM_HOST_MANAGED; + return 1; } - fclose(zoned); - - return is_zoned; + return 0; } @@ -147,7 +129,7 @@ } } - return( len ); + return len; } @@ -167,11 +149,10 @@ file = fopen(str, "r"); if ( file ) { len = zbc_block_get_str(file, str); - if ( len ) { + if ( len ) n = snprintf(dev->zbd_info.zbd_vendor_id, ZBC_DEVICE_INFO_LENGTH, "%s ", str); - } fclose(file); } @@ -181,11 +162,10 @@ file = fopen(str, "r"); if ( file ) { len = zbc_block_get_str(file, str); - if ( len ) { + if ( len ) n += snprintf(&dev->zbd_info.zbd_vendor_id[n], ZBC_DEVICE_INFO_LENGTH - n, "%s ", str); - } fclose(file); } @@ -195,11 +175,10 @@ file = fopen(str, "r"); if ( file ) { len = zbc_block_get_str(file, str); - if ( len ) { + if ( len ) snprintf(&dev->zbd_info.zbd_vendor_id[n], ZBC_DEVICE_INFO_LENGTH - n, "%s", str); - } fclose(file); ret = 1; } @@ -210,10 +189,10 @@ /** * Test if the device can be handled - * and set a the block device info. + * and get the block device info. */ static int -zbc_block_set_info(struct zbc_device *dev) +zbc_block_get_info(struct zbc_device *dev) { unsigned long long size64; struct stat st; @@ -236,10 +215,9 @@ } /* Is this a zoned device ? And do we have kernel support ? */ - if ( ! zbc_block_device_is_zoned(dev) ) { + if ( ! zbc_block_device_is_zoned(dev) ) /* Not a zoned block device: ignore */ return -ENXIO; - } /* Get logical block size */ ret = ioctl(dev->zbd_fd, BLKSSZGET, &size32); @@ -312,9 +290,8 @@ } /* Use SG_IO to get zone characteristics (maximum number of open zones, etc) */ - if ( zbc_scsi_get_zbd_chars(dev) ) { + if ( zbc_scsi_get_zbd_chars(dev) ) return -ENXIO; - } /* Get maximum command size */ zbc_sg_get_max_cmd_blocks(dev); @@ -331,13 +308,17 @@ int flags, struct zbc_device **pdev) { - zbc_block_device_t *bdev; struct zbc_device *dev; int fd, ret; zbc_debug("%s: ########## Trying BLOCK driver ##########\n", filename); +#ifndef HAVE_LINUX_BLKZONED_H + zbc_debug("libzbc compiled without block driver support\n"); + return -ENXIO; +#endif + /* Open block device: always add write mode for discard (reset zone) */ fd = open(filename, zbc_open_flags(flags) | O_WRONLY); if ( fd < 0 ) { @@ -351,24 +332,19 @@ /* Allocate a handle */ ret = -ENOMEM; - bdev = calloc(1, sizeof(*bdev)); - if ( ! bdev ) { + dev = calloc(1, sizeof(struct zbc_device)); + if ( ! dev ) goto out; - } - bdev->zone_sectors = 0; - dev = &bdev->dev; dev->zbd_fd = fd; dev->zbd_filename = strdup(filename); - if ( ! dev->zbd_filename ) { + if ( ! dev->zbd_filename ) goto out_free_dev; - } - /* Set the fake device information */ - ret = zbc_block_set_info(dev); - if ( ret != 0 ) { + /* Get device information */ + ret = zbc_block_get_info(dev); + if ( ret != 0 ) goto out_free_filename; - } *pdev = dev; @@ -383,13 +359,12 @@ out_free_dev: - free(bdev); + free(dev); out: - if ( fd >= 0 ) { + if ( fd >= 0 ) close(fd); - } zbc_debug("%s: ########## BLOCK driver failed %d ##########\n", filename, @@ -405,23 +380,23 @@ static int zbc_block_close(zbc_device_t *dev) { - zbc_block_device_t *bdev = zbc_dev_to_block_dev(dev); int ret = 0; /* Close device */ - if ( close(dev->zbd_fd) < 0 ) { + if ( close(dev->zbd_fd) < 0 ) ret = -errno; - } if ( ret == 0 ) { free(dev->zbd_filename); - free(bdev); + free(dev); } return ret; } +#ifdef HAVE_LINUX_BLKZONED_H + /** * Flush the device. */ @@ -435,9 +410,51 @@ } /** - * Get the block device zone information: use SG_IO, but - * sync the device first to ensure that the current write - * pointer value is returned. + * Test if a zone should be reported depending + * on the specified reporting options. + */ +static bool +zbc_block_must_report(struct zbc_zone *zone, + enum zbc_reporting_options ro) +{ + enum zbc_reporting_options options = ro & (~ZBC_RO_PARTIAL); + + switch ( options ) { + case ZBC_RO_ALL: + return true; + case ZBC_RO_EMPTY: + return zbc_zone_empty(zone); + case ZBC_RO_IMP_OPEN: + return zbc_zone_imp_open(zone); + case ZBC_RO_EXP_OPEN: + return zbc_zone_exp_open(zone); + case ZBC_RO_CLOSED: + return zbc_zone_closed(zone); + case ZBC_RO_FULL: + return zbc_zone_full(zone); + case ZBC_RO_RDONLY: + return zbc_zone_rdonly(zone); + case ZBC_RO_OFFLINE: + return zbc_zone_offline(zone); + case ZBC_RO_RESET: + return zbc_zone_need_reset(zone); + case ZBC_RO_NON_SEQ: + return zbc_zone_non_seq(zone); + case ZBC_RO_NOT_WP: + return zbc_zone_not_wp(zone); + default: + break; + } + + return false; + + +} + +#define ZBC_BLOCK_ZONE_REPORT_NR_ZONES 8192 + +/** + * Get the block device zone information. */ static int zbc_block_report_zones(struct zbc_device *dev, @@ -447,11 +464,77 @@ struct zbc_zone *zones, unsigned int *nr_zones) { + struct zbc_zone zone; + struct blk_zone_report *rep; + struct blk_zone *blkz; + unsigned int i, n = 0; + int ret; + + rep = malloc(sizeof(struct blk_zone_report) + + sizeof(struct blk_zone) * ZBC_BLOCK_ZONE_REPORT_NR_ZONES); + if ( ! rep ) { + zbc_error("%s: No memory for report zones\n", + dev->zbd_filename); + return -ENOMEM; + } + blkz = (struct blk_zone *)(rep + 1); + + while ( ((! *nr_zones) || (n < *nr_zones)) + && (start_lba < dev->zbd_info.zbd_logical_blocks) ) { + + /* Get zone info */ + memset(rep, 0, sizeof(struct blk_zone_report) + + sizeof(struct blk_zone) * ZBC_BLOCK_ZONE_REPORT_NR_ZONES); + rep->sector = zbc_block_lba2sector(dev, start_lba); + rep->nr_zones = ZBC_BLOCK_ZONE_REPORT_NR_ZONES; + + ret = ioctl(dev->zbd_fd, BLKREPORTZONE, rep); + if ( ret != 0 ) { + ret = -errno; + zbc_error("%s: ioctl BLKREPORTZONE at %llu failed %d (%s)\n", + dev->zbd_filename, + (unsigned long long)start_lba, + errno, + strerror(errno)); + goto out; + } + + for(i = 0; i < rep->nr_zones; i++) { + + if ( (*nr_zones && (n >= *nr_zones)) + || (start_lba >= dev->zbd_info.zbd_logical_blocks) ) + break; + + memset(&zone, 0, sizeof(struct zbc_zone)); + zone.zbz_type = blkz[i].type; + zone.zbz_condition = blkz[i].cond; + zone.zbz_length = zbc_block_sector2lba(dev, blkz[i].len); + zone.zbz_start = zbc_block_sector2lba(dev, blkz[i].start); + zone.zbz_write_pointer = zbc_block_sector2lba(dev, blkz[i].wp); + if ( blkz[i].reset ) + zone.zbz_flags |= ZBC_ZF_NEED_RESET; + if ( blkz[i].non_seq ) + zone.zbz_flags |= ZBC_ZF_NON_SEQ; + + if ( zbc_block_must_report(&zone, ro) ) { + if ( zones ) + memcpy(&zones[n], &zone, sizeof(struct zbc_zone)); + n++; + } + + start_lba += zbc_zone_length(&zone); + + } + + } + + /* Return number of zones */ + *nr_zones = n; - fdatasync(dev->zbd_fd); +out: + free(rep); - return zbc_scsi_report_zones(dev, start_lba, ro, - max_lba, zones, nr_zones); + return ret; } @@ -460,7 +543,7 @@ */ static int zbc_block_open_zone(zbc_device_t *dev, - uint64_t start_lba) + uint64_t start_lba) { return zbc_scsi_open_zone(dev, start_lba); } @@ -470,7 +553,7 @@ */ static int zbc_block_close_zone(zbc_device_t *dev, - uint64_t start_lba) + uint64_t start_lba) { return zbc_scsi_close_zone(dev, start_lba); } @@ -480,37 +563,130 @@ */ static int zbc_block_finish_zone(zbc_device_t *dev, - uint64_t start_lba) + uint64_t start_lba) { return zbc_scsi_finish_zone(dev, start_lba); } /** + * Reset a single zone write pointer. + */ +static int +zbc_block_reset_one(struct zbc_device *dev, + uint64_t start_lba) +{ + struct blk_zone_range range; + struct zbc_zone zone; + unsigned int nr_zones = 1; + int ret; + + /* Get zone info */ + ret = zbc_block_report_zones(dev, start_lba, + ZBC_RO_ALL, NULL, + &zone, &nr_zones); + if (ret) + return ret; + if (! nr_zones ) { + zbc_error("%s: Invalid LBA\n", + dev->zbd_filename); + return -EINVAL; + } + + if (zbc_zone_conventional(&zone) + || zbc_zone_empty(&zone)) + return 0; + + /* Reset zone */ + range.sector = zbc_block_lba2sector(dev, zbc_zone_start_lba(&zone)); + range.nr_sectors = zbc_block_lba2sector(dev, zbc_zone_length(&zone)); + ret = ioctl(dev->zbd_fd, BLKRESETZONE, &range); + if ( ret != 0 ) { + ret = -errno; + zbc_error("%s: ioctl BLKRESETZONE failed %d (%s)\n", + dev->zbd_filename, + errno, + strerror(errno)); + } + + return ret; + +} + +/** + * Reset all zones write pointer. + */ +static int +zbc_block_reset_all(struct zbc_device *dev) +{ + struct zbc_zone *zones; + unsigned int i, nr_zones; + struct blk_zone_range range; + uint64_t start_lba = 0; + int ret; + + zones = malloc(sizeof(struct zbc_zone) * ZBC_BLOCK_ZONE_REPORT_NR_ZONES); + if ( ! zones ) { + zbc_error("%s: No memory for report zones\n", + dev->zbd_filename); + return -ENOMEM; + } + + while ( 1 ) { + + /* Get zone info */ + nr_zones = ZBC_BLOCK_ZONE_REPORT_NR_ZONES; + ret = zbc_block_report_zones(dev, start_lba, + ZBC_RO_ALL, NULL, + zones, &nr_zones); + if (ret || (! nr_zones)) + break; + + for (i = 0; i < nr_zones; i++) { + + start_lba = zbc_zone_next_lba(&zones[i]); + + if (zbc_zone_conventional(&zones[i]) + || zbc_zone_empty(&zones[i])) + continue; + + /* Reset zone */ + range.sector = zbc_block_lba2sector(dev, zbc_zone_start_lba(&zones[i])); + range.nr_sectors = zbc_block_lba2sector(dev, zbc_zone_length(&zones[i])); + ret = ioctl(dev->zbd_fd, BLKRESETZONE, &range); + if ( ret != 0 ) { + ret = -errno; + zbc_error("%s: ioctl BLKRESETZONE failed %d (%s)\n", + dev->zbd_filename, + errno, + strerror(errno)); + goto out; + } + + } + + } + +out: + free(zones); + + return ret; + +} + +/** * Reset zone(s) write pointer: use BLKDISCARD ioctl. */ static int zbc_block_reset_wp(struct zbc_device *dev, uint64_t start_lba) { - zbc_block_device_t *bdev = zbc_dev_to_block_dev(dev); - uint64_t range[2]; - if ( start_lba == (uint64_t)-1 ) { - /* Reset all zones */ - range[0] = 0; - range[1] = dev->zbd_info.zbd_logical_blocks * dev->zbd_info.zbd_logical_block_size; - } else { - /* Reset only the zone at start_lba */ - range[0] = start_lba * dev->zbd_info.zbd_logical_block_size; - range[1] = bdev->zone_sectors << 9; - } - - /* Discard */ - if ( ioctl(dev->zbd_fd, BLKDISCARD, &range) != 0 ) { - return -errno; - } + if ( start_lba == (uint64_t)-1 ) + /* All zones */ + return zbc_block_reset_all(dev); - return 0; + /* One zone */ + return zbc_block_reset_one(dev, start_lba); } @@ -529,13 +705,12 @@ /* Read */ ret = pread(dev->zbd_fd, buf, - lba_count * dev->zbd_info.zbd_logical_block_size, - (zone->zbz_start + lba_ofst) * dev->zbd_info.zbd_logical_block_size); - if ( ret < 0 ) { + zbc_block_lba2bytes(dev, lba_count), + zbc_block_lba2bytes(dev, zone->zbz_start + lba_ofst)); + if ( ret < 0 ) ret = -errno; - } else { - ret /= dev->zbd_info.zbd_logical_block_size; - } + else + ret = zbc_block_bytes2lba(dev, ret); return ret; @@ -556,18 +731,90 @@ /* Read */ ret = pwrite(dev->zbd_fd, buf, - lba_count * dev->zbd_info.zbd_logical_block_size, - (zone->zbz_start + lba_ofst) * dev->zbd_info.zbd_logical_block_size); - if ( ret < 0 ) { + zbc_block_lba2bytes(dev, lba_count), + zbc_block_lba2bytes(dev, zone->zbz_start + lba_ofst)); + if ( ret < 0 ) ret = -errno; - } else { - ret /= dev->zbd_info.zbd_logical_block_size; - } + else + ret = zbc_block_bytes2lba(dev, ret); return ret; } +#else /* HAVE_LINUX_BLKZONED_H */ + +static int +zbc_block_report_zones(struct zbc_device *dev, + uint64_t start_lba, + enum zbc_reporting_options ro, + uint64_t *max_lba, + struct zbc_zone *zones, + unsigned int *nr_zones) +{ + return -EOPNOTSUPP; +} + +static int +zbc_block_open_zone(zbc_device_t *dev, + uint64_t start_lba) +{ + return -EOPNOTSUPP; +} + +static int +zbc_block_close_zone(zbc_device_t *dev, + uint64_t start_lba) +{ + return -EOPNOTSUPP; +} + +static int +zbc_block_finish_zone(zbc_device_t *dev, + uint64_t start_lba) +{ + return -EOPNOTSUPP; +} + + +static int +zbc_block_reset_wp(struct zbc_device *dev, + uint64_t start_lba) +{ + return -EOPNOTSUPP; +} + +static int32_t +zbc_block_pread(struct zbc_device *dev, + zbc_zone_t *zone, + void *buf, + uint32_t lba_count, + uint64_t lba_ofst) +{ + return -EOPNOTSUPP; +} + +static int32_t +zbc_block_pwrite(struct zbc_device *dev, + zbc_zone_t *zone, + const void *buf, + uint32_t lba_count, + uint64_t lba_ofst) +{ + return -EOPNOTSUPP; +} + +static int +zbc_block_flush(struct zbc_device *dev, + uint64_t lba_offset, + uint32_t lba_count, + int immediate) +{ + return -EOPNOTSUPP; +} + +#endif /* HAVE_LINUX_BLKZONED_H */ + struct zbc_ops zbc_block_ops = { .zbd_open = zbc_block_open, .zbd_close = zbc_block_close, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzbc-4.3.0/lib/zbc_scsi.c new/libzbc-4.3.3/lib/zbc_scsi.c --- old/libzbc-4.3.0/lib/zbc_scsi.c 2016-08-18 04:04:10.000000000 +0200 +++ new/libzbc-4.3.3/lib/zbc_scsi.c 2016-11-15 07:55:55.000000000 +0100 @@ -299,7 +299,7 @@ /** * Get a SCSI device zone information. */ -int +static int zbc_scsi_report_zones(zbc_device_t *dev, uint64_t start_lba, enum zbc_reporting_options ro, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzbc-4.3.0/test/scripts/zbc_test_lib.sh new/libzbc-4.3.3/test/scripts/zbc_test_lib.sh --- old/libzbc-4.3.0/test/scripts/zbc_test_lib.sh 2016-08-18 04:04:10.000000000 +0200 +++ new/libzbc-4.3.3/test/scripts/zbc_test_lib.sh 2016-11-15 07:55:55.000000000 +0100 @@ -32,6 +32,7 @@ # Store argument device=$2 + device_base=`basename ${device}` bin_path=$3 # Test name @@ -48,7 +49,7 @@ rm -f ${log_file} # Zone info file - zone_info_file="/tmp/${test_name}_zone_info.log" + zone_info_file="/tmp/${test_name}_zone_info.${device_base}.log" rm -f ${zone_info_file} # Dump zone info file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzbc-4.3.0/test/zbc_test.sh new/libzbc-4.3.3/test/zbc_test.sh --- old/libzbc-4.3.0/test/zbc_test.sh 2016-08-18 04:04:10.000000000 +0200 +++ new/libzbc-4.3.3/test/zbc_test.sh 2016-11-15 07:55:55.000000000 +0100 @@ -18,6 +18,7 @@ fi device_file=${1} +device_base=`basename ${device_file}` # Check credentials if [ $(id -u) -ne 0 ]; then @@ -25,16 +26,13 @@ exit 1 fi -# Set file names -log_file=${log_path}/${testname}.log - # Test function function zbc_run_test() { declare -i run_test_ret=0 ZBC_TEST_SUB_SCR_PATH=${ZBC_TEST_SCR_PATH}/${1} - ZBC_TEST_SUB_LOG_PATH=${ZBC_TEST_LOG_PATH}/${1} + ZBC_TEST_SUB_LOG_PATH=${ZBC_TEST_LOG_PATH}/${device_base}/${1} if [ ! -d ${ZBC_TEST_SUB_SCR_PATH} ]; then echo "Test script directory ${ZBC_TEST_SUB_SCR_PATH} does not exist" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzbc-4.3.0/tools/read_zone/zbc_read_zone.c new/libzbc-4.3.3/tools/read_zone/zbc_read_zone.c --- old/libzbc-4.3.0/tools/read_zone/zbc_read_zone.c 2016-08-18 04:04:10.000000000 +0200 +++ new/libzbc-4.3.3/tools/read_zone/zbc_read_zone.c 2016-11-15 07:55:55.000000000 +0100 @@ -41,7 +41,7 @@ /** * System time in usecs. */ -static __inline__ unsigned long long +static inline unsigned long long zbc_read_zone_usec(void) { struct timeval tv; @@ -264,7 +264,7 @@ ret = 1; goto out; } - ret = posix_memalign((void **) &iobuf, info.zbd_logical_block_size, iosize); + ret = posix_memalign((void **) &iobuf, sysconf(_SC_PAGESIZE), iosize); if ( ret != 0 ) { fprintf(stderr, "No memory for I/O buffer (%zu B)\n", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzbc-4.3.0/tools/report_zones/zbc_report_zones.c new/libzbc-4.3.3/tools/report_zones/zbc_report_zones.c --- old/libzbc-4.3.0/tools/report_zones/zbc_report_zones.c 2016-08-18 04:04:10.000000000 +0200 +++ new/libzbc-4.3.3/tools/report_zones/zbc_report_zones.c 2016-11-15 07:55:55.000000000 +0100 @@ -29,7 +29,7 @@ char **argv) { struct zbc_device_info info; - unsigned long long lba = 0; + unsigned long long lba = 0, nr_lba = 0; struct zbc_device *dev; enum zbc_reporting_options ro = ZBC_RO_ALL; int i, ret = 1; @@ -232,10 +232,27 @@ } printf("%u / %u zone%s:\n", nz, nr_zones, (nz > 1) ? "s" : ""); + lba = 0; for(i = 0; i < (int)nz; i++) { + z = &zones[i]; + + if (ro == ZBC_RO_ALL) { + /* Check */ + if (zbc_zone_start_lba(z) != lba) { + printf("[WARNING] Zone %05d: LBA %llu should be %llu\n", + i, + zbc_zone_start_lba(z), + lba); + lba = zbc_zone_start_lba(z); + } + nr_lba += zbc_zone_length(z); + lba += zbc_zone_length(z); + } + if ( zbc_zone_conventional(z) ) { - printf("Zone %05d: type 0x%x (%s), cond 0x%x (%s), LBA %llu, %llu sectors, wp N/A\n", + printf("Zone %05d: type 0x%x (%s), cond 0x%x (%s), LBA %llu, " + "%llu sectors, wp N/A\n", i, zbc_zone_type(z), zbc_zone_type_str(zbc_zone_type(z)), @@ -243,19 +260,41 @@ zbc_zone_condition_str(zbc_zone_condition(z)), zbc_zone_start_lba(z), zbc_zone_length(z)); - } else { - printf("Zone %05d: type 0x%x (%s), cond 0x%x (%s), need_reset %d, non_seq %d, LBA %llu, %llu sectors, wp %llu\n", - i, - zbc_zone_type(z), - zbc_zone_type_str(zbc_zone_type(z)), - zbc_zone_condition(z), - zbc_zone_condition_str(zbc_zone_condition(z)), - zbc_zone_need_reset(z), - zbc_zone_non_seq(z), - zbc_zone_start_lba(z), - zbc_zone_length(z), - zbc_zone_wp_lba(z)); + continue; + } + + if ( zbc_zone_sequential(z) ) { + printf("Zone %05d: type 0x%x (%s), cond 0x%x (%s), need_reset %d, " + "non_seq %d, LBA %llu, %llu sectors, wp %llu\n", + i, + zbc_zone_type(z), + zbc_zone_type_str(zbc_zone_type(z)), + zbc_zone_condition(z), + zbc_zone_condition_str(zbc_zone_condition(z)), + zbc_zone_need_reset(z), + zbc_zone_non_seq(z), + zbc_zone_start_lba(z), + zbc_zone_length(z), + zbc_zone_wp_lba(z)); + continue; } + + printf("Zone %05d: unknown type 0x%x, LBA %llu, %llu sectors\n", + i, + zbc_zone_type(z), + zbc_zone_start_lba(z), + zbc_zone_length(z)); + + } + + if ( ro == ZBC_RO_ALL ) { + /* Check */ + if ( nr_lba != info.zbd_logical_blocks ) { + printf("[WARNING] %llu logical blocks reported " + "but capacity is %llu logical blocks\n", + nr_lba, + (unsigned long long)info.zbd_logical_blocks); + } } out: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libzbc-4.3.0/tools/write_zone/zbc_write_zone.c new/libzbc-4.3.3/tools/write_zone/zbc_write_zone.c --- old/libzbc-4.3.0/tools/write_zone/zbc_write_zone.c 2016-08-18 04:04:10.000000000 +0200 +++ new/libzbc-4.3.3/tools/write_zone/zbc_write_zone.c 2016-11-15 07:55:55.000000000 +0100 @@ -268,11 +268,10 @@ zbc_zone_wp_lba(iozone)); /* Check I/O size alignment */ - if ( zbc_zone_sequential_req(iozone) ) { + if ( zbc_zone_sequential_req(iozone) ) ioalign = info.zbd_physical_block_size; - } else { + else ioalign = info.zbd_logical_block_size; - } if ( iosize % ioalign ) { fprintf(stderr, "Invalid I/O size %zu (must be aligned on %zu)\n", @@ -283,7 +282,7 @@ } /* Get an I/O buffer */ - ret = posix_memalign((void **) &iobuf, ioalign, iosize); + ret = posix_memalign((void **) &iobuf, sysconf(_SC_PAGESIZE), iosize); if ( ret != 0 ) { fprintf(stderr, "No memory for I/O buffer (%zu B)\n",
participants (1)
-
root@hilbert.suse.de