]> git.itanic.dy.fi Git - linux-stable/commit
xfs: reorder iunlink remove operation in xfs_ifree
authorDave Chinner <dchinner@redhat.com>
Wed, 20 Apr 2022 22:45:16 +0000 (08:45 +1000)
committerDave Chinner <david@fromorbit.com>
Wed, 20 Apr 2022 22:45:16 +0000 (08:45 +1000)
commit9a5280b312e2e7898b6397b2ca3cfd03f67d7be1
tree84fb79f27e7a84457ab82013e1e13c7d29d7bfc2
parentd65a92de4383e54b920ba11f333032b0ea5e4174
xfs: reorder iunlink remove operation in xfs_ifree

The O_TMPFILE creation implementation creates a specific order of
operations for inode allocation/freeing and unlinked list
modification. Currently both are serialised by the AGI, so the order
doesn't strictly matter as long as the are both in the same
transaction.

However, if we want to move the unlinked list insertions largely out
from under the AGI lock, then we have to be concerned about the
order in which we do unlinked list modification operations.
O_TMPFILE creation tells us this order is inode allocation/free,
then unlinked list modification.

Change xfs_ifree() to use this same ordering on unlinked list
removal. This way we always guarantee that when we enter the
iunlinked list removal code from this path, we already have the AGI
locked and we don't have to worry about lock nesting AGI reads
inside unlink list locks because it's already locked and attached to
the transaction.

We can do this safely as the inode freeing and unlinked list removal
are done in the same transaction and hence are atomic operations
with respect to log recovery.

Reported-by: Frank Hofmann <fhofmann@cloudflare.com>
Fixes: 298f7bec503f ("xfs: pin inode backing buffer to the inode log item")
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/xfs_inode.c