ARM/ARM64: tizen_bcm2711: enable CONFIG_RTL8192CU_VENDOR
[platform/kernel/linux-rpi.git] / block / blk-merge.c
index a11b3b5..d1435b6 100644 (file)
@@ -7,6 +7,7 @@
 #include <linux/bio.h>
 #include <linux/blkdev.h>
 #include <linux/scatterlist.h>
+#include <linux/blk-cgroup.h>
 
 #include <trace/events/block.h>
 
@@ -278,6 +279,16 @@ static struct bio *blk_bio_segment_split(struct request_queue *q,
        *segs = nsegs;
        return NULL;
 split:
+       /*
+        * We can't sanely support splitting for a REQ_NOWAIT bio. End it
+        * with EAGAIN if splitting is required and return an error pointer.
+        */
+       if (bio->bi_opf & REQ_NOWAIT) {
+               bio->bi_status = BLK_STS_AGAIN;
+               bio_endio(bio);
+               return ERR_PTR(-EAGAIN);
+       }
+
        *segs = nsegs;
 
        /*
@@ -285,7 +296,7 @@ split:
         * iopoll in direct IO routine. Given performance gain of iopoll for
         * big IO can be trival, disable iopoll when split needed.
         */
-       bio->bi_opf &= ~REQ_HIPRI;
+       bio_clear_hipri(bio);
 
        return bio_split(bio, sectors, GFP_NOIO, bs);
 }
@@ -337,17 +348,21 @@ void __blk_queue_split(struct bio **bio, unsigned int *nr_segs)
                        break;
                }
                split = blk_bio_segment_split(q, *bio, &q->bio_split, nr_segs);
+               if (IS_ERR(split))
+                       *bio = split = NULL;
                break;
        }
 
        if (split) {
-               /* there isn't chance to merge the splitted bio */
+               /* there isn't chance to merge the split bio */
                split->bi_opf |= REQ_NOMERGE;
 
                bio_chain(split, *bio);
                trace_block_split(split, (*bio)->bi_iter.bi_sector);
                submit_bio_noacct(*bio);
                *bio = split;
+
+               blk_throtl_charge_bio_split(*bio);
        }
 }
 
@@ -559,6 +574,9 @@ static inline unsigned int blk_rq_get_max_segments(struct request *rq)
 static inline int ll_new_hw_segment(struct request *req, struct bio *bio,
                unsigned int nr_phys_segs)
 {
+       if (!blk_cgroup_mergeable(req, bio))
+               goto no_merge;
+
        if (blk_integrity_merge_bio(req->q, req, bio) == false)
                goto no_merge;
 
@@ -655,6 +673,9 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
        if (total_phys_segments > blk_rq_get_max_segments(req))
                return 0;
 
+       if (!blk_cgroup_mergeable(req, next->bio))
+               return 0;
+
        if (blk_integrity_merge_rq(q, req, next) == false)
                return 0;
 
@@ -705,22 +726,6 @@ static void blk_account_io_merge_request(struct request *req)
        }
 }
 
-/*
- * Two cases of handling DISCARD merge:
- * If max_discard_segments > 1, the driver takes every bio
- * as a range and send them to controller together. The ranges
- * needn't to be contiguous.
- * Otherwise, the bios/requests will be handled as same as
- * others which should be contiguous.
- */
-static inline bool blk_discard_mergable(struct request *req)
-{
-       if (req_op(req) == REQ_OP_DISCARD &&
-           queue_max_discard_segments(req->q) > 1)
-               return true;
-       return false;
-}
-
 static enum elv_merge blk_try_req_merge(struct request *req,
                                        struct request *next)
 {
@@ -877,6 +882,10 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio)
        if (rq->rq_disk != bio->bi_bdev->bd_disk)
                return false;
 
+       /* don't merge across cgroup boundaries */
+       if (!blk_cgroup_mergeable(rq, bio))
+               return false;
+
        /* only merge integrity protected bio into ditto rq */
        if (blk_integrity_merge_bio(rq->q, rq, bio) == false)
                return false;