]> www.infradead.org Git - users/hch/xfs.git/commitdiff
block: lift bio_is_zone_append to bio.h
authorChristoph Hellwig <hch@lst.de>
Thu, 31 Oct 2024 14:09:05 +0000 (15:09 +0100)
committerChristoph Hellwig <hch@lst.de>
Tue, 5 Nov 2024 08:26:38 +0000 (09:26 +0100)
Make bio_is_zone_append globally available, because file systems need
to use to check for a zone append bio in their end_io handlers to deal
with the block layer emulation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
block/blk.h
include/linux/bio.h

index c718e4291db0624d5cf02233f3700dff914b10e3..c7305803dc1c23a40110d4e865c39bcaa04742b3 100644 (file)
@@ -463,11 +463,6 @@ static inline bool bio_zone_write_plugging(struct bio *bio)
 {
        return bio_flagged(bio, BIO_ZONE_WRITE_PLUGGING);
 }
-static inline bool bio_is_zone_append(struct bio *bio)
-{
-       return bio_op(bio) == REQ_OP_ZONE_APPEND ||
-               bio_flagged(bio, BIO_EMULATES_ZONE_APPEND);
-}
 void blk_zone_write_plug_bio_merged(struct bio *bio);
 void blk_zone_write_plug_init_request(struct request *rq);
 static inline void blk_zone_update_request_bio(struct request *rq,
@@ -516,10 +511,6 @@ static inline bool bio_zone_write_plugging(struct bio *bio)
 {
        return false;
 }
-static inline bool bio_is_zone_append(struct bio *bio)
-{
-       return false;
-}
 static inline void blk_zone_write_plug_bio_merged(struct bio *bio)
 {
 }
index faceadb040f9ac2c4e6cf8620494746278b4907f..66b7620a1b5333c5d525891b487425d3b9e208dc 100644 (file)
@@ -677,6 +677,23 @@ static inline void bio_clear_polled(struct bio *bio)
        bio->bi_opf &= ~REQ_POLLED;
 }
 
+/**
+ * bio_is_zone_append - is this a zone append bio?
+ * @bio:       bio to check
+ *
+ * Check if @bio is a zone append operation.  Core block layer code and end_io
+ * handlers must use this instead of an open coded REQ_OP_ZONE_APPEND check
+ * because the block layer can rewrite REQ_OP_ZONE_APPEND to REQ_OP_WRITE if
+ * it is not natively supported.
+ */
+static inline bool bio_is_zone_append(struct bio *bio)
+{
+       if (!IS_ENABLED(CONFIG_BLK_DEV_ZONED))
+               return false;
+       return bio_op(bio) == REQ_OP_ZONE_APPEND ||
+               bio_flagged(bio, BIO_EMULATES_ZONE_APPEND);
+}
+
 struct bio *blk_next_bio(struct bio *bio, struct block_device *bdev,
                unsigned int nr_pages, blk_opf_t opf, gfp_t gfp);
 struct bio *bio_chain_and_submit(struct bio *prev, struct bio *new);