From: Christoph Hellwig <hch@infradead.org>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Cc: Jens Axboe <axboe@kernel.dk>,
Christoph Hellwig <hch@infradead.org>,
linux-block <linux-block@vger.kernel.org>,
Damien Le Moal <Damien.LeMoal@wdc.com>,
Keith Busch <kbusch@kernel.org>,
"linux-scsi @ vger . kernel . org" <linux-scsi@vger.kernel.org>,
"Martin K . Petersen" <martin.petersen@oracle.com>,
"linux-fsdevel @ vger . kernel . org"
<linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH v5 07/10] scsi: sd_zbc: emulate ZONE_APPEND commands
Date: Fri, 10 Apr 2020 00:23:54 -0700 [thread overview]
Message-ID: <20200410072354.GB13404@infradead.org> (raw)
In-Reply-To: <20200409165352.2126-8-johannes.thumshirn@wdc.com>
> + spin_lock_bh(&sdkp->zones_wp_ofst_lock);
> +
> + wp_ofst = sdkp->zones_wp_ofst[zno];
> + if (wp_ofst == SD_ZBC_UPDATING_WP_OFST) {
> + /* Write pointer offset update in progress: ask for a requeue */
> + ret = BLK_STS_RESOURCE;
> + goto err;
> + }
> +
> + if (wp_ofst == SD_ZBC_INVALID_WP_OFST) {
> + /* Invalid write pointer offset: trigger an update from disk */
> + ret = sd_zbc_update_wp_ofst(sdkp, zno);
> + goto err;
> + }
Maybe I'm a little too clever for my own sake, but what about something
like:
spin_lock_bh(&sdkp->zones_wp_ofst_lock);
switch (wp_ofst) {
case SD_ZBC_INVALID_WP_OFST:
if (scsi_device_get(sdkp->device)) {
ret = BLK_STS_IOERR;
break;
}
sdkp->zones_wp_ofst[zno] = SD_ZBC_UPDATING_WP_OFST;
schedule_work(&sdkp->zone_wp_ofst_work);
/*FALLTHRU*/
case SD_ZBC_UPDATING_WP_OFST:
ret = BLK_STS_DEV_RESOURCE;
break;
default:
wp_ofst = sectors_to_logical(sdkp->device, wp_ofst);
if (wp_ofst + nr_blocks > sdkp->zone_blocks) {
ret = BLK_STS_IOERR;
break;
}
*lba += wp_ofst;
}
spin_unlock_bh(&sdkp->zones_wp_ofst_lock);
if (ret)
blk_req_zone_write_unlock(rq);
return ret;
}
> int result = cmd->result;
> @@ -294,7 +543,18 @@ void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
> * so be quiet about the error.
> */
> rq->rq_flags |= RQF_QUIET;
> + goto unlock_zone;
> }
> +
> + if (sd_zbc_need_zone_wp_update(rq))
> + good_bytes = sd_zbc_zone_wp_update(cmd, good_bytes);
> +
> +
> +unlock_zone:
why not use a good old "else if" here?
next prev parent reply other threads:[~2020-04-10 7:23 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-09 16:53 [PATCH v5 00/10] Introduce Zone Append for writing to zoned block devices Johannes Thumshirn
2020-04-09 16:53 ` [PATCH v5 01/10] block: provide fallbacks for blk_queue_zone_is_seq and blk_queue_zone_no Johannes Thumshirn
2020-04-09 16:53 ` [PATCH v5 02/10] block: Introduce REQ_OP_ZONE_APPEND Johannes Thumshirn
2020-04-10 7:10 ` Christoph Hellwig
2020-04-14 9:43 ` Johannes Thumshirn
2020-04-14 11:28 ` hch
2020-04-09 16:53 ` [PATCH v5 03/10] block: introduce blk_req_zone_write_trylock Johannes Thumshirn
2020-04-09 16:53 ` [PATCH v5 04/10] block: Modify revalidate zones Johannes Thumshirn
2020-04-10 0:27 ` Damien Le Moal
2020-04-10 6:40 ` Christoph Hellwig
2020-04-10 6:55 ` Damien Le Moal
2020-04-09 16:53 ` [PATCH v5 05/10] scsi: sd_zbc: factor out sanity checks for zoned commands Johannes Thumshirn
2020-04-09 16:53 ` [PATCH v5 06/10] scsi: export scsi_mq_free_sgtables Johannes Thumshirn
2020-04-10 5:58 ` Christoph Hellwig
2020-04-10 7:46 ` Johannes Thumshirn
2020-04-10 14:22 ` Bart Van Assche
2020-04-09 16:53 ` [PATCH v5 07/10] scsi: sd_zbc: emulate ZONE_APPEND commands Johannes Thumshirn
2020-04-10 0:30 ` Damien Le Moal
2020-04-10 6:18 ` Christoph Hellwig
2020-04-10 6:38 ` Christoph Hellwig
2020-04-10 8:01 ` Johannes Thumshirn
2020-04-14 11:09 ` Johannes Thumshirn
2020-04-14 11:30 ` hch
2020-04-10 7:54 ` Johannes Thumshirn
2020-04-10 7:23 ` Christoph Hellwig [this message]
2020-04-14 10:18 ` Johannes Thumshirn
2020-04-09 16:53 ` [PATCH v5 08/10] null_blk: Support REQ_OP_ZONE_APPEND Johannes Thumshirn
2020-04-09 16:53 ` [PATCH v5 09/10] block: export bio_release_pages and bio_iov_iter_get_pages Johannes Thumshirn
2020-04-09 16:53 ` [PATCH v5 10/10] zonefs: use REQ_OP_ZONE_APPEND for sync DIO Johannes Thumshirn
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=20200410072354.GB13404@infradead.org \
--to=hch@infradead.org \
--cc=Damien.LeMoal@wdc.com \
--cc=axboe@kernel.dk \
--cc=johannes.thumshirn@wdc.com \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@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).