summaryrefslogtreecommitdiff
path: root/fs/ufs
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ufs')
-rw-r--r--fs/ufs/inode.c9
-rw-r--r--fs/ufs/truncate.c60
-rw-r--r--fs/ufs/ufs.h2
3 files changed, 44 insertions, 27 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 0e4d88e0e709..282b0ced6272 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -884,14 +884,9 @@ void ufs_evict_inode(struct inode * inode)
truncate_inode_pages_final(&inode->i_data);
if (want_delete) {
- loff_t old_i_size;
- /*UFS_I(inode)->i_dtime = CURRENT_TIME;*/
- mark_inode_dirty(inode);
- ufs_update_inode(inode, IS_SYNC(inode));
- old_i_size = inode->i_size;
inode->i_size = 0;
- if (inode->i_blocks && ufs_truncate(inode, old_i_size))
- ufs_warning(inode->i_sb, __func__, "ufs_truncate failed\n");
+ if (inode->i_blocks)
+ ufs_truncate_blocks(inode);
}
invalidate_inode_buffers(inode);
diff --git a/fs/ufs/truncate.c b/fs/ufs/truncate.c
index 90cf3a76c500..5a2e7082a0ae 100644
--- a/fs/ufs/truncate.c
+++ b/fs/ufs/truncate.c
@@ -440,12 +440,36 @@ out:
return err;
}
-int ufs_truncate(struct inode *inode, loff_t old_i_size)
+static void __ufs_truncate_blocks(struct inode *inode)
{
struct ufs_inode_info *ufsi = UFS_I(inode);
struct super_block *sb = inode->i_sb;
struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
- int retry, err = 0;
+ int retry;
+
+ while (1) {
+ retry = ufs_trunc_direct(inode);
+ retry |= ufs_trunc_indirect(inode, UFS_IND_BLOCK,
+ ufs_get_direct_data_ptr(uspi, ufsi,
+ UFS_IND_BLOCK));
+ retry |= ufs_trunc_dindirect(inode, UFS_IND_BLOCK + uspi->s_apb,
+ ufs_get_direct_data_ptr(uspi, ufsi,
+ UFS_DIND_BLOCK));
+ retry |= ufs_trunc_tindirect (inode);
+ if (!retry)
+ break;
+ if (IS_SYNC(inode) && (inode->i_state & I_DIRTY))
+ ufs_sync_inode (inode);
+ yield();
+ }
+
+ ufsi->i_lastfrag = DIRECT_FRAGMENT;
+}
+
+int ufs_truncate(struct inode *inode, loff_t old_i_size)
+{
+ struct super_block *sb = inode->i_sb;
+ int err = 0;
UFSD("ENTER: ino %lu, i_size: %llu, old_i_size: %llu\n",
inode->i_ino, (unsigned long long)i_size_read(inode),
@@ -467,24 +491,8 @@ int ufs_truncate(struct inode *inode, loff_t old_i_size)
block_truncate_page(inode->i_mapping, inode->i_size, ufs_getfrag_block);
- while (1) {
- retry = ufs_trunc_direct(inode);
- retry |= ufs_trunc_indirect(inode, UFS_IND_BLOCK,
- ufs_get_direct_data_ptr(uspi, ufsi,
- UFS_IND_BLOCK));
- retry |= ufs_trunc_dindirect(inode, UFS_IND_BLOCK + uspi->s_apb,
- ufs_get_direct_data_ptr(uspi, ufsi,
- UFS_DIND_BLOCK));
- retry |= ufs_trunc_tindirect (inode);
- if (!retry)
- break;
- if (IS_SYNC(inode) && (inode->i_state & I_DIRTY))
- ufs_sync_inode (inode);
- yield();
- }
-
+ __ufs_truncate_blocks(inode);
inode->i_mtime = inode->i_ctime = CURRENT_TIME_SEC;
- ufsi->i_lastfrag = DIRECT_FRAGMENT;
mark_inode_dirty(inode);
out:
unlock_ufs(sb);
@@ -492,6 +500,20 @@ out:
return err;
}
+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) ||
+ S_ISLNK(inode->i_mode)))
+ return;
+ if (IS_APPEND(inode) || IS_IMMUTABLE(inode))
+ return;
+
+ lock_ufs(sb);
+ __ufs_truncate_blocks(inode);
+ unlock_ufs(sb);
+}
+
int ufs_setattr(struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 2e31ea2e35a3..43fcab381de1 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -141,7 +141,7 @@ extern const struct inode_operations ufs_fast_symlink_inode_operations;
extern const struct inode_operations ufs_symlink_inode_operations;
/* truncate.c */
-extern int ufs_truncate (struct inode *, loff_t);
+extern void ufs_truncate_blocks(struct inode *);
extern int ufs_setattr(struct dentry *dentry, struct iattr *attr);
static inline struct ufs_sb_info *UFS_SB(struct super_block *sb)