xfs: fix log intent recovery ENOSPC shutdowns when inactivating inodes
authorDarrick J. Wong <djwong@kernel.org>
Fri, 18 Jun 2021 18:57:07 +0000 (11:57 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 21 Jun 2021 17:14:24 +0000 (10:14 -0700)
commit81ed94751b1513fcc5978dcc06eb1f5b4e55a785
tree4cbeb8421194fce7b7612516703de4a1daab1ffb
parentc06ad17cfa0bac3b51c9b3448a843860d29bc85a
xfs: fix log intent recovery ENOSPC shutdowns when inactivating inodes

During regular operation, the xfs_inactive operations create
transactions with zero block reservation because in general we're
freeing space, not asking for more.  The per-AG space reservations
created at mount time enable us to handle expansions of the refcount
btree without needing to reserve blocks to the transaction.

Unfortunately, log recovery doesn't create the per-AG space reservations
when intent items are being recovered.  This isn't an issue for intent
item recovery itself because they explicitly request blocks, but any
inode inactivation that can happen during log recovery uses the same
xfs_inactive paths as regular runtime.  If a refcount btree expansion
happens, the transaction will fail due to blk_res_used > blk_res, and we
shut down the filesystem unnecessarily.

Fix this problem by making per-AG reservations temporarily so that we
can handle the inactivations, and releasing them at the end.  This
brings the recovery environment closer to the runtime environment.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/xfs_mount.c