Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ecryptfs: merge ecryptfs_inode_newsize_ok into truncate_upper

Both callers of ecryptfs_inode_newsize_ok call truncate_upper right
after. Merge ecryptfs_inode_newsize_ok into truncate_upper to simplify
the logic.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Tyler Hicks <code@tyhicks.com>

authored by

Christoph Hellwig and committed by
Tyler Hicks
081447ec 472dea1d

+17 -35
+17 -35
fs/ecryptfs/inode.c
··· 738 738 return 0; 739 739 } 740 740 741 + crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat; 742 + lower_size_before_truncate = 743 + upper_size_to_lower_size(crypt_stat, i_size); 744 + lower_size_after_truncate = 745 + upper_size_to_lower_size(crypt_stat, ia->ia_size); 746 + if (lower_size_after_truncate > lower_size_before_truncate) { 747 + /* 748 + * The eCryptfs inode and the new *lower* size are mixed here 749 + * because we may not have the lower i_mutex held and/or it may 750 + * not be appropriate to call inode_newsize_ok() with inodes 751 + * from other filesystems. 752 + */ 753 + rc = inode_newsize_ok(inode, lower_size_after_truncate); 754 + if (rc) 755 + return rc; 756 + } 757 + 741 758 rc = ecryptfs_get_lower_file(dentry, inode); 742 759 if (rc) 743 760 return rc; ··· 773 756 goto out; 774 757 } 775 758 776 - crypt_stat = &ecryptfs_inode_to_private(d_inode(dentry))->crypt_stat; 777 759 if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) { 778 760 truncate_setsize(inode, ia->ia_size); 779 761 lower_ia->ia_size = ia->ia_size; ··· 807 791 * We are reducing the size of the ecryptfs file, and need to know if we 808 792 * need to reduce the size of the lower file. 809 793 */ 810 - lower_size_before_truncate = 811 - upper_size_to_lower_size(crypt_stat, i_size); 812 - lower_size_after_truncate = 813 - upper_size_to_lower_size(crypt_stat, ia->ia_size); 814 794 if (lower_size_after_truncate < lower_size_before_truncate) { 815 795 lower_ia->ia_size = lower_size_after_truncate; 816 796 lower_ia->ia_valid |= ATTR_SIZE; ··· 816 804 out: 817 805 ecryptfs_put_lower_file(inode); 818 806 return rc; 819 - } 820 - 821 - static int ecryptfs_inode_newsize_ok(struct inode *inode, loff_t offset) 822 - { 823 - struct ecryptfs_crypt_stat *crypt_stat; 824 - loff_t lower_oldsize, lower_newsize; 825 - 826 - crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat; 827 - lower_oldsize = upper_size_to_lower_size(crypt_stat, 828 - i_size_read(inode)); 829 - lower_newsize = upper_size_to_lower_size(crypt_stat, offset); 830 - if (lower_newsize > lower_oldsize) { 831 - /* 832 - * The eCryptfs inode and the new *lower* size are mixed here 833 - * because we may not have the lower i_mutex held and/or it may 834 - * not be appropriate to call inode_newsize_ok() with inodes 835 - * from other filesystems. 836 - */ 837 - return inode_newsize_ok(inode, lower_newsize); 838 - } 839 - 840 - return 0; 841 807 } 842 808 843 809 /** ··· 833 843 struct iattr ia = { .ia_valid = ATTR_SIZE, .ia_size = new_length }; 834 844 struct iattr lower_ia = { .ia_valid = 0 }; 835 845 int rc; 836 - 837 - rc = ecryptfs_inode_newsize_ok(d_inode(dentry), new_length); 838 - if (rc) 839 - return rc; 840 846 841 847 rc = truncate_upper(dentry, &ia, &lower_ia); 842 848 if (!rc && lower_ia.ia_valid & ATTR_SIZE) { ··· 925 939 if (ia->ia_valid & ATTR_FILE) 926 940 lower_ia.ia_file = ecryptfs_file_to_lower(ia->ia_file); 927 941 if (ia->ia_valid & ATTR_SIZE) { 928 - rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size); 929 - if (rc) 930 - goto out; 931 - 932 942 rc = truncate_upper(dentry, ia, &lower_ia); 933 943 if (rc < 0) 934 944 goto out;