]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - block/ll_rw_blk.c
[BLOCK] blk_rq_map_sg: force clear termination bit
[linux-2.6-omap-h63xx.git] / block / ll_rw_blk.c
index 3935469e366222c793a429f65461bf4a0becf62e..de5ba479c2245b9e747558757fb6444eebc6745e 100644 (file)
@@ -1351,11 +1351,22 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
 new_segment:
                        if (!sg)
                                sg = sglist;
-                       else
+                       else {
+                               /*
+                                * If the driver previously mapped a shorter
+                                * list, we could see a termination bit
+                                * prematurely unless it fully inits the sg
+                                * table on each mapping. We KNOW that there
+                                * must be more entries here or the driver
+                                * would be buggy, so force clear the
+                                * termination bit to avoid doing a full
+                                * sg_init_table() in drivers for each command.
+                                */
+                               sg->page_link &= ~0x02;
                                sg = sg_next(sg);
+                       }
 
-                       memset(sg, 0, sizeof(*sg));
-                       sg->page = bvec->bv_page;
+                       sg_set_page(sg, bvec->bv_page);
                        sg->length = nbytes;
                        sg->offset = bvec->bv_offset;
                        nsegs++;
@@ -1363,6 +1374,9 @@ new_segment:
                bvprv = bvec;
        } /* segments in rq */
 
+       if (sg)
+               __sg_mark_end(sg);
+
        return nsegs;
 }
 
@@ -3367,7 +3381,7 @@ void submit_bio(int rw, struct bio *bio)
                if (unlikely(block_dump)) {
                        char b[BDEVNAME_SIZE];
                        printk(KERN_DEBUG "%s(%d): %s block %Lu on %s\n",
-                               current->comm, current->pid,
+                       current->comm, task_pid_nr(current),
                                (rw & WRITE) ? "WRITE" : "READ",
                                (unsigned long long)bio->bi_sector,
                                bdevname(bio->bi_bdev,b));
@@ -3739,7 +3753,7 @@ EXPORT_SYMBOL(end_dequeued_request);
 
 /**
  * end_request - end I/O on the current segment of the request
- * @rq:                the request being processed
+ * @req:       the request being processed
  * @uptodate:  error value or 0/1 uptodate flag
  *
  * Description: