From: Bart Van Assche <bvanassche@acm.org>
To: Jack Wang <jinpu.wang@cloud.ionos.com>,
linux-block@vger.kernel.org, linux-rdma@vger.kernel.org
Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me,
leon@kernel.org, dledford@redhat.com, jgg@ziepe.ca,
danil.kipnis@cloud.ionos.com, rpenyaev@suse.de,
pankaj.gupta@cloud.ionos.com
Subject: Re: [PATCH v11 18/26] block/rnbd: client: main functionality
Date: Fri, 27 Mar 2020 21:45:55 -0700 [thread overview]
Message-ID: <198cd2da-cbf8-17b0-3ee5-5dec366a43e2@acm.org> (raw)
In-Reply-To: <20200320121657.1165-19-jinpu.wang@cloud.ionos.com>
On 2020-03-20 05:16, Jack Wang wrote:
> +static void rnbd_clt_put_dev(struct rnbd_clt_dev *dev)
> +{
> + might_sleep();
> +
> + if (refcount_dec_and_test(&dev->refcount)) {
> + mutex_lock(&ida_lock);
> + ida_simple_remove(&index_ida, dev->clt_device_id);
> + mutex_unlock(&ida_lock);
> + kfree(dev->hw_queues);
> + rnbd_clt_put_sess(dev->sess);
> + mutex_destroy(&dev->lock);
> + kfree(dev);
> + }
> +}
Please use the coding style that is used elsewhere in the kernel, namely
return early to keep the indentation level low.
> +enum {
> + RNBD_DELAY_10ms = 10,
> + RNBD_DELAY_IFBUSY = -1,
> +};
How about removing the RNBD_DELAY_10ms constant and using 10/*ms*/ instead?
> +enum {
> + NO_WAIT = 0,
> + WAIT = 1
> +};
> +
> +static int send_usr_msg(struct rtrs_clt *rtrs, int dir,
> + struct rnbd_iu *iu, struct kvec *vec, size_t nr,
> + size_t len, struct scatterlist *sg, unsigned int sg_len,
> + void (*conf)(struct work_struct *work),
> + int *errno, bool wait)
Are the NO_WAIT and WAIT perhaps values that are passed as the last
argument to send_usr_msg()? If so, please use a proper enumeration type
instead of 'bool'.
> +static int rnbd_client_getgeo(struct block_device *block_device,
> + struct hd_geometry *geo)
> +{
> + u64 size;
> + struct rnbd_clt_dev *dev;
> +
> + dev = block_device->bd_disk->private_data;
> + size = dev->size * (dev->logical_block_size / SECTOR_SIZE);
> + geo->cylinders = (size & ~0x3f) >> 6; /* size/64 */
> + geo->heads = 4;
> + geo->sectors = 16;
> + geo->start = 0;
> +
> + return 0;
> +}
Is the "& ~0x3f" in the above function perhaps superfluous?
> +static void rnbd_clt_dev_kick_mq_queue(struct rnbd_clt_dev *dev,
> + struct blk_mq_hw_ctx *hctx,
> + int delay)
> +{
> + struct rnbd_queue *q = hctx->driver_data;
> +
> + if (delay != RNBD_DELAY_IFBUSY)
> + blk_mq_delay_run_hw_queue(hctx, delay);
> + else if (unlikely(!rnbd_clt_dev_add_to_requeue(dev, q)))
> + /*
> + * If session is not busy we have to restart
> + * the queue ourselves.
> + */
> + blk_mq_delay_run_hw_queue(hctx, RNBD_DELAY_10ms);
> +}
I think the above code will be easier to read if RNBD_DELAY_10ms is
changed into 10/*ms*/.
> +static blk_status_t rnbd_queue_rq(struct blk_mq_hw_ctx *hctx,
> + const struct blk_mq_queue_data *bd)
> +{
> + struct request *rq = bd->rq;
> + struct rnbd_clt_dev *dev = rq->rq_disk->private_data;
> + struct rnbd_iu *iu = blk_mq_rq_to_pdu(rq);
> + int err;
> +
> + if (unlikely(dev->dev_state != DEV_STATE_MAPPED))
> + return BLK_STS_IOERR;
> +
> + iu->permit = rnbd_get_permit(dev->sess, RTRS_IO_CON,
> + RTRS_PERMIT_NOWAIT);
> + if (unlikely(!iu->permit)) {
> + rnbd_clt_dev_kick_mq_queue(dev, hctx, RNBD_DELAY_IFBUSY);
> + return BLK_STS_RESOURCE;
> + }
> +
> + blk_mq_start_request(rq);
> + err = rnbd_client_xfer_request(dev, rq, iu);
> + if (likely(err == 0))
> + return BLK_STS_OK;
> + if (unlikely(err == -EAGAIN || err == -ENOMEM)) {
> + rnbd_clt_dev_kick_mq_queue(dev, hctx, RNBD_DELAY_10ms);
> + rnbd_put_permit(dev->sess, iu->permit);
> + return BLK_STS_RESOURCE;
> + }
> +
> + rnbd_put_permit(dev->sess, iu->permit);
> + return BLK_STS_IOERR;
> +}
Would it be possible to use the .get_budget / .put_budget callbacks for
obtaining / releasing a "permit" object? I'm asking this because it was
really tricky to get the .get_budget / .put_budget calls right in the
block layer core. See also commit 0bca799b9280 ("blk-mq: order getting
budget and driver tag") # v4.17.
Thanks,
Bart.
next prev parent reply other threads:[~2020-03-28 4:46 UTC|newest]
Thread overview: 71+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-20 12:16 [PATCH v11 00/26] RTRS (former IBTRS) RDMA Transport Library and RNBD (former IBNBD) RDMA Network Block Device Jack Wang
2020-03-20 12:16 ` [PATCH v11 01/26] sysfs: export sysfs_remove_file_self() Jack Wang
2020-03-20 12:16 ` [PATCH v11 02/26] RDMA/rtrs: public interface header to establish RDMA connections Jack Wang
2020-03-20 12:16 ` [PATCH v11 03/26] RDMA/rtrs: private headers with rtrs protocol structs and helpers Jack Wang
2020-03-20 12:16 ` [PATCH v11 04/26] RDMA/rtrs: core: lib functions shared between client and server modules Jack Wang
2020-03-28 4:26 ` Bart Van Assche
2020-03-30 10:34 ` Jinpu Wang
2020-03-30 22:25 ` Bart Van Assche
2020-03-31 7:11 ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 05/26] RDMA/rtrs: client: private header with client structs and functions Jack Wang
2020-03-20 12:16 ` [PATCH v11 06/26] RDMA/rtrs: client: main functionality Jack Wang
2020-03-20 12:16 ` [PATCH v11 07/26] RDMA/rtrs: client: statistics functions Jack Wang
2020-03-20 12:16 ` [PATCH v11 08/26] RDMA/rtrs: client: sysfs interface functions Jack Wang
2020-03-30 22:28 ` Bart Van Assche
2020-03-31 7:20 ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 09/26] RDMA/rtrs: server: private header with server structs and functions Jack Wang
2020-03-20 12:16 ` [PATCH v11 10/26] RDMA/rtrs: server: main functionality Jack Wang
2020-03-20 12:16 ` [PATCH v11 11/26] RDMA/rtrs: server: statistics functions Jack Wang
2020-03-20 12:16 ` [PATCH v11 12/26] RDMA/rtrs: server: sysfs interface functions Jack Wang
2020-03-30 22:29 ` Bart Van Assche
2020-03-31 7:13 ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 13/26] RDMA/rtrs: include client and server modules into kernel compilation Jack Wang
2020-03-20 12:16 ` [PATCH v11 14/26] RDMA/rtrs: a bit of documentation Jack Wang
2020-03-20 12:16 ` [PATCH v11 15/26] block: reexport bio_map_kern Jack Wang
2020-03-28 3:58 ` Bart Van Assche
2020-03-28 8:29 ` Christoph Hellwig
2020-03-28 16:16 ` Bart Van Assche
2020-03-29 15:05 ` Christoph Hellwig
2020-03-29 18:08 ` Chaitanya Kulkarni
2020-03-30 6:28 ` hch
2020-03-30 10:44 ` Jinpu Wang
2020-03-30 18:57 ` Chaitanya Kulkarni
2020-03-20 12:16 ` [PATCH v11 16/26] block/rnbd: private headers with rnbd protocol structs and helpers Jack Wang
2020-03-28 4:58 ` Bart Van Assche
2020-03-31 7:32 ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 17/26] block/rnbd: client: private header with client structs and functions Jack Wang
2020-03-28 4:26 ` Bart Van Assche
2020-03-31 9:08 ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 18/26] block/rnbd: client: main functionality Jack Wang
2020-03-28 4:45 ` Bart Van Assche [this message]
2020-03-31 9:23 ` Jinpu Wang
2020-04-02 16:27 ` Jinpu Wang
2020-03-28 4:59 ` Bart Van Assche
2020-03-31 9:25 ` Jinpu Wang
2020-03-31 14:12 ` Bart Van Assche
2020-03-31 14:20 ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 19/26] block/rnbd: client: sysfs interface functions Jack Wang
2020-03-28 4:59 ` Bart Van Assche
2020-03-31 9:26 ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 20/26] block/rnbd: server: private header with server structs and functions Jack Wang
2020-03-20 12:16 ` [PATCH v11 21/26] block/rnbd: server: main functionality Jack Wang
2020-03-28 17:40 ` Bart Van Assche
2020-03-31 9:29 ` Jinpu Wang
2020-03-31 15:32 ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 22/26] block/rnbd: server: functionality for IO submission to file or block dev Jack Wang
2020-03-28 18:39 ` Bart Van Assche
2020-03-31 10:06 ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 23/26] block/rnbd: server: sysfs interface functions Jack Wang
2020-03-28 19:31 ` Bart Van Assche
2020-03-28 23:06 ` Jason Gunthorpe
2020-03-30 13:14 ` Danil Kipnis
2020-03-20 12:16 ` [PATCH v11 24/26] block/rnbd: include client and server modules into kernel compilation Jack Wang
2020-03-28 19:34 ` Bart Van Assche
2020-03-31 7:23 ` Jinpu Wang
2020-03-20 12:16 ` [PATCH v11 25/26] block/rnbd: a bit of documentation Jack Wang
2020-03-28 19:40 ` Bart Van Assche
2020-03-30 10:17 ` Danil Kipnis
2020-03-20 12:16 ` [PATCH v11 26/26] MAINTAINERS: Add maintainers for RNBD/RTRS modules Jack Wang
2020-03-28 19:40 ` Bart Van Assche
2020-03-30 10:12 ` Danil Kipnis
2020-03-26 17:38 ` [PATCH v11 00/26] RTRS (former IBTRS) RDMA Transport Library and RNBD (former IBNBD) RDMA Network Block Device Jinpu Wang
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=198cd2da-cbf8-17b0-3ee5-5dec366a43e2@acm.org \
--to=bvanassche@acm.org \
--cc=axboe@kernel.dk \
--cc=danil.kipnis@cloud.ionos.com \
--cc=dledford@redhat.com \
--cc=hch@infradead.org \
--cc=jgg@ziepe.ca \
--cc=jinpu.wang@cloud.ionos.com \
--cc=leon@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=pankaj.gupta@cloud.ionos.com \
--cc=rpenyaev@suse.de \
--cc=sagi@grimberg.me \
/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).