aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/mmap.c
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2007-10-16 04:25:26 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 12:42:58 -0400
commit55144768e100b68447f44c5e5c9deb155ad661bd (patch)
tree9889682ee3b64627ad9eb504f30672fad844752f /fs/ecryptfs/mmap.c
parent03158cd7eb3374843de68421142ca5900df845d9 (diff)
fs: remove some AOP_TRUNCATED_PAGE
prepare/commit_write no longer returns AOP_TRUNCATED_PAGE since OCFS2 and GFS2 were converted to the new aops, so we can make some simplifications for that. [michal.k.k.piotrowski@gmail.com: fix warning] Signed-off-by: Nick Piggin <npiggin@suse.de> Cc: Michael Halcrow <mhalcrow@us.ibm.com> Cc: Mark Fasheh <mark.fasheh@oracle.com> Cc: Steven Whitehouse <swhiteho@redhat.com> Signed-off-by: Michal Piotrowski <michal.k.k.piotrowski@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ecryptfs/mmap.c')
-rw-r--r--fs/ecryptfs/mmap.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index fd3f94d4a668..aaea55a61ea1 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -446,11 +446,9 @@ out:
446 return rc; 446 return rc;
447} 447}
448 448
449static 449static void ecryptfs_release_lower_page(struct page *lower_page)
450void ecryptfs_release_lower_page(struct page *lower_page, int page_locked)
451{ 450{
452 if (page_locked) 451 unlock_page(lower_page);
453 unlock_page(lower_page);
454 page_cache_release(lower_page); 452 page_cache_release(lower_page);
455} 453}
456 454
@@ -471,7 +469,6 @@ static int ecryptfs_write_inode_size_to_header(struct file *lower_file,
471 const struct address_space_operations *lower_a_ops; 469 const struct address_space_operations *lower_a_ops;
472 u64 file_size; 470 u64 file_size;
473 471
474retry:
475 header_page = grab_cache_page(lower_inode->i_mapping, 0); 472 header_page = grab_cache_page(lower_inode->i_mapping, 0);
476 if (!header_page) { 473 if (!header_page) {
477 ecryptfs_printk(KERN_ERR, "grab_cache_page for " 474 ecryptfs_printk(KERN_ERR, "grab_cache_page for "
@@ -482,11 +479,7 @@ retry:
482 lower_a_ops = lower_inode->i_mapping->a_ops; 479 lower_a_ops = lower_inode->i_mapping->a_ops;
483 rc = lower_a_ops->prepare_write(lower_file, header_page, 0, 8); 480 rc = lower_a_ops->prepare_write(lower_file, header_page, 0, 8);
484 if (rc) { 481 if (rc) {
485 if (rc == AOP_TRUNCATED_PAGE) { 482 ecryptfs_release_lower_page(header_page);
486 ecryptfs_release_lower_page(header_page, 0);
487 goto retry;
488 } else
489 ecryptfs_release_lower_page(header_page, 1);
490 goto out; 483 goto out;
491 } 484 }
492 file_size = (u64)i_size_read(inode); 485 file_size = (u64)i_size_read(inode);
@@ -500,11 +493,7 @@ retry:
500 if (rc < 0) 493 if (rc < 0)
501 ecryptfs_printk(KERN_ERR, "Error commiting header page " 494 ecryptfs_printk(KERN_ERR, "Error commiting header page "
502 "write\n"); 495 "write\n");
503 if (rc == AOP_TRUNCATED_PAGE) { 496 ecryptfs_release_lower_page(header_page);
504 ecryptfs_release_lower_page(header_page, 0);
505 goto retry;
506 } else
507 ecryptfs_release_lower_page(header_page, 1);
508 lower_inode->i_mtime = lower_inode->i_ctime = CURRENT_TIME; 497 lower_inode->i_mtime = lower_inode->i_ctime = CURRENT_TIME;
509 mark_inode_dirty_sync(inode); 498 mark_inode_dirty_sync(inode);
510out: 499out:
@@ -593,7 +582,6 @@ int ecryptfs_get_lower_page(struct page **lower_page, struct inode *lower_inode,
593{ 582{
594 int rc = 0; 583 int rc = 0;
595 584
596retry:
597 *lower_page = grab_cache_page(lower_inode->i_mapping, lower_page_index); 585 *lower_page = grab_cache_page(lower_inode->i_mapping, lower_page_index);
598 if (!(*lower_page)) { 586 if (!(*lower_page)) {
599 rc = -EINVAL; 587 rc = -EINVAL;
@@ -607,16 +595,11 @@ retry:
607 byte_offset, 595 byte_offset,
608 region_bytes); 596 region_bytes);
609 if (rc) { 597 if (rc) {
610 if (rc == AOP_TRUNCATED_PAGE) { 598 ecryptfs_printk(KERN_ERR, "prepare_write for "
611 ecryptfs_release_lower_page(*lower_page, 0); 599 "lower_page_index = [0x%.16x] failed; rc = "
612 goto retry; 600 "[%d]\n", lower_page_index, rc);
613 } else { 601 ecryptfs_release_lower_page(*lower_page);
614 ecryptfs_printk(KERN_ERR, "prepare_write for " 602 (*lower_page) = NULL;
615 "lower_page_index = [0x%.16x] failed; rc = "
616 "[%d]\n", lower_page_index, rc);
617 ecryptfs_release_lower_page(*lower_page, 1);
618 (*lower_page) = NULL;
619 }
620 } 603 }
621out: 604out:
622 return rc; 605 return rc;
@@ -632,19 +615,16 @@ ecryptfs_commit_lower_page(struct page *lower_page, struct inode *lower_inode,
632 struct file *lower_file, int byte_offset, 615 struct file *lower_file, int byte_offset,
633 int region_size) 616 int region_size)
634{ 617{
635 int page_locked = 1;
636 int rc = 0; 618 int rc = 0;
637 619
638 rc = lower_inode->i_mapping->a_ops->commit_write( 620 rc = lower_inode->i_mapping->a_ops->commit_write(
639 lower_file, lower_page, byte_offset, region_size); 621 lower_file, lower_page, byte_offset, region_size);
640 if (rc == AOP_TRUNCATED_PAGE)
641 page_locked = 0;
642 if (rc < 0) { 622 if (rc < 0) {
643 ecryptfs_printk(KERN_ERR, 623 ecryptfs_printk(KERN_ERR,
644 "Error committing write; rc = [%d]\n", rc); 624 "Error committing write; rc = [%d]\n", rc);
645 } else 625 } else
646 rc = 0; 626 rc = 0;
647 ecryptfs_release_lower_page(lower_page, page_locked); 627 ecryptfs_release_lower_page(lower_page);
648 return rc; 628 return rc;
649} 629}
650 630