]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ufs: move calculation of offsets into ufs_getfrag_block()
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 4 Jun 2015 18:27:23 +0000 (14:27 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 6 Jul 2015 21:39:53 +0000 (17:39 -0400)
... and massage ufs_frag_map() to take those instead of fragment number.

As it is, we duplicate the damn thing on the write side, open-coded and
bloody hard to follow.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/ufs/inode.c

index 95cb0a8f5ec921459e005bf3346a0743ffd7a709..0f0c6dfccd105f80da6acde53476611f6ceda44d 100644 (file)
@@ -119,20 +119,18 @@ static inline int grow_chain64(struct ufs_inode_info *ufsi,
  * the beginning of the filesystem.
  */
 
-static u64 ufs_frag_map(struct inode *inode, sector_t frag)
+static u64 ufs_frag_map(struct inode *inode, unsigned offsets[4], int depth)
 {
        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;
        u64 mask = (u64) uspi->s_apbmask>>uspi->s_fpbshift;
        int shift = uspi->s_apbshift-uspi->s_fpbshift;
-       unsigned offsets[4], *p;
        Indirect chain[4], *q = chain;
-       int depth = ufs_block_to_path(inode, frag >> uspi->s_fpbshift, offsets);
+       unsigned *p;
        unsigned flags = UFS_SB(sb)->s_flags;
        u64 res = 0;
 
-       UFSD(": frag = %llu  depth = %d\n", (unsigned long long)frag, depth);
        UFSD(": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n",
                uspi->s_fpbshift, uspi->s_apbmask,
                (unsigned long long)mask);
@@ -191,7 +189,7 @@ ufs2:
        }
        res = fs64_to_cpu(sb, q->key64);
 found:
-       res += uspi->s_sbbase + (frag & uspi->s_fpbmask);
+       res += uspi->s_sbbase;
 no_block:
        while (q > chain) {
                brelse(q->bh);
@@ -443,14 +441,17 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
        struct ufs_sb_private_info * uspi = sbi->s_uspi;
        struct buffer_head * bh;
        int ret, err, new;
+       unsigned offsets[4];
+       int depth = ufs_block_to_path(inode, fragment >> uspi->s_fpbshift, offsets);
        unsigned long ptr,phys;
        u64 phys64 = 0;
 
        if (!create) {
-               phys64 = ufs_frag_map(inode, fragment);
-               UFSD("phys64 = %llu\n", (unsigned long long)phys64);
-               if (phys64)
+               phys64 = ufs_frag_map(inode, offsets, depth);
+               if (phys64) {
+                       phys64 += fragment & uspi->s_fpbmask;
                        map_bh(bh_result, sb, phys64);
+               }
                return 0;
        }