Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp900102lqt; Tue, 19 Mar 2024 07:15:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkGoGl+k6fpYybh62FlmDeq3mGWCwl3s1Zm5IkgkF1VXymaTqIKSy+gCGlbloBHjn5Uedm6jgS+SwsRhl7j2cEdKUzxRdnSR9aXjEG/g== X-Google-Smtp-Source: AGHT+IGTVYW5EDopsydDojvEEuryv8dGGSbaEtLO8vfMklKAGQqMXouCeypm3LJAZKHstociV5gF X-Received: by 2002:a05:6871:807:b0:21e:6d57:81f7 with SMTP id q7-20020a056871080700b0021e6d5781f7mr17357251oap.17.1710857704415; Tue, 19 Mar 2024 07:15:04 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710857704; cv=pass; d=google.com; s=arc-20160816; b=OingqeXVxqOkvMm+IimckZzGGDMmPgb8/2/A6/1zUeUzWf99EE0cPhoWqqD17nHhNw Iws9A+rVB8MLnztAgSC0wxbrZu1RjLsl3QiFfanQ/uFQ/bwoT242BzdhbM6efrg1CqNf Fi5PaWSjJ+8wk8fQgiHov1oLBNOGvFnP1wQskiRKpihXgE6WxK6Kpx+sSD0hbzOhz1Iy MRDd8/rscSZIycKh47XE2ACYBcsS2OhpOewNpE/PUpU52TE+AL/Lq3+H7CAW4Pf9ZhLg Jw7fW+KdEvH3MvhLsmVabdrcnWjadgF5kEmuso+MX4wJjizlMtCPbfyVy2OYrER6PyAW BzrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:cc:to:references :in-reply-to:from:organization:dkim-signature; bh=tO0V8aj/5qg/fr51DKNlXHyJU/GLErDbNftb0tj9j8Q=; fh=hZHbsLlDCmvEoxuIMkIPgIAEeB4IbsGpYKTRUhuhTd0=; b=C3Q6iamGqNlGwdO4NypYkVnAXta/1o57hf3Ng/B835qmcdmWUXCFOFP/vg0pemgjVy DRh6Z/gJ7B8+o5sgbsZF25S3noh+wE3TxtrMbi0rnQniaxwAsAOj/JGnmoRqJX1hD2se G3VobjDeWGTGbRs6zImvaK9z38AWl6taqVTxfiSrkG4WaQ5EAgfskiHQLpuQY5ornpsM aHmALvXJwSeL8yMcAZ4Wh11M5gKQXtUDtsTGxCy/QJVyiSj79nu7AV5+/RPzGhjeDamz TQNhp2R06u/E6J3L7OWZiPghCvkpkf5oOS9elrpW7q5UuCMTvpIw05kJNHAyzApmj8Iw unrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RtvmcyL4; 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-nfs+bounces-2395-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2395-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. [147.75.199.223]) by mx.google.com with ESMTPS id 8-20020ad45b88000000b006903099b236si10854240qvp.504.2024.03.19.07.15.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 07:15:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2395-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RtvmcyL4; 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-nfs+bounces-2395-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2395-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 22F5E1C22669 for ; Tue, 19 Mar 2024 14:15:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FB3B8174B; Tue, 19 Mar 2024 14:15:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RtvmcyL4" X-Original-To: linux-nfs@vger.kernel.org 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 936BD3BBD4 for ; Tue, 19 Mar 2024 14:14:59 +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=1710857701; cv=none; b=JR77aWTSDS9u11uf2BaQwnY+yJvDSE2+mgxragQNe/WSXE7hp4NA2rmNu4/Am7Ag4DdROk8RDOZeoKpC3UrtU3xfcC9corB7kDlp5MfIp6S+cFtYadge4iWjq9wdPYn2IXZSG3x/kGpyxSn44YLAANgfI/Jkb3qXPfwxE3ckKJo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710857701; c=relaxed/simple; bh=xkAb1InU9RoZkNjiU+AcuFfqyRq8G3AqX8f6uQ9VC8Q=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=gwxgpg4nt8UNCDGhXUmJ7UcIcCxLjZLG7EpcHFEqKvGPEzjk+Hn4RhvbCkjc9Fyizyg9FjCSlkWG6yZt5FEvbIXAEjqCna+zPED06u9zjT7HYJVnoDmOMlTgy54fmTPZ85OCFvaY/RNLPAbwiHtD9y1JhR0aaCXOYYGQp4XrZR0= 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=RtvmcyL4; 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=1710857698; 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: in-reply-to:in-reply-to:references:references; bh=tO0V8aj/5qg/fr51DKNlXHyJU/GLErDbNftb0tj9j8Q=; b=RtvmcyL4kzI30IanKwMzmLkflj0sG042jvnU7holnqxmexELP7MxHJeDyH+CiHgVXrWJGB pp+H3run3aSqbtOrP8WXieOQcLYaMK5Gx9x0X4nKKLQnIOwUcWeWg6OU7EA48R2zZYSuZg Yc/zWnfO4Jjimyw24NhDy2Z9zlHj82I= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-368--eOoKW_BP26pSFwrkb5TTQ-1; Tue, 19 Mar 2024 10:14:56 -0400 X-MC-Unique: -eOoKW_BP26pSFwrkb5TTQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 5463C101CF81; Tue, 19 Mar 2024 14:14:55 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58E25492BD0; Tue, 19 Mar 2024 14:14:52 +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> <1831809.1709807788@warthog.procyon.org.uk> To: Miklos Szeredi Cc: dhowells@redhat.com, Matthew Wilcox , Trond Myklebust , Christoph Hellwig , 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-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <651178.1710857687.1@warthog.procyon.org.uk> Date: Tue, 19 Mar 2024 14:14:47 +0000 Message-ID: <651179.1710857687@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Miklos Szeredi wrote: > > (2) invalidate_inode_pages2() is used in some places to effect > > invalidation of the pagecache in the case where the server tells us > > that a third party 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 laundered back to the server. Possibly it should > > be simply invalidated locally or the user asked how they want to > > handle the divergence. > > Skipping ->launder_page will mean there's a window where the data > *will* be lost, AFAICS. > > Of course concurrent cached writes on different hosts against the same > region (the size of which depends on how the caching is done) will > conflict. Indeed. Depending on when you're using invalidate_inode_pages2() and co. and what circumstances you're using it for, you *are* going to suffer data loss. For instance, if you have dirty data on the local host and get an invalidation notification from the server: if you write just your dirty data back, you may corrupt the file on the server, losing the third party changes; if you write back your entire copy of the file, you might avoid corrupting the file, but completely obliterate the third party changes; if you discard your changes, you lose those instead, but save the third party changes. I'm working towards supporting disconnected operation where I'll need to add some sort of user interaction mechanism that will allow the user to say how they want to handle this. > But if concurrent writes are to different regions, then they shouldn't > be lost, no? Without the current ->launder_page thing I don't see how > that could be guaranteed. Define "different regions". If they're not on the same folios, then why would they be lost by simply flushing the data before doing the invalidation? If they are on different parts of the same folio, all the above still apply when you flush the whole folio. Now, you can mitigate the latter case by keeping track of which bytes changed, but that still allows you to corrupt the file by writing back just your particular changes. And then there's the joker in the deck: mmap. The main advantage of invalidate_inode_pages2() is that it forcibly unmaps the page before laundering it. However, this doesn't prevent you then corrupting the upstream copy by writing the changes back. What particular usage case of invalidate_inode_pages2() are you thinking of? DIO read/write can only be best effort: flush, invalidate then do the DIO which may bring the buffers back in because they're mmapped. In which case doing a flush and a non-laundering invalidate that leaves dirty pages in place ought to be fine. David