summary refs log tree commit diff
path: root/block/bio.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2021-10-12 18:18:01 +0200
committerJens Axboe <axboe@kernel.dk>2021-10-18 06:17:35 -0600
commit9a6083becbe113ed1e28059ce659dc8ae71b33c3 (patch)
tree13aac80b0b2196750ddad1fe3aaa586d17638691 /block/bio.c
parentb6559d8f9fdd7f0e139161cffea2645bd8d084c6 (diff)
downloadlinux-9a6083becbe113ed1e28059ce659dc8ae71b33c3.tar.gz
block: move bio_full out of bio.h
bio_full is only used in bio.c, so move it there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20211012161804.991559-6-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/bio.c')
-rw-r--r--block/bio.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/block/bio.c b/block/bio.c
index 35b875563c8b..7e2899071de2 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -772,6 +772,23 @@ const char *bio_devname(struct bio *bio, char *buf)
 }
 EXPORT_SYMBOL(bio_devname);
 
+/**
+ * bio_full - check if the bio is full
+ * @bio:	bio to check
+ * @len:	length of one segment to be added
+ *
+ * Return true if @bio is full and one segment with @len bytes can't be
+ * added to the bio, otherwise return false
+ */
+static inline bool bio_full(struct bio *bio, unsigned len)
+{
+	if (bio->bi_vcnt >= bio->bi_max_vecs)
+		return true;
+	if (bio->bi_iter.bi_size > UINT_MAX - len)
+		return true;
+	return false;
+}
+
 static inline bool page_is_mergeable(const struct bio_vec *bv,
 		struct page *page, unsigned int len, unsigned int off,
 		bool *same_page)