From: Michael Halcrow The filesize for both the source and destination is getting set to the lower filesize on hard link creation. This patch saves and restores the filesize so it is correct after the link operation is complete. It also removes some extraneous initialization in ecryptfs_read_header_region(). Signed-off-by: Michael Halcrow Signed-off-by: Andrew Morton --- fs/ecryptfs/crypto.c | 6 +++--- fs/ecryptfs/inode.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff -puN fs/ecryptfs/crypto.c~ecryptfs-crypto-functions-fix-filesize-on-hard-link-creation fs/ecryptfs/crypto.c --- a/fs/ecryptfs/crypto.c~ecryptfs-crypto-functions-fix-filesize-on-hard-link-creation +++ a/fs/ecryptfs/crypto.c @@ -1080,10 +1080,10 @@ int ecryptfs_cipher_code_to_string(char int ecryptfs_read_header_region(char *data, struct dentry *dentry, struct nameidata *nd) { - int rc = 0; - struct vfsmount *mnt = NULL; - struct file *file = NULL; + struct vfsmount *mnt; + struct file *file; mm_segment_t oldfs; + int rc; mnt = mntget(nd->mnt); file = dentry_open(dentry, mnt, O_RDONLY); diff -puN fs/ecryptfs/inode.c~ecryptfs-crypto-functions-fix-filesize-on-hard-link-creation fs/ecryptfs/inode.c --- a/fs/ecryptfs/inode.c~ecryptfs-crypto-functions-fix-filesize-on-hard-link-creation +++ a/fs/ecryptfs/inode.c @@ -477,11 +477,13 @@ out: static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *new_dentry) { - int rc; struct dentry *lower_old_dentry; struct dentry *lower_new_dentry; struct dentry *lower_dir_dentry; + u64 file_size_save; + int rc; + file_size_save = i_size_read(old_dentry->d_inode); lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry); lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry); dget(lower_old_dentry); @@ -497,6 +499,7 @@ static int ecryptfs_link(struct dentry * ecryptfs_copy_attr_timesizes(dir, lower_new_dentry->d_inode); old_dentry->d_inode->i_nlink = ecryptfs_inode_to_lower(old_dentry->d_inode)->i_nlink; + i_size_write(new_dentry->d_inode, file_size_save); out_lock: unlock_dir(lower_dir_dentry); dput(lower_new_dentry); _