diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-06-04 14:27:23 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-07-06 17:39:53 -0400 |
commit | 4b7068c8b178401637ef2fb068d6256c97d23f4a (patch) | |
tree | c08bd8f7aa0d7a07ef71b636685f496834649fea /fs/ufs | |
parent | 5a39c25562aa5eab5a798919855cf41ddeed8b0d (diff) |
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.c | 17 |
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, | |||
119 | * the beginning of the filesystem. | 119 | * the beginning of the filesystem. |
120 | */ | 120 | */ |
121 | 121 | ||
122 | static u64 ufs_frag_map(struct inode *inode, sector_t frag) | 122 | static u64 ufs_frag_map(struct inode *inode, unsigned offsets[4], int depth) |
123 | { | 123 | { |
124 | struct ufs_inode_info *ufsi = UFS_I(inode); | 124 | struct ufs_inode_info *ufsi = UFS_I(inode); |
125 | struct super_block *sb = inode->i_sb; | 125 | struct super_block *sb = inode->i_sb; |
126 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; | 126 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
127 | u64 mask = (u64) uspi->s_apbmask>>uspi->s_fpbshift; | 127 | u64 mask = (u64) uspi->s_apbmask>>uspi->s_fpbshift; |
128 | int shift = uspi->s_apbshift-uspi->s_fpbshift; | 128 | int shift = uspi->s_apbshift-uspi->s_fpbshift; |
129 | unsigned offsets[4], *p; | ||
130 | Indirect chain[4], *q = chain; | 129 | Indirect chain[4], *q = chain; |
131 | int depth = ufs_block_to_path(inode, frag >> uspi->s_fpbshift, offsets); | 130 | unsigned *p; |
132 | unsigned flags = UFS_SB(sb)->s_flags; | 131 | unsigned flags = UFS_SB(sb)->s_flags; |
133 | u64 res = 0; | 132 | u64 res = 0; |
134 | 133 | ||
135 | UFSD(": frag = %llu depth = %d\n", (unsigned long long)frag, depth); | ||
136 | UFSD(": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n", | 134 | UFSD(": uspi->s_fpbshift = %d ,uspi->s_apbmask = %x, mask=%llx\n", |
137 | uspi->s_fpbshift, uspi->s_apbmask, | 135 | uspi->s_fpbshift, uspi->s_apbmask, |
138 | (unsigned long long)mask); | 136 | (unsigned long long)mask); |
@@ -191,7 +189,7 @@ ufs2: | |||
191 | } | 189 | } |
192 | res = fs64_to_cpu(sb, q->key64); | 190 | res = fs64_to_cpu(sb, q->key64); |
193 | found: | 191 | found: |
194 | res += uspi->s_sbbase + (frag & uspi->s_fpbmask); | 192 | res += uspi->s_sbbase; |
195 | no_block: | 193 | no_block: |
196 | while (q > chain) { | 194 | while (q > chain) { |
197 | brelse(q->bh); | 195 | brelse(q->bh); |
@@ -443,14 +441,17 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff | |||
443 | struct ufs_sb_private_info * uspi = sbi->s_uspi; | 441 | struct ufs_sb_private_info * uspi = sbi->s_uspi; |
444 | struct buffer_head * bh; | 442 | struct buffer_head * bh; |
445 | int ret, err, new; | 443 | int ret, err, new; |
444 | unsigned offsets[4]; | ||
445 | int depth = ufs_block_to_path(inode, fragment >> uspi->s_fpbshift, offsets); | ||
446 | unsigned long ptr,phys; | 446 | unsigned long ptr,phys; |
447 | u64 phys64 = 0; | 447 | u64 phys64 = 0; |
448 | 448 | ||
449 | if (!create) { | 449 | if (!create) { |
450 | phys64 = ufs_frag_map(inode, fragment); | 450 | phys64 = ufs_frag_map(inode, offsets, depth); |
451 | UFSD("phys64 = %llu\n", (unsigned long long)phys64); | 451 | if (phys64) { |
452 | if (phys64) | 452 | phys64 += fragment & uspi->s_fpbmask; |
453 | map_bh(bh_result, sb, phys64); | 453 | map_bh(bh_result, sb, phys64); |
454 | } | ||
454 | return 0; | 455 | return 0; |
455 | } | 456 | } |
456 | 457 | ||