ufs_inode_get{frag,block}(): consolidate success exits

These calling conventions are rudiments of pre-2.3 times; they
really need to be sanitized.  This is the first step; next
will be _always_ returning a block number, instead of this
"return a pointer to buffer_head, except when we get to the
actual data" crap.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2015-06-19 00:10:00 -04:00
parent 71dd42846f
commit bbb3eb9d34
1 changed files with 22 additions and 28 deletions

View File

@ -226,7 +226,6 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
struct ufs_inode_info *ufsi = UFS_I(inode); struct ufs_inode_info *ufsi = UFS_I(inode);
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, lastblockoff; unsigned blockoff, lastblockoff;
u64 tmp, goal, lastfrag, block, lastblock; u64 tmp, goal, lastfrag, block, lastblock;
void *p, *p2; void *p, *p2;
@ -249,14 +248,8 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
tmp = ufs_data_ptr_to_cpu(sb, p); tmp = ufs_data_ptr_to_cpu(sb, p);
lastfrag = ufsi->i_lastfrag; lastfrag = ufsi->i_lastfrag;
if (tmp && fragment < lastfrag) { if (tmp && fragment < lastfrag)
if (!phys) { goto out;
return sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
} else {
*phys = uspi->s_sbbase + tmp + blockoff;
return NULL;
}
}
lastblock = ufs_fragstoblks (lastfrag); lastblock = ufs_fragstoblks (lastfrag);
lastblockoff = ufs_fragnum (lastfrag); lastblockoff = ufs_fragnum (lastfrag);
@ -314,20 +307,22 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
return NULL; return NULL;
} }
if (!phys) { if (phys) {
result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
} else {
*phys = uspi->s_sbbase + tmp + blockoff;
result = NULL;
*err = 0; *err = 0;
*new = 1; *new = 1;
} }
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
if (IS_SYNC(inode)) if (IS_SYNC(inode))
ufs_sync_inode (inode); ufs_sync_inode (inode);
mark_inode_dirty(inode); mark_inode_dirty(inode);
return result; out:
tmp += uspi->s_sbbase + blockoff;
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.
@ -367,7 +362,7 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
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; struct buffer_head * result;
unsigned blockoff; unsigned blockoff;
u64 tmp, goal, block; u64 tmp = 0, goal, block;
void *p; void *p;
block = ufs_fragstoblks (fragment); block = ufs_fragstoblks (fragment);
@ -392,13 +387,8 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
p = (__fs32 *)bh->b_data + block; p = (__fs32 *)bh->b_data + block;
tmp = ufs_data_ptr_to_cpu(sb, p); tmp = ufs_data_ptr_to_cpu(sb, p);
if (tmp) { if (tmp)
if (!phys)
result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
else
*phys = uspi->s_sbbase + tmp + blockoff;
goto out; goto out;
}
if (block && (uspi->fs_magic == UFS2_MAGIC ? if (block && (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)[block-1])) :
@ -411,12 +401,8 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
if (!tmp) if (!tmp)
goto out; goto out;
if (!phys) { if (new)
result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
} else {
*phys = uspi->s_sbbase + tmp + blockoff;
*new = 1; *new = 1;
}
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
if (IS_SYNC(inode)) if (IS_SYNC(inode))
@ -425,6 +411,14 @@ 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; return result;
} }