aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTyler Hicks <tyhicks@canonical.com>2013-04-15 20:28:09 -0400
committerTyler Hicks <tyhicks@canonical.com>2013-06-07 20:28:23 -0400
commit24d15266bd86b7961f309a962fa3aa177a78c49f (patch)
treee41dfb1bf00797978a9f1009d60994e30a6b9250 /fs
parent0f89617623fed9541ead9497043e907466848a9f (diff)
eCryptfs: Simplify lower file offset calculation
Now that lower filesystem IO operations occur for complete PAGE_CACHE_SIZE bytes, the calculation for converting an eCryptfs extent index into a lower file offset can be simplified. Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ecryptfs/crypto.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 4185584594f5..3547708fb4e1 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -407,15 +407,15 @@ out:
407} 407}
408 408
409/** 409/**
410 * ecryptfs_lower_offset_for_extent 410 * lower_offset_for_page
411 * 411 *
412 * Convert an eCryptfs page index into a lower byte offset 412 * Convert an eCryptfs page index into a lower byte offset
413 */ 413 */
414static void ecryptfs_lower_offset_for_extent(loff_t *offset, loff_t extent_num, 414static loff_t lower_offset_for_page(struct ecryptfs_crypt_stat *crypt_stat,
415 struct ecryptfs_crypt_stat *crypt_stat) 415 struct page *page)
416{ 416{
417 (*offset) = ecryptfs_lower_header_size(crypt_stat) 417 return ecryptfs_lower_header_size(crypt_stat) +
418 + (crypt_stat->extent_size * extent_num); 418 (page->index << PAGE_CACHE_SHIFT);
419} 419}
420 420
421/** 421/**
@@ -517,9 +517,7 @@ int ecryptfs_encrypt_page(struct page *page)
517 } 517 }
518 } 518 }
519 519
520 ecryptfs_lower_offset_for_extent(&lower_offset, 520 lower_offset = lower_offset_for_page(crypt_stat, page);
521 page->index * (PAGE_CACHE_SIZE / crypt_stat->extent_size),
522 crypt_stat);
523 enc_extent_virt = kmap(enc_extent_page); 521 enc_extent_virt = kmap(enc_extent_page);
524 rc = ecryptfs_write_lower(ecryptfs_inode, enc_extent_virt, lower_offset, 522 rc = ecryptfs_write_lower(ecryptfs_inode, enc_extent_virt, lower_offset,
525 PAGE_CACHE_SIZE); 523 PAGE_CACHE_SIZE);
@@ -612,9 +610,7 @@ int ecryptfs_decrypt_page(struct page *page)
612 goto out; 610 goto out;
613 } 611 }
614 612
615 ecryptfs_lower_offset_for_extent(&lower_offset, 613 lower_offset = lower_offset_for_page(crypt_stat, page);
616 page->index * (PAGE_CACHE_SIZE / crypt_stat->extent_size),
617 crypt_stat);
618 enc_extent_virt = kmap(enc_extent_page); 614 enc_extent_virt = kmap(enc_extent_page);
619 rc = ecryptfs_read_lower(enc_extent_virt, lower_offset, PAGE_CACHE_SIZE, 615 rc = ecryptfs_read_lower(enc_extent_virt, lower_offset, PAGE_CACHE_SIZE,
620 ecryptfs_inode); 616 ecryptfs_inode);