aboutsummaryrefslogtreecommitdiffstats
path: root/fs
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 /fs
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/ecryptfs/crypto.c23
1 files changed, 7 insertions, 16 deletions
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