Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2276090rbb; Tue, 27 Feb 2024 17:25:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXQCnWgxT0Gopli3N+rgPPPURvEjupZXgauQHMT5mXtS2FcD+tY0vGvtNbYZ2eKVYPxYFxdtdYMcJo9y9+3YImas0v+z1BcfmRBDjIa3g== X-Google-Smtp-Source: AGHT+IH5FQVjZ8700w+Z8tudDrN8XRrMi3yKtm0UOp2ot9NJcMtkhjMZ8VG145io8smN+CMQdr5i X-Received: by 2002:a05:651c:2221:b0:2d2:6c9e:1035 with SMTP id y33-20020a05651c222100b002d26c9e1035mr9084994ljq.5.1709083523123; Tue, 27 Feb 2024 17:25:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709083523; cv=pass; d=google.com; s=arc-20160816; b=R+Jpuk/WeXYegA9QFH7u0iczaCymbOVg/onDV6feJ78Q7JBDW3zsfeIgJ7o11ZFGh7 6UNRtMHwmgvQ1aUDo5/3zJ38bpaHSuw/rUFjQ3wLb/rBjiT5JyZG+YCa18jadJCVSeVf HASuLJnMsQ1r3GCFgqov4v8KeDY4caXi5F2usAMSkxrWI1u7aj730QFpr7HS4com5HrY d1UBk7/AjYpRladFjtlfl5mjh1oRJeu2tfaD3UIPLI3fJ5K4P+THs1EmQB0nGUkN++yi NzV6xYmWlO+krf3xkzTMVU5JX0xwL5eZljmMvjwi8k7idnNpd18yHnU4PjMf4mmUrKUz 47EA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=FMMKc5dm7oGwPVnCfdovJL3oFncFeHb4dVX3GVkHgkM=; fh=y/7Wtt5UOSj/SCUlHdmMQBdr226cA96uA6lTOGta4DA=; b=CAYa6B7/fw0yp3wsU/xTwa6OVAp55ctEChdntpmFifN9PJyschniur29rtzi+1Rk9K hMz3S9I5Wr4UNKKyx9VYw0v+hQtFduC1wNMwEoLBA6zROCr4/MDsaVZ7CwUkYGj94a3E Llfw/m//kkc4FhWZdUztdadFulzoWd26mSL7enPFVjvmxwp9pF1zkFidTnI3rYYcfYRQ vcHC67PgZ/pgew/myCJb9PAeGUWntFj6siblUyrnjpRVwQdYpMd2TPXjBFNAnvkxjakb 6JX3PD1Tsrpim7bxB7g6M/r8YQP/DKevoeIUjXGyD6FPz/v0ApoFzh/Jab4V6PBYqLf+ W31A==; 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-84327-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84327-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r19-20020aa7da13000000b0056618452b17si1173279eds.186.2024.02.27.17.25.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 17:25:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84327-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-84327-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84327-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 DAF921F2307D for ; Wed, 28 Feb 2024 01:25:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7926A20DF5; Wed, 28 Feb 2024 01:23:17 +0000 (UTC) Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [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 D4326FBED; Wed, 28 Feb 2024 01:23:13 +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=1709083395; cv=none; b=ATPrBcSJO/IskJgntrhEI86rsIddrXQ6w4b8l4dBe5oXBm8QKTJzER39bpRNcIttDzRReZz6iv1Wh0QeVOV2sLX49joR60t48j/m+AQ1YPPd3ZgEvH3bkW2gumRBj4f8VyEY/HREAsV+UmzfLg2+EBRSrTpcy0thvuGrUOeEGgQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709083395; c=relaxed/simple; bh=wobu9kkXF6/BimHszN+V9hX7lzwqQsw+Tts6H4/vFXE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BiJ6e1Vc76rJ/2BumVQHSej3xnSr0OJcmXAZPBjvSInfNKGAsuXPygAzcTKQW6Ky8FxCQaqqskog8wSnfTB4Txa13xxzjS9RQ/eXB3N05k9LdIsgbj2KBnsPx4Q3VPxqIiVMit/EhkBSvvlqydIe2ALOHLf91D4jXzAdEkY3rrA= 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.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4TkxSC1QSLz4f3kK0; Wed, 28 Feb 2024 09:23:07 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 89F3B1A056D; Wed, 28 Feb 2024 09:23:10 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP1 (Coremail) with SMTP id cCh0CgDX8gv7it5lqQx6FQ--.57137S6; Wed, 28 Feb 2024 09:23:10 +0800 (CST) From: Kemeng Shi To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, tim.c.chen@linux.intel.com Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/6] fs/writeback: only calculate dirtied_before when b_io is empty Date: Wed, 28 Feb 2024 17:19:56 +0800 Message-Id: <20240228091958.288260-5-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240228091958.288260-1-shikemeng@huaweicloud.com> References: <20240228091958.288260-1-shikemeng@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgDX8gv7it5lqQx6FQ--.57137S6 X-Coremail-Antispam: 1UD129KBjvJXoW7tFy3uF17Kw17ZF45XFWUJwb_yoW8GFWrpF Zxt34Skr4jva1Sgrn7A3W29r1Fgw48GF47A3yxZFyfZw13Za42ga4Dt348Kw1kJr47Xr9a vws5GFWxC340yr7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUB2b4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAv FVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJw A2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE 3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AIxVAIcxkEcVAq07x20xvEncxIr2 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUIL05UUUUU X-CM-SenderInfo: 5vklyvpphqwq5kxd4v5lfo033gof0z/ The dirtied_before is only used when b_io is not empty, so only calculate when b_io is not empty. Signed-off-by: Kemeng Shi --- fs/fs-writeback.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c index 1c3134817865..c98684e9e6ba 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2105,20 +2105,21 @@ static long wb_writeback(struct bdi_writeback *wb, spin_lock(&wb->list_lock); - /* - * Kupdate and background works are special and we want to - * include all inodes that need writing. Livelock avoidance is - * handled by these works yielding to any other work so we are - * safe. - */ - if (work->for_kupdate) { - dirtied_before = jiffies - - msecs_to_jiffies(dirty_expire_interval * 10); - } else if (work->for_background) - dirtied_before = jiffies; - trace_writeback_start(wb, work); if (list_empty(&wb->b_io)) { + /* + * Kupdate and background works are special and we want + * to include all inodes that need writing. Livelock + * avoidance is handled by these works yielding to any + * other work so we are safe. + */ + if (work->for_kupdate) { + dirtied_before = jiffies - + msecs_to_jiffies(dirty_expire_interval * + 10); + } else if (work->for_background) + dirtied_before = jiffies; + queue_io(wb, work, dirtied_before); queued = true; } -- 2.30.0