]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs: always rejoin held resources during defer roll
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 24 Jul 2019 19:54:06 +0000 (15:54 -0400)
committerEric Sandeen <sandeen@redhat.com>
Wed, 24 Jul 2019 19:54:06 +0000 (15:54 -0400)
commit9833c1a425e00d1cf113ed66bea03c5d801ac2f7
tree75bb375ac2e7bad0f026a836907edae3bc15d7a4
parentf73690fe8807ff82fdb0c10c719fa8068096a6a6
xfs: always rejoin held resources during defer roll

Source kernel commit: 710d707d2fa9cf4c2aa9def129e71e99513466ea

During testing of xfs/141 on a V4 filesystem, I observed some
inconsistent behavior with regards to resources that are held (i.e.
remain locked) across a defer roll.  The transaction roll always gives
the defer roll function a new transaction, even if committing the old
transaction fails.  However, the defer roll function only rejoins the
held resources if the transaction commit succeedied.  This means that
callers of defer roll have to figure out whether the held resources are
attached to the transaction being passed back.

Worse yet, if the defer roll was part of a defer finish call, we have a
third possibility: the defer finish could pass back a dirty transaction
with dirty held resources and an error code.

The only sane way to handle all of these scenarios is to require that
the code that held the resource either cancel the transaction before
unlocking and releasing the resources, or use functions that detach
resources from a transaction properly (e.g.  xfs_trans_brelse) if they
need to drop the reference before committing or cancelling the
transaction.

In order to make this so, change the defer roll code to join held
resources to the new transaction unconditionally and fix all the bhold
callers to release the held buffers correctly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/xfs_trace.h
include/xfs_trans.h
libxfs/libxfs_api_defs.h
libxfs/trans.c
libxfs/xfs_attr.c
libxfs/xfs_attr.h
libxfs/xfs_defer.c