aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/crypto.c
diff options
context:
space:
mode:
authorMichael Halcrow <mhalcrow@us.ibm.com>2007-10-16 04:28:05 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:43:12 -0400
commit45eaab79678b9e27e08f0cf250eb2df9d6a48df0 (patch)
treeff13018aa1d66f1b1d9abbba6df7a361518bacb7 /fs/ecryptfs/crypto.c
parente9f6a99cb844a61b04cab5b82e333d6efef1f735 (diff)
eCryptfs: remove header_extent_size
There is no point to keeping a separate header_extent_size and an extent_size. The total size of the header can always be represented as some multiple of the regular data extent size. [randy.dunlap@oracle.com: ecryptfs: fix printk format warning] Signed-off-by: Michael Halcrow <mhalcrow@us.ibm.com> Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ecryptfs/crypto.c')
-rw-r--r--fs/ecryptfs/crypto.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
index 8e9b36df7881..9127b809044d 100644
--- a/fs/ecryptfs/crypto.c
+++ b/fs/ecryptfs/crypto.c
@@ -366,8 +366,8 @@ ecryptfs_extent_to_lwr_pg_idx_and_offset(unsigned long *lower_page_idx,
366 int extents_per_page; 366 int extents_per_page;
367 367
368 bytes_occupied_by_headers_at_front = 368 bytes_occupied_by_headers_at_front =
369 ( crypt_stat->header_extent_size 369 (crypt_stat->extent_size
370 * crypt_stat->num_header_extents_at_front ); 370 * crypt_stat->num_header_extents_at_front);
371 extents_occupied_by_headers_at_front = 371 extents_occupied_by_headers_at_front =
372 ( bytes_occupied_by_headers_at_front 372 ( bytes_occupied_by_headers_at_front
373 / crypt_stat->extent_size ); 373 / crypt_stat->extent_size );
@@ -376,8 +376,8 @@ ecryptfs_extent_to_lwr_pg_idx_and_offset(unsigned long *lower_page_idx,
376 (*lower_page_idx) = lower_extent_num / extents_per_page; 376 (*lower_page_idx) = lower_extent_num / extents_per_page;
377 extent_offset = lower_extent_num % extents_per_page; 377 extent_offset = lower_extent_num % extents_per_page;
378 (*byte_offset) = extent_offset * crypt_stat->extent_size; 378 (*byte_offset) = extent_offset * crypt_stat->extent_size;
379 ecryptfs_printk(KERN_DEBUG, " * crypt_stat->header_extent_size = " 379 ecryptfs_printk(KERN_DEBUG, " * crypt_stat->extent_size = "
380 "[%d]\n", crypt_stat->header_extent_size); 380 "[%d]\n", crypt_stat->extent_size);
381 ecryptfs_printk(KERN_DEBUG, " * crypt_stat->" 381 ecryptfs_printk(KERN_DEBUG, " * crypt_stat->"
382 "num_header_extents_at_front = [%d]\n", 382 "num_header_extents_at_front = [%d]\n",
383 crypt_stat->num_header_extents_at_front); 383 crypt_stat->num_header_extents_at_front);
@@ -899,15 +899,17 @@ void ecryptfs_set_default_sizes(struct ecryptfs_crypt_stat *crypt_stat)
899 crypt_stat->extent_size = ECRYPTFS_DEFAULT_EXTENT_SIZE; 899 crypt_stat->extent_size = ECRYPTFS_DEFAULT_EXTENT_SIZE;
900 set_extent_mask_and_shift(crypt_stat); 900 set_extent_mask_and_shift(crypt_stat);
901 crypt_stat->iv_bytes = ECRYPTFS_DEFAULT_IV_BYTES; 901 crypt_stat->iv_bytes = ECRYPTFS_DEFAULT_IV_BYTES;
902 if (PAGE_CACHE_SIZE <= ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE) {
903 crypt_stat->header_extent_size =
904 ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE;
905 } else
906 crypt_stat->header_extent_size = PAGE_CACHE_SIZE;
907 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR) 902 if (crypt_stat->flags & ECRYPTFS_METADATA_IN_XATTR)
908 crypt_stat->num_header_extents_at_front = 0; 903 crypt_stat->num_header_extents_at_front = 0;
909 else 904 else {
910 crypt_stat->num_header_extents_at_front = 1; 905 if (PAGE_CACHE_SIZE <= ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE)
906 crypt_stat->num_header_extents_at_front =
907 (ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE
908 / crypt_stat->extent_size);
909 else
910 crypt_stat->num_header_extents_at_front =
911 (PAGE_CACHE_SIZE / crypt_stat->extent_size);
912 }
911} 913}
912 914
913/** 915/**
@@ -1319,7 +1321,7 @@ ecryptfs_write_header_metadata(char *virt,
1319 u32 header_extent_size; 1321 u32 header_extent_size;
1320 u16 num_header_extents_at_front; 1322 u16 num_header_extents_at_front;
1321 1323
1322 header_extent_size = (u32)crypt_stat->header_extent_size; 1324 header_extent_size = (u32)crypt_stat->extent_size;
1323 num_header_extents_at_front = 1325 num_header_extents_at_front =
1324 (u16)crypt_stat->num_header_extents_at_front; 1326 (u16)crypt_stat->num_header_extents_at_front;
1325 header_extent_size = cpu_to_be32(header_extent_size); 1327 header_extent_size = cpu_to_be32(header_extent_size);
@@ -1415,7 +1417,7 @@ ecryptfs_write_metadata_to_contents(struct ecryptfs_crypt_stat *crypt_stat,
1415 set_fs(oldfs); 1417 set_fs(oldfs);
1416 goto out; 1418 goto out;
1417 } 1419 }
1418 header_pages = ((crypt_stat->header_extent_size 1420 header_pages = ((crypt_stat->extent_size
1419 * crypt_stat->num_header_extents_at_front) 1421 * crypt_stat->num_header_extents_at_front)
1420 / PAGE_CACHE_SIZE); 1422 / PAGE_CACHE_SIZE);
1421 memset(page_virt, 0, PAGE_CACHE_SIZE); 1423 memset(page_virt, 0, PAGE_CACHE_SIZE);
@@ -1532,17 +1534,16 @@ static int parse_header_metadata(struct ecryptfs_crypt_stat *crypt_stat,
1532 virt += 4; 1534 virt += 4;
1533 memcpy(&num_header_extents_at_front, virt, 2); 1535 memcpy(&num_header_extents_at_front, virt, 2);
1534 num_header_extents_at_front = be16_to_cpu(num_header_extents_at_front); 1536 num_header_extents_at_front = be16_to_cpu(num_header_extents_at_front);
1535 crypt_stat->header_extent_size = (int)header_extent_size;
1536 crypt_stat->num_header_extents_at_front = 1537 crypt_stat->num_header_extents_at_front =
1537 (int)num_header_extents_at_front; 1538 (int)num_header_extents_at_front;
1538 (*bytes_read) = 6; 1539 (*bytes_read) = (sizeof(u32) + sizeof(u16));
1539 if ((validate_header_size == ECRYPTFS_VALIDATE_HEADER_SIZE) 1540 if ((validate_header_size == ECRYPTFS_VALIDATE_HEADER_SIZE)
1540 && ((crypt_stat->header_extent_size 1541 && ((crypt_stat->extent_size
1541 * crypt_stat->num_header_extents_at_front) 1542 * crypt_stat->num_header_extents_at_front)
1542 < ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE)) { 1543 < ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE)) {
1543 rc = -EINVAL; 1544 rc = -EINVAL;
1544 ecryptfs_printk(KERN_WARNING, "Invalid header extent size: " 1545 printk(KERN_WARNING "Invalid number of header extents: [%zd]\n",
1545 "[%d]\n", crypt_stat->header_extent_size); 1546 crypt_stat->num_header_extents_at_front);
1546 } 1547 }
1547 return rc; 1548 return rc;
1548} 1549}
@@ -1557,8 +1558,7 @@ static int parse_header_metadata(struct ecryptfs_crypt_stat *crypt_stat,
1557 */ 1558 */
1558static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat) 1559static void set_default_header_data(struct ecryptfs_crypt_stat *crypt_stat)
1559{ 1560{
1560 crypt_stat->header_extent_size = 4096; 1561 crypt_stat->num_header_extents_at_front = 2;
1561 crypt_stat->num_header_extents_at_front = 1;
1562} 1562}
1563 1563
1564/** 1564/**