mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-07 14:32:23 +00:00
__ufs_trunc_blocks(): turn the part after switch into a loop
... and turn the switch into if (), since all cases with depth != 1 have just become identical. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
ef3a315d4c
commit
42432739b5
@ -1222,6 +1222,7 @@ static void __ufs_truncate_blocks(struct inode *inode)
|
|||||||
unsigned offsets[4];
|
unsigned offsets[4];
|
||||||
int depth = ufs_block_to_path(inode, DIRECT_BLOCK, offsets);
|
int depth = ufs_block_to_path(inode, DIRECT_BLOCK, offsets);
|
||||||
int depth2;
|
int depth2;
|
||||||
|
unsigned i;
|
||||||
|
|
||||||
if (!depth)
|
if (!depth)
|
||||||
return;
|
return;
|
||||||
@ -1232,33 +1233,17 @@ static void __ufs_truncate_blocks(struct inode *inode)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
mutex_lock(&ufsi->truncate_mutex);
|
mutex_lock(&ufsi->truncate_mutex);
|
||||||
switch (depth) {
|
if (depth == 1) {
|
||||||
case 1:
|
|
||||||
ufs_trunc_direct(inode);
|
ufs_trunc_direct(inode);
|
||||||
goto l1;
|
offsets[0] = UFS_IND_BLOCK;
|
||||||
case 2:
|
} else {
|
||||||
ufs_trunc_branch(inode, offsets + 1, depth2, 1,
|
ufs_trunc_branch(inode, offsets + 1, depth2, depth - 1,
|
||||||
ufs_get_direct_data_ptr(uspi, ufsi, UFS_IND_BLOCK));
|
ufs_get_direct_data_ptr(uspi, ufsi, offsets[0]++));
|
||||||
goto l2;
|
}
|
||||||
case 3:
|
for (i = offsets[0]; i <= UFS_TIND_BLOCK; i++) {
|
||||||
ufs_trunc_branch(inode, offsets + 1, depth2, 2,
|
ufs_trunc_branch(inode, NULL, 0, i - UFS_IND_BLOCK + 1,
|
||||||
ufs_get_direct_data_ptr(uspi, ufsi, UFS_DIND_BLOCK));
|
ufs_get_direct_data_ptr(uspi, ufsi, i));
|
||||||
goto l3;
|
|
||||||
case 4:
|
|
||||||
ufs_trunc_branch(inode, offsets + 1, depth2, 3,
|
|
||||||
ufs_get_direct_data_ptr(uspi, ufsi, UFS_TIND_BLOCK));
|
|
||||||
goto l4;
|
|
||||||
}
|
}
|
||||||
l1:
|
|
||||||
ufs_trunc_branch(inode, NULL, 0, 1,
|
|
||||||
ufs_get_direct_data_ptr(uspi, ufsi, UFS_IND_BLOCK));
|
|
||||||
l2:
|
|
||||||
ufs_trunc_branch(inode, NULL, 0, 2,
|
|
||||||
ufs_get_direct_data_ptr(uspi, ufsi, UFS_DIND_BLOCK));
|
|
||||||
l3:
|
|
||||||
ufs_trunc_branch(inode, NULL, 0, 3,
|
|
||||||
ufs_get_direct_data_ptr(uspi, ufsi, UFS_TIND_BLOCK));
|
|
||||||
l4:
|
|
||||||
ufsi->i_lastfrag = DIRECT_FRAGMENT;
|
ufsi->i_lastfrag = DIRECT_FRAGMENT;
|
||||||
mutex_unlock(&ufsi->truncate_mutex);
|
mutex_unlock(&ufsi->truncate_mutex);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user