~ubuntu-branches/ubuntu/quantal/linux-lowlatency/quantal

« back to all changes in this revision

Viewing changes to fs/ecryptfs/inode.c

  • Committer: Package Import Robot
  • Author(s): Alessio Igor Bogani
  • Date: 2011-10-26 11:13:05 UTC
  • Revision ID: package-import@ubuntu.com-20111026111305-04kado7d1u2er2rl
Tags: 3.2.0-16.25
Add new lowlatency kernel flavour

Show diffs side-by-side

added added

removed removed

Lines of Context:
841
841
                size_t num_zeros = (PAGE_CACHE_SIZE
842
842
                                    - (ia->ia_size & ~PAGE_CACHE_MASK));
843
843
 
844
 
 
845
 
                /*
846
 
                 * XXX(truncate) this should really happen at the begginning
847
 
                 * of ->setattr.  But the code is too messy to that as part
848
 
                 * of a larger patch.  ecryptfs is also totally missing out
849
 
                 * on the inode_change_ok check at the beginning of
850
 
                 * ->setattr while would include this.
851
 
                 */
852
 
                rc = inode_newsize_ok(inode, ia->ia_size);
853
 
                if (rc)
854
 
                        goto out;
855
 
 
856
844
                if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
857
845
                        truncate_setsize(inode, ia->ia_size);
858
846
                        lower_ia->ia_size = ia->ia_size;
902
890
        return rc;
903
891
}
904
892
 
 
893
static int ecryptfs_inode_newsize_ok(struct inode *inode, loff_t offset)
 
894
{
 
895
        struct ecryptfs_crypt_stat *crypt_stat;
 
896
        loff_t lower_oldsize, lower_newsize;
 
897
 
 
898
        crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
 
899
        lower_oldsize = upper_size_to_lower_size(crypt_stat,
 
900
                                                 i_size_read(inode));
 
901
        lower_newsize = upper_size_to_lower_size(crypt_stat, offset);
 
902
        if (lower_newsize > lower_oldsize) {
 
903
                /*
 
904
                 * The eCryptfs inode and the new *lower* size are mixed here
 
905
                 * because we may not have the lower i_mutex held and/or it may
 
906
                 * not be appropriate to call inode_newsize_ok() with inodes
 
907
                 * from other filesystems.
 
908
                 */
 
909
                return inode_newsize_ok(inode, lower_newsize);
 
910
        }
 
911
 
 
912
        return 0;
 
913
}
 
914
 
905
915
/**
906
916
 * ecryptfs_truncate
907
917
 * @dentry: The ecryptfs layer dentry
918
928
        struct iattr lower_ia = { .ia_valid = 0 };
919
929
        int rc;
920
930
 
 
931
        rc = ecryptfs_inode_newsize_ok(dentry->d_inode, new_length);
 
932
        if (rc)
 
933
                return rc;
 
934
 
921
935
        rc = truncate_upper(dentry, &ia, &lower_ia);
922
936
        if (!rc && lower_ia.ia_valid & ATTR_SIZE) {
923
937
                struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
997
1011
                }
998
1012
        }
999
1013
        mutex_unlock(&crypt_stat->cs_mutex);
 
1014
 
 
1015
        rc = inode_change_ok(inode, ia);
 
1016
        if (rc)
 
1017
                goto out;
 
1018
        if (ia->ia_valid & ATTR_SIZE) {
 
1019
                rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size);
 
1020
                if (rc)
 
1021
                        goto out;
 
1022
        }
 
1023
 
1000
1024
        if (S_ISREG(inode->i_mode)) {
1001
1025
                rc = filemap_write_and_wait(inode->i_mapping);
1002
1026
                if (rc)