Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp1035649rdb; Tue, 30 Jan 2024 06:16:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IEyKE5aWevVi7CXVYnoCnhZh9RncVuSu2YRAC6my6CnYSz+4/qkbyAzvxzoa4nmz9C7LMnm X-Received: by 2002:ad4:5bcc:0:b0:68c:4ac9:7693 with SMTP id t12-20020ad45bcc000000b0068c4ac97693mr5612976qvt.106.1706624180284; Tue, 30 Jan 2024 06:16:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706624180; cv=pass; d=google.com; s=arc-20160816; b=Ophj8uCCN+puIzN8UAJw1i4FE6hhSJYFyNaFkpqK7VPt+yTEqEKkLyQSQTjS897NFQ +1p9L6a8UV/8yoY0u78jm4FIZgrsvhcUdBC2R3zxqmheCNuN/XARyEAz5izaAxxaM0D0 VBwGkO4YUIF+iKsLJIsoFVG3jFQ+5bcuUezVaY4KpE8oaDyeB9/0/TdXxldvaZ/EHLEP VYmQLLGM2flRiodjHunD40cxvIeRMfS9rUEIvYZSEiq8DPLv1WesD5TDfAKqNlvMgQLe iLqRJCEujYYsWyTHEd+78oLccWyLZZgExnm3fg9I0qYLlN2G9VCRumNt2k4Zy2btV2xB usGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date; bh=cI5g0uYBr+vLeFJJ5y1vPxAZ0Tx+uCAvCHpzBjq2PmU=; fh=nXbUcV7x7g6s4I96XK8uOKt4C3JEo1/jzFKCJ616FQI=; b=fSsMQSO1Ryt/uqChgmYDrdPOwYLwc2yssIG7Igsn6d8pSqkDu2CXMJFPH/OuGuaykB hQolFCsqqjYOmBAQ4xe30brAAzdGMNRIYYuxSddRgofqlmnQi1L2WpliDouOITXJr+3I F6psZr+iAcBsWgTd+TbdFggzC2LTbmS4WaJAh7wE5qkceKlX9ynOOwu7ERPSWneSVLcB r65HipwoYhtE9T4KGseqiPxGUwjKD40eNimhZaJB/evsmiHwfaR5qpAM6UoQwCKXVEzL dUXVN564MASoJIUaLe52xzrUcW9eiI5JcfAWYL8dN5sEXvOJuxtdxBHTClE9SiY+l4no nJIA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=lst.de); spf=pass (google.com: domain of linux-kernel+bounces-44736-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44736-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id e7-20020a0562141d0700b0067f8393c2adsi8325022qvd.560.2024.01.30.06.16.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 06:16:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44736-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=lst.de); spf=pass (google.com: domain of linux-kernel+bounces-44736-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44736-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0E5CE1C210CA for ; Tue, 30 Jan 2024 14:16:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01DEC6DD0F; Tue, 30 Jan 2024 14:16:09 +0000 (UTC) Received: from verein.lst.de (verein.lst.de [213.95.11.211]) (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 9BD3F6DCE8; Tue, 30 Jan 2024 14:16:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.95.11.211 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706624168; cv=none; b=CzaTPxWoGGAml0EdGV7eXO5QpJfjPT9/nXEZz0jXMsc6ztp/ve5vQ5m8WP57NgCq98zW8mQmUZVUmJ4z+xn/y43HYYDV8WElRseDidnGcyYJg/C+1xqha2VUulnH28uIIFYNmYKVw9qCRbirF+BQSQYxv/8AZCZoGx72rUAQYak= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706624168; c=relaxed/simple; bh=ImXecEhuep996vGaWscJBS4axlSdLV1KhnIAesMx3bM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QA0stswuJyP7ZLuPv6KLqXt3Cnne3zZY5E/XWWSKmbAoUBdloDfIR1WKKOvJEfSxxb2JUIhH8ZpxipVrQxDrsQd/4olQgjwvRIkr+2zWOO5hhTnEq6GDFMC3C8lvKWxAhOkhJAUepBVyZMrG2O6FdKolrYtJTXUAZWxruiK4KIM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=pass smtp.mailfrom=lst.de; arc=none smtp.client-ip=213.95.11.211 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lst.de Received: by verein.lst.de (Postfix, from userid 2407) id 9847868C4E; Tue, 30 Jan 2024 15:16:01 +0100 (CET) Date: Tue, 30 Jan 2024 15:16:01 +0100 From: Christoph Hellwig To: Jan Kara Cc: Christoph Hellwig , linux-mm@kvack.org, Matthew Wilcox , Jan Kara , David Howells , Brian Foster , Christian Brauner , "Darrick J. Wong" , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 19/19] writeback: simplify writeback iteration Message-ID: <20240130141601.GA31330@lst.de> References: <20240125085758.2393327-1-hch@lst.de> <20240125085758.2393327-20-hch@lst.de> <20240130104605.2i6mmdncuhwwwfin@quack3> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240130104605.2i6mmdncuhwwwfin@quack3> User-Agent: Mutt/1.5.17 (2007-11-01) On Tue, Jan 30, 2024 at 11:46:05AM +0100, Jan Kara wrote: > Looking at it now I'm thinking whether we would not be better off to > completely dump the 'error' argument of writeback_iter() / > writeback_iter_next() and just make all .writepage implementations set > wbc->err directly. But that means touching all the ~20 writepage > implementations we still have... Heh. I actually had an earlier version that looked at wbc->err in the ->writepages callers. But it felt a bit too ugly. > > + */ > > + if (wbc->sync_mode == WB_SYNC_NONE && > > + (wbc->err || wbc->nr_to_write <= 0)) > > + goto finish; > > I think it would be a bit more comprehensible if we replace the goto with: > folio_batch_release(&wbc->fbatch); > if (wbc->range_cyclic) > mapping->writeback_index = > folio->index + folio_nr_pages(folio); > *error = wbc->err; > return NULL; I agree that keeping the logic on when to break and when to set the writeback_index is good, but duplicating the batch release and error assignment seems a bit suboptimal. Let me know what you think of the alternatŃ–ve variant below. > > + struct folio *folio = 0; > ^^ NULL please Fixed. > > ret = writeback_use_writepage(mapping, wbc); > > + if (!ret) > > + ret = wbc->err; > > AFAICT this should not be needed as writeback_iter() made sure wbc->err is > returned when set? Heh. That's a leftover from my above mentioned different attempt at error handling and shouldn't have stayed in.