summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-06-17 01:10:03 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2015-07-06 17:39:32 -0400
commit31cd043e1a09c579c4cd38ea432200fbeae6af1f (patch)
tree8f0217ce551152f0189f064821f43bf269fe725e
parent4e3911f3d704d681477cdb4e1a2bfd52d5e42d23 (diff)
downloadlinux-31cd043e1a09c579c4cd38ea432200fbeae6af1f.tar.bz2
ufs: beginning of __ufs_truncate_block() massage
Use ufs_block_to_path() to find the cutoff path in the block pointers' tree. For now just use the information about the depth (to bypass the fully preserved subtrees); subsequent commits will use the information about actual path. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/ufs/inode.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 43672183fee3..afb0f32b921c 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -1336,14 +1336,22 @@ 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;
+ unsigned offsets[4];
+ int depth = ufs_block_to_path(inode, DIRECT_BLOCK, offsets);
mutex_lock(&ufsi->truncate_mutex);
- ufs_trunc_direct(inode);
- ufs_trunc_indirect(inode, UFS_IND_BLOCK,
+ switch (depth) {
+ case 1:
+ ufs_trunc_direct(inode);
+ case 2:
+ ufs_trunc_indirect(inode, UFS_IND_BLOCK,
ufs_get_direct_data_ptr(uspi, ufsi, UFS_IND_BLOCK));
- ufs_trunc_dindirect(inode, UFS_IND_BLOCK + uspi->s_apb,
+ case 3:
+ ufs_trunc_dindirect(inode, UFS_IND_BLOCK + uspi->s_apb,
ufs_get_direct_data_ptr(uspi, ufsi, UFS_DIND_BLOCK));
- ufs_trunc_tindirect(inode);
+ case 4:
+ ufs_trunc_tindirect(inode);
+ }
ufsi->i_lastfrag = DIRECT_FRAGMENT;
mutex_unlock(&ufsi->truncate_mutex);
}