From patchwork Tue Jan 18 07:19:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 12715988 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0B413C46467 for ; Tue, 18 Jan 2022 07:20:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.258341.444740 (Exim 4.92) (envelope-from ) id 1n9inF-00044t-Ux; Tue, 18 Jan 2022 07:20:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 258341.444740; Tue, 18 Jan 2022 07:20:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n9inF-00044P-Of; Tue, 18 Jan 2022 07:20:37 +0000 Received: by outflank-mailman (input) for mailman id 258341; Tue, 18 Jan 2022 07:20:36 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1n9inE-0000in-Eg for xen-devel@lists.xenproject.org; Tue, 18 Jan 2022 07:20:36 +0000 Received: from bombadil.infradead.org (bombadil.infradead.org [2607:7c80:54:e::133]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 20997ad1-782f-11ec-9bbc-9dff3e4ee8c5; Tue, 18 Jan 2022 08:20:35 +0100 (CET) Received: from [2001:4bb8:184:72a4:a4a9:19c0:5242:7768] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9in3-000ZZB-B2; Tue, 18 Jan 2022 07:20:25 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 20997ad1-782f-11ec-9bbc-9dff3e4ee8c5 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=TFuNjWOQggavORrRfTn7QEkmrXfbLN3s/zkt8VyCKDo=; b=Fvxex5DsH2HLixCtNE6GaXHXb9 eb7X5NVH/zze+9OO124Q4i5lHHHoeMesXRUX/dgTu29ulCwPgxNXffPl6B3NZ6+ioOSlkh86HS0fk Q7Tw7HDU3omZEoU8kOrSwmkcVbExIt+e86DNCb9PEHbk7OXYZc7yt4sI0kQFwiK7yweFAGuKVIhHL mQZjqe4oVLEIkcf+/7LI26JSHgA59iL5Fjf/fZvxUcfinpD69gHjFUEG/z/VdVix3LNL/1k8IwA68 qfkuJh1GeEBZ+yutZdyTlncbQhqHUTUPql/cTKjNL/r/lYX76kz0BIBHTh53XgPEIpaB5iVK1Ya9J pAUyh75Q==; From: Christoph Hellwig To: Jens Axboe Cc: Pavel Begunkov , Mike Snitzer , Ryusuke Konishi , Konstantin Komarov , Andrew Morton , "Md . Haris Iqbal " , Jack Wang , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Philipp Reisner , Lars Ellenberg , linux-block@vger.kernel.org, dm-devel@redhat.com, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, ntfs3@lists.linux.dev, xen-devel@lists.xenproject.org, drbd-dev@lists.linbit.com Subject: [PATCH 11/19] rnbd-src: remove struct rnbd_dev_blk_io Date: Tue, 18 Jan 2022 08:19:44 +0100 Message-Id: <20220118071952.1243143-12-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220118071952.1243143-1-hch@lst.de> References: <20220118071952.1243143-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Only the priv field of rnbd_dev_blk_io is used, so store the value of that in bio->bi_private directly and remove the entire bio_set overhead. Signed-off-by: Christoph Hellwig --- drivers/block/rnbd/rnbd-srv-dev.c | 4 +--- drivers/block/rnbd/rnbd-srv-dev.h | 13 ++----------- drivers/block/rnbd/rnbd-srv.c | 30 +++++------------------------- drivers/block/rnbd/rnbd-srv.h | 1 - 4 files changed, 8 insertions(+), 40 deletions(-) diff --git a/drivers/block/rnbd/rnbd-srv-dev.c b/drivers/block/rnbd/rnbd-srv-dev.c index 98d3e591a0885..c5d0a03911659 100644 --- a/drivers/block/rnbd/rnbd-srv-dev.c +++ b/drivers/block/rnbd/rnbd-srv-dev.c @@ -12,8 +12,7 @@ #include "rnbd-srv-dev.h" #include "rnbd-log.h" -struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags, - struct bio_set *bs) +struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags) { struct rnbd_dev *dev; int ret; @@ -30,7 +29,6 @@ struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags, dev->blk_open_flags = flags; bdevname(dev->bdev, dev->name); - dev->ibd_bio_set = bs; return dev; diff --git a/drivers/block/rnbd/rnbd-srv-dev.h b/drivers/block/rnbd/rnbd-srv-dev.h index 1a14ece0be726..2c3df02b5e8ec 100644 --- a/drivers/block/rnbd/rnbd-srv-dev.h +++ b/drivers/block/rnbd/rnbd-srv-dev.h @@ -14,25 +14,16 @@ struct rnbd_dev { struct block_device *bdev; - struct bio_set *ibd_bio_set; fmode_t blk_open_flags; char name[BDEVNAME_SIZE]; }; -struct rnbd_dev_blk_io { - struct rnbd_dev *dev; - void *priv; - /* have to be last member for front_pad usage of bioset_init */ - struct bio bio; -}; - /** * rnbd_dev_open() - Open a device + * @path: path to open * @flags: open flags - * @bs: bio_set to use during block io, */ -struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags, - struct bio_set *bs); +struct rnbd_dev *rnbd_dev_open(const char *path, fmode_t flags); /** * rnbd_dev_close() - Close a device diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index 65c670e96075b..b1ac1414b56d5 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -116,9 +116,7 @@ rnbd_get_sess_dev(int dev_id, struct rnbd_srv_session *srv_sess) static void rnbd_dev_bi_end_io(struct bio *bio) { - struct rnbd_dev_blk_io *io = bio->bi_private; - - rnbd_endio(io->priv, blk_status_to_errno(bio->bi_status)); + rnbd_endio(bio->bi_private, blk_status_to_errno(bio->bi_status)); bio_put(bio); } @@ -131,7 +129,6 @@ static int process_rdma(struct rnbd_srv_session *srv_sess, struct rnbd_srv_sess_dev *sess_dev; u32 dev_id; int err; - struct rnbd_dev_blk_io *io; struct bio *bio; short prio; @@ -152,20 +149,16 @@ static int process_rdma(struct rnbd_srv_session *srv_sess, priv->sess_dev = sess_dev; priv->id = id; - bio = bio_alloc_bioset(GFP_KERNEL, 1, sess_dev->rnbd_dev->ibd_bio_set); + bio = bio_alloc(GFP_KERNEL, 1); if (bio_add_page(bio, virt_to_page(data), datalen, offset_in_page(data))) { rnbd_srv_err(sess_dev, "Failed to map data to bio\n"); err = -EINVAL; - goto sess_dev_put; + goto bio_put; } - io = container_of(bio, struct rnbd_dev_blk_io, bio); - io->dev = sess_dev->rnbd_dev; - io->priv = priv; - bio->bi_end_io = rnbd_dev_bi_end_io; - bio->bi_private = io; + bio->bi_private = priv; bio->bi_opf = rnbd_to_bio_flags(le32_to_cpu(msg->rw)); bio->bi_iter.bi_sector = le64_to_cpu(msg->sector); bio->bi_iter.bi_size = le32_to_cpu(msg->bi_size); @@ -180,7 +173,6 @@ static int process_rdma(struct rnbd_srv_session *srv_sess, bio_put: bio_put(bio); -sess_dev_put: rnbd_put_sess_dev(sess_dev); err: kfree(priv); @@ -261,7 +253,6 @@ static void destroy_sess(struct rnbd_srv_session *srv_sess) out: xa_destroy(&srv_sess->index_idr); - bioset_exit(&srv_sess->sess_bio_set); pr_info("RTRS Session %s disconnected\n", srv_sess->sessname); @@ -290,16 +281,6 @@ static int create_sess(struct rtrs_srv_sess *rtrs) return -ENOMEM; srv_sess->queue_depth = rtrs_srv_get_queue_depth(rtrs); - err = bioset_init(&srv_sess->sess_bio_set, srv_sess->queue_depth, - offsetof(struct rnbd_dev_blk_io, bio), - BIOSET_NEED_BVECS); - if (err) { - pr_err("Allocating srv_session for path %s failed\n", - pathname); - kfree(srv_sess); - return err; - } - xa_init_flags(&srv_sess->index_idr, XA_FLAGS_ALLOC); INIT_LIST_HEAD(&srv_sess->sess_dev_list); mutex_init(&srv_sess->lock); @@ -748,8 +729,7 @@ static int process_msg_open(struct rnbd_srv_session *srv_sess, goto reject; } - rnbd_dev = rnbd_dev_open(full_path, open_flags, - &srv_sess->sess_bio_set); + rnbd_dev = rnbd_dev_open(full_path, open_flags); if (IS_ERR(rnbd_dev)) { pr_err("Opening device '%s' on session %s failed, failed to open the block device, err: %ld\n", full_path, srv_sess->sessname, PTR_ERR(rnbd_dev)); diff --git a/drivers/block/rnbd/rnbd-srv.h b/drivers/block/rnbd/rnbd-srv.h index e5604bce123ab..be2ae486d407e 100644 --- a/drivers/block/rnbd/rnbd-srv.h +++ b/drivers/block/rnbd/rnbd-srv.h @@ -23,7 +23,6 @@ struct rnbd_srv_session { struct rtrs_srv_sess *rtrs; char sessname[NAME_MAX]; int queue_depth; - struct bio_set sess_bio_set; struct xarray index_idr; /* List of struct rnbd_srv_sess_dev */