From patchwork Mon Feb 6 14:07:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Hocko X-Patchwork-Id: 9558059 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 53F8860236 for ; Mon, 6 Feb 2017 14:08:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41A232522B for ; Mon, 6 Feb 2017 14:08:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3374026E90; Mon, 6 Feb 2017 14:08:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A561D2522B for ; Mon, 6 Feb 2017 14:08:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752027AbdBFOIa (ORCPT ); Mon, 6 Feb 2017 09:08:30 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:35999 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752148AbdBFOHg (ORCPT ); Mon, 6 Feb 2017 09:07:36 -0500 Received: by mail-wm0-f65.google.com with SMTP id r18so22175746wmd.3; Mon, 06 Feb 2017 06:07:34 -0800 (PST) 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; bh=50GjDt8RZngXPocnSWEu1VwuWlPqTShbkckDH1z8W10=; b=OCegqKVC7UaelGxmL1+E3Pom+8SyPXsdT3PUZvwD91DgUN8w1N3lmrKoQ960t6sgqb OrEME+3DLXirxMeBz2Mi60d5ERAmyjwvX+0QNQZS+mTE4vGaJR4p5PY9dcZtyOILbbFB 6K7dGJ8emPCy6DflOB4WXT2CCpNUm0JRZzCgTVdxmVPZfJWr5nhiXr+hH5f10zqUToTT GQYi/296KCxSrxc0EOWAxntBplwD1nIx3RpS4uxdWSmSlg878+aJqEDUGVJKaQFZOwcd bRQHIl4BCDcxrif2A6n7gSaexzR/xZo7xCwUBfill7MFAASgLLtAVGwyRmg7HNDeky14 vb0w== X-Gm-Message-State: AMke39kYvquuarCDJWwXE3ptv5sXTewALa4weMW2nLFscEVh0AR8MOvtEJI7Ne6f0fEA0g== X-Received: by 10.28.227.84 with SMTP id a81mr8491528wmh.121.1486390053636; Mon, 06 Feb 2017 06:07:33 -0800 (PST) Received: from tiehlicka.suse.cz (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id 191sm13112265wmo.21.2017.02.06.06.07.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Feb 2017 06:07:33 -0800 (PST) From: Michal Hocko To: Andrew Morton , Cc: , Dave Chinner , djwong@kernel.org, "Theodore Ts'o" , Chris Mason , David Sterba , Jan Kara , ceph-devel@vger.kernel.org, cluster-devel@redhat.com, linux-nfs@vger.kernel.org, logfs@logfs.org, linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mtd@lists.infradead.org, reiserfs-devel@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, linux-f2fs-devel@lists.sourceforge.net, linux-afs@lists.infradead.org, LKML , Michal Hocko Subject: [PATCH 5/6] jbd2: mark the transaction context with the scope GFP_NOFS context Date: Mon, 6 Feb 2017 15:07:17 +0100 Message-Id: <20170206140718.16222-6-mhocko@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170206140718.16222-1-mhocko@kernel.org> References: <20170206140718.16222-1-mhocko@kernel.org> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Michal Hocko now that we have memalloc_nofs_{save,restore} api we can mark the whole transaction context as implicitly GFP_NOFS. All allocations will automatically inherit GFP_NOFS this way. This means that we do not have to mark any of those requests with GFP_NOFS and moreover all the ext4_kv[mz]alloc(GFP_NOFS) are also safe now because even the hardcoded GFP_KERNEL allocations deep inside the vmalloc will be NOFS now. Reviewed-by: Jan Kara Signed-off-by: Michal Hocko --- fs/jbd2/transaction.c | 11 +++++++++++ include/linux/jbd2.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index e1652665bd93..35a5d3d76182 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -388,6 +388,11 @@ static int start_this_handle(journal_t *journal, handle_t *handle, rwsem_acquire_read(&journal->j_trans_commit_map, 0, 0, _THIS_IP_); jbd2_journal_free_transaction(new_transaction); + /* + * Make sure that no allocations done while the transaction is + * open is going to recurse back to the fs layer. + */ + handle->saved_alloc_context = memalloc_nofs_save(); return 0; } @@ -466,6 +471,7 @@ handle_t *jbd2__journal_start(journal_t *journal, int nblocks, int rsv_blocks, trace_jbd2_handle_start(journal->j_fs_dev->bd_dev, handle->h_transaction->t_tid, type, line_no, nblocks); + return handle; } EXPORT_SYMBOL(jbd2__journal_start); @@ -1760,6 +1766,11 @@ int jbd2_journal_stop(handle_t *handle) if (handle->h_rsv_handle) jbd2_journal_free_reserved(handle->h_rsv_handle); free_and_exit: + /* + * scope of th GFP_NOFS context is over here and so we can + * restore the original alloc context. + */ + memalloc_nofs_restore(handle->saved_alloc_context); jbd2_free_handle(handle); return err; } diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index dfaa1f4dcb0c..606b6bce3a5b 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h @@ -491,6 +491,8 @@ struct jbd2_journal_handle unsigned long h_start_jiffies; unsigned int h_requested_credits; + + unsigned int saved_alloc_context; };