From patchwork Tue Dec 22 01:21:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 11985573 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AB54C433DB for ; Tue, 22 Dec 2020 01:22:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B8B0E22B3B for ; Tue, 22 Dec 2020 01:22:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B8B0E22B3B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5A94D6B007E; Mon, 21 Dec 2020 20:22:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 580256B0080; Mon, 21 Dec 2020 20:22:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 495C98D0001; Mon, 21 Dec 2020 20:22:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 34EDF6B007E for ; Mon, 21 Dec 2020 20:22:19 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EDF71181AF5C3 for ; Tue, 22 Dec 2020 01:22:18 +0000 (UTC) X-FDA: 77619167556.30.bikes62_08015d72745c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin30.hostedemail.com (Postfix) with ESMTP id CF283180B3AA7 for ; Tue, 22 Dec 2020 01:22:18 +0000 (UTC) X-HE-Tag: bikes62_08015d72745c X-Filterd-Recvd-Size: 4854 Received: from mail-ot1-f47.google.com (mail-ot1-f47.google.com [209.85.210.47]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 22 Dec 2020 01:22:18 +0000 (UTC) Received: by mail-ot1-f47.google.com with SMTP id n42so4633079ota.12 for ; Mon, 21 Dec 2020 17:22:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A7LGrv9arxrfdu1GFoCf8wflov+CFF7/hYY5Y4CreBA=; b=ZsOihlsXrtaRcPzizcEnEy3F5PmTWYsEcy1f5kKeLj8jJSOcNF0xwlbgW3ejiR1AWv Z1UMMX4HR0/vSYxVlOmRl59NYU+LQT2BISdKDnMNIaVZC8ENmywrpFa4l+CX3Brb3yvu 3JU56JnXRF4Wcf5wKqVRgYlJFOrvJ3TkQT6xMhDjm8XQ52zSRqvZSxobNECUuefHS+o5 ZnpANifQGAwhxWXHja0wkEeS0EUoKwjTLsb7IF/3fEQyfoti7vyUn1aZ0mpGCR0lPmMQ A6jMVYzgRptUqhBbk7GPDeYh8weR/Tu3rTfsyP8g/5lBuHkq6DoETuRdjE8Lvht6VZ/V ZVtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A7LGrv9arxrfdu1GFoCf8wflov+CFF7/hYY5Y4CreBA=; b=HPQwRe8+tyb49zpMh+J3KKW/s1G8HZipoWzQ6vVjQNi2MoH8x4w2r0vUxT//AOTqo7 i+BEbiMJ5TBOYkAkKLiieqlqLNi4FXTpODyZnrTx1f4ZBbc+Ow1HnJ+TXMvKHrPOaZ8X tc30Xol2do6/n9WPkt58EaC2ROJ/vyaHpMjtO1SkRbREd5BPEHzYLSTn3nkzxjgV1Zqe V5SPGyS/ZVDEwdximPtaK4LPdrfRdSRe0rTAbPLeejZB9Y/X/Ujb4qpuE7tUOQP7fDty k9r1XFkRRSpJmMVAR7+wX2/HId/0/JBJCsSuReECPAJsqV55C6dcr/ggwgehCPMJisLm pwYg== X-Gm-Message-State: AOAM530GS3gFJx9/r0wbbLb9zxMRyhFHIT01B0cfYC4xH4MGEEgNSelI vmQzbWto5ZDzTZNs7DZDYpM= X-Google-Smtp-Source: ABdhPJzWauZ4OUHVQCKycQCUNjLregUj88VEqRI/lgKXVo6Q989mL8effGg+mlhu6BTPp9ocg7Ka+g== X-Received: by 2002:a9d:a4e:: with SMTP id 72mr14436297otg.267.1608600137947; Mon, 21 Dec 2020 17:22:17 -0800 (PST) Received: from localhost.localdomain ([50.236.19.102]) by smtp.gmail.com with ESMTPSA id x20sm4070098oov.33.2020.12.21.17.22.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Dec 2020 17:22:16 -0800 (PST) From: Yafang Shao 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 , Christoph Hellwig Subject: [PATCH v14 3/4] xfs: introduce xfs_trans_context_swap() for rolling transaction Date: Tue, 22 Dec 2020 09:21:30 +0800 Message-Id: <20201222012131.47020-4-laoar.shao@gmail.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: <20201222012131.47020-1-laoar.shao@gmail.com> References: <20201222012131.47020-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Cc: Darrick J. Wong Cc: Matthew Wilcox (Oracle) Cc: Christoph Hellwig Cc: Dave Chinner Signed-off-by: Yafang Shao --- 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__ */