__ufs_truncate(); find cutoff distances into branches by offsets[] array
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 18 Jun 2015 18:28:54 +0000 (14:28 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 6 Jul 2015 21:39:36 +0000 (17:39 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ufs/inode.c

index b4d6398a2d540a42207839b274fcac5ff4011176..c2544d62adf20e8608139453985dfb59c729e2c8 100644 (file)
@@ -1324,12 +1324,16 @@ static void __ufs_truncate_blocks(struct inode *inode)
                ufs_trunc_tindirect(inode, 0);
                break;
        case 3:
-               ufs_trunc_dindirect(inode, DIRECT_BLOCK - UFS_IND_BLOCK - uspi->s_apb,
+               ufs_trunc_dindirect(inode,
+                           (offsets[1] << uspi->s_apbshift) + offsets[2],
                            ufs_get_direct_data_ptr(uspi, ufsi, UFS_DIND_BLOCK));
                ufs_trunc_tindirect(inode, 0);
                break;
        case 4:
-               ufs_trunc_tindirect(inode, DIRECT_BLOCK - UFS_NDADDR - uspi->s_apb - uspi->s_2apb);
+               ufs_trunc_tindirect(inode,
+                          (offsets[1] << uspi->s_2apbshift) +
+                          (offsets[2] << uspi->s_apbshift) +
+                          offsets[3]);
        }
        ufsi->i_lastfrag = DIRECT_FRAGMENT;
        mutex_unlock(&ufsi->truncate_mutex);