linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Damien Le Moal <damien.lemoal@wdc.com>
Cc: linux-scsi@vger.kernel.org,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-block@vger.kernel.org, Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@lst.de>,
	Bart Van Assche <Bart.VanAssche@wdc.com>
Subject: Re: [PATCH V4 07/16] scsi: sd_zbc: Initialize device request queue zoned data
Date: Sun, 24 Sep 2017 17:07:01 +0200	[thread overview]
Message-ID: <20170924150701.GF14806@lst.de> (raw)
In-Reply-To: <20170924070247.25560-8-damien.lemoal@wdc.com>

> +static inline unsigned long *sd_zbc_alloc_zone_bitmap(struct scsi_disk *sdkp)
> +{
> +	struct request_queue *q = sdkp->disk->queue;
> +
> +	return kzalloc_node(BITS_TO_LONGS(sdkp->nr_zones)
> +			    * sizeof(unsigned long),
> +			    GFP_KERNEL, q->node);

This really screams for kcalloc_node and friends that I think Johannes
volunteered to add.

> + * sd_zbc_setup_seq_zones - Initialize the disk request queue zone type bitmap.
> + * @sdkp: The disk of the bitmap
> + *
> + * Allocate a zone bitmap and initialize it by identifying sequential zones.
> + */
> +static int sd_zbc_setup_seq_zones(struct scsi_disk *sdkp)
> +{
> +	struct request_queue *q = sdkp->disk->queue;
> +	unsigned long *seq_zones;
> +	sector_t block = 0;
> +	unsigned char *buf;
> +	unsigned char *rec;
> +	unsigned int buf_len;
> +	unsigned int list_length;
> +	unsigned int n = 0;
> +	u8 type, cond;
> +	int ret = -ENOMEM;
> +
> +	kfree(q->seq_zones);
> +	q->seq_zones = NULL;

We also free the previous version, which isn't documented above.
Which in general begs the question:  What scheme protects access
to q->seq_zones?

And the previous patch should probably grow a comment to document
that q->seq_zones is entirely managed by the driver.

> +		/*
> +		 * Parse reported zone descriptors to find sequiential zones.
> +		 * Since read-only and offline zones cannot be written, do not
> +		 * mark them as sequential in the bitmap.
> +		 */
> +		list_length = get_unaligned_be32(&buf[0]) + 64;
> +		rec = buf + 64;
> +		buf_len = min(list_length, SD_ZBC_BUF_SIZE);
> +		while (rec < buf + buf_len) {
> +			type = rec[0] & 0x0f;
> +			cond = (rec[1] >> 4) & 0xf;
> +			if (type != ZBC_ZONE_TYPE_CONV &&
> +			    cond != ZBC_ZONE_COND_READONLY &&
> +			    cond != ZBC_ZONE_COND_OFFLINE)
> +				set_bit(n, seq_zones);
> +			block = get_unaligned_be64(&rec[8]) +
> +				get_unaligned_be64(&rec[16]);
> +			rec += 64;
> +			n++;
> +		}

Split this out into a helper?

  reply	other threads:[~2017-09-24 15:07 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-24  7:02 [PATCH V4 00/16] scsi-mq support for ZBC disks Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 01/16] scsi: sd_zbc: Move ZBC declarations to scsi_proto.h Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 02/16] scsi: sd_zbc: Fix comments and indentation Damien Le Moal
2017-09-24 14:56   ` Christoph Hellwig
2017-09-25  9:14   ` Johannes Thumshirn
2017-09-24  7:02 ` [PATCH V4 03/16] scsi: sd_zbc: Rearrange code Damien Le Moal
2017-09-25  9:17   ` Johannes Thumshirn
2017-09-24  7:02 ` [PATCH V4 04/16] scsi: sd_zbc: Use well defined macros Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 05/16] scsi: sd_zbc: Fix sd_zbc_read_zoned_characteristics() Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 06/16] block: Add zoned block device information to request queue Damien Le Moal
2017-09-24 14:59   ` Christoph Hellwig
2017-09-24 16:34     ` Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 07/16] scsi: sd_zbc: Initialize device request queue zoned data Damien Le Moal
2017-09-24 15:07   ` Christoph Hellwig [this message]
2017-09-24 16:44     ` Damien Le Moal
2017-09-25  9:36     ` Johannes Thumshirn
2017-09-24  7:02 ` [PATCH V4 08/16] scsi: sd_zbc: Limit zone write locking to sequential zones Damien Le Moal
2017-09-24 15:18   ` Christoph Hellwig
2017-09-24 16:51     ` Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 09/16] scsi: sd_zbc: Disable zone write locking with scsi-mq Damien Le Moal
2017-09-24 15:16   ` Christoph Hellwig
2017-09-24  7:02 ` [PATCH V4 10/16] block: mq-deadline: Add zoned block device data Damien Le Moal
2017-09-24 15:14   ` Christoph Hellwig
2017-09-24 16:48     ` Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 11/16] block: mq-deadline: Introduce zones_wlock attribute Damien Le Moal
2017-09-24 15:19   ` Christoph Hellwig
2017-09-24 16:52     ` Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 12/16] blokc: mq-deadline: Introduce dispatch helpers Damien Le Moal
2017-09-24 15:21   ` Christoph Hellwig
2017-09-24  7:02 ` [PATCH V4 13/16] block: mq-deadline: Introduce zone locking support Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 14/16] block: mq-deadline: Limit write dispatch for zoned block devices Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 15/16] block: do not set mq defaulte scheduler Damien Le Moal
2017-09-24  7:02 ` [PATCH V4 16/16] block: mq-deadline: Update documentation Damien Le Moal
2017-09-24 15:02 ` [PATCH V4 00/16] scsi-mq support for ZBC disks Christoph Hellwig
2017-09-24 16:36   ` Damien Le Moal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170924150701.GF14806@lst.de \
    --to=hch@lst.de \
    --cc=Bart.VanAssche@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=damien.lemoal@wdc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).