Commit f6cf89fc authored by Al Viro's avatar Al Viro Committed by Ben Hutchings

excessive checks in ufs_write_failed() and ufs_evict_inode()

commit babef37d upstream.

As it is, short copy in write() to append-only file will fail
to truncate the excessive allocated blocks.  As the matter of
fact, all checks in ufs_truncate_blocks() are either redundant
or wrong for that caller.  As for the only other caller
(ufs_evict_inode()), we only need the file type checks there.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
[bwh: Backported to 3.16:
 - No functions need to be renamed
 - Adjust filenames, context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent bc5d4a86
...@@ -894,7 +894,10 @@ void ufs_evict_inode(struct inode * inode) ...@@ -894,7 +894,10 @@ void ufs_evict_inode(struct inode * inode)
ufs_update_inode(inode, IS_SYNC(inode)); ufs_update_inode(inode, IS_SYNC(inode));
old_i_size = inode->i_size; old_i_size = inode->i_size;
inode->i_size = 0; inode->i_size = 0;
if (inode->i_blocks && ufs_truncate(inode, old_i_size)) if (inode->i_blocks &&
(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
S_ISLNK(inode->i_mode)) &&
ufs_truncate(inode, old_i_size))
ufs_warning(inode->i_sb, __func__, "ufs_truncate failed\n"); ufs_warning(inode->i_sb, __func__, "ufs_truncate failed\n");
unlock_ufs(inode->i_sb); unlock_ufs(inode->i_sb);
} }
......
...@@ -451,12 +451,6 @@ int ufs_truncate(struct inode *inode, loff_t old_i_size) ...@@ -451,12 +451,6 @@ int ufs_truncate(struct inode *inode, loff_t old_i_size)
inode->i_ino, (unsigned long long)i_size_read(inode), inode->i_ino, (unsigned long long)i_size_read(inode),
(unsigned long long)old_i_size); (unsigned long long)old_i_size);
if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
S_ISLNK(inode->i_mode)))
return -EINVAL;
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
return -EPERM;
err = ufs_alloc_lastblock(inode); err = ufs_alloc_lastblock(inode);
if (err) { if (err) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment