diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2015-06-19 01:06:21 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-07-06 17:39:58 -0400 |
commit | 721435a7679e13f810133dbea769f87ad7bae3a1 (patch) | |
tree | 54dcf11089989e1536cb2bcc612ffccba44c20d7 | |
parent | 177848a018cb2cb196feac2990814ac8d7bb3c8e (diff) |
ufs_inode_getblock(): pass index instead of 'fragment'
The value passed to ufs_inode_getblock() as the 3rd argument
had lower bits ignored; the upper bits were shifted down
and used and they actually make sense - those are _lower_ bits
of index in indirect block (i.e. they form the index within
a fragment within an indirect block).
Pass those as argument. Upper bits of index (i.e. the number
of fragment within indirect block) will join them shortly.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/ufs/inode.c | 32 |
1 files changed, 13 insertions, 19 deletions
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c index eeccf45fcd57..6866b904f148 100644 --- a/fs/ufs/inode.c +++ b/fs/ufs/inode.c @@ -338,8 +338,7 @@ repeat2: * ufs_inode_getblock() - allocate new block * @inode: pointer to inode * @bh: pointer to block which hold "pointer" to new allocated block - * @fragment: number of `fragment' which hold pointer - * to new allocated block + * @index: number of pointer in the indirect block * @new_fragment: number of new allocated fragment * (block will hold this fragment and also uspi->s_fpb-1) * @err: see ufs_inode_getfrag() @@ -349,20 +348,14 @@ repeat2: */ static u64 ufs_inode_getblock(struct inode *inode, struct buffer_head *bh, - u64 fragment, sector_t new_fragment, int *err, + unsigned index, sector_t new_fragment, int *err, long *phys, int *new, struct page *locked_page) { struct super_block *sb = inode->i_sb; struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; - u64 tmp = 0, goal, block; + u64 tmp = 0, goal; void *p; - block = ufs_fragstoblks (fragment); - - UFSD("ENTER, ino %lu, fragment %llu, new_fragment %llu, metadata %d\n", - inode->i_ino, (unsigned long long)fragment, - (unsigned long long)new_fragment, !phys); - if (!bh) goto out; if (!buffer_uptodate(bh)) { @@ -372,17 +365,17 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh, goto out; } if (uspi->fs_magic == UFS2_MAGIC) - p = (__fs64 *)bh->b_data + block; + p = (__fs64 *)bh->b_data + index; else - p = (__fs32 *)bh->b_data + block; + p = (__fs32 *)bh->b_data + index; tmp = ufs_data_ptr_to_cpu(sb, p); if (tmp) goto out; - if (block && (uspi->fs_magic == UFS2_MAGIC ? - (tmp = fs64_to_cpu(sb, ((__fs64 *)bh->b_data)[block-1])) : - (tmp = fs32_to_cpu(sb, ((__fs32 *)bh->b_data)[block-1])))) + if (index && (uspi->fs_magic == UFS2_MAGIC ? + (tmp = fs64_to_cpu(sb, ((__fs64 *)bh->b_data)[index-1])) : + (tmp = fs32_to_cpu(sb, ((__fs32 *)bh->b_data)[index-1])))) goal = tmp + uspi->s_fpb; else goal = bh->b_blocknr + uspi->s_fpb; @@ -424,6 +417,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff unsigned long ptr,phys; u64 phys64 = 0; unsigned frag = fragment & uspi->s_fpbmask; + unsigned mask = uspi->s_apbmask >> uspi->s_fpbshift; if (!create) { phys64 = ufs_frag_map(inode, offsets, depth); @@ -499,7 +493,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff bh = NULL; } phys64 = ufs_inode_getblock(inode, bh, - (ptr >> uspi->s_2apbshift) & uspi->s_apbmask, + offsets[1] & mask, fragment, &err, NULL, NULL, NULL); if (phys64) { phys64 += (ptr >> uspi->s_2apbshift) & uspi->s_fpbmask, @@ -509,7 +503,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff } get_double: phys64 = ufs_inode_getblock(inode, bh, - (ptr >> uspi->s_apbshift) & uspi->s_apbmask, + offsets[depth - 2] & mask, fragment, &err, NULL, NULL, NULL); if (phys64) { phys64 += (ptr >> uspi->s_apbshift) & uspi->s_fpbmask, @@ -518,8 +512,8 @@ get_double: bh = NULL; } get_indirect: - phys64 = ufs_inode_getblock(inode, bh, ptr & uspi->s_apbmask, fragment, - &err, &phys, &new, bh_result->b_page); + phys64 = ufs_inode_getblock(inode, bh, offsets[depth - 1] & mask, + fragment, &err, &phys, &new, bh_result->b_page); if (phys64) { phys64 += frag; phys = phys64; |