From patchwork Mon Jul 29 16:19:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13745305 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0F03C3DA7E for ; Mon, 29 Jul 2024 16:23:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7498A6B00BA; Mon, 29 Jul 2024 12:23:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FAAD6B00BC; Mon, 29 Jul 2024 12:23:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59B3A6B00BD; Mon, 29 Jul 2024 12:23:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 365A46B00BA for ; Mon, 29 Jul 2024 12:23:02 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E6BA616046F for ; Mon, 29 Jul 2024 16:23:01 +0000 (UTC) X-FDA: 82393309362.14.7F59101 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 3D0591C0023 for ; Mon, 29 Jul 2024 16:23:00 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SbvPr75K; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722270153; a=rsa-sha256; cv=none; b=8TUr3D20l1rzpoynirweSL/8HxOwzbiNpadHoEcfc8xguGER2hftZSYdcq/ALN1YnbYKoc uZ7xlgofbR7rcQbqAAmFxhJ6vmIeW6fAbYRbIq86zo58o40eDu9kCJB7y85zzoPnTkQljz rUNhqiOOOBqkGZacoUsKvjQ0DJRP8oc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SbvPr75K; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722270153; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=x0kZOPMyNmDVYhInpXB87sOLpVD7+5JBPbyefcGWBPI=; b=O+WWQZKeAz3Ka+325XpPHZpNhyOxjsNL0ki/7w1XOxW2xprpxemWuY6SLiV1vAqfhH8c0H JdEU3Zm2D5gkANn5wesnhYDwF+C8JjXsZP2e2coFZwTEhk3FORZY9QNXQB/L2Uw/JQceSv gjzzgX3tKjpgjHoddIfhD4FniFJt41g= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722270179; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x0kZOPMyNmDVYhInpXB87sOLpVD7+5JBPbyefcGWBPI=; b=SbvPr75KrD1cKg6jj3LYb+56a3uqCr2k7JTXhhB46T9YJgRPc/eM77F7J95F874XcDzSnR rcl4qnFy+Kt5FagDBbrcjZUBIrY3kmq2TbPtJWRgn1z5EWFKO4Ssh+RF9QJD7+xT98F419 cIX5lMTg6niczcfKv4ESIix5GWyG9BI= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-117-sRFi_MKbN4WqT1BJaC2kbQ-1; Mon, 29 Jul 2024 12:22:53 -0400 X-MC-Unique: sRFi_MKbN4WqT1BJaC2kbQ-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (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 mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 269871955D45; Mon, 29 Jul 2024 16:22:50 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.216]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5BA9B19560AA; Mon, 29 Jul 2024 16:22:44 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 21/24] netfs: Cancel dirty folios that have no storage destination Date: Mon, 29 Jul 2024 17:19:50 +0100 Message-ID: <20240729162002.3436763-22-dhowells@redhat.com> In-Reply-To: <20240729162002.3436763-1-dhowells@redhat.com> References: <20240729162002.3436763-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Stat-Signature: 9ycn8rc1ckeckar6jdyn48feyzrfbwk6 X-Rspamd-Queue-Id: 3D0591C0023 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1722270180-582650 X-HE-Meta: U2FsdGVkX18HBZJoj/1AROQPDbWU/h6E2KpfPGjTdZgDpogH1/L0/sqUXiUNn8Pu6or3zkOju4KUg9qbzqBtVQoazzJcnJiv9qs+SYMyL4wNnPNRtbfRxJ+JRloeBBBckyzRlPw59KF3seOg8a50Fcx+0FnmUTgsEbQkQdt80uTlfVRqaZAi+GjdJd/gfaUAYnMuYltKAm7uHpfXaaNnA61gvm5/h5vnTde2/vwQB2nGVgwmx1tV28u+WOAYU2eWnlV9/zfSz9oRB0eEKYxYN6Eie7atySc0TaYQuONRaJvTMm+B9YNkvDijzyTivo5dIkCwI10LdrP+4MvZ1Un4sfDDI0qlk5ws38D8wFESQH50SwaNdfcXG1HA2GPdedD4MsPIGw2gUeZ79lnM3SIIl8bEbgZTIr5r+0p/XWPVylYULUZKwF9iVHRleQXlg78e7WRWbWFXyy1QtY5FE2G8QqW4d834dnNe+zZ/TectBr/wp5WRZmMufsBa/XPKIsSzj3Ww8u29Dxyh+sI0fDzntHSwEiK2FH0B8OXcOeWkkrJ5F/LlJyJEaWqBq2dD3PJZApmN97cpK3JbtC/lZQeM9uVHJXDdRZb9TPD7/iVLIXXejp2fYq2u53Z5X4EzU6TWtq/oI3RdE6y4lcreZYETXNKmhFMyLrCjIZqQeCsAkwDGmwf42uPa0/Bk9Y7wFy/CqnFFZtoKYB9s0ozdbkCarCmgvrqTqTOgyz/obS3HcKbluOOAmYNGs9UqNrWpsMhNyLbMI/C8UlgF3mHFyof9PeOU8Cq4vfHszKO6M9AZDohdPrtLaLjk4WVj0LD6wF782CvdpEUyo4gWR7UJ8ofEU7RtPclKROsQeYPy2c/eE1aNO7flEIYjgi0MKzCaCKyPv1fKe9C4WCfX6+we8HK5ojlwkUO6sP3dKkjTx0YynRPoyolxYhyQKBvMUXexT55XAs3XdhrKroDnt8eAhLk IHJ2Zal/ GY/lDXfVayUTq/Bw8jZPDqG2XjnQIYVrWKyTs1MeEJ2EuRrdOyRImv+eOQH2wrEG47jLyaondu4LKxYAxjh4dmzyhxoBOGRP20j1q+TPEYcJbng1h31lAvU4vBNzMBi662LZk/kHVB93X3225p4XC90AvBhC4DAsYUrs0gjnRYHPrx8uxdiz1j93ij3IUnmwUgE+Eg9B3aMsIigcTbuABgKdPZ7OknpLixCo4yQHzubElk+uTX7SWL5dTcRwkffmoGUuhnmmF3F9UCd3/VRlboQKtt4S7VkmZeFPtbQOMf+zlzOlpuk8OJmGY1sVUVcEoj37SffxoXzg+8WGERa0krZBg0jIwIfNmNCNAOv0aRAzfO3Y= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Kafs wants to be able to cache the contents of directories (and symlinks), but whilst these are downloaded from the server with the FS.FetchData RPC op and similar, the same as for regular files, they can't be updated by FS.StoreData, but rather have special operations (FS.MakeDir, etc.). Now, rather than redownloading a directory's content after each change made to that directory, kafs modifies the local blob. This blob can be saved out to the cache, and since it's using netfslib, kafs just marks the folios dirty and lets ->writepages() on the directory take care of it, as for an regular file. This is fine as long as there's a cache as although the upload stream is disabled, there's a cache stream to drive the procedure. But if the cache goes away in the meantime, suddenly there's no way do any writes and the code gets confused, complains "R=%x: No submit" to dmesg and leaves the dirty folio hanging. Fix this by just cancelling the store of the folio if neither stream is active. (If there's no cache at the time of dirtying, we should just not mark the folio dirty). Signed-off-by: David Howells cc: Jeff Layton cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/netfs/write_issue.c | 6 +++++- include/trace/events/netfs.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c index 87a5aeb77073..0cd12c86ea91 100644 --- a/fs/netfs/write_issue.c +++ b/fs/netfs/write_issue.c @@ -397,13 +397,17 @@ static int netfs_write_folio(struct netfs_io_request *wreq, folio_unlock(folio); if (fgroup == NETFS_FOLIO_COPY_TO_CACHE) { - if (!fscache_resources_valid(&wreq->cache_resources)) { + if (!cache->avail) { trace_netfs_folio(folio, netfs_folio_trace_cancel_copy); netfs_issue_write(wreq, upload); netfs_folio_written_back(folio); return 0; } trace_netfs_folio(folio, netfs_folio_trace_store_copy); + } else if (!upload->avail && !cache->avail) { + trace_netfs_folio(folio, netfs_folio_trace_cancel_store); + netfs_folio_written_back(folio); + return 0; } else if (!upload->construct) { trace_netfs_folio(folio, netfs_folio_trace_store); } else { diff --git a/include/trace/events/netfs.h b/include/trace/events/netfs.h index 4ac3b5d56ebd..1ece47af0b2f 100644 --- a/include/trace/events/netfs.h +++ b/include/trace/events/netfs.h @@ -151,6 +151,7 @@ EM(netfs_streaming_cont_filled_page, "mod-streamw-f+") \ EM(netfs_folio_trace_abandon, "abandon") \ EM(netfs_folio_trace_cancel_copy, "cancel-copy") \ + EM(netfs_folio_trace_cancel_store, "cancel-store") \ EM(netfs_folio_trace_clear, "clear") \ EM(netfs_folio_trace_clear_cc, "clear-cc") \ EM(netfs_folio_trace_clear_g, "clear-g") \