diff options
author | Brian Foster <bfoster@redhat.com> | 2018-07-24 13:43:11 -0700 |
---|---|---|
committer | Darrick J. Wong <darrick.wong@oracle.com> | 2018-07-26 10:15:14 -0700 |
commit | e021a2e5fc520d930f949f303e7307038e258645 (patch) | |
tree | 68349c1264484a817a5f8da9285add82f6b7ded2 /fs/xfs/libxfs/xfs_defer.c | |
parent | 44fd294681de73990da656294e3dacaa7878f577 (diff) | |
download | linux-e021a2e5fc520d930f949f303e7307038e258645.tar.bz2 |
xfs: support embedded dfops in transaction
The dfops structure used by multi-transaction operations is
typically stored on the stack and carried around by the associated
transaction. The lifecycle of dfops does not quite match that of the
transaction, but they are tightly related in that the former depends
on the latter.
The relationship of these objects is tight enough that we can avoid
the cumbersome boilerplate code required in most cases to manage
them separately by just embedding an xfs_defer_ops in the
transaction itself. This means that a transaction allocation returns
with an initialized dfops, a transaction commit finishes pending
deferred items before the tx commit, a transaction cancel cancels
the dfops before the transaction and a transaction dup operation
transfers the current dfops state to the new transaction.
The dup operation is slightly complicated by the fact that we can no
longer just copy a dfops pointer from the old transaction to the new
transaction. This is solved through a dfops move helper that
transfers the pending items and other dfops state across the
transactions. This also requires that transaction rolling code
always refer to the transaction for the current dfops reference.
Finally, to facilitate incremental conversion to the internal dfops
and continue to support the current external dfops mode of
operation, create the new ->t_dfops_internal field with a layer of
indirection. On allocation, ->t_dfops points to the internal dfops.
This state is overridden by callers who re-init a local dfops on the
transaction. Once ->t_dfops is overridden, the external dfops
reference is maintained as the transaction rolls.
This patch adds the fundamental ability to support an internal
dfops. All codepaths that perform deferred processing continue to
override the internal dfops until they are converted over in
subsequent patches.
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_defer.c')
-rw-r--r-- | fs/xfs/libxfs/xfs_defer.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/fs/xfs/libxfs/xfs_defer.c b/fs/xfs/libxfs/xfs_defer.c index 23f2a52b088e..b63cc9e730da 100644 --- a/fs/xfs/libxfs/xfs_defer.c +++ b/fs/xfs/libxfs/xfs_defer.c @@ -555,3 +555,25 @@ xfs_defer_init( } trace_xfs_defer_init(mp, dop, _RET_IP_); } + +/* + * Move state from one xfs_defer_ops to another and reset the source to initial + * state. This is primarily used to carry state forward across transaction rolls + * with internal dfops. + */ +void +xfs_defer_move( + struct xfs_defer_ops *dst, + struct xfs_defer_ops *src) +{ + ASSERT(dst != src); + + list_splice_init(&src->dop_intake, &dst->dop_intake); + list_splice_init(&src->dop_pending, &dst->dop_pending); + + memcpy(dst->dop_inodes, src->dop_inodes, sizeof(dst->dop_inodes)); + memcpy(dst->dop_bufs, src->dop_bufs, sizeof(dst->dop_bufs)); + dst->dop_low = src->dop_low; + + xfs_defer_reset(src); +} |