diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-06-18 15:47:17 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-07-06 17:39:41 -0400 |
commit | 42432739b5902f72011f701f5cd5b4227ebe991c (patch) | |
tree | 885f27b11eb8bf25056a50d15b5fd26c23be2273 /fs/ufs | |
parent | ef3a315d4ca179fd0b56597e695cd262a8b559b7 (diff) |
__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>
Diffstat (limited to 'fs/ufs')
-rw-r--r-- | fs/ufs/inode.c | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index 1427d277a690..285eacd02d60 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c | |||
@@ -1222,6 +1222,7 @@ static void __ufs_truncate_blocks(struct inode *inode) | |||
1222 | unsigned offsets[4]; | 1222 | unsigned offsets[4]; |
1223 | int depth = ufs_block_to_path(inode, DIRECT_BLOCK, offsets); | 1223 | int depth = ufs_block_to_path(inode, DIRECT_BLOCK, offsets); |
1224 | int depth2; | 1224 | int depth2; |
1225 | unsigned i; | ||
1225 | 1226 | ||
1226 | if (!depth) | 1227 | if (!depth) |
1227 | return; | 1228 | return; |
@@ -1232,33 +1233,17 @@ static void __ufs_truncate_blocks(struct inode *inode) | |||
1232 | break; | 1233 | break; |
1233 | 1234 | ||
1234 | mutex_lock(&ufsi->truncate_mutex); | 1235 | mutex_lock(&ufsi->truncate_mutex); |
1235 | switch (depth) { | 1236 | if (depth == 1) { |
1236 | case 1: | ||
1237 | ufs_trunc_direct(inode); | 1237 | ufs_trunc_direct(inode); |
1238 | goto l1; | 1238 | offsets[0] = UFS_IND_BLOCK; |
1239 | case 2: | 1239 | } else { |
1240 | ufs_trunc_branch(inode, offsets + 1, depth2, 1, | 1240 | ufs_trunc_branch(inode, offsets + 1, depth2, depth - 1, |
1241 | ufs_get_direct_data_ptr(uspi, ufsi, UFS_IND_BLOCK)); | 1241 | ufs_get_direct_data_ptr(uspi, ufsi, offsets[0]++)); |
1242 | goto l2; | 1242 | } |
1243 | case 3: | 1243 | for (i = offsets[0]; i <= UFS_TIND_BLOCK; i++) { |
1244 | ufs_trunc_branch(inode, offsets + 1, depth2, 2, | 1244 | ufs_trunc_branch(inode, NULL, 0, i - UFS_IND_BLOCK + 1, |
1245 | ufs_get_direct_data_ptr(uspi, ufsi, UFS_DIND_BLOCK)); | 1245 | ufs_get_direct_data_ptr(uspi, ufsi, i)); |
1246 | goto l3; | ||
1247 | case 4: | ||
1248 | ufs_trunc_branch(inode, offsets + 1, depth2, 3, | ||
1249 | ufs_get_direct_data_ptr(uspi, ufsi, UFS_TIND_BLOCK)); | ||
1250 | goto l4; | ||
1251 | } | 1246 | } |
1252 | l1: | ||
1253 | ufs_trunc_branch(inode, NULL, 0, 1, | ||
1254 | ufs_get_direct_data_ptr(uspi, ufsi, UFS_IND_BLOCK)); | ||
1255 | l2: | ||
1256 | ufs_trunc_branch(inode, NULL, 0, 2, | ||
1257 | ufs_get_direct_data_ptr(uspi, ufsi, UFS_DIND_BLOCK)); | ||
1258 | l3: | ||
1259 | ufs_trunc_branch(inode, NULL, 0, 3, | ||
1260 | ufs_get_direct_data_ptr(uspi, ufsi, UFS_TIND_BLOCK)); | ||
1261 | l4: | ||
1262 | ufsi->i_lastfrag = DIRECT_FRAGMENT; | 1247 | ufsi->i_lastfrag = DIRECT_FRAGMENT; |
1263 | mutex_unlock(&ufsi->truncate_mutex); | 1248 | mutex_unlock(&ufsi->truncate_mutex); |
1264 | } | 1249 | } |