From patchwork Mon Dec 18 15:35:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 180496 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp1327725dyi; Mon, 18 Dec 2023 07:38:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHs4n5z+dBA1yhWO7rfbrwsR9+K9gd1LYvT2mW1nqvUnFf7Vcd8GyD83t7M1poFcGpYybZw X-Received: by 2002:a05:6a20:8e04:b0:18c:ba47:74ea with SMTP id y4-20020a056a208e0400b0018cba4774eamr19901627pzj.31.1702913915881; Mon, 18 Dec 2023 07:38:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702913915; cv=none; d=google.com; s=arc-20160816; b=kc3sMyyyN4p8iOsfB2HE4E09JQAhaDXrX50PDBMMoJjoVbtvXN5E5ajTWBmPsFaHoM khRUtDKhDftfOt2hrVtt+1FnnUKxAqq2aKL9N854e5K7Y3TNTh4BNGDADfG32Lr1399+ 97aMRzwFI+fF35GWFzGprBJQbs+koIWshaA6u1qjtbq/N9ezn3rmiRSsGKV7OpKdqyVU XrqUReD4ebs93KVtljbGyVy5bU9kHFDq1jCllUdXP+Y08M3ufF9jyB5aBoFTyUVkuo8J lSJICuCW7g81WaaUcxKFxiTjtZ4ANUzqh4d4WomjJ1jsBNBXmoYsGKJM9gstXOOBjJ/7 LRTg== ARC-Message-Signature: i=1; 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:dkim-signature; bh=fDBIexIwQQEq1Dyw3cSe2v/4ysO2ouYCXslUPJX9cLQ=; fh=m0HBXuwgOCKat7wyuY7vstPypqMqxNmINnjBv5+EUjU=; b=a28h4B6hSvVF2Ahynu+KYvd65i5kFnIZ1NNvndp9jdVS7vA8rQX6QA/vEtfV1phEQr 2wrHcuRJM6moP9lTZx3mo4YSkfttbFf30wvj+huAG6wQIJXdL+l20wGLCET57iOhoumD ULRsRgM/6FA8YKRiCPuDSsYYd6+prshyfTSiPQJt5jG4OutQ17/fshiRiHnj4ecn3XdJ TxwZdEJkBY6Lwva5ORpoxIZbGduk4Kxn4gLSpKCWEORMiC4kFHMZVdK+yyrnnZlgfdt4 8Y08rr9A9xHhzz+XMmdrbeOqy15LExtkqEGZ2pIJJEFAH9BDgNjaNCctUVxJ9egvpcXg DGZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=VdO2027f; spf=pass (google.com: domain of linux-kernel+bounces-3948-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3948-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id bt21-20020a056a00439500b006d511505de0si3284519pfb.166.2023.12.18.07.38.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 07:38:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3948-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=VdO2027f; spf=pass (google.com: domain of linux-kernel+bounces-3948-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3948-ouuuleilei=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 A6125283B54 for ; Mon, 18 Dec 2023 15:38:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E2D75D721; Mon, 18 Dec 2023 15:36:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="VdO2027f" X-Original-To: linux-kernel@vger.kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 2DF1C5A865; Mon, 18 Dec 2023 15:36:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=fDBIexIwQQEq1Dyw3cSe2v/4ysO2ouYCXslUPJX9cLQ=; b=VdO2027fZSQ6+ARV1T/HY1vjUJ qO+GRQF4owYZjioIiUVuSwZTEQ/cN/nrg5ibAjNHnyq/cr4zSGzlcM3y2Q1UMgHoJjGN5t8V1EETI Dpwa6PCMko3S+HiZS52aj4OQNyFjw58ZygjiHjXBfLsvnE/Xaz+CYmUQUEyXNr1g8ps8aTfa+ueqv L5OSfZ0qwYzFm6wuHHBT8kMKqm3isVDi4DjtWHI7vcv8A1rqKaok+5uIIQfDRfIgfvKrprHGmV/PM XheCITb/c+GkDmqgc2t1vJgBr7RoVG3iJpGyIdSONPMKpgv5v6LKHArfqGzB8I/iBFTcGlAch4WA7 2FJMcPyw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rFFf3-00BEKx-2M; Mon, 18 Dec 2023 15:36:06 +0000 From: Christoph Hellwig To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/17] writeback: only update ->writeback_index for range_cyclic writeback Date: Mon, 18 Dec 2023 16:35:40 +0100 Message-Id: <20231218153553.807799-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231218153553.807799-1-hch@lst.de> References: <20231218153553.807799-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785634662105589684 X-GMAIL-MSGID: 1785634662105589684 mapping->writeback_index is only [1] used as the starting point for range_cyclic writeback, so there is no point in updating it for other types of writeback. [1] except for btrfs_defrag_file which does really odd things with mapping->writeback_index. But btrfs doesn't use write_cache_pages at all, so this isn't relevant here. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara --- mm/page-writeback.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 7ed6c2bc8dd51c..c798c0d6d0abb4 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2403,7 +2403,6 @@ int write_cache_pages(struct address_space *mapping, pgoff_t index; pgoff_t end; /* Inclusive */ pgoff_t done_index; - int range_whole = 0; xa_mark_t tag; folio_batch_init(&fbatch); @@ -2413,8 +2412,6 @@ int write_cache_pages(struct address_space *mapping, } else { index = wbc->range_start >> PAGE_SHIFT; end = wbc->range_end >> PAGE_SHIFT; - if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) - range_whole = 1; } if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) { tag_pages_for_writeback(mapping, index, end); @@ -2514,14 +2511,21 @@ int write_cache_pages(struct address_space *mapping, } /* - * If we hit the last page and there is more work to be done: wrap - * back the index back to the start of the file for the next - * time we are called. + * For range cyclic writeback we need to remember where we stopped so + * that we can continue there next time we are called. If we hit the + * last page and there is more work to be done, wrap back to the start + * of the file. + * + * For non-cyclic writeback we always start looking up at the beginning + * of the file if we are called again, which can only happen due to + * -ENOMEM from the file system. */ - if (wbc->range_cyclic && !done) - done_index = 0; - if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0)) - mapping->writeback_index = done_index; + if (wbc->range_cyclic) { + if (done) + mapping->writeback_index = done_index; + else + mapping->writeback_index = 0; + } return ret; }