of: property: fw_devlink: Add support for "phy-handle" property
[linux-2.6-microblaze.git] / block / blk-merge.c
index 4d97fb6..a11b3b5 100644 (file)
@@ -559,10 +559,14 @@ 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 (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
+       if (blk_integrity_merge_bio(req->q, req, bio) == false)
                goto no_merge;
 
-       if (blk_integrity_merge_bio(req->q, req, bio) == false)
+       /* discard request merge won't add new segment */
+       if (req_op(req) == REQ_OP_DISCARD)
+               return 1;
+
+       if (req->nr_phys_segments + nr_phys_segs > blk_rq_get_max_segments(req))
                goto no_merge;
 
        /*
@@ -846,18 +850,15 @@ static struct request *attempt_front_merge(struct request_queue *q,
        return NULL;
 }
 
-int blk_attempt_req_merge(struct request_queue *q, struct request *rq,
-                         struct request *next)
+/*
+ * Try to merge 'next' into 'rq'. Return true if the merge happened, false
+ * otherwise. The caller is responsible for freeing 'next' if the merge
+ * happened.
+ */
+bool blk_attempt_req_merge(struct request_queue *q, struct request *rq,
+                          struct request *next)
 {
-       struct request *free;
-
-       free = attempt_merge(q, rq, next);
-       if (free) {
-               blk_put_request(free);
-               return 1;
-       }
-
-       return 0;
+       return attempt_merge(q, rq, next);
 }
 
 bool blk_rq_merge_ok(struct request *rq, struct bio *bio)