Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp466808lqi; Thu, 7 Mar 2024 02:36:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUb2UHCB2khaQw24AF81IzRLoY0Op8L7dr0J+GxI1XnxAWmwIve6RwdYUoa9PM2ujNqOWyyG+PMmY9oMvpxMZy6v8QzeUrN2TLO/Nf5Cw== X-Google-Smtp-Source: AGHT+IH7VtTmTq8sZ2mYg75z7YthQmWlSIS70YaSvrtHuRIn/5PvgsVWTs4EmOVh/5GOaPjHvDyV X-Received: by 2002:a25:1645:0:b0:dcd:6c0:da64 with SMTP id 66-20020a251645000000b00dcd06c0da64mr13678121ybw.58.1709807804548; Thu, 07 Mar 2024 02:36:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709807804; cv=pass; d=google.com; s=arc-20160816; b=FgZ2HQUVIeccV16VIbLr6KvKPjacT9J5rGZwMbj/PYkSd81+sbPz3wvaUZTqee/Wac tWqDmuH7GA8kpx6xuYnXssZO9aA1axAM1uDh4uTAwf+i7/Pr52XlkJrZ5BldAeT2CjU4 kb7QQY+P57A3iTEGA71D+FVCSSTtGICxG7W6LiBzmCnoO310YbjP3ytLeZTOSxl8J8EY p1UpKmi0w/5xIG8PRN6RsdXdh90hsSFT9Gr1l7sRi+hG9J6ToAHcVaXCTXlZvXvqpPaV 2/hfh7erurANNjFyylEpdM0tsCQfbl7wMLPZqaWRFV2S6GSPWcwbQLcSwhqW10QunqaM 79Rg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-transfer-encoding:content-id:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:cc:to :references:in-reply-to:from:organization:dkim-signature; bh=rD9pKOLlJMagBhvvso8urKdJzEY4DWr9MOofjPhNFFA=; fh=Fs646Ctu1f1EZLkQtPigxfJGMO4ivmXWogfdC2XgNHM=; b=lJmJ761UtSHZPgE6YrVdRStGFyTh0U1rWzfe3IUrA02usUYRBeKGEayrffazv6Ppsy llxbHB0r6pEUxQJtE68gIqszTQ2PjLpqHqaV4QEhtZpmmSej6YyNNfDFHqLJd/xvRJ4O vyhFfGErVEPzybkP1ny3A+TsxcaSWJM2C6meIVEOJ14FHZuYYKOxxZXUyMybPEvhPWVg 1fhhtvpWS/c3g1DXWu+pNL+IjJyqpTWJglCwXVYHWXxoePYqos8DseS5TBeI7RESwBID uLIu3mm1bZvI1eDNxGZZCBRFTzYyMPF/deEjCjWYFUqDy8MyocaVB9IX2eCoJ1vzM7qa d8bA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CZRrB0zA; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-95345-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95345-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c6-20020ac87dc6000000b0042ef5ec8e41si8379550qte.679.2024.03.07.02.36.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 02:36:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95345-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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CZRrB0zA; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-95345-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95345-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 3A6AD1C20A43 for ; Thu, 7 Mar 2024 10:36:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE65985626; Thu, 7 Mar 2024 10:36:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CZRrB0zA" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 19F05EAEB for ; Thu, 7 Mar 2024 10:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709807797; cv=none; b=hq6xuhYCc3yClzmFAliz/dqZJA6J4ZfEbg39NleHpqncIvl4r4QZ2anw3s43OYBHqumumNbGNO9ZOIsXj5GG/kJuSu3PiqA9GSvAGDvT8uHnDtMJ/k6S6BQ+cs7EAsZMDiddst0D3Ga+H+RK5/9SV8SnVgXRPO/JSgisK97ozB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709807797; c=relaxed/simple; bh=oSvpQF78OH2SIBcN2hrMJ6J8dbzBxbdEOqWa3QXaon8=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=OhdICG91ko767L8hQXtZgpp+ZHlsM3dS5UsyLjZXFxnfGGBuAS6s+c8RYharzxWnTpFrHAaj9ri0Mde13t3PKfcxr4OyfJVYdRyjJPimI4mLxKXIUgfOaxnMOWH3LCkaV6f33jK92fJ/WDhfOXCAVgbxcIsBCUEoAv8VpuC6LFE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CZRrB0zA; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709807794; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rD9pKOLlJMagBhvvso8urKdJzEY4DWr9MOofjPhNFFA=; b=CZRrB0zA78RUduIO0smpVmRzUhPqgq+DsC9itHwWXuhRsQ0im+GgnjgNDbe8x+21JqQdRU rpyZ1cbQa+76eaKXXoy85+T5zzHU4WCCj2kXFqDEjBwWj3kvI1MbOzQr5abUQltFvp8z8x WmPtt/2cdBej1xOxEeeFGZzq4dykbRM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-358-zJKFNu4oMJWt0JTIEUyesQ-1; Thu, 07 Mar 2024 05:36:33 -0500 X-MC-Unique: zJKFNu4oMJWt0JTIEUyesQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F4E329AC020; Thu, 7 Mar 2024 10:36:32 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 23538C01600; Thu, 7 Mar 2024 10:36:29 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <1668172.1709764777@warthog.procyon.org.uk> To: Matthew Wilcox , Trond Myklebust , Miklos Szeredi , Christoph Hellwig Cc: dhowells@redhat.com, Andrew Morton , Alexander Viro , Christian Brauner , Jeff Layton , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, netfs@lists.linux.dev, v9fs@lists.linux.dev, linux-afs@lists.infradead.org, ceph-devel@vger.kernel.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, devel@lists.orangefs.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH] mm: Replace ->launder_folio() with flush and wait 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-ID: <1831808.1709807788.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Thu, 07 Mar 2024 10:36:28 +0000 Message-ID: <1831809.1709807788@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 Matthew Wilcox wrote: > On Wed, Mar 06, 2024 at 10:39:37PM +0000, David Howells wrote: > > Here's a patch to have a go at getting rid of ->launder_folio(). Sinc= e it's > > failable and cannot guarantee that pages in the range are removed, I'v= e tried > > to replace laundering with just flush-and-wait, dropping the folio loc= k around > > the I/O. > = > My sense is that ->launder_folio doesn't actually need to be replaced. > = > commit e3db7691e9f3dff3289f64e3d98583e28afe03db > Author: Trond Myklebust > Date: Wed Jan 10 23:15:39 2007 -0800 > = > [PATCH] NFS: Fix race in nfs_release_page() > = > NFS: Fix race in nfs_release_page() > = > invalidate_inode_pages2() may find the dirty bit has been set on= a page > owing to the fact that the page may still be mapped after it was= locked. > Only after the call to unmap_mapping_range() are we sure that th= e page > can no longer be dirtied. > In order to fix this, NFS has hooked the releasepage() method an= d tries > to write the page out between the call to unmap_mapping_range() = and the > call to remove_mapping(). This, however leads to deadlocks in th= e page > reclaim code, where the page may be locked without holding a ref= erence > to the inode or dentry. > = > Fix is to add a new address_space_operation, launder_page(), whi= ch will > attempt to write out a dirty page without releasing the page loc= k. > = > Signed-off-by: Trond Myklebust > = > I don't understand why this couldn't've been solved by page_mkwrite. > NFS did later add nfs_vm_page_mkwrite in July 2007, and maybe it's just > not needed any more? I haven't looked into it enough to make sure, > but my belief is that we should be able to get rid of it. Okay, it's slightly more complex than I thought - and I'm not sure all cal= lers are actually using it correctly. There are some additional interesting ca= ses I've found, beyond the pre-/post-DIO case: (1) NFS relies on it to retry the write before stripping the pages in the case where a writeback error occurs. I think this can probably be de= alt with by sticking a filemap_fdatawrite() call before the invalidation. I'm not sure if this would incur the deadlock with the page reclaim c= ode of which Trond speaks. (2) invalidate_inode_pages2() is used in some places to effect invalidati= on of the pagecache in the case where the server tells us that a third p= arty modified the server copy of a file. What the right behaviour should = be here, I'm not sure, but at the moment, any dirty data will get launde= red back to the server. Possibly it should be simply invalidated locally= or the user asked how they want to handle the divergence. Some filesystems use invalidate_remote_inode() instead which seems to leave the dirty pages in place locally. If it is desirous to save the dirty data, then filemap_fdatawrite() could be deployed before invalidating the pages. (3) Fuse uses invalidate_inode_pages2() in fuse_do_setattr() to strip all= the pages from an inode that has had its size changed, laundering any pag= e that's still dirty. This would seem to be excessive, but maybe Miklo= s had a reason for doing it that way. There are some places that should perhaps be using kiocb_invalidate_pages(= ) and kiocb_invalidate_post_direct_write() instead - assuming Christoph has = no objection to the latter function being exported. David