ufs_getfrag_block(): turn following indirects into a loop
authorAl Viro <viro@zeniv.linux.org.uk>
Fri, 19 Jun 2015 18:08:16 +0000 (14:08 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 6 Jul 2015 21:40:02 +0000 (17:40 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ufs/inode.c

index c05cf14ef8ff47df47a0305bf5ae5012c0df2bed..f2d8cc2166afeccf1c3390d85119929643d0b9e5 100644 (file)
@@ -444,37 +444,21 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
        if (depth == 1) {
                phys64 = ufs_inode_getfrag(inode, offsets[0], fragment,
                                           &err, &phys, &new, bh_result->b_page);
-               if (phys64) {
-                       phys64 += frag;
-                       phys = phys64;
-               }
-               goto out;
-       }
-       if (depth == 2) {
-               phys64 = ufs_inode_getfrag(inode, offsets[0], fragment,
-                                          &err, NULL, NULL, bh_result->b_page);
-               goto get_indirect;
-       }
-       if (depth == 3) {
+       } else {
+               int i;
                phys64 = ufs_inode_getfrag(inode, offsets[0], fragment,
                                           &err, NULL, NULL, bh_result->b_page);
-               goto get_double;
+               for (i = 1; i < depth - 1; i++)
+                       phys64 = ufs_inode_getblock(inode, phys64, offsets[i],
+                                               fragment, &err, NULL, NULL, NULL);
+               phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 1],
+                                       fragment, &err, &phys, &new, bh_result->b_page);
        }
-       phys64 = ufs_inode_getfrag(inode, offsets[0], fragment,
-                                  &err, NULL, NULL, bh_result->b_page);
-       phys64 = ufs_inode_getblock(inode, phys64, offsets[1],
-                               fragment, &err, NULL, NULL, NULL);
-get_double:
-       phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 2],
-                               fragment, &err, NULL, NULL, NULL);
-get_indirect:
-       phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 1],
-                               fragment, &err, &phys, &new, bh_result->b_page);
+out:
        if (phys64) {
                phys64 += frag;
                phys = phys64;
        }
-out:
        if (err)
                goto abort;
        if (new)