Skip to content

Commit 4fcc94d

Browse files
dgchinnerdchinner
authored andcommitted
xfs: track the iunlink list pointer in the xfs_inode
Having direct access to the i_next_unlinked pointer in unlinked inodes greatly simplifies the processing of inodes on the unlinked list. We no longer need to look up the inode buffer just to find next inode in the list if the xfs_inode is in memory. These improvements will be realised over upcoming patches as other dependencies on the inode buffer for unlinked list processing are removed. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de>
1 parent a4454cd commit 4fcc94d

4 files changed

Lines changed: 10 additions & 18 deletions

File tree

fs/xfs/libxfs/xfs_inode_buf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ xfs_inode_from_disk(
229229
ip->i_nblocks = be64_to_cpu(from->di_nblocks);
230230
ip->i_extsize = be32_to_cpu(from->di_extsize);
231231
ip->i_forkoff = from->di_forkoff;
232-
ip->i_diflags = be16_to_cpu(from->di_flags);
232+
ip->i_diflags = be16_to_cpu(from->di_flags);
233+
ip->i_next_unlinked = be32_to_cpu(from->di_next_unlinked);
233234

234235
if (from->di_dmevmask || from->di_dmstate)
235236
xfs_iflags_set(ip, XFS_IPRESERVE_DM_FIELDS);

fs/xfs/xfs_inode.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,8 @@ xfs_iunlink_update_inode(
20842084

20852085
/* Make sure the old pointer isn't garbage. */
20862086
old_value = be32_to_cpu(dip->di_next_unlinked);
2087-
if (!xfs_verify_agino_or_null(pag, old_value)) {
2087+
if (old_value != ip->i_next_unlinked ||
2088+
!xfs_verify_agino_or_null(pag, old_value)) {
20882089
xfs_inode_verifier_error(ip, -EFSCORRUPTED, __func__, dip,
20892090
sizeof(*dip), __this_address);
20902091
error = -EFSCORRUPTED;
@@ -2153,6 +2154,7 @@ xfs_iunlink_insert_inode(
21532154
if (error)
21542155
return error;
21552156
ASSERT(old_agino == NULLAGINO);
2157+
ip->i_next_unlinked = next_agino;
21562158

21572159
/*
21582160
* agino has been unlinked, add a backref from the next inode
@@ -2354,6 +2356,7 @@ xfs_iunlink_remove_inode(
23542356
error = xfs_iunlink_update_inode(tp, ip, pag, NULLAGINO, &next_agino);
23552357
if (error)
23562358
return error;
2359+
ip->i_next_unlinked = NULLAGINO;
23572360

23582361
/*
23592362
* If there was a backref pointing from the next inode back to this

fs/xfs/xfs_inode.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ typedef struct xfs_inode {
6868
uint64_t i_diflags2; /* XFS_DIFLAG2_... */
6969
struct timespec64 i_crtime; /* time created */
7070

71+
/* unlinked list pointers */
72+
xfs_agino_t i_next_unlinked;
73+
7174
/* VFS inode */
7275
struct inode i_vnode; /* embedded VFS inode */
7376

fs/xfs/xfs_log_recover.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,8 +2673,6 @@ xlog_recover_process_one_iunlink(
26732673
xfs_agino_t agino,
26742674
int bucket)
26752675
{
2676-
struct xfs_buf *ibp;
2677-
struct xfs_dinode *dip;
26782676
struct xfs_inode *ip;
26792677
xfs_ino_t ino;
26802678
int error;
@@ -2684,27 +2682,14 @@ xlog_recover_process_one_iunlink(
26842682
if (error)
26852683
goto fail;
26862684

2687-
/*
2688-
* Get the on disk inode to find the next inode in the bucket.
2689-
*/
2690-
error = xfs_imap_to_bp(pag->pag_mount, NULL, &ip->i_imap, &ibp);
2691-
if (error)
2692-
goto fail_iput;
2693-
dip = xfs_buf_offset(ibp, ip->i_imap.im_boffset);
2694-
26952685
xfs_iflags_clear(ip, XFS_IRECOVERY);
26962686
ASSERT(VFS_I(ip)->i_nlink == 0);
26972687
ASSERT(VFS_I(ip)->i_mode != 0);
26982688

2699-
/* setup for the next pass */
2700-
agino = be32_to_cpu(dip->di_next_unlinked);
2701-
xfs_buf_relse(ibp);
2702-
2689+
agino = ip->i_next_unlinked;
27032690
xfs_irele(ip);
27042691
return agino;
27052692

2706-
fail_iput:
2707-
xfs_irele(ip);
27082693
fail:
27092694
/*
27102695
* We can't read in the inode this bucket points to, or this inode

0 commit comments

Comments
 (0)