]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
xfs: reorder iunlink remove operation in xfs_ifree
authorDave Chinner <dchinner@redhat.com>
Thu, 22 Sep 2022 15:14:59 +0000 (08:14 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 23 Nov 2022 14:11:40 +0000 (15:11 +0100)
commit5c88b0aa4d75467d86cf6c8da4723f86c868b62c
tree6b9336428c90afae0d8c7d645a08bd733dca4798
parenta862fd3ad261ef0d997d93e7195487f684e80e5c
xfs: reorder iunlink remove operation in xfs_ifree

BugLink: https://bugs.launchpad.net/bugs/1995420
[ Upstream commit 9a5280b312e2e7898b6397b2ca3cfd03f67d7be1 ]

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>
Signed-off-by: Leah Rumancik <leah.rumancik@gmail.com>
Acked-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/xfs/xfs_inode.c