ufs: move lock_ufs() down into __ufs_truncate_blocks()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
2401aa29ab
commit
493b4537a2
@ -447,6 +447,7 @@ static void __ufs_truncate_blocks(struct inode *inode)
|
|||||||
struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
|
struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
|
||||||
int retry;
|
int retry;
|
||||||
|
|
||||||
|
lock_ufs(sb);
|
||||||
while (1) {
|
while (1) {
|
||||||
retry = ufs_trunc_direct(inode);
|
retry = ufs_trunc_direct(inode);
|
||||||
retry |= ufs_trunc_indirect(inode, UFS_IND_BLOCK,
|
retry |= ufs_trunc_indirect(inode, UFS_IND_BLOCK,
|
||||||
@ -464,11 +465,11 @@ static void __ufs_truncate_blocks(struct inode *inode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ufsi->i_lastfrag = DIRECT_FRAGMENT;
|
ufsi->i_lastfrag = DIRECT_FRAGMENT;
|
||||||
|
unlock_ufs(sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ufs_truncate(struct inode *inode, loff_t size)
|
int ufs_truncate(struct inode *inode, loff_t size)
|
||||||
{
|
{
|
||||||
struct super_block *sb = inode->i_sb;
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
UFSD("ENTER: ino %lu, i_size: %llu, old_i_size: %llu\n",
|
UFSD("ENTER: ino %lu, i_size: %llu, old_i_size: %llu\n",
|
||||||
@ -481,7 +482,6 @@ int ufs_truncate(struct inode *inode, loff_t size)
|
|||||||
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
|
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
lock_ufs(sb);
|
|
||||||
err = ufs_alloc_lastblock(inode, size);
|
err = ufs_alloc_lastblock(inode, size);
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
@ -495,23 +495,18 @@ int ufs_truncate(struct inode *inode, loff_t size)
|
|||||||
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
|
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
out:
|
out:
|
||||||
unlock_ufs(sb);
|
|
||||||
UFSD("EXIT: err %d\n", err);
|
UFSD("EXIT: err %d\n", err);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ufs_truncate_blocks(struct inode *inode)
|
void ufs_truncate_blocks(struct inode *inode)
|
||||||
{
|
{
|
||||||
struct super_block *sb = inode->i_sb;
|
|
||||||
if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
|
if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
|
||||||
S_ISLNK(inode->i_mode)))
|
S_ISLNK(inode->i_mode)))
|
||||||
return;
|
return;
|
||||||
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
|
if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
lock_ufs(sb);
|
|
||||||
__ufs_truncate_blocks(inode);
|
__ufs_truncate_blocks(inode);
|
||||||
unlock_ufs(sb);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ufs_setattr(struct dentry *dentry, struct iattr *attr)
|
int ufs_setattr(struct dentry *dentry, struct iattr *attr)
|
||||||
|
Loading…
Reference in New Issue
Block a user