aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2007-10-24 05:20:47 -0400
committerJens Axboe <jens.axboe@oracle.com>2007-10-24 05:20:47 -0400
commit642f149031d70415d9318b919d50b71e4724adbd (patch)
treee792ad29dedffc6756d55e9d63e18ada35515b4b
parentbd6dee6f30a0f6943df190b387b5f8fe98a848f3 (diff)
SG: Change sg_set_page() to take length and offset argument
Most drivers need to set length and offset as well, so may as well fold those three lines into one. Add sg_assign_page() for those two locations that only needed to set the page, where the offset/length is set outside of the function context. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--block/ll_rw_blk.c4
-rw-r--r--crypto/hmac.c3
-rw-r--r--drivers/ata/libata-core.c4
-rw-r--r--drivers/block/cryptoloop.c9
-rw-r--r--drivers/block/ub.c9
-rw-r--r--drivers/ieee1394/dma.c4
-rw-r--r--drivers/infiniband/core/umem.c4
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c9
-rw-r--r--drivers/md/dm-crypt.c8
-rw-r--r--drivers/media/common/saa7146_core.c3
-rw-r--r--drivers/media/video/ivtv/ivtv-udma.c6
-rw-r--r--drivers/media/video/videobuf-dma-sg.c10
-rw-r--r--drivers/net/mlx4/icm.c4
-rw-r--r--drivers/s390/scsi/zfcp_aux.c10
-rw-r--r--drivers/s390/scsi/zfcp_def.h3
-rw-r--r--drivers/s390/scsi/zfcp_erp.c7
-rw-r--r--drivers/scsi/ipr.c2
-rw-r--r--drivers/scsi/iscsi_tcp.c4
-rw-r--r--drivers/scsi/osst.c6
-rw-r--r--drivers/scsi/sg.c13
-rw-r--r--drivers/scsi/st.c14
-rw-r--r--fs/ecryptfs/crypto.c23
-rw-r--r--include/asm-frv/scatterlist.h3
-rw-r--r--include/linux/scatterlist.h40
-rw-r--r--net/core/skbuff.c9
-rw-r--r--net/ieee80211/ieee80211_crypt_tkip.c9
-rw-r--r--net/sctp/auth.c4
-rw-r--r--net/sctp/sm_make_chunk.c8
-rw-r--r--net/sunrpc/auth_gss/gss_krb5_crypto.c14
-rw-r--r--net/sunrpc/xdr.c4
-rw-r--r--net/xfrm/xfrm_algo.c9
31 files changed, 98 insertions, 161 deletions
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index de5ba479c224..b01dee3ae7f3 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -1366,9 +1366,7 @@ new_segment:
1366 sg = sg_next(sg); 1366 sg = sg_next(sg);
1367 } 1367 }
1368 1368
1369 sg_set_page(sg, bvec->bv_page); 1369 sg_set_page(sg, bvec->bv_page, nbytes, bvec->bv_offset);
1370 sg->length = nbytes;
1371 sg->offset = bvec->bv_offset;
1372 nsegs++; 1370 nsegs++;
1373 } 1371 }
1374 bvprv = bvec; 1372 bvprv = bvec;
diff --git a/crypto/hmac.c b/crypto/hmac.c
index e4eb6ac53b5c..6691981bda11 100644
--- a/crypto/hmac.c
+++ b/crypto/hmac.c
@@ -160,8 +160,7 @@ static int hmac_digest(struct hash_desc *pdesc, struct scatterlist *sg,
160 160
161 sg_set_buf(sg1, ipad, bs); 161 sg_set_buf(sg1, ipad, bs);
162 162
163 sg_set_page(&sg[1], (void *) sg); 163 sg_set_page(&sg[1], (void *) sg, 0, 0);
164 sg1[1].length = 0;
165 sg_set_buf(sg2, opad, bs + ds); 164 sg_set_buf(sg2, opad, bs + ds);
166 165
167 err = crypto_hash_digest(&desc, sg1, nbytes + bs, digest); 166 err = crypto_hash_digest(&desc, sg1, nbytes + bs, digest);
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
index 2d147b51c978..b5f7c5913062 100644
--- a/drivers/ata/libata-core.c
+++ b/drivers/ata/libata-core.c
@@ -4689,8 +4689,8 @@ static int ata_sg_setup(struct ata_queued_cmd *qc)
4689 * data in this function or read data in ata_sg_clean. 4689 * data in this function or read data in ata_sg_clean.
4690 */ 4690 */
4691 offset = lsg->offset + lsg->length - qc->pad_len; 4691 offset = lsg->offset + lsg->length - qc->pad_len;
4692 sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT)); 4692 sg_set_page(psg, nth_page(sg_page(lsg), offset >> PAGE_SHIFT),
4693 psg->offset = offset_in_page(offset); 4693 qc->pad_len, offset_in_page(offset));
4694 4694
4695 if (qc->tf.flags & ATA_TFLAG_WRITE) { 4695 if (qc->tf.flags & ATA_TFLAG_WRITE) {
4696 void *addr = kmap_atomic(sg_page(psg), KM_IRQ0); 4696 void *addr = kmap_atomic(sg_page(psg), KM_IRQ0);
diff --git a/drivers/block/cryptoloop.c b/drivers/block/cryptoloop.c
index 1b58b010797f..241167878edf 100644
--- a/drivers/block/cryptoloop.c
+++ b/drivers/block/cryptoloop.c
@@ -150,13 +150,8 @@ cryptoloop_transfer(struct loop_device *lo, int cmd,
150 u32 iv[4] = { 0, }; 150 u32 iv[4] = { 0, };
151 iv[0] = cpu_to_le32(IV & 0xffffffff); 151 iv[0] = cpu_to_le32(IV & 0xffffffff);
152 152
153 sg_set_page(&sg_in, in_page); 153 sg_set_page(&sg_in, in_page, sz, in_offs);
154 sg_in.offset = in_offs; 154 sg_set_page(&sg_out, out_page, sz, out_offs);
155 sg_in.length = sz;
156
157 sg_set_page(&sg_out, out_page);
158 sg_out.offset = out_offs;
159 sg_out.length = sz;
160 155
161 desc.info = iv; 156 desc.info = iv;
162 err = encdecfunc(&desc, &sg_out, &sg_in, sz); 157 err = encdecfunc(&desc, &sg_out, &sg_in, sz);
diff --git a/drivers/block/ub.c b/drivers/block/ub.c
index 14143f2c484d..5e740e14ab35 100644
--- a/drivers/block/ub.c
+++ b/drivers/block/ub.c
@@ -1428,9 +1428,8 @@ static void ub_state_sense(struct ub_dev *sc, struct ub_scsi_cmd *cmd)
1428 scmd->state = UB_CMDST_INIT; 1428 scmd->state = UB_CMDST_INIT;
1429 scmd->nsg = 1; 1429 scmd->nsg = 1;
1430 sg = &scmd->sgv[0]; 1430 sg = &scmd->sgv[0];
1431 sg_set_page(sg, virt_to_page(sc->top_sense)); 1431 sg_set_page(sg, virt_to_page(sc->top_sense), UB_SENSE_SIZE,
1432 sg->offset = (unsigned long)sc->top_sense & (PAGE_SIZE-1); 1432 (unsigned long)sc->top_sense & (PAGE_SIZE-1));
1433 sg->length = UB_SENSE_SIZE;
1434 scmd->len = UB_SENSE_SIZE; 1433 scmd->len = UB_SENSE_SIZE;
1435 scmd->lun = cmd->lun; 1434 scmd->lun = cmd->lun;
1436 scmd->done = ub_top_sense_done; 1435 scmd->done = ub_top_sense_done;
@@ -1864,9 +1863,7 @@ static int ub_sync_read_cap(struct ub_dev *sc, struct ub_lun *lun,
1864 cmd->state = UB_CMDST_INIT; 1863 cmd->state = UB_CMDST_INIT;
1865 cmd->nsg = 1; 1864 cmd->nsg = 1;
1866 sg = &cmd->sgv[0]; 1865 sg = &cmd->sgv[0];
1867 sg_set_page(sg, virt_to_page(p)); 1866 sg_set_page(sg, virt_to_page(p), 8, (unsigned long)p & (PAGE_SIZE-1));
1868 sg->offset = (unsigned long)p & (PAGE_SIZE-1);
1869 sg->length = 8;
1870 cmd->len = 8; 1867 cmd->len = 8;
1871 cmd->lun = lun; 1868 cmd->lun = lun;
1872 cmd->done = ub_probe_done; 1869 cmd->done = ub_probe_done;
diff --git a/drivers/ieee1394/dma.c b/drivers/ieee1394/dma.c
index 3051e312fdc8..f5f4983dfbf3 100644
--- a/drivers/ieee1394/dma.c
+++ b/drivers/ieee1394/dma.c
@@ -111,8 +111,8 @@ int dma_region_alloc(struct dma_region *dma, unsigned long n_bytes,
111 unsigned long va = 111 unsigned long va =
112 (unsigned long)dma->kvirt + (i << PAGE_SHIFT); 112 (unsigned long)dma->kvirt + (i << PAGE_SHIFT);
113 113
114 sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va)); 114 sg_set_page(&dma->sglist[i], vmalloc_to_page((void *)va),
115 dma->sglist[i].length = PAGE_SIZE; 115 PAGE_SIZE, 0);
116 } 116 }
117 117
118 /* map sglist to the IOMMU */ 118 /* map sglist to the IOMMU */
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 14159ff29408..4e3128ff73c1 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -171,9 +171,7 @@ struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
171 if (vma_list && 171 if (vma_list &&
172 !is_vm_hugetlb_page(vma_list[i + off])) 172 !is_vm_hugetlb_page(vma_list[i + off]))
173 umem->hugetlb = 0; 173 umem->hugetlb = 0;
174 sg_set_page(&chunk->page_list[i], page_list[i + off]); 174 sg_set_page(&chunk->page_list[i], page_list[i + off], PAGE_SIZE, 0);
175 chunk->page_list[i].offset = 0;
176 chunk->page_list[i].length = PAGE_SIZE;
177 } 175 }
178 176
179 chunk->nmap = ib_dma_map_sg(context->device, 177 chunk->nmap = ib_dma_map_sg(context->device,
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 007b38157fc4..1f4d27d7c16d 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -113,9 +113,7 @@ static int mthca_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_m
113 if (!page) 113 if (!page)
114 return -ENOMEM; 114 return -ENOMEM;
115 115
116 sg_set_page(mem, page); 116 sg_set_page(mem, page, PAGE_SIZE << order, 0);
117 mem->length = PAGE_SIZE << order;
118 mem->offset = 0;
119 return 0; 117 return 0;
120} 118}
121 119
@@ -481,9 +479,8 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
481 if (ret < 0) 479 if (ret < 0)
482 goto out; 480 goto out;
483 481
484 sg_set_page(&db_tab->page[i].mem, pages[0]); 482 sg_set_page(&db_tab->page[i].mem, pages[0], MTHCA_ICM_PAGE_SIZE,
485 db_tab->page[i].mem.length = MTHCA_ICM_PAGE_SIZE; 483 uaddr & ~PAGE_MASK);
486 db_tab->page[i].mem.offset = uaddr & ~PAGE_MASK;
487 484
488 ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE); 485 ret = pci_map_sg(dev->pdev, &db_tab->page[i].mem, 1, PCI_DMA_TODEVICE);
489 if (ret < 0) { 486 if (ret < 0) {
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index ac54f697c508..1c159ac68c98 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -351,14 +351,10 @@ static int crypt_convert(struct crypt_config *cc,
351 struct scatterlist sg_in, sg_out; 351 struct scatterlist sg_in, sg_out;
352 352
353 sg_init_table(&sg_in, 1); 353 sg_init_table(&sg_in, 1);
354 sg_set_page(&sg_in, bv_in->bv_page); 354 sg_set_page(&sg_in, bv_in->bv_page, 1 << SECTOR_SHIFT, bv_in->bv_offset + ctx->offset_in);
355 sg_in.offset = bv_in->bv_offset + ctx->offset_in;
356 sg_in.length = 1 << SECTOR_SHIFT;
357 355
358 sg_init_table(&sg_out, 1); 356 sg_init_table(&sg_out, 1);
359 sg_set_page(&sg_out, bv_out->bv_page); 357 sg_set_page(&sg_out, bv_out->bv_page, 1 << SECTOR_SHIFT, bv_out->bv_offset + ctx->offset_out);
360 sg_out.offset = bv_out->bv_offset + ctx->offset_out;
361 sg_out.length = 1 << SECTOR_SHIFT;
362 358
363 ctx->offset_in += sg_in.length; 359 ctx->offset_in += sg_in.length;
364 if (ctx->offset_in >= bv_in->bv_len) { 360 if (ctx->offset_in >= bv_in->bv_len) {
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index 2b1f8b4be00a..cb034ead95ab 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -118,8 +118,7 @@ static struct scatterlist* vmalloc_to_sg(unsigned char *virt, int nr_pages)
118 if (NULL == pg) 118 if (NULL == pg)
119 goto err; 119 goto err;
120 BUG_ON(PageHighMem(pg)); 120 BUG_ON(PageHighMem(pg));
121 sg_set_page(&sglist[i], pg); 121 sg_set_page(&sglist[i], pg, PAGE_SIZE, 0);
122 sglist[i].length = PAGE_SIZE;
123 } 122 }
124 return sglist; 123 return sglist;
125 124
diff --git a/drivers/media/video/ivtv/ivtv-udma.c b/drivers/media/video/ivtv/ivtv-udma.c
index 912b424e5204..460db03b0ba0 100644
--- a/drivers/media/video/ivtv/ivtv-udma.c
+++ b/drivers/media/video/ivtv/ivtv-udma.c
@@ -49,8 +49,6 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info
49 unsigned int len = (i == dma_page->page_count - 1) ? 49 unsigned int len = (i == dma_page->page_count - 1) ?
50 dma_page->tail : PAGE_SIZE - offset; 50 dma_page->tail : PAGE_SIZE - offset;
51 51
52 dma->SGlist[map_offset].length = len;
53 dma->SGlist[map_offset].offset = offset;
54 if (PageHighMem(dma->map[map_offset])) { 52 if (PageHighMem(dma->map[map_offset])) {
55 void *src; 53 void *src;
56 54
@@ -63,10 +61,10 @@ int ivtv_udma_fill_sg_list (struct ivtv_user_dma *dma, struct ivtv_dma_page_info
63 memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len); 61 memcpy(page_address(dma->bouncemap[map_offset]) + offset, src, len);
64 kunmap_atomic(src, KM_BOUNCE_READ); 62 kunmap_atomic(src, KM_BOUNCE_READ);
65 local_irq_restore(flags); 63 local_irq_restore(flags);
66 sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset]); 64 sg_set_page(&dma->SGlist[map_offset], dma->bouncemap[map_offset], len, offset);
67 } 65 }
68 else { 66 else {
69 sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset]); 67 sg_set_page(&dma->SGlist[map_offset], dma->map[map_offset], len, offset);
70 } 68 }
71 offset = 0; 69 offset = 0;
72 map_offset++; 70 map_offset++;
diff --git a/drivers/media/video/videobuf-dma-sg.c b/drivers/media/video/videobuf-dma-sg.c
index 9ab94a749d81..44ee408e145f 100644
--- a/drivers/media/video/videobuf-dma-sg.c
+++ b/drivers/media/video/videobuf-dma-sg.c
@@ -67,8 +67,7 @@ videobuf_vmalloc_to_sg(unsigned char *virt, int nr_pages)
67 if (NULL == pg) 67 if (NULL == pg)
68 goto err; 68 goto err;
69 BUG_ON(PageHighMem(pg)); 69 BUG_ON(PageHighMem(pg));
70 sg_set_page(&sglist[i], pg); 70 sg_set_page(&sglist[i], pg, PAGE_SIZE, 0);
71 sglist[i].length = PAGE_SIZE;
72 } 71 }
73 return sglist; 72 return sglist;
74 73
@@ -95,16 +94,13 @@ videobuf_pages_to_sg(struct page **pages, int nr_pages, int offset)
95 if (PageHighMem(pages[0])) 94 if (PageHighMem(pages[0]))
96 /* DMA to highmem pages might not work */ 95 /* DMA to highmem pages might not work */
97 goto highmem; 96 goto highmem;
98 sg_set_page(&sglist[0], pages[0]); 97 sg_set_page(&sglist[0], pages[0], PAGE_SIZE - offset, offset);
99 sglist[0].offset = offset;
100 sglist[0].length = PAGE_SIZE - offset;
101 for (i = 1; i < nr_pages; i++) { 98 for (i = 1; i < nr_pages; i++) {
102 if (NULL == pages[i]) 99 if (NULL == pages[i])
103 goto nopage; 100 goto nopage;
104 if (PageHighMem(pages[i])) 101 if (PageHighMem(pages[i]))
105 goto highmem; 102 goto highmem;
106 sg_set_page(&sglist[i], pages[i]); 103 sg_set_page(&sglist[i], pages[i], PAGE_SIZE, 0);
107 sglist[i].length = PAGE_SIZE;
108 } 104 }
109 return sglist; 105 return sglist;
110 106
diff --git a/drivers/net/mlx4/icm.c b/drivers/net/mlx4/icm.c
index 887633b207d9..2a5bef6388fe 100644
--- a/drivers/net/mlx4/icm.c
+++ b/drivers/net/mlx4/icm.c
@@ -101,9 +101,7 @@ static int mlx4_alloc_icm_pages(struct scatterlist *mem, int order, gfp_t gfp_ma
101 if (!page) 101 if (!page)
102 return -ENOMEM; 102 return -ENOMEM;
103 103
104 sg_set_page(mem, page); 104 sg_set_page(mem, page, PAGE_SIZE << order, 0);
105 mem->length = PAGE_SIZE << order;
106 mem->offset = 0;
107 return 0; 105 return 0;
108} 106}
109 107
diff --git a/drivers/s390/scsi/zfcp_aux.c b/drivers/s390/scsi/zfcp_aux.c
index d9e7be979760..00118499018b 100644
--- a/drivers/s390/scsi/zfcp_aux.c
+++ b/drivers/s390/scsi/zfcp_aux.c
@@ -562,8 +562,6 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size)
562 sg_init_table(sg_list->sg, sg_list->count); 562 sg_init_table(sg_list->sg, sg_list->count);
563 563
564 for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) { 564 for (i = 0, sg = sg_list->sg; i < sg_list->count; i++, sg++) {
565 sg->length = min(size, PAGE_SIZE);
566 sg->offset = 0;
567 address = (void *) get_zeroed_page(GFP_KERNEL); 565 address = (void *) get_zeroed_page(GFP_KERNEL);
568 if (address == NULL) { 566 if (address == NULL) {
569 sg_list->count = i; 567 sg_list->count = i;
@@ -571,7 +569,7 @@ zfcp_sg_list_alloc(struct zfcp_sg_list *sg_list, size_t size)
571 retval = -ENOMEM; 569 retval = -ENOMEM;
572 goto out; 570 goto out;
573 } 571 }
574 zfcp_address_to_sg(address, sg); 572 zfcp_address_to_sg(address, sg, min(size, PAGE_SIZE));
575 size -= sg->length; 573 size -= sg->length;
576 } 574 }
577 575
@@ -1523,10 +1521,8 @@ zfcp_gid_pn_buffers_alloc(struct zfcp_gid_pn_data **gid_pn, mempool_t *pool)
1523 data->ct.req = &data->req; 1521 data->ct.req = &data->req;
1524 data->ct.resp = &data->resp; 1522 data->ct.resp = &data->resp;
1525 data->ct.req_count = data->ct.resp_count = 1; 1523 data->ct.req_count = data->ct.resp_count = 1;
1526 zfcp_address_to_sg(&data->ct_iu_req, &data->req); 1524 zfcp_address_to_sg(&data->ct_iu_req, &data->req, sizeof(struct ct_iu_gid_pn_req));
1527 zfcp_address_to_sg(&data->ct_iu_resp, &data->resp); 1525 zfcp_address_to_sg(&data->ct_iu_resp, &data->resp, sizeof(struct ct_iu_gid_pn_resp));
1528 data->req.length = sizeof(struct ct_iu_gid_pn_req);
1529 data->resp.length = sizeof(struct ct_iu_gid_pn_resp);
1530 1526
1531 *gid_pn = data; 1527 *gid_pn = data;
1532 return 0; 1528 return 0;
diff --git a/drivers/s390/scsi/zfcp_def.h b/drivers/s390/scsi/zfcp_def.h
index 326e7ee232cb..0754542978b6 100644
--- a/drivers/s390/scsi/zfcp_def.h
+++ b/drivers/s390/scsi/zfcp_def.h
@@ -74,8 +74,7 @@ zfcp_sg_to_address(struct scatterlist *list)
74static inline void 74static inline void
75zfcp_address_to_sg(void *address, struct scatterlist *list) 75zfcp_address_to_sg(void *address, struct scatterlist *list)
76{ 76{
77 sg_set_page(list, virt_to_page(address)); 77 sg_set_buf(list, address, 0);
78 list->offset = ((unsigned long) address) & (PAGE_SIZE - 1);
79} 78}
80 79
81#define REQUEST_LIST_SIZE 128 80#define REQUEST_LIST_SIZE 128
diff --git a/drivers/s390/scsi/zfcp_erp.c b/drivers/s390/scsi/zfcp_erp.c
index 9438d0b28799..5552b755c08a 100644
--- a/drivers/s390/scsi/zfcp_erp.c
+++ b/drivers/s390/scsi/zfcp_erp.c
@@ -322,9 +322,9 @@ zfcp_erp_adisc(struct zfcp_port *port)
322 if (address == NULL) 322 if (address == NULL)
323 goto nomem; 323 goto nomem;
324 324
325 zfcp_address_to_sg(address, send_els->req); 325 zfcp_address_to_sg(address, send_els->req, sizeof(struct zfcp_ls_adisc));
326 address += PAGE_SIZE >> 1; 326 address += PAGE_SIZE >> 1;
327 zfcp_address_to_sg(address, send_els->resp); 327 zfcp_address_to_sg(address, send_els->resp, sizeof(struct zfcp_ls_adisc_acc));
328 send_els->req_count = send_els->resp_count = 1; 328 send_els->req_count = send_els->resp_count = 1;
329 329
330 send_els->adapter = adapter; 330 send_els->adapter = adapter;
@@ -336,9 +336,6 @@ zfcp_erp_adisc(struct zfcp_port *port)
336 adisc = zfcp_sg_to_address(send_els->req); 336 adisc = zfcp_sg_to_address(send_els->req);
337 send_els->ls_code = adisc->code = ZFCP_LS_ADISC; 337 send_els->ls_code = adisc->code = ZFCP_LS_ADISC;
338 338
339 send_els->req->length = sizeof(struct zfcp_ls_adisc);
340 send_els->resp->length = sizeof(struct zfcp_ls_adisc_acc);
341
342 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports 339 /* acc. to FC-FS, hard_nport_id in ADISC should not be set for ports
343 without FC-AL-2 capability, so we don't set it */ 340 without FC-AL-2 capability, so we don't set it */
344 adisc->wwpn = fc_host_port_name(adapter->scsi_host); 341 adisc->wwpn = fc_host_port_name(adapter->scsi_host);
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 439b97a6a269..0841df01bc19 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -2890,7 +2890,7 @@ static struct ipr_sglist *ipr_alloc_ucode_buffer(int buf_len)
2890 return NULL; 2890 return NULL;
2891 } 2891 }
2892 2892
2893 sg_set_page(&scatterlist[i], page); 2893 sg_set_page(&scatterlist[i], page, 0, 0);
2894 } 2894 }
2895 2895
2896 return sglist; 2896 return sglist;
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 6ce4109efdf3..097a136398cb 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -79,9 +79,7 @@ static inline void
79iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg) 79iscsi_buf_init_sg(struct iscsi_buf *ibuf, struct scatterlist *sg)
80{ 80{
81 sg_init_table(&ibuf->sg, 1); 81 sg_init_table(&ibuf->sg, 1);
82 sg_set_page(&ibuf->sg, sg_page(sg)); 82 sg_set_page(&ibuf->sg, sg_page(sg), sg->length, sg->offset);
83 ibuf->sg.offset = sg->offset;
84 ibuf->sg.length = sg->length;
85 /* 83 /*
86 * Fastpath: sg element fits into single page 84 * Fastpath: sg element fits into single page
87 */ 85 */
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 1c5c4b68f20f..4652ad22516b 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -5256,8 +5256,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma)
5256 5256
5257 STbuffer->sg[0].offset = 0; 5257 STbuffer->sg[0].offset = 0;
5258 if (page != NULL) { 5258 if (page != NULL) {
5259 sg_set_page(&STbuffer->sg[0], page); 5259 sg_set_page(&STbuffer->sg[0], page, b_size, 0);
5260 STbuffer->sg[0].length = b_size;
5261 STbuffer->b_data = page_address(page); 5260 STbuffer->b_data = page_address(page);
5262 break; 5261 break;
5263 } 5262 }
@@ -5285,8 +5284,7 @@ static int enlarge_buffer(struct osst_buffer *STbuffer, int need_dma)
5285 normalize_buffer(STbuffer); 5284 normalize_buffer(STbuffer);
5286 return 0; 5285 return 0;
5287 } 5286 }
5288 sg_set_page(&STbuffer->sg[segs], page); 5287 sg_set_page(&STbuffer->sg[segs], page, (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size, 0);
5289 STbuffer->sg[segs].length = (OS_FRAME_SIZE - got <= PAGE_SIZE / 2) ? (OS_FRAME_SIZE - got) : b_size;
5290 got += STbuffer->sg[segs].length; 5288 got += STbuffer->sg[segs].length;
5291 STbuffer->buffer_size = got; 5289 STbuffer->buffer_size = got;
5292 STbuffer->sg_segs = ++segs; 5290 STbuffer->sg_segs = ++segs;
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index cc1971002846..b5fa4f091387 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1717,16 +1717,12 @@ st_map_user_pages(struct scatterlist *sgl, const unsigned int max_pages,
1717 goto out_unlock; */ 1717 goto out_unlock; */
1718 } 1718 }
1719 1719
1720 sg_set_page(sgl, pages[0]); 1720 sg_set_page(sgl, pages[0], 0, uaddr & ~PAGE_MASK);
1721 sgl[0].offset = uaddr & ~PAGE_MASK;
1722 if (nr_pages > 1) { 1721 if (nr_pages > 1) {
1723 sgl[0].length = PAGE_SIZE - sgl[0].offset; 1722 sgl[0].length = PAGE_SIZE - sgl[0].offset;
1724 count -= sgl[0].length; 1723 count -= sgl[0].length;
1725 for (i=1; i < nr_pages ; i++) { 1724 for (i=1; i < nr_pages ; i++)
1726 sg_set_page(&sgl[i], pages[i]); 1725 sg_set_page(&sgl[i], pages[i], count < PAGE_SIZE ? count : PAGE_SIZE, 0);
1727 sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE;
1728 count -= PAGE_SIZE;
1729 }
1730 } 1726 }
1731 else { 1727 else {
1732 sgl[0].length = count; 1728 sgl[0].length = count;
@@ -1854,8 +1850,7 @@ sg_build_indirect(Sg_scatter_hold * schp, Sg_fd * sfp, int buff_size)
1854 scatter_elem_sz_prev = ret_sz; 1850 scatter_elem_sz_prev = ret_sz;
1855 } 1851 }
1856 } 1852 }
1857 sg_set_page(sg, p); 1853 sg_set_page(sg, p, (ret_sz > num) ? num : ret_sz, 0);
1858 sg->length = (ret_sz > num) ? num : ret_sz;
1859 1854
1860 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, " 1855 SCSI_LOG_TIMEOUT(5, printk("sg_build_indirect: k=%d, num=%d, "
1861 "ret_sz=%d\n", k, num, ret_sz)); 1856 "ret_sz=%d\n", k, num, ret_sz));
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c
index ce69b9efc102..98dfd6ea209c 100644
--- a/drivers/scsi/st.c
+++ b/drivers/scsi/st.c
@@ -3797,13 +3797,11 @@ static void buf_to_sg(struct st_buffer *STbp, unsigned int length)
3797 sg = &(STbp->sg[0]); 3797 sg = &(STbp->sg[0]);
3798 frp = STbp->frp; 3798 frp = STbp->frp;
3799 for (i=count=0; count < length; i++) { 3799 for (i=count=0; count < length; i++) {
3800 sg_set_page(&sg[i], frp[i].page);
3801 if (length - count > frp[i].length) 3800 if (length - count > frp[i].length)
3802 sg[i].length = frp[i].length; 3801 sg_set_page(&sg[i], frp[i].page, frp[i].length, 0);
3803 else 3802 else
3804 sg[i].length = length - count; 3803 sg_set_page(&sg[i], frp[i].page, length - count, 0);
3805 count += sg[i].length; 3804 count += sg[i].length;
3806 sg[i].offset = 0;
3807 } 3805 }
3808 STbp->sg_segs = i; 3806 STbp->sg_segs = i;
3809 STbp->frp_sg_current = length; 3807 STbp->frp_sg_current = length;
@@ -4446,15 +4444,13 @@ static int sgl_map_user_pages(struct scatterlist *sgl, const unsigned int max_pa
4446 } 4444 }
4447 4445
4448 /* Populate the scatter/gather list */ 4446 /* Populate the scatter/gather list */
4449 sg_set_page(&sgl[0], pages[0]); 4447 sg_set_page(&sgl[0], pages[0], 0, uaddr & ~PAGE_MASK);
4450 sgl[0].offset = uaddr & ~PAGE_MASK;
4451 if (nr_pages > 1) { 4448 if (nr_pages > 1) {
4452 sgl[0].length = PAGE_SIZE - sgl[0].offset; 4449 sgl[0].length = PAGE_SIZE - sgl[0].offset;
4453 count -= sgl[0].length; 4450 count -= sgl[0].length;
4454 for (i=1; i < nr_pages ; i++) { 4451 for (i=1; i < nr_pages ; i++) {
4455 sg_set_page(&sgl[i], pages[i]);; 4452 sg_set_page(&sgl[i], pages[i],
4456 sgl[i].offset = 0; 4453 count < PAGE_SIZE ? count : PAGE_SIZE, 0);;
4457 sgl[i].length = count < PAGE_SIZE ? count : PAGE_SIZE;
4458 count -= PAGE_SIZE; 4454 count -= PAGE_SIZE;
4459 } 4455 }
4460 } 4456 }
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 0a9882edf562..7a472b129997 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -282,10 +282,8 @@ int virt_to_scatterlist(const void *addr, int size, struct scatterlist *sg,
282 while (size > 0 && i < sg_size) { 282 while (size > 0 && i < sg_size) {
283 pg = virt_to_page(addr); 283 pg = virt_to_page(addr);
284 offset = offset_in_page(addr); 284 offset = offset_in_page(addr);
285 if (sg) { 285 if (sg)
286 sg_set_page(&sg[i], pg); 286 sg_set_page(&sg[i], pg, 0, offset);
287 sg[i].offset = offset;
288 }
289 remainder_of_page = PAGE_CACHE_SIZE - offset; 287 remainder_of_page = PAGE_CACHE_SIZE - offset;
290 if (size >= remainder_of_page) { 288 if (size >= remainder_of_page) {
291 if (sg) 289 if (sg)
@@ -716,12 +714,8 @@ ecryptfs_encrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
716 sg_init_table(&src_sg, 1); 714 sg_init_table(&src_sg, 1);
717 sg_init_table(&dst_sg, 1); 715 sg_init_table(&dst_sg, 1);
718 716
719 sg_set_page(&src_sg, src_page); 717 sg_set_page(&src_sg, src_page, size, src_offset);
720 src_sg.offset = src_offset; 718 sg_set_page(&dst_sg, dst_page, size, dst_offset);
721 src_sg.length = size;
722 sg_set_page(&dst_sg, dst_page);
723 dst_sg.offset = dst_offset;
724 dst_sg.length = size;
725 return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); 719 return encrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv);
726} 720}
727 721
@@ -746,14 +740,11 @@ ecryptfs_decrypt_page_offset(struct ecryptfs_crypt_stat *crypt_stat,
746 struct scatterlist src_sg, dst_sg; 740 struct scatterlist src_sg, dst_sg;
747 741
748 sg_init_table(&src_sg, 1); 742 sg_init_table(&src_sg, 1);
743 sg_set_page(&src_sg, src_page, size, src_offset);
744
749 sg_init_table(&dst_sg, 1); 745 sg_init_table(&dst_sg, 1);
746 sg_set_page(&dst_sg, dst_page, size, dst_offset);
750 747
751 sg_set_page(&src_sg, src_page);
752 src_sg.offset = src_offset;
753 src_sg.length = size;
754 sg_set_page(&dst_sg, dst_page);
755 dst_sg.offset = dst_offset;
756 dst_sg.length = size;
757 return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv); 748 return decrypt_scatterlist(crypt_stat, &dst_sg, &src_sg, size, iv);
758} 749}
759 750
diff --git a/include/asm-frv/scatterlist.h b/include/asm-frv/scatterlist.h
index 99ba76edc42a..2e7143b5a7ad 100644
--- a/include/asm-frv/scatterlist.h
+++ b/include/asm-frv/scatterlist.h
@@ -16,8 +16,7 @@
16 * 16 *
17 * can be rewritten as 17 * can be rewritten as
18 * 18 *
19 * sg_set_page(virt_to_page(some_ptr)); 19 * sg_set_buf(sg, some_ptr, length);
20 * sg->offset = (unsigned long) some_ptr & ~PAGE_MASK;
21 * 20 *
22 * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens 21 * and that's it. There's no excuse for not highmem enabling YOUR driver. /jens
23 */ 22 */
diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h
index df7ddcee7c4b..809b2ac2e37e 100644
--- a/include/linux/scatterlist.h
+++ b/include/linux/scatterlist.h
@@ -26,18 +26,16 @@
26#define SG_MAGIC 0x87654321 26#define SG_MAGIC 0x87654321
27 27
28/** 28/**
29 * sg_set_page - Set sg entry to point at given page 29 * sg_assign_page - Assign a given page to an SG entry
30 * @sg: SG entry 30 * @sg: SG entry
31 * @page: The page 31 * @page: The page
32 * 32 *
33 * Description: 33 * Description:
34 * Use this function to set an sg entry pointing at a page, never assign 34 * Assign page to sg entry. Also see sg_set_page(), the most commonly used
35 * the page directly. We encode sg table information in the lower bits 35 * variant.
36 * of the page pointer. See sg_page() for looking up the page belonging
37 * to an sg entry.
38 * 36 *
39 **/ 37 **/
40static inline void sg_set_page(struct scatterlist *sg, struct page *page) 38static inline void sg_assign_page(struct scatterlist *sg, struct page *page)
41{ 39{
42 unsigned long page_link = sg->page_link & 0x3; 40 unsigned long page_link = sg->page_link & 0x3;
43 41
@@ -52,6 +50,28 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page)
52 sg->page_link = page_link | (unsigned long) page; 50 sg->page_link = page_link | (unsigned long) page;
53} 51}
54 52
53/**
54 * sg_set_page - Set sg entry to point at given page
55 * @sg: SG entry
56 * @page: The page
57 * @len: Length of data
58 * @offset: Offset into page
59 *
60 * Description:
61 * Use this function to set an sg entry pointing at a page, never assign
62 * the page directly. We encode sg table information in the lower bits
63 * of the page pointer. See sg_page() for looking up the page belonging
64 * to an sg entry.
65 *
66 **/
67static inline void sg_set_page(struct scatterlist *sg, struct page *page,
68 unsigned int len, unsigned int offset)
69{
70 sg_assign_page(sg, page);
71 sg->offset = offset;
72 sg->length = len;
73}
74
55#define sg_page(sg) ((struct page *) ((sg)->page_link & ~0x3)) 75#define sg_page(sg) ((struct page *) ((sg)->page_link & ~0x3))
56 76
57/** 77/**
@@ -64,9 +84,7 @@ static inline void sg_set_page(struct scatterlist *sg, struct page *page)
64static inline void sg_set_buf(struct scatterlist *sg, const void *buf, 84static inline void sg_set_buf(struct scatterlist *sg, const void *buf,
65 unsigned int buflen) 85 unsigned int buflen)
66{ 86{
67 sg_set_page(sg, virt_to_page(buf)); 87 sg_set_page(sg, virt_to_page(buf), buflen, offset_in_page(buf));
68 sg->offset = offset_in_page(buf);
69 sg->length = buflen;
70} 88}
71 89
72/* 90/*
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 4e2c84fcf276..7b7c6c44c2da 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2045,9 +2045,7 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2045 if (copy > 0) { 2045 if (copy > 0) {
2046 if (copy > len) 2046 if (copy > len)
2047 copy = len; 2047 copy = len;
2048 sg_set_page(&sg[elt], virt_to_page(skb->data + offset)); 2048 sg_set_buf(sg, skb->data + offset, copy);
2049 sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
2050 sg[elt].length = copy;
2051 elt++; 2049 elt++;
2052 if ((len -= copy) == 0) 2050 if ((len -= copy) == 0)
2053 return elt; 2051 return elt;
@@ -2065,9 +2063,8 @@ skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
2065 2063
2066 if (copy > len) 2064 if (copy > len)
2067 copy = len; 2065 copy = len;
2068 sg_set_page(&sg[elt], frag->page); 2066 sg_set_page(&sg[elt], frag->page, copy,
2069 sg[elt].offset = frag->page_offset+offset-start; 2067 frag->page_offset+offset-start);
2070 sg[elt].length = copy;
2071 elt++; 2068 elt++;
2072 if (!(len -= copy)) 2069 if (!(len -= copy))
2073 return elt; 2070 return elt;
diff --git a/net/ieee80211/ieee80211_crypt_tkip.c b/net/ieee80211/ieee80211_crypt_tkip.c
index 74d017520a23..4cce3534e408 100644
--- a/net/ieee80211/ieee80211_crypt_tkip.c
+++ b/net/ieee80211/ieee80211_crypt_tkip.c
@@ -537,13 +537,8 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 * key, u8 * hdr,
537 return -1; 537 return -1;
538 } 538 }
539 sg_init_table(sg, 2); 539 sg_init_table(sg, 2);
540 sg_set_page(&sg[0], virt_to_page(hdr)); 540 sg_set_buf(&sg[0], hdr, 16);
541 sg[0].offset = offset_in_page(hdr); 541 sg_set_buf(&sg[1], data, data_len);
542 sg[0].length = 16;
543
544 sg_set_page(&sg[1], virt_to_page(data));
545 sg[1].offset = offset_in_page(data);
546 sg[1].length = data_len;
547 542
548 if (crypto_hash_setkey(tfm_michael, key, 8)) 543 if (crypto_hash_setkey(tfm_michael, key, 8))
549 return -1; 544 return -1;
diff --git a/net/sctp/auth.c b/net/sctp/auth.c
index cbd64b216cce..621113a109b2 100644
--- a/net/sctp/auth.c
+++ b/net/sctp/auth.c
@@ -727,9 +727,7 @@ void sctp_auth_calculate_hmac(const struct sctp_association *asoc,
727 /* set up scatter list */ 727 /* set up scatter list */
728 end = skb_tail_pointer(skb); 728 end = skb_tail_pointer(skb);
729 sg_init_table(&sg, 1); 729 sg_init_table(&sg, 1);
730 sg_set_page(&sg, virt_to_page(auth)); 730 sg_set_buf(&sg, auth, end - (unsigned char *)auth);
731 sg.offset = (unsigned long)(auth) % PAGE_SIZE;
732 sg.length = end - (unsigned char *)auth;
733 731
734 desc.tfm = asoc->ep->auth_hmacs[hmac_id]; 732 desc.tfm = asoc->ep->auth_hmacs[hmac_id];
735 desc.flags = 0; 733 desc.flags = 0;
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index 658476c4d587..c055212875f6 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1514,9 +1514,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep,
1514 1514
1515 /* Sign the message. */ 1515 /* Sign the message. */
1516 sg_init_table(&sg, 1); 1516 sg_init_table(&sg, 1);
1517 sg_set_page(&sg, virt_to_page(&cookie->c)); 1517 sg_set_buf(&sg, &cookie->c, bodysize);
1518 sg.offset = (unsigned long)(&cookie->c) % PAGE_SIZE;
1519 sg.length = bodysize;
1520 keylen = SCTP_SECRET_SIZE; 1518 keylen = SCTP_SECRET_SIZE;
1521 key = (char *)ep->secret_key[ep->current_key]; 1519 key = (char *)ep->secret_key[ep->current_key];
1522 desc.tfm = sctp_sk(ep->base.sk)->hmac; 1520 desc.tfm = sctp_sk(ep->base.sk)->hmac;
@@ -1587,9 +1585,7 @@ struct sctp_association *sctp_unpack_cookie(
1587 /* Check the signature. */ 1585 /* Check the signature. */
1588 keylen = SCTP_SECRET_SIZE; 1586 keylen = SCTP_SECRET_SIZE;
1589 sg_init_table(&sg, 1); 1587 sg_init_table(&sg, 1);
1590 sg_set_page(&sg, virt_to_page(bear_cookie)); 1588 sg_set_buf(&sg, bear_cookie, bodysize);
1591 sg.offset = (unsigned long)(bear_cookie) % PAGE_SIZE;
1592 sg.length = bodysize;
1593 key = (char *)ep->secret_key[ep->current_key]; 1589 key = (char *)ep->secret_key[ep->current_key];
1594 desc.tfm = sctp_sk(ep->base.sk)->hmac; 1590 desc.tfm = sctp_sk(ep->base.sk)->hmac;
1595 desc.flags = 0; 1591 desc.flags = 0;
diff --git a/net/sunrpc/auth_gss/gss_krb5_crypto.c b/net/sunrpc/auth_gss/gss_krb5_crypto.c
index 32be431affcf..24711be4b2dc 100644
--- a/net/sunrpc/auth_gss/gss_krb5_crypto.c
+++ b/net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -199,7 +199,7 @@ encryptor(struct scatterlist *sg, void *data)
199 } else { 199 } else {
200 in_page = sg_page(sg); 200 in_page = sg_page(sg);
201 } 201 }
202 sg_set_page(&desc->infrags[desc->fragno], in_page); 202 sg_assign_page(&desc->infrags[desc->fragno], in_page);
203 desc->fragno++; 203 desc->fragno++;
204 desc->fraglen += sg->length; 204 desc->fraglen += sg->length;
205 desc->pos += sg->length; 205 desc->pos += sg->length;
@@ -215,11 +215,10 @@ encryptor(struct scatterlist *sg, void *data)
215 if (ret) 215 if (ret)
216 return ret; 216 return ret;
217 if (fraglen) { 217 if (fraglen) {
218 sg_set_page(&desc->outfrags[0], sg_page(sg)); 218 sg_set_page(&desc->outfrags[0], sg_page(sg), fraglen,
219 desc->outfrags[0].offset = sg->offset + sg->length - fraglen; 219 sg->offset + sg->length - fraglen);
220 desc->outfrags[0].length = fraglen;
221 desc->infrags[0] = desc->outfrags[0]; 220 desc->infrags[0] = desc->outfrags[0];
222 sg_set_page(&desc->infrags[0], in_page); 221 sg_assign_page(&desc->infrags[0], in_page);
223 desc->fragno = 1; 222 desc->fragno = 1;
224 desc->fraglen = fraglen; 223 desc->fraglen = fraglen;
225 } else { 224 } else {
@@ -287,9 +286,8 @@ decryptor(struct scatterlist *sg, void *data)
287 if (ret) 286 if (ret)
288 return ret; 287 return ret;
289 if (fraglen) { 288 if (fraglen) {
290 sg_set_page(&desc->frags[0], sg_page(sg)); 289 sg_set_page(&desc->frags[0], sg_page(sg), fraglen,
291 desc->frags[0].offset = sg->offset + sg->length - fraglen; 290 sg->offset + sg->length - fraglen);
292 desc->frags[0].length = fraglen;
293 desc->fragno = 1; 291 desc->fragno = 1;
294 desc->fraglen = fraglen; 292 desc->fraglen = fraglen;
295 } else { 293 } else {
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 3d1f7cdf9dd0..f38dac30481b 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -1059,9 +1059,7 @@ xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len,
1059 do { 1059 do {
1060 if (thislen > page_len) 1060 if (thislen > page_len)
1061 thislen = page_len; 1061 thislen = page_len;
1062 sg_set_page(sg, buf->pages[i]); 1062 sg_set_page(sg, buf->pages[i], thislen, page_offset);
1063 sg->offset = page_offset;
1064 sg->length = thislen;
1065 ret = actor(sg, data); 1063 ret = actor(sg, data);
1066 if (ret) 1064 if (ret)
1067 goto out; 1065 goto out;
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index 313d4bed3aa9..fa45989a716a 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -553,9 +553,7 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
553 if (copy > len) 553 if (copy > len)
554 copy = len; 554 copy = len;
555 555
556 sg_set_page(&sg, virt_to_page(skb->data + offset)); 556 sg_set_buf(&sg, skb->data + offset, copy);
557 sg.offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
558 sg.length = copy;
559 557
560 err = icv_update(desc, &sg, copy); 558 err = icv_update(desc, &sg, copy);
561 if (unlikely(err)) 559 if (unlikely(err))
@@ -578,9 +576,8 @@ int skb_icv_walk(const struct sk_buff *skb, struct hash_desc *desc,
578 if (copy > len) 576 if (copy > len)
579 copy = len; 577 copy = len;
580 578
581 sg_set_page(&sg, frag->page); 579 sg_set_page(&sg, frag->page, copy,
582 sg.offset = frag->page_offset + offset-start; 580 frag->page_offset + offset-start);
583 sg.length = copy;
584 581
585 err = icv_update(desc, &sg, copy); 582 err = icv_update(desc, &sg, copy);
586 if (unlikely(err)) 583 if (unlikely(err))