aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs
diff options
context:
space:
mode:
authorDmitriy Monakhov <dmonakhov@openvz.org>2007-03-05 03:30:47 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-03-05 10:57:53 -0500
commita8fa74ab529f23f812092ece8d7a4766af092332 (patch)
treebdd3636671755f9022cb2f4dcc6af3a498711bdb /fs/ecryptfs
parent82b16528405131eadc18285da982d4806f6db34e (diff)
[PATCH] ecryptfs: handle AOP_TRUNCATED_PAGE better
- In fact we don't have to fail if AOP_TRUNCATED_PAGE was returned from prepare_write or commit_write. It is beter to retry attempt where it is possible. - Rearange ecryptfs_get_lower_page() error handling logic, make it more clean. Signed-off-by: Dmitriy Monakhov <dmonakhov@openvz.org> Acked-by: Michael Halcrow <mhalcrow@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r--fs/ecryptfs/mmap.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index 7def4be83e61..b731b09499cb 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -446,6 +446,7 @@ static int ecryptfs_write_inode_size_to_header(struct file *lower_file,
446 const struct address_space_operations *lower_a_ops; 446 const struct address_space_operations *lower_a_ops;
447 u64 file_size; 447 u64 file_size;
448 448
449retry:
449 header_page = grab_cache_page(lower_inode->i_mapping, 0); 450 header_page = grab_cache_page(lower_inode->i_mapping, 0);
450 if (!header_page) { 451 if (!header_page) {
451 ecryptfs_printk(KERN_ERR, "grab_cache_page for " 452 ecryptfs_printk(KERN_ERR, "grab_cache_page for "
@@ -456,9 +457,10 @@ static int ecryptfs_write_inode_size_to_header(struct file *lower_file,
456 lower_a_ops = lower_inode->i_mapping->a_ops; 457 lower_a_ops = lower_inode->i_mapping->a_ops;
457 rc = lower_a_ops->prepare_write(lower_file, header_page, 0, 8); 458 rc = lower_a_ops->prepare_write(lower_file, header_page, 0, 8);
458 if (rc) { 459 if (rc) {
459 if (rc == AOP_TRUNCATED_PAGE) 460 if (rc == AOP_TRUNCATED_PAGE) {
460 ecryptfs_release_lower_page(header_page, 0); 461 ecryptfs_release_lower_page(header_page, 0);
461 else 462 goto retry;
463 } else
462 ecryptfs_release_lower_page(header_page, 1); 464 ecryptfs_release_lower_page(header_page, 1);
463 goto out; 465 goto out;
464 } 466 }
@@ -473,9 +475,10 @@ static int ecryptfs_write_inode_size_to_header(struct file *lower_file,
473 if (rc < 0) 475 if (rc < 0)
474 ecryptfs_printk(KERN_ERR, "Error commiting header page " 476 ecryptfs_printk(KERN_ERR, "Error commiting header page "
475 "write\n"); 477 "write\n");
476 if (rc == AOP_TRUNCATED_PAGE) 478 if (rc == AOP_TRUNCATED_PAGE) {
477 ecryptfs_release_lower_page(header_page, 0); 479 ecryptfs_release_lower_page(header_page, 0);
478 else 480 goto retry;
481 } else
479 ecryptfs_release_lower_page(header_page, 1); 482 ecryptfs_release_lower_page(header_page, 1);
480 lower_inode->i_mtime = lower_inode->i_ctime = CURRENT_TIME; 483 lower_inode->i_mtime = lower_inode->i_ctime = CURRENT_TIME;
481 mark_inode_dirty_sync(inode); 484 mark_inode_dirty_sync(inode);
@@ -565,6 +568,7 @@ int ecryptfs_get_lower_page(struct page **lower_page, struct inode *lower_inode,
565{ 568{
566 int rc = 0; 569 int rc = 0;
567 570
571retry:
568 *lower_page = grab_cache_page(lower_inode->i_mapping, lower_page_index); 572 *lower_page = grab_cache_page(lower_inode->i_mapping, lower_page_index);
569 if (!(*lower_page)) { 573 if (!(*lower_page)) {
570 rc = -EINVAL; 574 rc = -EINVAL;
@@ -578,18 +582,18 @@ int ecryptfs_get_lower_page(struct page **lower_page, struct inode *lower_inode,
578 byte_offset, 582 byte_offset,
579 region_bytes); 583 region_bytes);
580 if (rc) { 584 if (rc) {
581 ecryptfs_printk(KERN_ERR, "prepare_write for " 585 if (rc == AOP_TRUNCATED_PAGE) {
586 ecryptfs_release_lower_page(*lower_page, 0);
587 goto retry;
588 } else {
589 ecryptfs_printk(KERN_ERR, "prepare_write for "
582 "lower_page_index = [0x%.16x] failed; rc = " 590 "lower_page_index = [0x%.16x] failed; rc = "
583 "[%d]\n", lower_page_index, rc); 591 "[%d]\n", lower_page_index, rc);
584 }
585out:
586 if (rc && (*lower_page)) {
587 if (rc == AOP_TRUNCATED_PAGE)
588 ecryptfs_release_lower_page(*lower_page, 0);
589 else
590 ecryptfs_release_lower_page(*lower_page, 1); 592 ecryptfs_release_lower_page(*lower_page, 1);
591 (*lower_page) = NULL; 593 (*lower_page) = NULL;
594 }
592 } 595 }
596out:
593 return rc; 597 return rc;
594} 598}
595 599