Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp64341rdb; Thu, 21 Dec 2023 02:59:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnwuAEVAdaZIal/2b/UQ42VdGmQNJIgvEKNyhBT1a0JgJm5/5SDr1N41p2kx6K6tISUg3Q X-Received: by 2002:a05:6a00:170a:b0:6cd:faa6:fc4b with SMTP id h10-20020a056a00170a00b006cdfaa6fc4bmr27439522pfc.33.1703156394772; Thu, 21 Dec 2023 02:59:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703156394; cv=none; d=google.com; s=arc-20160816; b=KaPIDDhGcFnDbTF223JgN+FBfPA0mioc+lCG+IPUV3V7eKhXRyPE0WR8iez/Thy6PL 0fyUMtBEIsrq9jYZOS0/zCaaJBRu/OovrPDqjX7UXMNOXQ1tZ9RUL/N96TKQENCA1uGP bXNsMDgfFAK4SpvNReVFHp6YyF3TXUSTRPtJpyYuTaVgG1FTsZy4sKbP3cqPZ2b/BeCe gWgS55vWfbM6oozBALe64ydpObPExkoph1nLwa0OiWdOsaMT6viN8687VhhEGCl7YNgt 3R8hl9RtX6J1tduuppxZO82pODlWXtAXIGAXrp+Dyn20olMwPFsNEZlR8hx5PKw5Yhhc UK+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature; bh=9lr7w1qfXBqyv9nqbmtcLJAQk34Gbv+KRr+izpr/xd4=; fh=i6rGHk/clC1f9Y4mpJyYVOWW6p98QflrI/jjeassMJc=; b=iGDrA7fVUThYR8oVSK0OsC42yDjoIIbedzRdlqWrDHvoc8uwiN/2QvG8k2ItSFEg4R QBGMav/djzG1xcae+2l93wA0GmQcaiulSqafIEmUa02u9Lx2wZODIf+CpIoLpcE7J0K3 qN/xETZvg7bjNq3vl0lIzyZjQAFIB3Iz+EG+hFnIVuZtwhg5VHW1tslwScWjX8X4gzeX JAIS4/YikDip7R5t+9wUr0o7exM4lxEZbpFlDupO4v+ADY7jp9aKqW9AvXOiRxAlhXp/ ifFcDfmErKQjZByOTVD/JtsjYulExTyKeISrzhg8X3+dCGVI+M83uzzSMdDFYBDuxss9 h09w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=dYXJRTOF; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=sdHrz2rS; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-8255-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8255-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f17-20020a056a00239100b006d974a3e6cdsi801479pfc.264.2023.12.21.02.59.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 02:59:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8255-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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=dYXJRTOF; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=sdHrz2rS; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; spf=pass (google.com: domain of linux-kernel+bounces-8255-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8255-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 412CA286062 for ; Thu, 21 Dec 2023 10:59:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C617E6ABA9; Thu, 21 Dec 2023 10:59:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="dYXJRTOF"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="jotvAD5S"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="sdHrz2rS"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ANYb3JrT" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C170F6A02D; Thu, 21 Dec 2023 10:59:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C2EA021C5E; Thu, 21 Dec 2023 10:59:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1703156379; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9lr7w1qfXBqyv9nqbmtcLJAQk34Gbv+KRr+izpr/xd4=; b=dYXJRTOFpDduwZofbTStEhhIllBr0x/tOq5sQQNppYoKHnXxQldv7dfNTb0gX8u0L2t/Mn OToUxz14MtCjBRf7KNIIrCh1IOKghOo8WlW++4FZN1lvsfO5Rs86zqtAGy7PZULvGbpxiB +RVoepx00ZsNS/Sa+Mi0rTMab3ddm1A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1703156379; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9lr7w1qfXBqyv9nqbmtcLJAQk34Gbv+KRr+izpr/xd4=; b=jotvAD5Sup4uY5AoS+xXzCOomowB1BTS9w69zmXvvaBdt+G/2ebz4lkN6b7rHlMwLGBcl0 huaOENkpkgH6XzDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1703156378; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9lr7w1qfXBqyv9nqbmtcLJAQk34Gbv+KRr+izpr/xd4=; b=sdHrz2rSXSmj5jlM9KoOqHJeqUTm6rf+GsHhoGSgaTkEvG8Q5X8BiOqQuQR34AVfFc82BR 3zX4z0UNNG1rt6Olj0CPEy++M8WkJ+5UT4NIXlYquNU/GvUojr3nvWdzgkwiU4tMuYzg1b oceB3osZ8pgTbUVwTMBkn/yq6AkvXX0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1703156378; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=9lr7w1qfXBqyv9nqbmtcLJAQk34Gbv+KRr+izpr/xd4=; b=ANYb3JrT2fsxz4GV0aZdJApHl1LzLqxQgp8pyoy7vl0IrT6OYSAj/giYN8Gs/mSci7HCA0 z3eUrrmvd50A2WAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B8A0513725; Thu, 21 Dec 2023 10:59:38 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Rj8PLZoahGUxUQAAD6G6ig (envelope-from ); Thu, 21 Dec 2023 10:59:38 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 5BB51A07E3; Thu, 21 Dec 2023 11:59:34 +0100 (CET) Date: Thu, 21 Dec 2023 11:59:34 +0100 From: Jan Kara To: Christoph Hellwig Cc: linux-mm@kvack.org, "Matthew Wilcox (Oracle)" , Jan Kara , David Howells , Brian Foster , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 04/17] writeback: only update ->writeback_index for range_cyclic writeback Message-ID: <20231221105934.6bhdl73siuu3fct6@quack3> References: <20231218153553.807799-1-hch@lst.de> <20231218153553.807799-5-hch@lst.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231218153553.807799-5-hch@lst.de> X-Spam-Level: X-Spam-Level: X-Spamd-Result: default: False [-2.60 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[8]; DBL_BLOCKED_OPENRESOLVER(0.00)[lst.de:email,suse.com:email,suse.cz:email]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; MID_RHS_NOT_FQDN(0.50)[]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] Authentication-Results: smtp-out1.suse.de; none X-Spam-Score: -2.60 X-Spam-Flag: NO On Mon 18-12-23 16:35:40, Christoph Hellwig wrote: > 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 Looks good. Feel free to add: Reviewed-by: Jan Kara Honza > --- > 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; > } > -- > 2.39.2 > -- Jan Kara SUSE Labs, CR