ARM/ARM64: tizen_bcm2711: enable CONFIG_RTL8192CU_VENDOR
[platform/kernel/linux-rpi.git] / block / blk-merge.c
index 7a5c81c..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;
 
        /*
@@ -337,11 +348,13 @@ 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);
@@ -561,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;
 
@@ -657,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;
 
@@ -863,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;