mirror of
https://github.com/torvalds/linux.git
synced 2026-05-26 08:02:27 +02:00
xfs: add some rtgroup inode helpers
Create some simple helpers to reduce the amount of typing whenever we access rtgroup inodes. Conversion was done with this spatch and some minor reformatting: @@ expression rtg; @@ - rtg->rtg_inodes[XFS_RTGI_BITMAP] + rtg_bitmap(rtg) @@ expression rtg; @@ - rtg->rtg_inodes[XFS_RTGI_SUMMARY] + rtg_summary(rtg) and the CLI command: $ spatch --sp-file /tmp/moo.cocci --dir fs/xfs/ --use-gitgrep --in-place Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
This commit is contained in:
parent
05290bd5c6
commit
af32541081
|
|
@ -1055,7 +1055,7 @@ xfs_rtfree_extent(
|
|||
xfs_rtxlen_t len) /* length of extent freed */
|
||||
{
|
||||
struct xfs_mount *mp = tp->t_mountp;
|
||||
struct xfs_inode *rbmip = rtg->rtg_inodes[XFS_RTGI_BITMAP];
|
||||
struct xfs_inode *rbmip = rtg_bitmap(rtg);
|
||||
struct xfs_rtalloc_args args = {
|
||||
.mp = mp,
|
||||
.tp = tp,
|
||||
|
|
|
|||
|
|
@ -197,10 +197,10 @@ xfs_rtgroup_lock(
|
|||
* Lock both realtime free space metadata inodes for a freespace
|
||||
* update.
|
||||
*/
|
||||
xfs_ilock(rtg->rtg_inodes[XFS_RTGI_BITMAP], XFS_ILOCK_EXCL);
|
||||
xfs_ilock(rtg->rtg_inodes[XFS_RTGI_SUMMARY], XFS_ILOCK_EXCL);
|
||||
xfs_ilock(rtg_bitmap(rtg), XFS_ILOCK_EXCL);
|
||||
xfs_ilock(rtg_summary(rtg), XFS_ILOCK_EXCL);
|
||||
} else if (rtglock_flags & XFS_RTGLOCK_BITMAP_SHARED) {
|
||||
xfs_ilock(rtg->rtg_inodes[XFS_RTGI_BITMAP], XFS_ILOCK_SHARED);
|
||||
xfs_ilock(rtg_bitmap(rtg), XFS_ILOCK_SHARED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -215,10 +215,10 @@ xfs_rtgroup_unlock(
|
|||
!(rtglock_flags & XFS_RTGLOCK_BITMAP));
|
||||
|
||||
if (rtglock_flags & XFS_RTGLOCK_BITMAP) {
|
||||
xfs_iunlock(rtg->rtg_inodes[XFS_RTGI_SUMMARY], XFS_ILOCK_EXCL);
|
||||
xfs_iunlock(rtg->rtg_inodes[XFS_RTGI_BITMAP], XFS_ILOCK_EXCL);
|
||||
xfs_iunlock(rtg_summary(rtg), XFS_ILOCK_EXCL);
|
||||
xfs_iunlock(rtg_bitmap(rtg), XFS_ILOCK_EXCL);
|
||||
} else if (rtglock_flags & XFS_RTGLOCK_BITMAP_SHARED) {
|
||||
xfs_iunlock(rtg->rtg_inodes[XFS_RTGI_BITMAP], XFS_ILOCK_SHARED);
|
||||
xfs_iunlock(rtg_bitmap(rtg), XFS_ILOCK_SHARED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -236,10 +236,8 @@ xfs_rtgroup_trans_join(
|
|||
ASSERT(!(rtglock_flags & XFS_RTGLOCK_BITMAP_SHARED));
|
||||
|
||||
if (rtglock_flags & XFS_RTGLOCK_BITMAP) {
|
||||
xfs_trans_ijoin(tp, rtg->rtg_inodes[XFS_RTGI_BITMAP],
|
||||
XFS_ILOCK_EXCL);
|
||||
xfs_trans_ijoin(tp, rtg->rtg_inodes[XFS_RTGI_SUMMARY],
|
||||
XFS_ILOCK_EXCL);
|
||||
xfs_trans_ijoin(tp, rtg_bitmap(rtg), XFS_ILOCK_EXCL);
|
||||
xfs_trans_ijoin(tp, rtg_summary(rtg), XFS_ILOCK_EXCL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,16 @@ static inline xfs_rgnumber_t rtg_rgno(const struct xfs_rtgroup *rtg)
|
|||
return rtg->rtg_group.xg_gno;
|
||||
}
|
||||
|
||||
static inline struct xfs_inode *rtg_bitmap(const struct xfs_rtgroup *rtg)
|
||||
{
|
||||
return rtg->rtg_inodes[XFS_RTGI_BITMAP];
|
||||
}
|
||||
|
||||
static inline struct xfs_inode *rtg_summary(const struct xfs_rtgroup *rtg)
|
||||
{
|
||||
return rtg->rtg_inodes[XFS_RTGI_SUMMARY];
|
||||
}
|
||||
|
||||
/* Passive rtgroup references */
|
||||
static inline struct xfs_rtgroup *
|
||||
xfs_rtgroup_get(
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ xchk_setup_rtbitmap(
|
|||
if (error)
|
||||
return error;
|
||||
|
||||
error = xchk_install_live_inode(sc,
|
||||
sc->sr.rtg->rtg_inodes[XFS_RTGI_BITMAP]);
|
||||
error = xchk_install_live_inode(sc, rtg_bitmap(sc->sr.rtg));
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
|
|
@ -146,7 +145,7 @@ xchk_rtbitmap(
|
|||
{
|
||||
struct xfs_mount *mp = sc->mp;
|
||||
struct xfs_rtgroup *rtg = sc->sr.rtg;
|
||||
struct xfs_inode *rbmip = rtg->rtg_inodes[XFS_RTGI_BITMAP];
|
||||
struct xfs_inode *rbmip = rtg_bitmap(rtg);
|
||||
struct xchk_rtbitmap *rtb = sc->buf;
|
||||
int error;
|
||||
|
||||
|
|
@ -215,7 +214,7 @@ xchk_xref_is_used_rt_space(
|
|||
xfs_extlen_t len)
|
||||
{
|
||||
struct xfs_rtgroup *rtg = sc->sr.rtg;
|
||||
struct xfs_inode *rbmip = rtg->rtg_inodes[XFS_RTGI_BITMAP];
|
||||
struct xfs_inode *rbmip = rtg_bitmap(rtg);
|
||||
xfs_rtxnum_t startext;
|
||||
xfs_rtxnum_t endext;
|
||||
bool is_free;
|
||||
|
|
|
|||
|
|
@ -81,8 +81,7 @@ xchk_setup_rtsummary(
|
|||
if (error)
|
||||
return error;
|
||||
|
||||
error = xchk_install_live_inode(sc,
|
||||
sc->sr.rtg->rtg_inodes[XFS_RTGI_SUMMARY]);
|
||||
error = xchk_install_live_inode(sc, rtg_summary(sc->sr.rtg));
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
|
|
@ -191,8 +190,7 @@ xchk_rtsum_record_free(
|
|||
rtlen = xfs_rtxlen_to_extlen(mp, rec->ar_extcount);
|
||||
|
||||
if (!xfs_verify_rtbext(mp, rtbno, rtlen)) {
|
||||
xchk_ino_xref_set_corrupt(sc,
|
||||
rtg->rtg_inodes[XFS_RTGI_BITMAP]->i_ino);
|
||||
xchk_ino_xref_set_corrupt(sc, rtg_bitmap(rtg)->i_ino);
|
||||
return -EFSCORRUPTED;
|
||||
}
|
||||
|
||||
|
|
@ -218,7 +216,7 @@ xchk_rtsum_compute(
|
|||
|
||||
/* If the bitmap size doesn't match the computed size, bail. */
|
||||
if (XFS_FSB_TO_B(mp, xfs_rtbitmap_blockcount(mp)) !=
|
||||
rtg->rtg_inodes[XFS_RTGI_BITMAP]->i_disk_size)
|
||||
rtg_bitmap(rtg)->i_disk_size)
|
||||
return -EFSCORRUPTED;
|
||||
|
||||
return xfs_rtalloc_query_all(rtg, sc->tp, xchk_rtsum_record_free, sc);
|
||||
|
|
@ -310,8 +308,8 @@ xchk_rtsummary(
|
|||
{
|
||||
struct xfs_mount *mp = sc->mp;
|
||||
struct xfs_rtgroup *rtg = sc->sr.rtg;
|
||||
struct xfs_inode *rbmip = rtg->rtg_inodes[XFS_RTGI_BITMAP];
|
||||
struct xfs_inode *rsumip = rtg->rtg_inodes[XFS_RTGI_SUMMARY];
|
||||
struct xfs_inode *rbmip = rtg_bitmap(rtg);
|
||||
struct xfs_inode *rsumip = rtg_summary(rtg);
|
||||
struct xchk_rtsummary *rts = sc->buf;
|
||||
int error;
|
||||
|
||||
|
|
|
|||
|
|
@ -230,10 +230,10 @@ xfs_qm_unmount_rt(
|
|||
|
||||
if (!rtg)
|
||||
return;
|
||||
if (rtg->rtg_inodes[XFS_RTGI_BITMAP])
|
||||
xfs_qm_dqdetach(rtg->rtg_inodes[XFS_RTGI_BITMAP]);
|
||||
if (rtg->rtg_inodes[XFS_RTGI_SUMMARY])
|
||||
xfs_qm_dqdetach(rtg->rtg_inodes[XFS_RTGI_SUMMARY]);
|
||||
if (rtg_bitmap(rtg))
|
||||
xfs_qm_dqdetach(rtg_bitmap(rtg));
|
||||
if (rtg_summary(rtg))
|
||||
xfs_qm_dqdetach(rtg_summary(rtg));
|
||||
xfs_rtgroup_rele(rtg);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -856,8 +856,8 @@ xfs_growfs_rt_bmblock(
|
|||
xfs_fileoff_t bmbno)
|
||||
{
|
||||
struct xfs_mount *mp = rtg_mount(rtg);
|
||||
struct xfs_inode *rbmip = rtg->rtg_inodes[XFS_RTGI_BITMAP];
|
||||
struct xfs_inode *rsumip = rtg->rtg_inodes[XFS_RTGI_SUMMARY];
|
||||
struct xfs_inode *rbmip = rtg_bitmap(rtg);
|
||||
struct xfs_inode *rsumip = rtg_summary(rtg);
|
||||
struct xfs_rtalloc_args args = {
|
||||
.mp = mp,
|
||||
.rtg = rtg,
|
||||
|
|
@ -1041,8 +1041,8 @@ xfs_growfs_rt_alloc_blocks(
|
|||
xfs_extlen_t *nrbmblocks)
|
||||
{
|
||||
struct xfs_mount *mp = rtg_mount(rtg);
|
||||
struct xfs_inode *rbmip = rtg->rtg_inodes[XFS_RTGI_BITMAP];
|
||||
struct xfs_inode *rsumip = rtg->rtg_inodes[XFS_RTGI_SUMMARY];
|
||||
struct xfs_inode *rbmip = rtg_bitmap(rtg);
|
||||
struct xfs_inode *rsumip = rtg_summary(rtg);
|
||||
xfs_extlen_t orbmblocks = 0;
|
||||
xfs_extlen_t orsumblocks = 0;
|
||||
struct xfs_mount *nmp;
|
||||
|
|
@ -1622,7 +1622,7 @@ xfs_rtpick_extent(
|
|||
xfs_rtxlen_t len) /* allocation length (rtextents) */
|
||||
{
|
||||
struct xfs_mount *mp = rtg_mount(rtg);
|
||||
struct xfs_inode *rbmip = rtg->rtg_inodes[XFS_RTGI_BITMAP];
|
||||
struct xfs_inode *rbmip = rtg_bitmap(rtg);
|
||||
xfs_rtxnum_t b = 0; /* result rtext */
|
||||
int log2; /* log of sequence number */
|
||||
uint64_t resid; /* residual after log removed */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user