提交 721435a7 编写于 作者: A Al Viro

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: NAl Viro <viro@zeniv.linux.org.uk>
上级 177848a0
...@@ -338,8 +338,7 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment, ...@@ -338,8 +338,7 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
* ufs_inode_getblock() - allocate new block * ufs_inode_getblock() - allocate new block
* @inode: pointer to inode * @inode: pointer to inode
* @bh: pointer to block which hold "pointer" to new allocated block * @bh: pointer to block which hold "pointer" to new allocated block
* @fragment: number of `fragment' which hold pointer * @index: number of pointer in the indirect block
* to new allocated block
* @new_fragment: number of new allocated fragment * @new_fragment: number of new allocated fragment
* (block will hold this fragment and also uspi->s_fpb-1) * (block will hold this fragment and also uspi->s_fpb-1)
* @err: see ufs_inode_getfrag() * @err: see ufs_inode_getfrag()
...@@ -349,20 +348,14 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment, ...@@ -349,20 +348,14 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
*/ */
static u64 static u64
ufs_inode_getblock(struct inode *inode, struct buffer_head *bh, 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) long *phys, int *new, struct page *locked_page)
{ {
struct super_block *sb = inode->i_sb; struct super_block *sb = inode->i_sb;
struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
u64 tmp = 0, goal, block; u64 tmp = 0, goal;
void *p; 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) if (!bh)
goto out; goto out;
if (!buffer_uptodate(bh)) { if (!buffer_uptodate(bh)) {
...@@ -372,17 +365,17 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh, ...@@ -372,17 +365,17 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
goto out; goto out;
} }
if (uspi->fs_magic == UFS2_MAGIC) if (uspi->fs_magic == UFS2_MAGIC)
p = (__fs64 *)bh->b_data + block; p = (__fs64 *)bh->b_data + index;
else else
p = (__fs32 *)bh->b_data + block; p = (__fs32 *)bh->b_data + index;
tmp = ufs_data_ptr_to_cpu(sb, p); tmp = ufs_data_ptr_to_cpu(sb, p);
if (tmp) if (tmp)
goto out; goto out;
if (block && (uspi->fs_magic == UFS2_MAGIC ? if (index && (uspi->fs_magic == UFS2_MAGIC ?
(tmp = fs64_to_cpu(sb, ((__fs64 *)bh->b_data)[block-1])) : (tmp = fs64_to_cpu(sb, ((__fs64 *)bh->b_data)[index-1])) :
(tmp = fs32_to_cpu(sb, ((__fs32 *)bh->b_data)[block-1])))) (tmp = fs32_to_cpu(sb, ((__fs32 *)bh->b_data)[index-1]))))
goal = tmp + uspi->s_fpb; goal = tmp + uspi->s_fpb;
else else
goal = bh->b_blocknr + uspi->s_fpb; goal = bh->b_blocknr + uspi->s_fpb;
...@@ -424,6 +417,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff ...@@ -424,6 +417,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
unsigned long ptr,phys; unsigned long ptr,phys;
u64 phys64 = 0; u64 phys64 = 0;
unsigned frag = fragment & uspi->s_fpbmask; unsigned frag = fragment & uspi->s_fpbmask;
unsigned mask = uspi->s_apbmask >> uspi->s_fpbshift;
if (!create) { if (!create) {
phys64 = ufs_frag_map(inode, offsets, depth); phys64 = ufs_frag_map(inode, offsets, depth);
...@@ -499,7 +493,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff ...@@ -499,7 +493,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
bh = NULL; bh = NULL;
} }
phys64 = ufs_inode_getblock(inode, bh, phys64 = ufs_inode_getblock(inode, bh,
(ptr >> uspi->s_2apbshift) & uspi->s_apbmask, offsets[1] & mask,
fragment, &err, NULL, NULL, NULL); fragment, &err, NULL, NULL, NULL);
if (phys64) { if (phys64) {
phys64 += (ptr >> uspi->s_2apbshift) & uspi->s_fpbmask, 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 ...@@ -509,7 +503,7 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
} }
get_double: get_double:
phys64 = ufs_inode_getblock(inode, bh, phys64 = ufs_inode_getblock(inode, bh,
(ptr >> uspi->s_apbshift) & uspi->s_apbmask, offsets[depth - 2] & mask,
fragment, &err, NULL, NULL, NULL); fragment, &err, NULL, NULL, NULL);
if (phys64) { if (phys64) {
phys64 += (ptr >> uspi->s_apbshift) & uspi->s_fpbmask, phys64 += (ptr >> uspi->s_apbshift) & uspi->s_fpbmask,
...@@ -518,8 +512,8 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff ...@@ -518,8 +512,8 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
bh = NULL; bh = NULL;
} }
get_indirect: get_indirect:
phys64 = ufs_inode_getblock(inode, bh, ptr & uspi->s_apbmask, fragment, phys64 = ufs_inode_getblock(inode, bh, offsets[depth - 1] & mask,
&err, &phys, &new, bh_result->b_page); fragment, &err, &phys, &new, bh_result->b_page);
if (phys64) { if (phys64) {
phys64 += frag; phys64 += frag;
phys = phys64; phys = phys64;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册