All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Pavel Begunkov" <asml.silence@gmail.com>,
	"Mike Snitzer" <snitzer@redhat.com>,
	"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
	"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	"Md . Haris Iqbal " <haris.iqbal@ionos.com>,
	"Jack Wang" <jinpu.wang@ionos.com>,
	"Roger Pau Monné" <roger.pau@citrix.co>,
	"Philipp Reisner" <philipp.reisner@linbit.com>,
	"Lars Ellenberg" <lars.ellenberg@linbit.com>,
	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 02/19] nilfs2: remove nilfs_alloc_seg_bio
Date: Mon, 24 Jan 2022 10:10:50 +0100	[thread overview]
Message-ID: <20220124091107.642561-3-hch@lst.de> (raw)
In-Reply-To: <20220124091107.642561-1-hch@lst.de>

bio_alloc will never fail when it can sleep.  Remove the now simple
nilfs_alloc_seg_bio helper and open code it in the only caller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/nilfs2/segbuf.c | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c
index 43287b0d3e9b6..53b7c6d21cdd8 100644
--- a/fs/nilfs2/segbuf.c
+++ b/fs/nilfs2/segbuf.c
@@ -371,29 +371,6 @@ static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf,
 	return err;
 }
 
-/**
- * nilfs_alloc_seg_bio - allocate a new bio for writing log
- * @nilfs: nilfs object
- * @start: start block number of the bio
- * @nr_vecs: request size of page vector.
- *
- * Return Value: On success, pointer to the struct bio is returned.
- * On error, NULL is returned.
- */
-static struct bio *nilfs_alloc_seg_bio(struct the_nilfs *nilfs, sector_t start,
-				       int nr_vecs)
-{
-	struct bio *bio;
-
-	bio = bio_alloc(GFP_NOIO, nr_vecs);
-	if (likely(bio)) {
-		bio_set_dev(bio, nilfs->ns_bdev);
-		bio->bi_iter.bi_sector =
-			start << (nilfs->ns_blocksize_bits - 9);
-	}
-	return bio;
-}
-
 static void nilfs_segbuf_prepare_write(struct nilfs_segment_buffer *segbuf,
 				       struct nilfs_write_info *wi)
 {
@@ -414,10 +391,10 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,
 	BUG_ON(wi->nr_vecs <= 0);
  repeat:
 	if (!wi->bio) {
-		wi->bio = nilfs_alloc_seg_bio(wi->nilfs, wi->blocknr + wi->end,
-					      wi->nr_vecs);
-		if (unlikely(!wi->bio))
-			return -ENOMEM;
+		wi->bio = bio_alloc(GFP_NOIO, wi->nr_vecs);
+		bio_set_dev(wi->bio, wi->nilfs->ns_bdev);
+		wi->bio->bi_iter.bi_sector = (wi->blocknr + wi->end) <<
+			(wi->nilfs->ns_blocksize_bits - 9);
 	}
 
 	len = bio_add_page(wi->bio, bh->b_page, bh->b_size, bh_offset(bh));
-- 
2.30.2


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-nfs@vger.kernel.org,
	linux-nilfs@vger.kernel.org, "Mike Snitzer" <snitzer@redhat.com>,
	"Philipp Reisner" <philipp.reisner@linbit.com>,
	"Ryusuke Konishi" <konishi.ryusuke@gmail.com>,
	"Konstantin Komarov" <almaz.alexandrovich@paragon-software.com>,
	"Roger Pau Monné" <roger.pau@citrix.co>,
	dm-devel@redhat.com, "Md . Haris Iqbal " <haris.iqbal@ionos.com>,
	"Lars Ellenberg" <lars.ellenberg@linbit.com>,
	linux-fsdevel@vger.kernel.org, xen-devel@lists.xenproject.org,
	"Andrew Morton" <akpm@linux-foundation.org>,
	ntfs3@lists.linux.dev, "Jack Wang" <jinpu.wang@ionos.com>,
	"Pavel Begunkov" <asml.silence@gmail.com>,
	drbd-dev@lists.linbit.com
Subject: [dm-devel] [PATCH 02/19] nilfs2: remove nilfs_alloc_seg_bio
Date: Mon, 24 Jan 2022 10:10:50 +0100	[thread overview]
Message-ID: <20220124091107.642561-3-hch@lst.de> (raw)
In-Reply-To: <20220124091107.642561-1-hch@lst.de>

bio_alloc will never fail when it can sleep.  Remove the now simple
nilfs_alloc_seg_bio helper and open code it in the only caller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/nilfs2/segbuf.c | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c
index 43287b0d3e9b6..53b7c6d21cdd8 100644
--- a/fs/nilfs2/segbuf.c
+++ b/fs/nilfs2/segbuf.c
@@ -371,29 +371,6 @@ static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf,
 	return err;
 }
 
-/**
- * nilfs_alloc_seg_bio - allocate a new bio for writing log
- * @nilfs: nilfs object
- * @start: start block number of the bio
- * @nr_vecs: request size of page vector.
- *
- * Return Value: On success, pointer to the struct bio is returned.
- * On error, NULL is returned.
- */
-static struct bio *nilfs_alloc_seg_bio(struct the_nilfs *nilfs, sector_t start,
-				       int nr_vecs)
-{
-	struct bio *bio;
-
-	bio = bio_alloc(GFP_NOIO, nr_vecs);
-	if (likely(bio)) {
-		bio_set_dev(bio, nilfs->ns_bdev);
-		bio->bi_iter.bi_sector =
-			start << (nilfs->ns_blocksize_bits - 9);
-	}
-	return bio;
-}
-
 static void nilfs_segbuf_prepare_write(struct nilfs_segment_buffer *segbuf,
 				       struct nilfs_write_info *wi)
 {
@@ -414,10 +391,10 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,
 	BUG_ON(wi->nr_vecs <= 0);
  repeat:
 	if (!wi->bio) {
-		wi->bio = nilfs_alloc_seg_bio(wi->nilfs, wi->blocknr + wi->end,
-					      wi->nr_vecs);
-		if (unlikely(!wi->bio))
-			return -ENOMEM;
+		wi->bio = bio_alloc(GFP_NOIO, wi->nr_vecs);
+		bio_set_dev(wi->bio, wi->nilfs->ns_bdev);
+		wi->bio->bi_iter.bi_sector = (wi->blocknr + wi->end) <<
+			(wi->nilfs->ns_blocksize_bits - 9);
 	}
 
 	len = bio_add_page(wi->bio, bh->b_page, bh->b_size, bh_offset(bh));
-- 
2.30.2

--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


WARNING: multiple messages have this Message-ID (diff)
From: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
To: Jens Axboe <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>
Cc: "Pavel Begunkov"
	<asml.silence-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Mike Snitzer" <snitzer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"Ryusuke Konishi"
	<konishi.ryusuke-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"Konstantin Komarov"
	<almaz.alexandrovich-m5I1DM4ARimttCpgsWEBFlaTQe2KTcn/@public.gmane.org>,
	"Andrew Morton"
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	"Md . Haris Iqbal "
	<haris.iqbal-vEVw2sk9H7kAvxtiuMwx3w@public.gmane.org>,
	"Jack Wang" <jinpu.wang-vEVw2sk9H7kAvxtiuMwx3w@public.gmane.org>,
	"Roger Pau Monné"
	<roger.pau-Sxgqhf6Nn4Bhl2p70BpVqQ@public.gmane.org>,
	"Philipp Reisner"
	<philipp.reisner-63ez5xqkn6DQT0dZR+AlfA@public.gmane.org>,
	"Lars Ellenberg"
	<lars.ellenberg-63ez5xqkn6DQT0dZR+AlfA@public.gmane.org>,
	linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	dm-devel-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
	linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	ntfs3-cunTk1MwBs/YUNznpcFYbw@public.gmane.org,
	xen-devel-GuqFBffKawtpuQazS67q72D2FQJk+8+b@public.gmane.org,
	drbd-dev-cunTk1MwBs8qoQakbn7OcQ@public.gmane.org
Subject: [PATCH 02/19] nilfs2: remove nilfs_alloc_seg_bio
Date: Mon, 24 Jan 2022 10:10:50 +0100	[thread overview]
Message-ID: <20220124091107.642561-3-hch@lst.de> (raw)
In-Reply-To: <20220124091107.642561-1-hch-jcswGhMUV9g@public.gmane.org>

bio_alloc will never fail when it can sleep.  Remove the now simple
nilfs_alloc_seg_bio helper and open code it in the only caller.

Signed-off-by: Christoph Hellwig <hch-jcswGhMUV9g@public.gmane.org>
---
 fs/nilfs2/segbuf.c | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c
index 43287b0d3e9b6..53b7c6d21cdd8 100644
--- a/fs/nilfs2/segbuf.c
+++ b/fs/nilfs2/segbuf.c
@@ -371,29 +371,6 @@ static int nilfs_segbuf_submit_bio(struct nilfs_segment_buffer *segbuf,
 	return err;
 }
 
-/**
- * nilfs_alloc_seg_bio - allocate a new bio for writing log
- * @nilfs: nilfs object
- * @start: start block number of the bio
- * @nr_vecs: request size of page vector.
- *
- * Return Value: On success, pointer to the struct bio is returned.
- * On error, NULL is returned.
- */
-static struct bio *nilfs_alloc_seg_bio(struct the_nilfs *nilfs, sector_t start,
-				       int nr_vecs)
-{
-	struct bio *bio;
-
-	bio = bio_alloc(GFP_NOIO, nr_vecs);
-	if (likely(bio)) {
-		bio_set_dev(bio, nilfs->ns_bdev);
-		bio->bi_iter.bi_sector =
-			start << (nilfs->ns_blocksize_bits - 9);
-	}
-	return bio;
-}
-
 static void nilfs_segbuf_prepare_write(struct nilfs_segment_buffer *segbuf,
 				       struct nilfs_write_info *wi)
 {
@@ -414,10 +391,10 @@ static int nilfs_segbuf_submit_bh(struct nilfs_segment_buffer *segbuf,
 	BUG_ON(wi->nr_vecs <= 0);
  repeat:
 	if (!wi->bio) {
-		wi->bio = nilfs_alloc_seg_bio(wi->nilfs, wi->blocknr + wi->end,
-					      wi->nr_vecs);
-		if (unlikely(!wi->bio))
-			return -ENOMEM;
+		wi->bio = bio_alloc(GFP_NOIO, wi->nr_vecs);
+		bio_set_dev(wi->bio, wi->nilfs->ns_bdev);
+		wi->bio->bi_iter.bi_sector = (wi->blocknr + wi->end) <<
+			(wi->nilfs->ns_blocksize_bits - 9);
 	}
 
 	len = bio_add_page(wi->bio, bh->b_page, bh->b_size, bh_offset(bh));
-- 
2.30.2


  parent reply	other threads:[~2022-01-24  9:11 UTC|newest]

Thread overview: 83+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24  9:10 improve the bio allocation interface v2 Christoph Hellwig
2022-01-24  9:10 ` [dm-devel] " Christoph Hellwig
2022-01-24  9:10 ` [PATCH 01/19] fs: remove mpage_alloc Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-03-22 21:19   ` Guenter Roeck
2022-03-22 21:19     ` Guenter Roeck
2022-03-22 21:38     ` Ryusuke Konishi
2022-03-22 21:38       ` Ryusuke Konishi
2022-03-22 21:38       ` Ryusuke Konishi
2022-03-23  6:42       ` Christoph Hellwig
2022-03-23  6:42         ` Christoph Hellwig
2022-03-23  6:42         ` Christoph Hellwig
2022-03-23  9:29         ` Ryusuke Konishi
2022-03-23  9:29           ` Ryusuke Konishi
2022-01-24  9:10 ` Christoph Hellwig [this message]
2022-01-24  9:10   ` [PATCH 02/19] nilfs2: remove nilfs_alloc_seg_bio Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-01-27 21:38   ` Ryusuke Konishi
2022-01-27 21:38     ` [dm-devel] " Ryusuke Konishi
2022-01-24  9:10 ` [PATCH 03/19] nfs/blocklayout: remove bl_alloc_init_bio Christoph Hellwig
2022-01-24  9:10   ` Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:10 ` [PATCH 04/19] ntfs3: remove ntfs_alloc_bio Christoph Hellwig
2022-01-24  9:10   ` Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:10 ` [PATCH 05/19] dm: bio_alloc can't fail if it is allowed to sleep Christoph Hellwig
2022-01-24  9:10   ` Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-01-27 17:08   ` Mike Snitzer
2022-01-27 17:08     ` Mike Snitzer
2022-01-27 17:08     ` [dm-devel] " Mike Snitzer
2022-01-24  9:10 ` [PATCH 06/19] dm-crypt: remove clone_init Christoph Hellwig
2022-01-24  9:10   ` Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-01-27 17:09   ` Mike Snitzer
2022-01-27 17:09     ` [dm-devel] " Mike Snitzer
2022-01-24  9:10 ` [PATCH 07/19] dm-snap: use blkdev_issue_flush instead of open coding it Christoph Hellwig
2022-01-24  9:10   ` Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-01-27 17:11   ` Mike Snitzer
2022-01-27 17:11     ` Mike Snitzer
2022-01-27 17:11     ` [dm-devel] " Mike Snitzer
2022-01-24  9:10 ` [PATCH 08/19] dm-thin: " Christoph Hellwig
2022-01-24  9:10   ` Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-01-27 17:11   ` Mike Snitzer
2022-01-27 17:11     ` [dm-devel] " Mike Snitzer
2022-01-24  9:10 ` [PATCH 09/19] drbd: bio_alloc can't fail if it is allow to sleep Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:10 ` [PATCH 10/19] rnbd-srv: simplify bio mapping in process_rdma Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:10 ` [PATCH 11/19] rnbd-srv: remove struct rnbd_dev_blk_io Christoph Hellwig
2022-01-24  9:10   ` Christoph Hellwig
2022-01-24  9:10   ` [dm-devel] " Christoph Hellwig
2022-01-24 21:07   ` Jinpu Wang
2022-01-24 21:07     ` Jinpu Wang
2022-01-24 21:07     ` [dm-devel] " Jinpu Wang
2022-01-24  9:11 ` [PATCH 12/19] xen-blkback: bio_alloc can't fail if it is allow to sleep Christoph Hellwig
2022-01-24  9:11   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:11 ` [PATCH 13/19] block: move blk_next_bio to bio.c Christoph Hellwig
2022-01-24  9:11   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:11 ` [PATCH 14/19] block: pass a block_device and opf to blk_next_bio Christoph Hellwig
2022-01-24  9:11   ` Christoph Hellwig
2022-01-24  9:11   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:11 ` [PATCH 15/19] block: pass a block_device and opf to bio_alloc_bioset Christoph Hellwig
2022-01-24  9:11   ` Christoph Hellwig
2022-01-24  9:11   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:11 ` [PATCH 16/19] block: pass a block_device and opf to bio_alloc_kiocb Christoph Hellwig
2022-01-24  9:11   ` Christoph Hellwig
2022-01-24  9:11   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:11 ` [PATCH 17/19] block: pass a block_device and opf to bio_alloc Christoph Hellwig
2022-01-24  9:11   ` Christoph Hellwig
2022-01-24  9:11   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:11 ` [PATCH 18/19] block: pass a block_device and opf to bio_init Christoph Hellwig
2022-01-24  9:11   ` Christoph Hellwig
2022-01-24  9:11   ` [dm-devel] " Christoph Hellwig
2022-01-24  9:11 ` [PATCH 19/19] block: pass a block_device and opf to bio_reset Christoph Hellwig
2022-01-24  9:11   ` Christoph Hellwig
2022-01-24  9:11   ` [dm-devel] " Christoph Hellwig
2022-02-02 14:50 ` improve the bio allocation interface v2 Jens Axboe
2022-02-02 14:50 ` Jens Axboe
2022-02-02 14:50   ` [dm-devel] " Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2022-01-18  7:19 improve the bio allocation interface Christoph Hellwig
2022-01-18  7:19 ` [PATCH 02/19] nilfs2: remove nilfs_alloc_seg_bio Christoph Hellwig

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=20220124091107.642561-3-hch@lst.de \
    --to=hch@lst.de \
    --cc=akpm@linux-foundation.org \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=drbd-dev@lists.linbit.com \
    --cc=haris.iqbal@ionos.com \
    --cc=jinpu.wang@ionos.com \
    --cc=konishi.ryusuke@gmail.com \
    --cc=lars.ellenberg@linbit.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=philipp.reisner@linbit.com \
    --cc=roger.pau@citrix.co \
    --cc=snitzer@redhat.com \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.