Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs
[pandora-kernel.git] / block / blk-merge.c
index 5a244f0..63760ca 100644 (file)
@@ -338,6 +338,22 @@ static int ll_merge_requests_fn(struct request_queue *q, struct request *req,
        return 1;
 }
 
+static void blk_account_io_merge(struct request *req)
+{
+       if (blk_do_io_stat(req)) {
+               struct hd_struct *part;
+               int cpu;
+
+               cpu = part_stat_lock();
+               part = disk_map_sector_rcu(req->rq_disk, req->sector);
+
+               part_round_stats(cpu, part);
+               part_dec_in_flight(part);
+
+               part_stat_unlock();
+       }
+}
+
 /*
  * Has to be called with the request spinlock acquired
  */
@@ -386,23 +402,14 @@ static int attempt_merge(struct request_queue *q, struct request *req,
 
        elv_merge_requests(q, req, next);
 
-       if (req->rq_disk) {
-               struct hd_struct *part;
-               int cpu;
-
-               cpu = part_stat_lock();
-               part = disk_map_sector_rcu(req->rq_disk, req->sector);
-
-               part_round_stats(cpu, part);
-               part_dec_in_flight(part);
-
-               part_stat_unlock();
-       }
+       blk_account_io_merge(req);
 
        req->ioprio = ioprio_best(req->ioprio, next->ioprio);
        if (blk_rq_cpu_valid(next))
                req->cpu = next->cpu;
 
+       /* owner-ship of bio passed from next to req */
+       next->bio = NULL;
        __blk_put_request(q, next);
        return 1;
 }