History

excessive checks in ufs_write_failed() and ufs_evict_inode()

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.

Al Viro committed 9 years ago

Commit babef371 parent 006351a1 file · +5 −13Browse files

Unified · Split

fs/ufs/inode.c+5−13
@@ -844,7 +844,9 @@ void ufs_evict_inode(struct inode * inode) · 843 unmodified lines
844 truncate_inode_pages_final(&inode->i_data);844 truncate_inode_pages_final(&inode->i_data);
845 if (want_delete) {845 if (want_delete) {
846 inode->i_size = 0;846 inode->i_size = 0;
847 if (inode->i_blocks)847 if (inode->i_blocks &&
848 (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
849 S_ISLNK(inode->i_mode)))
848 ufs_truncate_blocks(inode);850 ufs_truncate_blocks(inode);
849 }851 }
850 852
@@ -1103,7 +1105,7 @@ out: · 252 unmodified lines
1103 return err;1105 return err;
1104}1106}
1105 1107
1106static void __ufs_truncate_blocks(struct inode *inode)1108static void ufs_truncate_blocks(struct inode *inode)
1107{1109{
1108 struct ufs_inode_info *ufsi = UFS_I(inode);1110 struct ufs_inode_info *ufsi = UFS_I(inode);
1109 struct super_block *sb = inode->i_sb;1111 struct super_block *sb = inode->i_sb;
@@ -1186,7 +1188,7 @@ static int ufs_truncate(struct inode *inode, loff_t size) · 76 unmodified lines
1186 1188
1187 truncate_setsize(inode, size);1189 truncate_setsize(inode, size);
1188 1190
1189 __ufs_truncate_blocks(inode);1191 ufs_truncate_blocks(inode);
1190 inode->i_mtime = inode->i_ctime = current_time(inode);1192 inode->i_mtime = inode->i_ctime = current_time(inode);
1191 mark_inode_dirty(inode);1193 mark_inode_dirty(inode);
1192out:1194out:
@@ -1194,16 +1196,6 @@ out: · 1 unmodified line
1194 return err;1196 return err;
1195}1197}
1196 1198
1197static void ufs_truncate_blocks(struct inode *inode)
1198{
1199 if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
1200 S_ISLNK(inode->i_mode)))
1201 return;
1202 if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
1203 return;
1204 __ufs_truncate_blocks(inode);
1205}
1206
1207int ufs_setattr(struct dentry *dentry, struct iattr *attr)1199int ufs_setattr(struct dentry *dentry, struct iattr *attr)
1208{1200{
1209 struct inode *inode = d_inode(dentry);1201 struct inode *inode = d_inode(dentry);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t