From patchwork Tue Jul 3 04:11:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10502911 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 0B11160225 for ; Tue, 3 Jul 2018 04:11:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBE1028AF1 for ; Tue, 3 Jul 2018 04:11:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD71B28AFF; Tue, 3 Jul 2018 04:11:35 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF80828AF1 for ; Tue, 3 Jul 2018 04:11:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E3D36B0003; Tue, 3 Jul 2018 00:11:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2BA756B0006; Tue, 3 Jul 2018 00:11:33 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 184F26B0007; Tue, 3 Jul 2018 00:11:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id C78F16B0003 for ; Tue, 3 Jul 2018 00:11:32 -0400 (EDT) Received: by mail-pf0-f200.google.com with SMTP id g20-v6so422106pfi.2 for ; Mon, 02 Jul 2018 21:11:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=nbgkjemLxDcdAFKnX0WMbOmDNTJp9briEAiUFVBQS0U=; b=moo4nzgR1Uue2hMP0QBbINwf7e2yYkCbTUM1aCAU+Wmn6CD3fdN1XIqybevmWyLENR MCzFP0bUpFJgb3t31/L/nM5tzeFVIOsILvhtVO8Ie+SDMwW4ZYzjkssFTWjw4yGkmBEw XV8q1jXtCfIJFw4EDQ2jIZwsfd/CwweQoUGWsG9zteR5k2zriCjB59jsaeF65Mw16JY+ rCm27GLYa8CyZGZp05wifsht2P2K3lDxVlc09cZiUV1HpyFHtWiFN5TIUqZCOGfLXA0X u3v30CbL2dY307Q0s+UBWRD5cyOOk49d8IsncuF+LOEmL9YCNBAFrDy5QZbXRaE1xNWe xMRA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: APt69E2QdoQfHRmlpckDIvQ/ydwUa80brQHGXO50nWs9A6/vblsv5G7H uGQtRDUVeuJk5NTBGtXKL2Btd0YtGVewdwPhDlP3BjM30oo5NRfF7zlqdQH/nyXxJcD9sXZ0p4J VcmEek2ZFALuHFBoMLjHxpNNj9n3quNw5gVJ/eCF//+5aaCe1gwBNSR12viDVkF/+Aw== X-Received: by 2002:a62:a3d1:: with SMTP id q78-v6mr27720695pfl.5.1530591092505; Mon, 02 Jul 2018 21:11:32 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfc3Wjm1qnOkpw6K581xOVdecJCKbdulfcNSRyfESr58O3tmaEQkCXCGfZgVh9lGu1otgWS X-Received: by 2002:a62:a3d1:: with SMTP id q78-v6mr27720652pfl.5.1530591091358; Mon, 02 Jul 2018 21:11:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530591091; cv=none; d=google.com; s=arc-20160816; b=vPpEozN1QwUY5CwGKRHddMor2a9TBWtt7jnGVzmTW25jPUwp7acdGn0qzJaKWLHaad t3rZwvK67lfd3QUOLDnlVO6ukEW/UO1eOxO1EmCqO2pJl01MlR77J6n3R9afmssOXDwn SdtwhO9zmJh36ocLz3EOBwuWs6aNVgUrZ4Fy8idFavseVBxg6Ezb4EzjMB2Gtw8OOKYk jt3HawFWUVWnGFWEbIBgIr0eMIG0PHplbnC8qq1wdI0pyQk+3kfNdK1+oWHKswD7CaNR 76ErZrbRPmdEyB9BckRdMsAdCQUxDJYP05If8FntvctYJ7u03mbj72xUwkMa4lr2R9C8 6pJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=nbgkjemLxDcdAFKnX0WMbOmDNTJp9briEAiUFVBQS0U=; b=K6K6lWpDMLurGxsV6j6syfjAnu0SFcYRs3ooeysI2uafQYihNN7ZEyP2DO5dJr8EtJ TzdjOX3MngVXYOA/wKwGwMyfHRvGTCKUGxU9/9Mey0NvpgFrC9Fy8C1Jxve+50xQ0Qg8 aavvNFQUDGG3LELRNLTWT6OE1jDzHWxFsGiVttgC2eEB0q5yLO6K+3rmCxlPIZREix9y ultLggbh3Xo40Q0DND6s87/DfFbwo1+yUUPR3/ygAZUM+FltMrs78gKF0RcwHqRMkriI wje8BosKtG+xEXHB7MSIahDfYnNg6gTHdeAxgb4dPJTRr3z2RwNq9mOlZlIo3S1fpa2M OSBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out30-132.freemail.mail.aliyun.com (out30-132.freemail.mail.aliyun.com. [115.124.30.132]) by mx.google.com with ESMTPS id v127-v6si184060pgv.212.2018.07.02.21.11.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 21:11:31 -0700 (PDT) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) client-ip=115.124.30.132; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 115.124.30.132 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R331e4; CH=green; FP=0|-1|-1|-1|0|-1|-1|-1; HT=e01e01355; MF=yang.shi@linux.alibaba.com; NM=1; PH=DS; RN=12; SR=0; TI=SMTPD_---0T3scjyw_1530591079; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T3scjyw_1530591079) by smtp.aliyun-inc.com(127.0.0.1); Tue, 03 Jul 2018 12:11:27 +0800 From: Yang Shi To: mgorman@techsingularity.net, tytso@mit.edu, adilger.kernel@dilger.ca, darrick.wong@oracle.com, dchinner@redhat.com, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] fs: ext4: use BUG_ON if writepage call comes from direct reclaim Date: Tue, 3 Jul 2018 12:11:18 +0800 Message-Id: <1530591079-33813-1-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 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: X-Virus-Scanned: ClamAV using ClamSMTP direct reclaim doesn't write out filesystem page, only kswapd could do it. So, if the call comes from direct reclaim, it is definitely a bug. And, Mel Gormane also mentioned "Ultimately, this will be a BUG_ON." In commit 94054fa3fca1fd78db02cb3d68d5627120f0a1d4 ("xfs: warn if direct reclaim tries to writeback pages"). Although it is for xfs, ext4 has the similar behavior, so elevate WARN_ON to BUG_ON. And, correct the comment accordingly. Cc: Mel Gorman Cc: "Theodore Ts'o" Cc: Andreas Dilger Signed-off-by: Yang Shi --- fs/ext4/inode.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 2ea07ef..089e388 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2071,7 +2071,7 @@ static int __ext4_journalled_writepage(struct page *page, * This function can get called via... * - ext4_writepages after taking page lock (have journal handle) * - journal_submit_inode_data_buffers (no journal handle) - * - shrink_page_list via the kswapd/direct reclaim (no journal handle) + * - shrink_page_list via the kswapd (no journal handle) * - grab_page_cache when doing write_begin (have journal handle) * * We don't do any block allocation in this function. If we have page with @@ -2148,10 +2148,10 @@ static int ext4_writepage(struct page *page, (inode->i_sb->s_blocksize == PAGE_SIZE)) { /* * For memory cleaning there's no point in writing only - * some buffers. So just bail out. Warn if we came here - * from direct reclaim. + * some buffers. So just bail out. It is a bug if we + * came here from direct reclaim. */ - WARN_ON_ONCE((current->flags & (PF_MEMALLOC|PF_KSWAPD)) + BUG_ON((current->flags & (PF_MEMALLOC|PF_KSWAPD)) == PF_MEMALLOC); unlock_page(page); return 0;