From: Yafang Shao <laoar.shao@gmail.com>
To: darrick.wong@oracle.com, willy@infradead.org,
david@fromorbit.com, hch@infradead.org, mhocko@kernel.org,
akpm@linux-foundation.org, dhowells@redhat.com,
jlayton@redhat.com
Cc: linux-fsdevel@vger.kernel.org, linux-cachefs@redhat.com,
linux-xfs@vger.kernel.org, linux-mm@kvack.org,
Yafang Shao <laoar.shao@gmail.com>,
Christoph Hellwig <hch@lst.de>
Subject: [PATCH v14 3/4] xfs: introduce xfs_trans_context_swap() for rolling transaction
Date: Tue, 22 Dec 2020 09:21:30 +0800 [thread overview]
Message-ID: <20201222012131.47020-4-laoar.shao@gmail.com> (raw)
In-Reply-To: <20201222012131.47020-1-laoar.shao@gmail.com>
In the rolling transaction, thread's NOFS state is transferred from the
old transaction to the new transaction, and then the NOFS state stored
in the old one should be cleared.
Suggested-by: Dave Chinner <david@fromorbit.com>
Cc: Darrick J. Wong <darrick.wong@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
fs/xfs/xfs_trans.c | 4 +++-
fs/xfs/xfs_trans.h | 10 +++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index 11d390f0d3f2..733e0113aebe 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -119,7 +119,9 @@ xfs_trans_dup(
ntp->t_rtx_res = tp->t_rtx_res - tp->t_rtx_res_used;
tp->t_rtx_res = tp->t_rtx_res_used;
- ntp->t_pflags = tp->t_pflags;
+
+ /* Associate the new transaction with this thread. */
+ xfs_trans_context_swap(tp, ntp);
/* move deferred ops over to the new tp */
xfs_defer_move(ntp, tp);
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 44b11c64a15e..b428704eeb20 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -277,7 +277,15 @@ xfs_trans_context_set(struct xfs_trans *tp)
static inline void
xfs_trans_context_clear(struct xfs_trans *tp)
{
- memalloc_nofs_restore(tp->t_pflags);
+ if (!tp->t_flags)
+ memalloc_nofs_restore(tp->t_pflags);
+}
+
+static inline void
+xfs_trans_context_swap(struct xfs_trans *tp, struct xfs_trans *ntp)
+{
+ ntp->t_pflags = tp->t_pflags;
+ tp->t_flags = -1;
}
#endif /* __XFS_TRANS_H__ */
--
2.18.4
next prev parent reply other threads:[~2020-12-22 1:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-22 1:21 [PATCH v14 0/4] xfs: avoid transaction reservation recursion Yafang Shao
2020-12-22 1:21 ` [PATCH v14 1/4] mm: Add become_kswapd and restore_kswapd Yafang Shao
2020-12-22 1:21 ` [PATCH v14 2/4] xfs: use memalloc_nofs_{save,restore} in xfs transaction Yafang Shao
2020-12-22 1:21 ` Yafang Shao [this message]
2020-12-22 1:21 ` [PATCH v14 4/4] xfs: use current->journal_info to avoid transaction reservation recursion Yafang Shao
2020-12-31 3:01 ` [xfs] db962cd266: Assertion_failed kernel test robot
2021-01-01 9:10 ` Yafang Shao
2021-01-01 21:53 ` Dave Chinner
2021-01-04 10:42 ` Yafang Shao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201222012131.47020-4-laoar.shao@gmail.com \
--to=laoar.shao@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=dhowells@redhat.com \
--cc=hch@infradead.org \
--cc=hch@lst.de \
--cc=jlayton@redhat.com \
--cc=linux-cachefs@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mhocko@kernel.org \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).