]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
Target/sbc: Fix protection copy routine
authorSagi Grimberg <sagig@mellanox.com>
Wed, 12 Feb 2014 09:40:25 +0000 (11:40 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 12 Feb 2014 23:14:45 +0000 (15:14 -0800)
Need to take into account that protection sg_list
(copy-buffer) may consist of multiple entries.

Changes from v0:
- Changed commit description

Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_sbc.c

index fa3cae393e13e64056da79e9a8daf43bfe8dc721..a4489444ffbc640d940869ca7de305b2ae6c4b58 100644 (file)
@@ -1074,12 +1074,19 @@ sbc_dif_copy_prot(struct se_cmd *cmd, unsigned int sectors, bool read,
        struct scatterlist *psg;
        void *paddr, *addr;
        unsigned int i, len, left;
+       unsigned int offset = 0;
 
        left = sectors * dev->prot_length;
 
        for_each_sg(cmd->t_prot_sg, psg, cmd->t_prot_nents, i) {
 
                len = min(psg->length, left);
+               if (offset >= sg->length) {
+                       sg = sg_next(sg);
+                       offset = 0;
+                       sg_off = sg->offset;
+               }
+
                paddr = kmap_atomic(sg_page(psg)) + psg->offset;
                addr = kmap_atomic(sg_page(sg)) + sg_off;
 
@@ -1089,6 +1096,7 @@ sbc_dif_copy_prot(struct se_cmd *cmd, unsigned int sectors, bool read,
                        memcpy(addr, paddr, len);
 
                left -= len;
+               offset += len;
                kunmap_atomic(paddr);
                kunmap_atomic(addr);
        }