]> www.infradead.org Git - users/willy/xarray.git/commitdiff
block: move dma_pad handling from blk_rq_map_sg into the callers
authorChristoph Hellwig <hch@lst.de>
Tue, 14 Apr 2020 07:42:25 +0000 (09:42 +0200)
committerJens Axboe <axboe@kernel.dk>
Wed, 22 Apr 2020 16:47:39 +0000 (10:47 -0600)
There are only two callers of blk_rq_map_sg/__blk_rq_map_sg that set
the dma_pad value in the queue.  Move the handling into those callers
instead of burdening the common code, and move the ->extra_len field
from struct request to struct scsi_cmnd.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-core.c
block/blk-merge.c
block/blk-mq.c
drivers/ata/libata-scsi.c
drivers/ide/ide-io.c
drivers/scsi/scsi_lib.c
include/linux/blkdev.h
include/scsi/scsi_cmnd.h

index 7e4a1da0715ea85c4f1340522b97e5ec1f4d9d04..311596d5dbc417fc0cf672669fc1f49ed1ac4b63 100644 (file)
@@ -1638,7 +1638,6 @@ int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
        }
        rq->nr_phys_segments = rq_src->nr_phys_segments;
        rq->ioprio = rq_src->ioprio;
-       rq->extra_len = rq_src->extra_len;
 
        return 0;
 
index 25f5a5e00ee67ec6c7f217b15e86664a8b671af3..c49eb3bdd0be8b5950b5130e5bc50892bde7d2f8 100644 (file)
@@ -531,14 +531,6 @@ int __blk_rq_map_sg(struct request_queue *q, struct request *rq,
        else if (rq->bio)
                nsegs = __blk_bios_map_sg(q, rq->bio, sglist, last_sg);
 
-       if (blk_rq_bytes(rq) && (blk_rq_bytes(rq) & q->dma_pad_mask)) {
-               unsigned int pad_len =
-                       (q->dma_pad_mask & ~blk_rq_bytes(rq)) + 1;
-
-               (*last_sg)->length += pad_len;
-               rq->extra_len += pad_len;
-       }
-
        if (*last_sg)
                sg_mark_end(*last_sg);
 
index 2c105cb2a75b426048b39c485acae4e888ca8888..71d0894ce1c58dbaa70cf911861daff9214ecaf7 100644 (file)
@@ -318,7 +318,6 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data,
        rq->nr_integrity_segments = 0;
 #endif
        /* tag was already set */
-       rq->extra_len = 0;
        WRITE_ONCE(rq->deadline, 0);
 
        rq->timeout = 0;
index feb13b8f93d7f777370546add24da4265f7101c9..435781a16875060eceae802775a6ae820b4bdf29 100644 (file)
@@ -649,7 +649,7 @@ static void ata_qc_set_pc_nbytes(struct ata_queued_cmd *qc)
 {
        struct scsi_cmnd *scmd = qc->scsicmd;
 
-       qc->extrabytes = scmd->request->extra_len;
+       qc->extrabytes = scmd->extra_len;
        qc->nbytes = scsi_bufflen(scmd) + qc->extrabytes;
 }
 
index b137f27a34d585b5d1472624d9d021fee833a8f0..c31f1d2b3b0733820a1d874302e07a8bb935b7d1 100644 (file)
@@ -233,10 +233,13 @@ static ide_startstop_t do_special(ide_drive_t *drive)
 void ide_map_sg(ide_drive_t *drive, struct ide_cmd *cmd)
 {
        ide_hwif_t *hwif = drive->hwif;
-       struct scatterlist *sg = hwif->sg_table;
+       struct scatterlist *sg = hwif->sg_table, *last_sg = NULL;
        struct request *rq = cmd->rq;
 
-       cmd->sg_nents = blk_rq_map_sg(drive->queue, rq, sg);
+       cmd->sg_nents = __blk_rq_map_sg(drive->queue, rq, sg, &last_sg);
+       if (blk_rq_bytes(rq) && (blk_rq_bytes(rq) & rq->q->dma_pad_mask))
+               last_sg->length +=
+                       (rq->q->dma_pad_mask & ~blk_rq_bytes(rq)) + 1;
 }
 EXPORT_SYMBOL_GPL(ide_map_sg);
 
index 88cac92fc1536199dec7e856ca2d85110a7b1e26..0a73230a8f1635d91b63bdf76c89ecb4dbb01cb9 100644 (file)
@@ -1030,13 +1030,21 @@ blk_status_t scsi_init_io(struct scsi_cmnd *cmd)
         */
        count = __blk_rq_map_sg(rq->q, rq, cmd->sdb.table.sgl, &last_sg);
 
+       if (blk_rq_bytes(rq) & rq->q->dma_pad_mask) {
+               unsigned int pad_len =
+                       (rq->q->dma_pad_mask & ~blk_rq_bytes(rq)) + 1;
+
+               last_sg->length += pad_len;
+               cmd->extra_len += pad_len;
+       }
+
        if (need_drain) {
                sg_unmark_end(last_sg);
                last_sg = sg_next(last_sg);
                sg_set_buf(last_sg, sdev->dma_drain_buf, sdev->dma_drain_len);
                sg_mark_end(last_sg);
 
-               rq->extra_len += sdev->dma_drain_len;
+               cmd->extra_len += sdev->dma_drain_len;
                count++;
        }
 
index 8e4726bce4985f3022af08405628e7f81a27c521..f00bd4042295967d4432f4dda01b05b849b19c06 100644 (file)
@@ -224,8 +224,6 @@ struct request {
        unsigned short write_hint;
        unsigned short ioprio;
 
-       unsigned int extra_len; /* length of alignment and padding */
-
        enum mq_rq_state state;
        refcount_t ref;
 
index 80ac89e47b47d072eefe5ce9e2c1c4556453af4e..f93c0b800790e2d8cc0e08e378d4f3c44ff1504c 100644 (file)
@@ -142,6 +142,7 @@ struct scsi_cmnd {
        unsigned long state;    /* Command completion state */
 
        unsigned char tag;      /* SCSI-II queued command tag */
+       unsigned int extra_len; /* length of alignment and padding */
 };
 
 /*