linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Song Liu <song@kernel.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-block@vger.kernel.org, linux-raid@vger.kernel.org
Subject: [PATCH 06/11] block: turn the nr_iovecs argument to bio_alloc* into an unsigned short
Date: Tue,  2 Feb 2021 18:19:24 +0100	[thread overview]
Message-ID: <20210202171929.1504939-7-hch@lst.de> (raw)
In-Reply-To: <20210202171929.1504939-1-hch@lst.de>

The bi_max_vecs and bi_vcnt fields are defined as unsigned short, so
don't allow passing larger values in.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 block/bio.c         | 4 ++--
 include/linux/bio.h | 7 ++++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/block/bio.c b/block/bio.c
index ae241252ea14e5..3d28d4723f6f2f 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -407,7 +407,7 @@ static void punt_bios_to_rescuer(struct bio_set *bs)
  *
  * Returns: Pointer to new bio on success, NULL on failure.
  */
-struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned int nr_iovecs,
+struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned short nr_iovecs,
 			     struct bio_set *bs)
 {
 	gfp_t saved_gfp = gfp_mask;
@@ -493,7 +493,7 @@ EXPORT_SYMBOL(bio_alloc_bioset);
  *
  * Returns: Pointer to new bio on success, NULL on failure.
  */
-struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs)
+struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned short nr_iovecs)
 {
 	struct bio *bio;
 
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 4a84207dd99663..9ceeb8ecdb7f23 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -407,8 +407,9 @@ extern void bioset_exit(struct bio_set *);
 extern int biovec_init_pool(mempool_t *pool, int pool_entries);
 extern int bioset_init_from_src(struct bio_set *bs, struct bio_set *src);
 
-extern struct bio *bio_alloc_bioset(gfp_t, unsigned int, struct bio_set *);
-struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs);
+struct bio *bio_alloc_bioset(gfp_t gfp, unsigned short nr_iovecs,
+		struct bio_set *bs);
+struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned short nr_iovecs);
 extern void bio_put(struct bio *);
 
 extern void __bio_clone_fast(struct bio *, struct bio *);
@@ -416,7 +417,7 @@ extern struct bio *bio_clone_fast(struct bio *, gfp_t, struct bio_set *);
 
 extern struct bio_set fs_bio_set;
 
-static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs)
+static inline struct bio *bio_alloc(gfp_t gfp_mask, unsigned short nr_iovecs)
 {
 	return bio_alloc_bioset(gfp_mask, nr_iovecs, &fs_bio_set);
 }
-- 
2.29.2


  parent reply	other threads:[~2021-02-02 17:23 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02 17:19 cleanup bvec allocation Christoph Hellwig
2021-02-02 17:19 ` [PATCH 01/11] block: reuse BIO_INLINE_VECS for integrity bvecs Christoph Hellwig
2021-02-02 17:19 ` [PATCH 02/11] block: move struct biovec_slab to bio.c Christoph Hellwig
2021-02-02 17:19 ` [PATCH 03/11] block: factor out a bvec_alloc_gfp helper Christoph Hellwig
2021-02-02 17:19 ` [PATCH 04/11] block: streamline bvec_alloc Christoph Hellwig
2021-02-02 17:19 ` [PATCH 05/11] block: remove the 1 and 4 vec bvec_slabs entries Christoph Hellwig
2021-02-02 17:19 ` Christoph Hellwig [this message]
2021-02-02 17:19 ` [PATCH 07/11] block: remove a layer of indentation in bio_iov_iter_get_pages Christoph Hellwig
2021-02-02 17:19 ` [PATCH 08/11] block: set BIO_NO_PAGE_REF in bio_iov_bvec_set Christoph Hellwig
2021-02-02 17:19 ` [PATCH 09/11] block: mark the bio as cloned " Christoph Hellwig
2021-02-02 17:19 ` [PATCH 10/11] md/raid10: remove dead code in reshape_request Christoph Hellwig
2021-02-04 17:57   ` Song Liu
2021-02-02 17:19 ` [PATCH 11/11] block: use bi_max_vecs to find the bvec pool Christoph Hellwig
2021-02-07 16:21 ` cleanup bvec allocation Christoph Hellwig
2021-02-08 15:33 ` Jens Axboe

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=20210202171929.1504939-7-hch@lst.de \
    --to=hch@lst.de \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=song@kernel.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 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).