Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp464157rdb; Sat, 17 Feb 2024 18:11:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXmOu1nVpSMKsZrxZyJPQh4GMrcjMCX7buZ1962Ggrt4QUqQxTV3Iw2rCnUCxwQVEqjlNJA47DFaFuSNi6J1vvhiyZMK5nv+I8yi0ZX4w== X-Google-Smtp-Source: AGHT+IH9necG+dBRSrsOTIhbQtcEv6Vxj1min3E+6rYWcmxNxW4HiHj1mzniIy/ol1ybdqzHoLt6 X-Received: by 2002:a05:6512:1150:b0:512:8a8f:4bf9 with SMTP id m16-20020a056512115000b005128a8f4bf9mr5954618lfg.66.1708222315620; Sat, 17 Feb 2024 18:11:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708222315; cv=pass; d=google.com; s=arc-20160816; b=Lfrwu7zLRdD1ky9HN9Mdvnnoretincz9fQGkAjGUNDnfZrnn8tiAb7C3WvCg/VKK1V tehVk3TTdlT6D65UhhF1G+CJfU4KPDQxKOiCx1NprX0OU2r6eE8ZElDHWSzfjN71u3Xn 2DrP7mT00wFbzPpZW6Eh+emcFUwCtRAvthwLhziJbMJ06kpjkKDI9uIoHUy7sCI3IG69 V3wLbNdXTMFo7pV4rPDkyPb1j97u71e0c/IG70EbEPPWjJRUEAWz2w6lz6euhtb7g5Rd 3kfw3bLT7LRRp/lbwQdYCM2/2fr2LwXOVPjxQ3Pd2RIMCKWCNBsUUPYUUndu1LsySULN Px5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:cc:to:subject; bh=6urQUtqKPvhfFzcOLZVRmSEjpPV631V4xGrPao0j4Hk=; fh=snXmzSMKyyW/OP1KaM2PppFnHaSnLM2IYKXcvxNZNog=; b=DiMdlNezMyAUMUMUUMCNbIjBq2ZTqCpz/qGNc6QtrqxRHaG8EwkcUOkpVhT2F6PrAl WOo2UNWM170Z7xa5zMBqidO0ThqbITKHf0Vun2ZXidKfddjL2FAd5VivY6X4JjnJIwq4 w8nNB9sCJPnLWA0ulnnOkbHV50lmcOCsZBI0POPwnx3QaOeTQq10LHWdRx6G7Bk1XvkM OLxQC1V6roRmSSAk+fBYVvhYVRNjD9mi8Ouhx+hiSwzfNLEZ/WVU6wZL6+v5/6+fi78A rdFP0TbKN4thiRAc/I+Oyvorja9nInmnDJUjeJgY7ohmfYIJG7VwH1mhydL4UXoD3Zjs P3zQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-70149-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70149-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id le4-20020a170907170400b00a3e0d50c8f1si1137789ejc.1028.2024.02.17.18.11.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 18:11:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70149-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-70149-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70149-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5C50F1F21B83 for ; Sun, 18 Feb 2024 02:11:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D05117FF; Sun, 18 Feb 2024 02:11:47 +0000 (UTC) Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64F54EA4; Sun, 18 Feb 2024 02:11:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708222306; cv=none; b=d5toFk52QuFMnxMibZ3NnfLoYcLJgpX7ZuyWre/Rxn5JwPuasfgJJy/vz/5+s0X85EZ3rs7Vy2J3dKKi9nAeiZQoKr+2uo7f5dey/GRImebWNyV4eltLHQVKyvqIhXc37TNzRm4CRj8ufDbLTZcNDugRhQGpsQ9FyvSKECARNLI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708222306; c=relaxed/simple; bh=jvy6VlvkMJg85//QhK6/hGyp7KCFJSO3KQbJdFbXdPg=; h=Subject:To:Cc:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=MSX9rvi7a+o6KFqTP8kdv/PII4l8Odmp0GliRJdKqFEzZxsqjk+sTXSZTUVL4Rd+Np27hJST3OfOlgDO/bpL03+nv4lAtyhIVwTFlLccQaqgGR6Ueiww9WA1nGf0wSxLc3Y2sz4sDkzAyqkJC98F6yM7QGnIbQ80LrJzzWsrt/A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Tcq0n6qV8z4f3k6L; Sun, 18 Feb 2024 10:11:37 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.252]) by mail.maildlp.com (Postfix) with ESMTP id 09CDF1A0172; Sun, 18 Feb 2024 10:11:41 +0800 (CST) Received: from [10.174.178.129] (unknown [10.174.178.129]) by APP3 (Coremail) with SMTP id _Ch0CgAnNZ1cZ9FlYBQdEQ--.23895S2; Sun, 18 Feb 2024 10:11:40 +0800 (CST) Subject: Re: [PATCH 2/7] fs/writeback: bail out if there is no more inodes for IO and queued once To: Tim Chen , viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240208172024.23625-1-shikemeng@huaweicloud.com> <20240208172024.23625-3-shikemeng@huaweicloud.com> From: Kemeng Shi Message-ID: Date: Sun, 18 Feb 2024 10:11:40 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-CM-TRANSID:_Ch0CgAnNZ1cZ9FlYBQdEQ--.23895S2 X-Coremail-Antispam: 1UD129KBjvJXoW7WFyrKFy8WFy7KrWDtr43Jrb_yoW8ZFWkpF WrtFy5KFWqy3y7Crn7Ca42qr1aqw4DtF45Jryfu3WUtr93ZFy09Fy0gr1FyF1xA3y3uFWI vr4rX348Jry8t3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4 vEj48ve4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Ar0_tr1l84ACjcxK6xIIjxv20xvEc7Cj xVAFwI0_Gr1j6F4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x 0267AKxVW0oVCq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG 6I80ewAv7VC0I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFV Cjc4AY6r1j6r4UM4x0Y48IcVAKI48JMxk0xIA0c2IEe2xFo4CEbIxvr21l42xK82IYc2Ij 64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x 8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE 2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42 xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv 6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUrNtxDUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ on 2/9/2024 3:21 AM, Tim Chen wrote: > On Fri, 2024-02-09 at 01:20 +0800, Kemeng Shi wrote: >> For case there is no more inodes for IO in io list from last wb_writeback, >> We may bail out early even there is inode in dirty list should be written >> back. Only bail out when we queued once to avoid missing dirtied inode. >> >> This is from code reading... >> >> Signed-off-by: Kemeng Shi >> --- >> fs/fs-writeback.c | 7 +++++-- >> 1 file changed, 5 insertions(+), 2 deletions(-) >> >> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c >> index a9a918972719..edb0cff51673 100644 >> --- a/fs/fs-writeback.c >> +++ b/fs/fs-writeback.c >> @@ -2086,6 +2086,7 @@ static long wb_writeback(struct bdi_writeback *wb, >> struct inode *inode; >> long progress; >> struct blk_plug plug; >> + bool queued = false; >> >> if (work->for_kupdate) >> filter_expired_io(wb); >> @@ -2131,8 +2132,10 @@ static long wb_writeback(struct bdi_writeback *wb, >> dirtied_before = jiffies; >> >> trace_writeback_start(wb, work); >> - if (list_empty(&wb->b_io)) >> + if (list_empty(&wb->b_io)) { >> queue_io(wb, work, dirtied_before); >> + queued = true; >> + } >> if (work->sb) >> progress = writeback_sb_inodes(work->sb, wb, work); >> else >> @@ -2155,7 +2158,7 @@ static long wb_writeback(struct bdi_writeback *wb, >> /* >> * No more inodes for IO, bail >> */ >> - if (list_empty(&wb->b_more_io)) { >> + if (list_empty(&wb->b_more_io) && queued) { > > Wonder if we can simply do > if (list_empty(&wb->b_more_io) && list_empty(&wb->b_io)) { > > if the intention is to not bail if there are still inodes to be be flushed. I suppose not as there may be inodes in wb->b_dirty should be flushed. For case that there is a inode in wb->b_io which is not flushed in last wb_writeback and there are a lot of inodes in wb->dirty, the next background flush is supposed to make dirty pages under threshold however only the inode in wb->b_io is flushed. > > Tim > >> spin_unlock(&wb->list_lock); >> break; >> } >