ufs_inode_get{frag,block}(): leave sb_getblk() to caller

just return the damn block number

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2015-06-19 00:53:06 -04:00
parent 8d9dcf1436
commit 177848a018
1 changed files with 55 additions and 33 deletions

View File

@ -218,7 +218,7 @@ changed:
* @new: we set it if we allocate new block * @new: we set it if we allocate new block
* @locked_page: for ufs_new_fragments() * @locked_page: for ufs_new_fragments()
*/ */
static struct buffer_head * static u64
ufs_inode_getfrag(struct inode *inode, u64 fragment, ufs_inode_getfrag(struct inode *inode, u64 fragment,
sector_t new_fragment, unsigned int required, int *err, sector_t new_fragment, unsigned int required, int *err,
long *phys, int *new, struct page *locked_page) long *phys, int *new, struct page *locked_page)
@ -267,7 +267,7 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
uspi->s_fpb - lastblockoff, uspi->s_fpb - lastblockoff,
err, locked_page); err, locked_page);
if (!tmp) if (!tmp)
return NULL; return 0;
lastfrag = ufsi->i_lastfrag; lastfrag = ufsi->i_lastfrag;
} }
tmp = ufs_data_ptr_to_cpu(sb, tmp = ufs_data_ptr_to_cpu(sb,
@ -304,7 +304,7 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
} }
if (!tmp) { if (!tmp) {
*err = -ENOSPC; *err = -ENOSPC;
return NULL; return 0;
} }
if (phys) { if (phys) {
@ -316,13 +316,7 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
ufs_sync_inode (inode); ufs_sync_inode (inode);
mark_inode_dirty(inode); mark_inode_dirty(inode);
out: out:
tmp += uspi->s_sbbase + blockoff; return tmp + uspi->s_sbbase;
if (!phys) {
return sb_getblk(sb, tmp);
} else {
*phys = tmp;
return NULL;
}
/* This part : To be implemented .... /* This part : To be implemented ....
Required only for writing, not required for READ-ONLY. Required only for writing, not required for READ-ONLY.
@ -353,26 +347,22 @@ repeat2:
* @new: see ufs_inode_getfrag() * @new: see ufs_inode_getfrag()
* @locked_page: see ufs_inode_getfrag() * @locked_page: see ufs_inode_getfrag()
*/ */
static struct buffer_head * 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, u64 fragment, 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;
struct buffer_head * result;
unsigned blockoff;
u64 tmp = 0, goal, block; u64 tmp = 0, goal, block;
void *p; void *p;
block = ufs_fragstoblks (fragment); block = ufs_fragstoblks (fragment);
blockoff = ufs_fragnum (fragment);
UFSD("ENTER, ino %lu, fragment %llu, new_fragment %llu, metadata %d\n", UFSD("ENTER, ino %lu, fragment %llu, new_fragment %llu, metadata %d\n",
inode->i_ino, (unsigned long long)fragment, inode->i_ino, (unsigned long long)fragment,
(unsigned long long)new_fragment, !phys); (unsigned long long)new_fragment, !phys);
result = NULL;
if (!bh) if (!bh)
goto out; goto out;
if (!buffer_uptodate(bh)) { if (!buffer_uptodate(bh)) {
@ -411,16 +401,10 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
mark_inode_dirty(inode); mark_inode_dirty(inode);
out: out:
brelse (bh); brelse (bh);
if (tmp) {
tmp += uspi->s_sbbase + blockoff;
if (phys) {
*phys = tmp;
} else {
result = sb_getblk(sb, tmp);
}
}
UFSD("EXIT\n"); UFSD("EXIT\n");
return result; if (tmp)
tmp += uspi->s_sbbase;
return tmp;
} }
/** /**
@ -439,11 +423,12 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
int depth = ufs_block_to_path(inode, fragment >> uspi->s_fpbshift, offsets); int depth = ufs_block_to_path(inode, fragment >> uspi->s_fpbshift, offsets);
unsigned long ptr,phys; unsigned long ptr,phys;
u64 phys64 = 0; u64 phys64 = 0;
unsigned frag = fragment & uspi->s_fpbmask;
if (!create) { if (!create) {
phys64 = ufs_frag_map(inode, offsets, depth); phys64 = ufs_frag_map(inode, offsets, depth);
if (phys64) { if (phys64) {
phys64 += fragment & uspi->s_fpbmask; phys64 += frag;
map_bh(bh_result, sb, phys64); map_bh(bh_result, sb, phys64);
} }
return 0; return 0;
@ -466,42 +451,79 @@ static int ufs_getfrag_block(struct inode *inode, sector_t fragment, struct buff
ptr = fragment; ptr = fragment;
if (depth == 1) { if (depth == 1) {
bh = ufs_inode_getfrag(inode, ptr, fragment, 1, &err, &phys, phys64 = ufs_inode_getfrag(inode, ptr, fragment, 1, &err, &phys,
&new, bh_result->b_page); &new, bh_result->b_page);
if (phys64) {
phys64 += frag;
phys = phys64;
}
goto out; goto out;
} }
ptr -= UFS_NDIR_FRAGMENT; ptr -= UFS_NDIR_FRAGMENT;
if (depth == 2) { if (depth == 2) {
bh = ufs_inode_getfrag(inode, phys64 = ufs_inode_getfrag(inode,
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);
if (depth == 3) { if (depth == 3) {
bh = ufs_inode_getfrag(inode, phys64 = ufs_inode_getfrag(inode,
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);
bh = ufs_inode_getfrag(inode, phys64 = ufs_inode_getfrag(inode,
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);
bh = ufs_inode_getblock(inode, bh, if (phys64) {
phys64 += (ptr >> uspi->s_3apbshift) & uspi->s_fpbmask;
bh = sb_getblk(sb, phys64);
} else {
bh = NULL;
}
phys64 = ufs_inode_getblock(inode, bh,
(ptr >> uspi->s_2apbshift) & uspi->s_apbmask, (ptr >> uspi->s_2apbshift) & uspi->s_apbmask,
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:
bh = ufs_inode_getblock(inode, bh, phys64 = ufs_inode_getblock(inode, bh,
(ptr >> uspi->s_apbshift) & uspi->s_apbmask, (ptr >> uspi->s_apbshift) & uspi->s_apbmask,
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:
bh = ufs_inode_getblock(inode, bh, ptr & uspi->s_apbmask, fragment, phys64 = ufs_inode_getblock(inode, bh, ptr & uspi->s_apbmask, fragment,
&err, &phys, &new, bh_result->b_page); &err, &phys, &new, bh_result->b_page);
if (phys64) {
phys64 += frag;
phys = phys64;
}
out: out:
if (err) if (err)
goto abort; goto abort;