From patchwork Wed Aug 14 20:38:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13764104 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 95F9FC52D7F for ; Wed, 14 Aug 2024 20:41:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E4006B00A0; Wed, 14 Aug 2024 16:41:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 292296B00BC; Wed, 14 Aug 2024 16:41:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 10C936B00BD; Wed, 14 Aug 2024 16:41:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E40316B00A0 for ; Wed, 14 Aug 2024 16:41:54 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 9F3E0C1179 for ; Wed, 14 Aug 2024 20:41:54 +0000 (UTC) X-FDA: 82452022548.20.751EC78 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 023E48000B for ; Wed, 14 Aug 2024 20:41:52 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hqCw/m5M"; spf=pass (imf02.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=1723668041; 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=71aFx04FBERopiPPtaaAjec9tErJI5QLn4peDvc3p4I=; b=Mb5yZyG/ijGW8pfgyS8DT8UxzyNxVFAOCc6F+vwiMvyZZzGX480kzgujz8LaE6b9kSx11t NBSQp1nPDbMtg5taOFgVc8xNAPo735S1bWErjmt+MnyJwyV6Jgwv27h3R671CfQpNlSX+t OdbReltL7xa/2KYiDYW2rP5UDVqbRQc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723668041; a=rsa-sha256; cv=none; b=QHp4gxm9prG3lL1YjZcXjzPMRSj9P7QtnkwMwC6RBnql/kNPesHAS94bODaQexVSKV+PHJ qwweahUOYMeIdFukXIasCay7HbgygeksWa0bZ5Q0QVbvXRHIgwbfXx+lWFN8m+b/PjM2Q3 S3PIqPlQXFrfni9b35uKKZobXed7tZQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hqCw/m5M"; spf=pass (imf02.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1723668112; 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=71aFx04FBERopiPPtaaAjec9tErJI5QLn4peDvc3p4I=; b=hqCw/m5MKIx0/luPCcNDucYEbrhPTxw9ZMJwegR6/kIvVw52D9d/ofny+3Xo5LIr0MxFyY +s7Q1IWxJJgm65dmf/0t0lZmxZtyu0qtBEp6dYjf3R4wNelardLLncqALGk7Ht+Ocrd79s cTCUHS7Bi6Dj0ctkeuPJn56choIUFyc= Received: from mx-prod-mc-01.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-277-F-R71-2QP0anx8F_m7msPg-1; Wed, 14 Aug 2024 16:41:49 -0400 X-MC-Unique: F-R71-2QP0anx8F_m7msPg-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2B0671954B11; Wed, 14 Aug 2024 20:41:46 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.30]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A276F1955D88; Wed, 14 Aug 2024 20:41:39 +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 v2 22/25] netfs: Cancel dirty folios that have no storage destination Date: Wed, 14 Aug 2024 21:38:42 +0100 Message-ID: <20240814203850.2240469-23-dhowells@redhat.com> In-Reply-To: <20240814203850.2240469-1-dhowells@redhat.com> References: <20240814203850.2240469-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Rspamd-Queue-Id: 023E48000B X-Stat-Signature: naaszpbjg8j63hgmko1ope7jpjftc8wh X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1723668112-778465 X-HE-Meta: U2FsdGVkX188OOK13JqL8bCSxMoMgzGSYC5HXzy8m3BIhl0x4i+zBcjjXaFL/9zlXO/4nGsHcNwnFL7LWZ9LhDsxbGC7aOjIjd2w8RLDKtntVURMqUMwX+lgEnur7yWagtbCxGxuEqBv6mPEo56ICUGUHeEZl4Vln2h09MpdLuEn8kA+XTW4qNe4MbYtb+PHrQ++ioLjwrBbyhCWsjQK7yWq3DYgNoojAt9/bNdcfYmbmsLlAVDICpAkqlCpTtZ1wbBmNZMKJmb44FpaQabZvfuajR7kgtDt4kJ6QaY4TJgAVQ4N8quK1PdDlHr/GOGJTn1DGlnXF/+LwKC6lfbvGCj8u2fRPQSlLxp9M9N30bnbrw9w1OXQX9yN7ynHtlbRlH7mJzZj4z5kK25CtMhAOm/B+tNrd9qGC+e/+Xt0LKOyrMRDxweqikQYdSCAH7W7Aqo9904POKHPP99TemqplvG5U1dHXKPMjG59FF4w8HsqKfWjuwRgyu6r2Vf4CiUb726NjFvn0RWOsVarGJnO70NhafCjrHbRGPhaEk0rAV0RqOsNPovi3LwXMuTQKQf0Sph+DU601wr2MYP3llcbFauJSOkSuz3bFzBxQviZkILQBmBtm/JG5Ycb+/Y0CSzhiLol3dASdFLqRNDVwNefchDFglurHzjL9savZ8KNT08JBxutbnS+fme7FTKNg7iC8ka1HOuoOVKlRszff4EOdXhQXasGxKg8/RHNA81DM2lX7yS6d3ZM5fdowRi2ExJxsZ4S/HFIL4fvujM2zK8PhVKt75ui2E2iYTj70++VJOH7m+AUQxsSKS9fOmwoQA1QiWhkSM6kMOE+NRZWLphxjI9JMy0IqBhrcbjd8ZQWiDK4uqNfoXmRr03stluAMc2FFYH6GafygEK2kqGPwLu9iwOtjGjXauxfkKIykh2d5bX+H7+z2cuhGcteg8LKQCNAxunrTeA2j1N5uz9fngv eXRJkS9v oaK3KtgGeA6gO7FYA6cbnXuBGmSvbIiDbueYcUIFpnP7S5uMzcUjYZJTips3iu7hToNTezywvwiHabqOZ7waH5Ox6Frzx5EakBUc7Ob4TGNkPv9WJZvqYkwX7dFz+yoKvoYdyaQiyDqMtej8BYhi9EAdSKf128cJubbPy5Xx34xVUml9ojU5ilAH9JQvHiJnyb0m7k91TmaurG+UaGK9eG2jF7NJv3TIndxlFF659BWYpUFMbz3W4WqxsrkBRlTZ6XCEJp0KKGA3DnHa/QzAB/Hms+FQLbVyI+W8YDpxNLgSoulrc2h8eiM1xvcDEVyZsCvar1Nhf4QyQ5FHkSPV+CfO6f5XescIIs5+WahIwr+g0ltQ= 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 f7d59f0bb8c2..04e66d587f77 100644 --- a/fs/netfs/write_issue.c +++ b/fs/netfs/write_issue.c @@ -400,13 +400,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 7b26463cb98f..76bd42a96815 100644 --- a/include/trace/events/netfs.h +++ b/include/trace/events/netfs.h @@ -153,6 +153,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") \