ufs_inode_get{frag,block}(): get rid of retries

We are holding ->truncate_mutex, so nobody else can alter our
block pointers.  Rechecks/retries were needed back when we
only held BKL there, and had to cope with write_begin/writepage
and writepage/truncate races.  Can't happen anymore...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
Al Viro 2015-06-18 22:39:46 -04:00
parent f53bd1421b
commit 5a39c25562
1 changed files with 8 additions and 35 deletions

View File

@ -248,20 +248,12 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
goal = 0; goal = 0;
repeat:
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) { if (!phys) {
result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); return sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
if (tmp == ufs_data_ptr_to_cpu(sb, p)) {
UFSD("EXIT, result %llu\n",
(unsigned long long)tmp + blockoff);
return result;
}
brelse (result);
goto repeat;
} else { } else {
*phys = uspi->s_sbbase + tmp + blockoff; *phys = uspi->s_sbbase + tmp + blockoff;
return NULL; return NULL;
@ -283,14 +275,9 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
ufs_data_ptr_to_cpu(sb, p2), ufs_data_ptr_to_cpu(sb, p2),
uspi->s_fpb - lastblockoff, uspi->s_fpb - lastblockoff,
err, locked_page); err, locked_page);
if (!tmp) { if (!tmp)
if (lastfrag != ufsi->i_lastfrag) return NULL;
goto repeat;
else
return NULL;
}
lastfrag = ufsi->i_lastfrag; lastfrag = ufsi->i_lastfrag;
} }
tmp = ufs_data_ptr_to_cpu(sb, tmp = ufs_data_ptr_to_cpu(sb,
ufs_get_direct_data_ptr(uspi, ufsi, ufs_get_direct_data_ptr(uspi, ufsi,
@ -325,9 +312,6 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
phys != NULL ? locked_page : NULL); phys != NULL ? locked_page : NULL);
} }
if (!tmp) { if (!tmp) {
if ((!blockoff && ufs_data_ptr_to_cpu(sb, p)) ||
(blockoff && lastfrag != ufsi->i_lastfrag))
goto repeat;
*err = -ENOSPC; *err = -ENOSPC;
return NULL; return NULL;
} }
@ -345,7 +329,6 @@ ufs_inode_getfrag(struct inode *inode, u64 fragment,
if (IS_SYNC(inode)) if (IS_SYNC(inode))
ufs_sync_inode (inode); ufs_sync_inode (inode);
mark_inode_dirty(inode); mark_inode_dirty(inode);
UFSD("EXIT, result %llu\n", (unsigned long long)tmp + blockoff);
return result; return result;
/* This part : To be implemented .... /* This part : To be implemented ....
@ -409,19 +392,14 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
p = (__fs64 *)bh->b_data + block; p = (__fs64 *)bh->b_data + block;
else else
p = (__fs32 *)bh->b_data + block; p = (__fs32 *)bh->b_data + block;
repeat:
tmp = ufs_data_ptr_to_cpu(sb, p); tmp = ufs_data_ptr_to_cpu(sb, p);
if (tmp) { if (tmp) {
if (!phys) { if (!phys)
result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
if (tmp == ufs_data_ptr_to_cpu(sb, p)) else
goto out;
brelse (result);
goto repeat;
} else {
*phys = uspi->s_sbbase + tmp + blockoff; *phys = uspi->s_sbbase + tmp + blockoff;
goto out; goto out;
}
} }
if (block && (uspi->fs_magic == UFS2_MAGIC ? if (block && (uspi->fs_magic == UFS2_MAGIC ?
@ -432,12 +410,8 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
goal = bh->b_blocknr + uspi->s_fpb; goal = bh->b_blocknr + uspi->s_fpb;
tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), goal, tmp = ufs_new_fragments(inode, p, ufs_blknum(new_fragment), goal,
uspi->s_fpb, err, locked_page); uspi->s_fpb, err, locked_page);
if (!tmp) { if (!tmp)
if (ufs_data_ptr_to_cpu(sb, p))
goto repeat;
goto out; goto out;
}
if (!phys) { if (!phys) {
result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff); result = sb_getblk(sb, uspi->s_sbbase + tmp + blockoff);
@ -451,7 +425,6 @@ ufs_inode_getblock(struct inode *inode, struct buffer_head *bh,
sync_dirty_buffer(bh); sync_dirty_buffer(bh);
inode->i_ctime = CURRENT_TIME_SEC; inode->i_ctime = CURRENT_TIME_SEC;
mark_inode_dirty(inode); mark_inode_dirty(inode);
UFSD("result %llu\n", (unsigned long long)tmp + blockoff);
out: out:
brelse (bh); brelse (bh);
UFSD("EXIT\n"); UFSD("EXIT\n");