Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17840976rwd; Tue, 27 Jun 2023 08:11:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5yVv6xZxCsEhiucKLK4QiCvK1WwULKT1uQUDXUOdQdP4MIWE7w2wyqcBuU+OHLEKLVCGib X-Received: by 2002:a05:6a21:340a:b0:ef:7aa2:3cfd with SMTP id yn10-20020a056a21340a00b000ef7aa23cfdmr21385502pzb.50.1687878695637; Tue, 27 Jun 2023 08:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687878695; cv=none; d=google.com; s=arc-20160816; b=vsg1jwueiAQCwm16xFY3Xu2+YmuWM5e0ZEYWkp62b18+BiVeDHebfbhX7XQ5BRJU+N i/Akq27B/KOYbiT1WcRoAtaBnkTbclB65Qjag3ghiVowIEKs6ZqV1OmLeYT+dEC/2INU jOWRF7XjylY3qbTLEyKIJ6qajiRqi3bwlBQiAtP+5y73s04miYCLUncKLoVfQCHutoP8 nWzwDUN3HXADdXGl9PVWw7XhA7J9jWbf93CP3U3pWThaz/t7VJyLa52PSwnK5juPqvT2 Ue+NhJ/2KSwUvEVHKk3E6eOnmE03laUSBhZUAF6Pf6Hh+JMEgPc7+YGAWqHcv7TUmhiO fIKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2q4n1zKRqrV3v5scjVFFq+TN6vQz15i/WxunL9evbOk=; fh=7/+bH645pXOMPUvchXG33u55fF+jis9y1S98vUjQIUs=; b=jzEU944J+4CwCSbWuAuUj46QB1VPKNrClcyv7W6cH7IXBDfqd4bLe9XUVm+eVcLopK vv8jfbXZXbnsyF08QpLSrIr6QSId4/k1UF/W227JuWMzijysrIpNquaObu2QFhxFfpV+ u6YWu5jCPVi6by9uo8eoldRxkAHawMKTNJQkASBAz9ymzfz0BGuk4YCLKv0TA2AEKqoU qusry5mVPSmJue4+fExPKeNIL087PPSL+bLv8NWwF0PU1SSJsmAIpeliU2uDL2XeE9gS w8gPbDk/+0noQEt47kvOb0pKGMB7yj2kgcF4S4uQFO7ORizi7XHTOSqNky41l2Pl5TWR EhiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=PadBDPEn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f16-20020a631010000000b00552db08cd8bsi7721253pgl.730.2023.06.27.08.11.21; Tue, 27 Jun 2023 08:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=PadBDPEn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232277AbjF0Ovi (ORCPT + 99 others); Tue, 27 Jun 2023 10:51:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231684AbjF0OvT (ORCPT ); Tue, 27 Jun 2023 10:51:19 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BC8346BB; Tue, 27 Jun 2023 07:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2q4n1zKRqrV3v5scjVFFq+TN6vQz15i/WxunL9evbOk=; b=PadBDPEnw+r1U1a2NesSR9R0J3 4D4avMQnSzeeXMJTw4OZDlNRLAzlJoOTXBDCcYfMfgwnucu67fcOxbkZFax5h9PwM9a3oI3GEIw4n afRibzDA8+iYgWNTFxz5G9rROJXu4Acexu3PWFqA6XyZ4uMs8CYgWcmxlzch9cLoODVgX3GD9crJc D/b9QFOo77xyhUvjS68Fso+p5um4Dw3z05lScl7baFip/xNorcmYi67oqcV2tXXdJu7nf75qFy5fO gzpa+fFMOviRbwqTPE80Hm22Yo8vcBphziqcI6qLzanIu8lSi+Den6TujPfHnRibWe9W7aGMFa1hG DHt63sZQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1qE9zS-002oS5-26; Tue, 27 Jun 2023 14:48:22 +0000 Date: Tue, 27 Jun 2023 15:48:22 +0100 From: Matthew Wilcox To: Christoph Hellwig Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , David Howells Subject: Re: [PATCH 03/12] writeback: Factor should_writeback_folio() out of write_cache_pages() Message-ID: References: <20230626173521.459345-1-willy@infradead.org> <20230626173521.459345-4-willy@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 27, 2023 at 12:16:34PM +0100, Matthew Wilcox wrote: > This might be a good point to share that I'm considering (eventually) > not taking the folio lock here. > > My plan looks something like this (not fully baked): > > truncation (and similar) paths currently lock the folio, They would both > lock the folio _and_ claim that they were doing writeback on the folio. > > Filesystems would receive the folio from the writeback iterator with > the writeback flag already set. > > > This allows, eg, folio mapping/unmapping to take place completely > independent of writeback. That seems like a good thing; I can't see > why the two should be connected. Ah, i_size is a problem. With an extending write, i_size is updated while holding the folio lock. If we're writing back a partial folio, we zero the tail. That must not race with an extending write. So either we'd need to take both the folio lock & wb_lock when updating i_size, or we'd need to take both the lock and wb_lock when writing back the last page of a file.