diff options
Diffstat (limited to 'fs/ecryptfs/crypto.c')
-rw-r--r-- | fs/ecryptfs/crypto.c | 18 |
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 | */ |
414 | static void ecryptfs_lower_offset_for_extent(loff_t *offset, loff_t extent_num, | 414 | static 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); |