Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2191638iob; Thu, 5 May 2022 18:32:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9ZR0exNNh+3cxtU7ZJpR8O1hy5rne2WgfMeIJaJ4jSApEnkeUdG0I6Q6FBoRWHSBfDfPu X-Received: by 2002:a05:6402:2793:b0:428:1303:1b43 with SMTP id b19-20020a056402279300b0042813031b43mr1097151ede.226.1651800772851; Thu, 05 May 2022 18:32:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651800772; cv=none; d=google.com; s=arc-20160816; b=WV8hJpudswv1cJMyQ8vFUSDWe4z2SS2Fmx5PSG3uRCXAKbFo6nf8X+YUKI7xhYR9Ic irQmn44aTdwM7DFP1aWlc8yFRiCK6yyFrLxJrotOaS/oRwDcjWRdP9vhaevyJCWDdVKz f7oWULrRYiMgF6xpCI1sgo7w9m4O3yeEHSD9M0ZBZjBmGC564ga16khNSM3/0SoHgE8c ymqcB7MfvEryIWA9XRmzYMMR8iPEBkhKrfPQss7g6gv6pfavDIXFNFdFTuDnGyzGB2c3 VgNNSb52cJaSCp18q5N2erjq9aDeDDJsquro8sg35XTrG0Ewp9n+iAi2xgE0kfGk+S4d EzFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=dwtDHtHr1R9zOfTQ4+m78lEH/YlQf05t0UtiRjhSdjc=; b=d15wf41nZ/Jy/p/Xts7LvqQzs3lKYly6GJb9WPMgrUQQq1zn6VUfah5qGBikfvc2RI BeFmLp7N1RtzuPm+TQUFENMmGMZUvUXWrbHTTJAs38oogoEAJ66xfLh4aTmaEMh3cQMr SZtpY2Ms4F93aNTe1Q4Z2hvfntN64itVDvcTZpgeOwjp7D0/8zU+yb/kikZ8A4pbd2v+ HM7nckHhZcKsyxQtRFaZ5n8SGsWuBTtnSTdYcc+tEJJMqiTb+hyX0Upb3sraEO9Px/wW sHPM/HV//RJ+rmprRavKXU+L6kQPKic8yxwZq5TvagJxeTE9Cf13xnrdEzBVI0hBkt3n S60Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a50d506000000b0041d130a5087si3529541edi.427.2022.05.05.18.32.29; Thu, 05 May 2022 18:32:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1380001AbiEENwM (ORCPT + 99 others); Thu, 5 May 2022 09:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379994AbiEENwE (ORCPT ); Thu, 5 May 2022 09:52:04 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED24257994; Thu, 5 May 2022 06:48:19 -0700 (PDT) Received: from SHSend.spreadtrum.com (shmbx04.spreadtrum.com [10.0.1.214]) by SHSQR01.spreadtrum.com with ESMTPS id 245Dlgb1015983 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NO); Thu, 5 May 2022 21:47:42 +0800 (CST) (envelope-from Jing.Xia@unisoc.com) Received: from bj08259pcu.spreadtrum.com (10.0.74.59) by shmbx04.spreadtrum.com (10.0.1.214) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Thu, 5 May 2022 21:47:44 +0800 From: Jing Xia To: CC: , , , , Subject: [PATCH] writeback: Avoid skipping inode writeback Date: Thu, 5 May 2022 21:47:31 +0800 Message-ID: <20220505134731.5295-1-jing.xia@unisoc.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.74.59] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To shmbx04.spreadtrum.com (10.0.1.214) X-MAIL: SHSQR01.spreadtrum.com 245Dlgb1015983 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We have run into an issue that a task gets stuck in balance_dirty_pages_ratelimited() when perform I/O stress testing. The reason we observed is that an I_DIRTY_PAGES inode with lots of dirty pages is in b_dirty_time list and standard background writeback cannot writeback the inode. After studing the relevant code, the following scenario may lead to the issue: task1 task2 ----- ----- fuse_flush write_inode_now //in b_dirty_time writeback_single_inode __writeback_single_inode fuse_write_end filemap_dirty_folio __xa_set_mark:PAGECACHE_TAG_DIRTY lock inode->i_lock if mapping tagged PAGECACHE_TAG_DIRTY inode->i_state |= I_DIRTY_PAGES unlock inode->i_lock __mark_inode_dirty:I_DIRTY_PAGES lock inode->i_lock -was dirty,inode stays in -b_dirty_time unlock inode->i_lock if(!(inode->i_state & I_DIRTY_All)) -not true,so nothing done This patch moves the dirty inode to b_dirty list when the inode currently is not queued in b_io or b_more_io list at the end of writeback_single_inode. Signed-off-by: Jing Xia --- fs/fs-writeback.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 591fe9cf1659..d7763feaf14a 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -1712,6 +1712,9 @@ static int writeback_single_inode(struct inode *inode, */ if (!(inode->i_state & I_DIRTY_ALL)) inode_cgwb_move_to_attached(inode, wb); + else if (!(inode->i_state & I_SYNC_QUEUED) && (inode->i_state & I_DIRTY)) + redirty_tail_locked(inode, wb); + spin_unlock(&wb->list_lock); inode_sync_complete(inode); out: -- 2.17.1