ufs_inode_getblock(): pass indirect block number and full index
... instead of messing with buffer_head. We can bloody well do sb_bread() in there. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
721435a767
commit
619cfac091
@ -337,8 +337,8 @@ repeat2:
|
|||||||
/**
|
/**
|
||||||
* 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
|
* @ind_block: block number of the indirect block
|
||||||
* @index: number of pointer in the indirect block
|
* @index: number of pointer within the indirect 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()
|
||||||
@ -347,23 +347,25 @@ repeat2:
|
|||||||
* @locked_page: see ufs_inode_getfrag()
|
* @locked_page: see ufs_inode_getfrag()
|
||||||
*/
|
*/
|
||||||
static u64
|
static u64
|
||||||
ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
|
ufs_inode_getblock(struct inode *inode, u64 ind_block,
|
||||||
unsigned index, 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;
|
||||||
|
int shift = uspi->s_apbshift - uspi->s_fpbshift;
|
||||||
u64 tmp = 0, goal;
|
u64 tmp = 0, goal;
|
||||||
|
struct buffer_head *bh;
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
if (!bh)
|
if (!ind_block)
|
||||||
goto out;
|
return 0;
|
||||||
if (!buffer_uptodate(bh)) {
|
|
||||||
ll_rw_block (READ, 1, &bh);
|
bh = sb_bread(sb, ind_block + (index >> shift));
|
||||||
wait_on_buffer (bh);
|
if (unlikely(!bh))
|
||||||
if (!buffer_uptodate(bh))
|
return 0;
|
||||||
goto out;
|
|
||||||
}
|
index &= uspi->s_apbmask >> uspi->s_fpbshift;
|
||||||
if (uspi->fs_magic == UFS2_MAGIC)
|
if (uspi->fs_magic == UFS2_MAGIC)
|
||||||
p = (__fs64 *)bh->b_data + index;
|
p = (__fs64 *)bh->b_data + index;
|
||||||
else
|
else
|
||||||
@ -459,12 +461,6 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
|
|||||||
UFS_IND_FRAGMENT + (ptr >> uspi->s_apbshift),
|
UFS_IND_FRAGMENT + (ptr >> uspi->s_apbshift),
|
||||||
fragment, uspi->s_fpb, &err, NULL, NULL,
|
fragment, uspi->s_fpb, &err, NULL, NULL,
|
||||||
bh_result->b_page);
|
bh_result->b_page);
|
||||||
if (phys64) {
|
|
||||||
phys64 += (ptr >> uspi->s_apbshift) & uspi->s_fpbmask;
|
|
||||||
bh = sb_getblk(sb, phys64);
|
|
||||||
} else {
|
|
||||||
bh = NULL;
|
|
||||||
}
|
|
||||||
goto get_indirect;
|
goto get_indirect;
|
||||||
}
|
}
|
||||||
ptr -= 1 << (uspi->s_apbshift + uspi->s_fpbshift);
|
ptr -= 1 << (uspi->s_apbshift + uspi->s_fpbshift);
|
||||||
@ -473,12 +469,6 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
|
|||||||
UFS_DIND_FRAGMENT + (ptr >> uspi->s_2apbshift),
|
UFS_DIND_FRAGMENT + (ptr >> uspi->s_2apbshift),
|
||||||
fragment, uspi->s_fpb, &err, NULL, NULL,
|
fragment, uspi->s_fpb, &err, NULL, NULL,
|
||||||
bh_result->b_page);
|
bh_result->b_page);
|
||||||
if (phys64) {
|
|
||||||
phys64 += (ptr >> uspi->s_2apbshift) & uspi->s_fpbmask;
|
|
||||||
bh = sb_getblk(sb, phys64);
|
|
||||||
} else {
|
|
||||||
bh = NULL;
|
|
||||||
}
|
|
||||||
goto get_double;
|
goto get_double;
|
||||||
}
|
}
|
||||||
ptr -= 1 << (uspi->s_2apbshift + uspi->s_fpbshift);
|
ptr -= 1 << (uspi->s_2apbshift + uspi->s_fpbshift);
|
||||||
@ -486,33 +476,13 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
|
|||||||
UFS_TIND_FRAGMENT + (ptr >> uspi->s_3apbshift),
|
UFS_TIND_FRAGMENT + (ptr >> uspi->s_3apbshift),
|
||||||
fragment, uspi->s_fpb, &err, NULL, NULL,
|
fragment, uspi->s_fpb, &err, NULL, NULL,
|
||||||
bh_result->b_page);
|
bh_result->b_page);
|
||||||
if (phys64) {
|
phys64 = ufs_inode_getblock(inode, phys64, offsets[1],
|
||||||
phys64 += (ptr >> uspi->s_3apbshift) & uspi->s_fpbmask;
|
|
||||||
bh = sb_getblk(sb, phys64);
|
|
||||||
} else {
|
|
||||||
bh = NULL;
|
|
||||||
}
|
|
||||||
phys64 = ufs_inode_getblock(inode, bh,
|
|
||||||
offsets[1] & mask,
|
|
||||||
fragment, &err, NULL, NULL, NULL);
|
fragment, &err, NULL, NULL, NULL);
|
||||||
if (phys64) {
|
|
||||||
phys64 += (ptr >> uspi->s_2apbshift) & uspi->s_fpbmask,
|
|
||||||
bh = sb_getblk(sb, phys64);
|
|
||||||
} else {
|
|
||||||
bh = NULL;
|
|
||||||
}
|
|
||||||
get_double:
|
get_double:
|
||||||
phys64 = ufs_inode_getblock(inode, bh,
|
phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 2],
|
||||||
offsets[depth - 2] & mask,
|
|
||||||
fragment, &err, NULL, NULL, NULL);
|
fragment, &err, NULL, NULL, NULL);
|
||||||
if (phys64) {
|
|
||||||
phys64 += (ptr >> uspi->s_apbshift) & uspi->s_fpbmask,
|
|
||||||
bh = sb_getblk(sb, phys64);
|
|
||||||
} else {
|
|
||||||
bh = NULL;
|
|
||||||
}
|
|
||||||
get_indirect:
|
get_indirect:
|
||||||
phys64 = ufs_inode_getblock(inode, bh, offsets[depth - 1] & mask,
|
phys64 = ufs_inode_getblock(inode, phys64, offsets[depth - 1],
|
||||||
fragment, &err, &phys, &new, bh_result->b_page);
|
fragment, &err, &phys, &new, bh_result->b_page);
|
||||||
if (phys64) {
|
if (phys64) {
|
||||||
phys64 += frag;
|
phys64 += frag;
|
||||||
|
Loading…
Reference in New Issue
Block a user