Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 31cd043e authored by Al Viro's avatar Al Viro
Browse files

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: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 4e3911f3
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -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);
	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));
	case 3:
		ufs_trunc_dindirect(inode, UFS_IND_BLOCK + uspi->s_apb,
			    ufs_get_direct_data_ptr(uspi, ufsi, UFS_DIND_BLOCK));
	case 4:
		ufs_trunc_tindirect(inode);
	}
	ufsi->i_lastfrag = DIRECT_FRAGMENT;
	mutex_unlock(&ufsi->truncate_mutex);
}