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
844844 truncate_inode_pages_final(&inode->i_data);
845845 if (want_delete) {
846846 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)))
848850 ufs_truncate_blocks(inode);
849851 }
850852
@@ -1103,7 +1105,7 @@ out: · 252 unmodified lines
11031105 return err;
11041106 }
11051107
1106−static void __ufs_truncate_blocks(struct inode *inode)
1108+static void ufs_truncate_blocks(struct inode *inode)
11071109 {
11081110 struct ufs_inode_info *ufsi = UFS_I(inode);
11091111 struct super_block *sb = inode->i_sb;
@@ -1186,7 +1188,7 @@ static int ufs_truncate(struct inode *inode, loff_t size) · 76 unmodified lines
11861188
11871189 truncate_setsize(inode, size);
11881190
1189− __ufs_truncate_blocks(inode);
1191+ ufs_truncate_blocks(inode);
11901192 inode->i_mtime = inode->i_ctime = current_time(inode);
11911193 mark_inode_dirty(inode);
11921194 out:
@@ -1194,16 +1196,6 @@ out: · 1 unmodified line
11941196 return err;
11951197 }
11961198
1197−static 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−
12071199 int ufs_setattr(struct dentry *dentry, struct iattr *attr)
12081200 {
12091201 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