Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp145399rdb; Thu, 8 Feb 2024 01:27:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcUCINqb8Uv2KovFHXix6dbrwUe7pFeZc//mgTEkqFHEiHmdpjY5tpCcesMJid5Z26WA94 X-Received: by 2002:a17:90b:817:b0:295:f706:add5 with SMTP id bk23-20020a17090b081700b00295f706add5mr3085173pjb.24.1707384426458; Thu, 08 Feb 2024 01:27:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707384426; cv=pass; d=google.com; s=arc-20160816; b=ggiZG7zYXP9Ch14Zy/BXpDpUe3tGIGiNp8uV9wHwLoYVxGY7Lsz916yJL4vTa+AROI 5vIY16hWfgr8LbVozj+1a6SmhHI06uBy8dBy77p7zfkJNJFrpAFEUH78cZVjqe0k7nTg uhg3bT/8fjwqSI2nKW6kaGoGs5yLSOzEVdUQ4Dic30oyRnE+Bd+UwkX6eu9rbeNukV4W 3+JuZShKL7IcytR7OV0jmRMeyQMETosluze77arJ43aaTfDnTwWFw9TykFzSYUIKH0+7 h8DdLsWtwJdQlL8NrqN3b6phNMjQaSoN9E+U3VIZgtyLCBhM6+V9BmfXvKVFvJqDZlFo f/SQ== 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=d5gDhkwcs4L5yBRyFroHJbX+9G2HHje3LIbIQe5Bqzo=; fh=3GmiKxsZCZhuziQsHrcuVujvvEayc4u8EoDRCKiDuvM=; b=IXcHK4jMGbRVhiqiL18Vm7TIGH1aSn/fN0UjZjZLiCk59xEPDhLKjIRDHlntXDGBbe 16D4PjyJGFnVBB4NPE2YddYTmSfGH6P7cSwZkepAvj7fpSesFgQ/2/hKTXPaEb4FU4hc O0Bl1iZAmIz8bxoBxt/lgFrH3mVdzlCFPrwtXC2Ws84e41zgASk0SfFEP8YrAS+PnHap ccGxnSW541F4jha7HfQBykiFCOc7ltAm3Kj2llhmQFAC8irbSysdVqFm0AoOjs0OGY0L H+QeDzT/UPMv5vatkrKFBQaZ+WLOLvGrdJTOXYXsjStt/Rzqd5ZZNZttWAHxY8kCOkYT lgGw==; 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-57737-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57737-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCUm22tGfg2I2kmx2dh8mgMhB2D0sYk2uxIrpm1vIUf18MO0afbsouh/oRV1gAcxnvdMPCoMxa1FCZmCowXw19XzpV90AZEz1b7ye5xhMg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ee6-20020a17090afc4600b00296e583547dsi1031416pjb.118.2024.02.08.01.27.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Feb 2024 01:27:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57737-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-57737-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57737-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 2190A282C06 for ; Thu, 8 Feb 2024 09:27:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12A00762E7; Thu, 8 Feb 2024 09:23:15 +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 1063A6BB49; Thu, 8 Feb 2024 09:23:10 +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=1707384194; cv=none; b=bgBkcWns0VY01dhoJeNvXQqUZTRdFOv6wtlBOxCdxclVpbBtC9BzAp9Rv/kYBFCiSkKkyeDzzt1gTnC4zqwzIcZT+pK3j5DxuxDdw1zt/LXEJ6fv5cnDJqlPSsY8qAyMRMeEVd0Lbqf5DTVVq/wPtE98zYMyBAtlG04XkEKljcA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707384194; c=relaxed/simple; bh=r/VLr9jN9dklOWb2ltJL6vuxoLRUWPZW50wD8+UThOQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MB4cZ+4h79T4h0/3i4n4559+Ka57OdyxqTkugR2bTrMPEL65Y7nCAKqFMtgrAB2q+EKEAI8vOGz/suU06cRNWrnaePJLRs7Be4+Q98AfB+pKxRBCftRnKd4Cj9GxOnEcwcS0BnzDnM99R/ZP+YaO9swMrtPl0ikctEMQgUiVY9s= 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 4TVs3F1MYsz4f3kk5; Thu, 8 Feb 2024 17:23:05 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 05B111A016E; Thu, 8 Feb 2024 17:23:08 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.124.27]) by APP2 (Coremail) with SMTP id Syh0CgAnSQx4ncRl3tGXDQ--.8574S7; Thu, 08 Feb 2024 17:23:07 +0800 (CST) From: Kemeng Shi To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] fs/writeback: only calculate dirtied_before when b_io is empty Date: Fri, 9 Feb 2024 01:20:22 +0800 Message-Id: <20240208172024.23625-6-shikemeng@huaweicloud.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20240208172024.23625-1-shikemeng@huaweicloud.com> References: <20240208172024.23625-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:Syh0CgAnSQx4ncRl3tGXDQ--.8574S7 X-Coremail-Antispam: 1UD129KBjvJXoW7tFykCr17uFy7tFWxur4kZwb_yoW8GFWrpF Zxt3sxKr4jvw4Sgrn7A3W29r1rWw4xGF47A34xZFyIvw13Za42ga4vq348Kw1kJr47Zr9a vws8GFWxC348t3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBFb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k2 6cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M280x2IEY4vEnII2IxkI6r1a6r45M2 8IrcIa0xkI8VA2jI8067AKxVWUAVCq3wA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAv FVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7Jw A2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv67AKxVW0oVCq 3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_GcCE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8w Aqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE 14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E 7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcV C0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF 04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7 CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jstxDUUUUU= 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 b61bf2075931..e8868e814e0a 100644 --- a/fs/fs-writeback.c +++ b/fs/fs-writeback.c @@ -2118,20 +2118,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