mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
xfs: cleanup xfs_imap
Reshuffle the code a bit so that the imap_lookup and filling out of the xfs_imap structure aren't duplicated. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
parent
f8e9350fff
commit
41397e7ca8
|
|
@ -2511,43 +2511,37 @@ xfs_imap(
|
|||
* inodes in stale state on disk. Hence we have to do a btree lookup
|
||||
* in all cases where an untrusted inode number is passed.
|
||||
*/
|
||||
if (flags & XFS_IGET_UNTRUSTED) {
|
||||
error = xfs_imap_lookup(pag, tp, agino, agbno,
|
||||
&chunk_agbno, &offset_agbno, flags);
|
||||
if (error)
|
||||
return error;
|
||||
goto out_map;
|
||||
if (!(flags & XFS_IGET_UNTRUSTED)) {
|
||||
/*
|
||||
* If the inode cluster size is the same or smaller than the
|
||||
* blocksize, get to the buffer by simple arithmetics.
|
||||
*/
|
||||
if (M_IGEO(mp)->blocks_per_cluster == 1) {
|
||||
cluster_agbno = agbno;
|
||||
offset = XFS_INO_TO_OFFSET(mp, ino);
|
||||
ASSERT(offset < mp->m_sb.sb_inopblock);
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the inode chunks are aligned, use simple maths to find the
|
||||
* location.
|
||||
*/
|
||||
if (M_IGEO(mp)->inoalign_mask) {
|
||||
offset_agbno = agbno & M_IGEO(mp)->inoalign_mask;
|
||||
chunk_agbno = agbno - offset_agbno;
|
||||
goto out_map;
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise we have to do a btree lookup to find the location.
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
* If the inode cluster size is the same as the blocksize or
|
||||
* smaller we get to the buffer by simple arithmetics.
|
||||
*/
|
||||
if (M_IGEO(mp)->blocks_per_cluster == 1) {
|
||||
offset = XFS_INO_TO_OFFSET(mp, ino);
|
||||
ASSERT(offset < mp->m_sb.sb_inopblock);
|
||||
|
||||
imap->im_blkno = xfs_agbno_to_daddr(pag, agbno);
|
||||
imap->im_len = XFS_FSB_TO_BB(mp, 1);
|
||||
imap->im_boffset = (unsigned short)(offset <<
|
||||
mp->m_sb.sb_inodelog);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If the inode chunks are aligned then use simple maths to
|
||||
* find the location. Otherwise we have to do a btree
|
||||
* lookup to find the location.
|
||||
*/
|
||||
if (M_IGEO(mp)->inoalign_mask) {
|
||||
offset_agbno = agbno & M_IGEO(mp)->inoalign_mask;
|
||||
chunk_agbno = agbno - offset_agbno;
|
||||
} else {
|
||||
error = xfs_imap_lookup(pag, tp, agino, agbno,
|
||||
&chunk_agbno, &offset_agbno, flags);
|
||||
if (error)
|
||||
return error;
|
||||
}
|
||||
error = xfs_imap_lookup(pag, tp, agino, agbno, &chunk_agbno,
|
||||
&offset_agbno, flags);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
out_map:
|
||||
ASSERT(agbno >= chunk_agbno);
|
||||
|
|
@ -2556,7 +2550,7 @@ xfs_imap(
|
|||
M_IGEO(mp)->blocks_per_cluster);
|
||||
offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +
|
||||
XFS_INO_TO_OFFSET(mp, ino);
|
||||
|
||||
out:
|
||||
imap->im_blkno = xfs_agbno_to_daddr(pag, cluster_agbno);
|
||||
imap->im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster);
|
||||
imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user