Commit 1050c71e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Alex Elder

xfs: stop using xfs_trans_iget in the RT allocator

During mount we establish references to the RT inodes, which we keep for
the lifetime of the filesystem.  Instead of using xfs_trans_iget to grab
additional references when adding RT inodes to transactions use the
combination of xfs_ilock and xfs_trans_ijoin_ref, which archives the same
end result with less overhead.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarAlex Elder <aelder@sgi.com>
parent 5d157655
...@@ -2333,7 +2333,6 @@ xfs_bmap_rtalloc( ...@@ -2333,7 +2333,6 @@ xfs_bmap_rtalloc(
xfs_extlen_t prod = 0; /* product factor for allocators */ xfs_extlen_t prod = 0; /* product factor for allocators */
xfs_extlen_t ralen = 0; /* realtime allocation length */ xfs_extlen_t ralen = 0; /* realtime allocation length */
xfs_extlen_t align; /* minimum allocation alignment */ xfs_extlen_t align; /* minimum allocation alignment */
xfs_inode_t *ip; /* bitmap incore inode */
xfs_rtblock_t rtb; xfs_rtblock_t rtb;
mp = ap->ip->i_mount; mp = ap->ip->i_mount;
...@@ -2370,11 +2369,8 @@ xfs_bmap_rtalloc( ...@@ -2370,11 +2369,8 @@ xfs_bmap_rtalloc(
/* /*
* Lock out other modifications to the RT bitmap inode. * Lock out other modifications to the RT bitmap inode.
*/ */
error = xfs_trans_iget(mp, ap->tp, mp->m_sb.sb_rbmino, 0, xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL);
XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP, &ip); xfs_trans_ijoin_ref(ap->tp, mp->m_rbmip, XFS_ILOCK_EXCL);
if (error)
return error;
ASSERT(ip == mp->m_rbmip);
/* /*
* If it's an allocation to an empty file at offset 0, * If it's an allocation to an empty file at offset 0,
......
...@@ -76,7 +76,7 @@ xfs_growfs_rt_alloc( ...@@ -76,7 +76,7 @@ xfs_growfs_rt_alloc(
xfs_mount_t *mp, /* file system mount point */ xfs_mount_t *mp, /* file system mount point */
xfs_extlen_t oblocks, /* old count of blocks */ xfs_extlen_t oblocks, /* old count of blocks */
xfs_extlen_t nblocks, /* new count of blocks */ xfs_extlen_t nblocks, /* new count of blocks */
xfs_ino_t ino) /* inode number (bitmap/summary) */ xfs_inode_t *ip) /* inode (bitmap/summary) */
{ {
xfs_fileoff_t bno; /* block number in file */ xfs_fileoff_t bno; /* block number in file */
xfs_buf_t *bp; /* temporary buffer for zeroing */ xfs_buf_t *bp; /* temporary buffer for zeroing */
...@@ -86,7 +86,6 @@ xfs_growfs_rt_alloc( ...@@ -86,7 +86,6 @@ xfs_growfs_rt_alloc(
xfs_fsblock_t firstblock; /* first block allocated in xaction */ xfs_fsblock_t firstblock; /* first block allocated in xaction */
xfs_bmap_free_t flist; /* list of freed blocks */ xfs_bmap_free_t flist; /* list of freed blocks */
xfs_fsblock_t fsbno; /* filesystem block for bno */ xfs_fsblock_t fsbno; /* filesystem block for bno */
xfs_inode_t *ip; /* pointer to incore inode */
xfs_bmbt_irec_t map; /* block map output */ xfs_bmbt_irec_t map; /* block map output */
int nmap; /* number of block maps */ int nmap; /* number of block maps */
int resblks; /* space reservation */ int resblks; /* space reservation */
...@@ -112,9 +111,9 @@ xfs_growfs_rt_alloc( ...@@ -112,9 +111,9 @@ xfs_growfs_rt_alloc(
/* /*
* Lock the inode. * Lock the inode.
*/ */
if ((error = xfs_trans_iget(mp, tp, ino, 0, xfs_ilock(ip, XFS_ILOCK_EXCL);
XFS_ILOCK_EXCL, &ip))) xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL);
goto error_cancel;
xfs_bmap_init(&flist, &firstblock); xfs_bmap_init(&flist, &firstblock);
/* /*
* Allocate blocks to the bitmap file. * Allocate blocks to the bitmap file.
...@@ -155,9 +154,8 @@ xfs_growfs_rt_alloc( ...@@ -155,9 +154,8 @@ xfs_growfs_rt_alloc(
/* /*
* Lock the bitmap inode. * Lock the bitmap inode.
*/ */
if ((error = xfs_trans_iget(mp, tp, ino, 0, xfs_ilock(ip, XFS_ILOCK_EXCL);
XFS_ILOCK_EXCL, &ip))) xfs_trans_ijoin_ref(tp, ip, XFS_ILOCK_EXCL);
goto error_cancel;
/* /*
* Get a buffer for the block. * Get a buffer for the block.
*/ */
...@@ -1854,7 +1852,6 @@ xfs_growfs_rt( ...@@ -1854,7 +1852,6 @@ xfs_growfs_rt(
xfs_rtblock_t bmbno; /* bitmap block number */ xfs_rtblock_t bmbno; /* bitmap block number */
xfs_buf_t *bp; /* temporary buffer */ xfs_buf_t *bp; /* temporary buffer */
int error; /* error return value */ int error; /* error return value */
xfs_inode_t *ip; /* bitmap inode, used as lock */
xfs_mount_t *nmp; /* new (fake) mount structure */ xfs_mount_t *nmp; /* new (fake) mount structure */
xfs_drfsbno_t nrblocks; /* new number of realtime blocks */ xfs_drfsbno_t nrblocks; /* new number of realtime blocks */
xfs_extlen_t nrbmblocks; /* new number of rt bitmap blocks */ xfs_extlen_t nrbmblocks; /* new number of rt bitmap blocks */
...@@ -1918,11 +1915,11 @@ xfs_growfs_rt( ...@@ -1918,11 +1915,11 @@ xfs_growfs_rt(
/* /*
* Allocate space to the bitmap and summary files, as necessary. * Allocate space to the bitmap and summary files, as necessary.
*/ */
if ((error = xfs_growfs_rt_alloc(mp, rbmblocks, nrbmblocks, error = xfs_growfs_rt_alloc(mp, rbmblocks, nrbmblocks, mp->m_rbmip);
mp->m_sb.sb_rbmino))) if (error)
return error; return error;
if ((error = xfs_growfs_rt_alloc(mp, rsumblocks, nrsumblocks, error = xfs_growfs_rt_alloc(mp, rsumblocks, nrsumblocks, mp->m_rsumip);
mp->m_sb.sb_rsumino))) if (error)
return error; return error;
/* /*
* Allocate a new (fake) mount/sb. * Allocate a new (fake) mount/sb.
...@@ -1972,12 +1969,8 @@ xfs_growfs_rt( ...@@ -1972,12 +1969,8 @@ xfs_growfs_rt(
/* /*
* Lock out other callers by grabbing the bitmap inode lock. * Lock out other callers by grabbing the bitmap inode lock.
*/ */
error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL);
XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP, xfs_trans_ijoin_ref(tp, mp->m_rbmip, XFS_ILOCK_EXCL);
&ip);
if (error)
goto error_cancel;
ASSERT(ip == mp->m_rbmip);
/* /*
* Update the bitmap inode's size. * Update the bitmap inode's size.
*/ */
...@@ -1988,11 +1981,8 @@ xfs_growfs_rt( ...@@ -1988,11 +1981,8 @@ xfs_growfs_rt(
/* /*
* Get the summary inode into the transaction. * Get the summary inode into the transaction.
*/ */
error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rsumino, 0, xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL);
XFS_ILOCK_EXCL | XFS_ILOCK_RTSUM, &ip); xfs_trans_ijoin_ref(tp, mp->m_rsumip, XFS_ILOCK_EXCL);
if (error)
goto error_cancel;
ASSERT(ip == mp->m_rsumip);
/* /*
* Update the summary inode's size. * Update the summary inode's size.
*/ */
...@@ -2154,7 +2144,6 @@ xfs_rtfree_extent( ...@@ -2154,7 +2144,6 @@ xfs_rtfree_extent(
xfs_extlen_t len) /* length of extent freed */ xfs_extlen_t len) /* length of extent freed */
{ {
int error; /* error value */ int error; /* error value */
xfs_inode_t *ip; /* bitmap file inode */
xfs_mount_t *mp; /* file system mount structure */ xfs_mount_t *mp; /* file system mount structure */
xfs_fsblock_t sb; /* summary file block number */ xfs_fsblock_t sb; /* summary file block number */
xfs_buf_t *sumbp; /* summary file block buffer */ xfs_buf_t *sumbp; /* summary file block buffer */
...@@ -2163,10 +2152,9 @@ xfs_rtfree_extent( ...@@ -2163,10 +2152,9 @@ xfs_rtfree_extent(
/* /*
* Synchronize by locking the bitmap inode. * Synchronize by locking the bitmap inode.
*/ */
error = xfs_trans_iget(mp, tp, mp->m_sb.sb_rbmino, 0, xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL);
XFS_ILOCK_EXCL | XFS_ILOCK_RTBITMAP, &ip); xfs_trans_ijoin_ref(tp, mp->m_rbmip, XFS_ILOCK_EXCL);
if (error)
return error;
#if defined(__KERNEL__) && defined(DEBUG) #if defined(__KERNEL__) && defined(DEBUG)
/* /*
* Check to see that this whole range is currently allocated. * Check to see that this whole range is currently allocated.
...@@ -2199,10 +2187,10 @@ xfs_rtfree_extent( ...@@ -2199,10 +2187,10 @@ xfs_rtfree_extent(
*/ */
if (tp->t_frextents_delta + mp->m_sb.sb_frextents == if (tp->t_frextents_delta + mp->m_sb.sb_frextents ==
mp->m_sb.sb_rextents) { mp->m_sb.sb_rextents) {
if (!(ip->i_d.di_flags & XFS_DIFLAG_NEWRTBM)) if (!(mp->m_rbmip->i_d.di_flags & XFS_DIFLAG_NEWRTBM))
ip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM; mp->m_rbmip->i_d.di_flags |= XFS_DIFLAG_NEWRTBM;
*(__uint64_t *)&ip->i_d.di_atime = 0; *(__uint64_t *)&mp->m_rbmip->i_d.di_atime = 0;
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE);
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment