summaryrefslogtreecommitdiff
path: root/fs/ufs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2015-06-04 21:27:23 +0300
committerAl Viro <viro@zeniv.linux.org.uk>2015-07-07 00:39:53 +0300
commit4b7068c8b178401637ef2fb068d6256c97d23f4a (patch)
treec08bd8f7aa0d7a07ef71b636685f496834649fea /fs/ufs
parent5a39c25562aa5eab5a798919855cf41ddeed8b0d (diff)
downloadlinux-4b7068c8b178401637ef2fb068d6256c97d23f4a.tar.xz
ufs: move calculation of offsets into ufs_getfrag_block()
... 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>
Diffstat (limited to 'fs/ufs')
-rw-r--r--fs/ufs/inode.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 95cb0a8f5ec9..0f0c6dfccd10 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -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;
}