linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hristo Venev <hristo@venev.name>
To: Max Kellermann <max.kellermann@ionos.com>,
	David Howells <dhowells@redhat.com>
Cc: Ilya Dryomov <idryomov@gmail.com>, Xiubo Li <xiubli@redhat.com>,
	Jeff Layton <jlayton@kernel.org>,
	willy@infradead.org, ceph-devel@vger.kernel.org,
	 netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org,
	 linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org,
	blokos <blokos@free.fr>,
	 Trond Myklebust <trondmy@hammerspace.com>,
	"dan.aloni@vastdata.com" <dan.aloni@vastdata.com>
Subject: [PATCH] netfs: Set NETFS_RREQ_WRITE_TO_CACHE when caching is possible
Date: Sun, 04 Aug 2024 16:57:38 +0300	[thread overview]
Message-ID: <845520c7e608c31751506f8162f994b48d235776.camel@venev.name> (raw)
In-Reply-To: <CAKPOu+-4LQM2-Ciro0LbbhVPa+YyHD3BnLL+drmG5Ca-b4wmLg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1870 bytes --]

In addition to Ceph, in NFS there are also some crashes related to the
use of 0x356 as a pointer.

`netfs_is_cache_enabled()` only returns true when the fscache cookie is
fully initialized. This may happen after the request has been created,
so check for the cookie's existence instead.

Link: https://lore.kernel.org/linux-nfs/b78c88db-8b3a-4008-94cb-82ae08f0e37b@free.fr/T/
Fixes: 2ff1e97587f4 ("netfs: Replace PG_fscache by setting folio->private and marking dirty")
Cc: linux-nfs@vger.kernel.org <linux-nfs@vger.kernel.org>
Cc: blokos <blokos@free.fr>
Cc: Trond Myklebust <trondmy@hammerspace.com>
Cc: dan.aloni@vastdata.com <dan.aloni@vastdata.com>
Signed-off-by: Hristo Venev <hristo@venev.name>
---
 fs/netfs/objects.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/netfs/objects.c b/fs/netfs/objects.c
index f4a6427274792..a74ca90c86c9b 100644
--- a/fs/netfs/objects.c
+++ b/fs/netfs/objects.c
@@ -27,7 +27,6 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping,
 	bool is_unbuffered = (origin == NETFS_UNBUFFERED_WRITE ||
 			      origin == NETFS_DIO_READ ||
 			      origin == NETFS_DIO_WRITE);
-	bool cached = !is_unbuffered && netfs_is_cache_enabled(ctx);
 	int ret;
 
 	for (;;) {
@@ -56,8 +55,9 @@ struct netfs_io_request *netfs_alloc_request(struct address_space *mapping,
 	refcount_set(&rreq->ref, 1);
 
 	__set_bit(NETFS_RREQ_IN_PROGRESS, &rreq->flags);
-	if (cached) {
-		__set_bit(NETFS_RREQ_WRITE_TO_CACHE, &rreq->flags);
+	if (!is_unbuffered && fscache_cookie_valid(netfs_i_cookie(ctx))) {
+		if(netfs_is_cache_enabled(ctx))
+			__set_bit(NETFS_RREQ_WRITE_TO_CACHE, &rreq->flags);
 		if (test_bit(NETFS_ICTX_USE_PGPRIV2, &ctx->flags))
 			/* Filesystem uses deprecated PG_private_2 marking. */
 			__set_bit(NETFS_RREQ_USE_PGPRIV2, &rreq->flags);


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 858 bytes --]

  reply	other threads:[~2024-08-04 13:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-29  9:15 [PATCH] fs/netfs/fscache_io: remove the obsolete "using_pgpriv2" flag Max Kellermann
2024-07-29 12:56 ` Jeff Layton
2024-07-29 13:04   ` Max Kellermann
2024-07-29 15:35   ` Max Kellermann
2024-07-29 15:51     ` Jeff Layton
2024-07-30 16:01 ` [PATCH] netfs, ceph: Revert "netfs: Remove deprecated use of PG_private_2 as a second writeback flag" David Howells
2024-07-30 16:28   ` Max Kellermann
2024-07-30 20:00     ` Max Kellermann
2024-07-31  8:16     ` Max Kellermann
2024-07-31 10:41     ` David Howells
2024-07-31 11:37       ` Max Kellermann
2024-08-04 13:57         ` Hristo Venev [this message]
2024-08-04 23:22           ` [PATCH] netfs: Set NETFS_RREQ_WRITE_TO_CACHE when caching is possible Trond Myklebust
2024-08-05 15:34             ` Hristo Venev
2024-08-07 20:17       ` [RFC][PATCH] netfs: Fix handling of USE_PGPRIV2 and WRITE_TO_CACHE flags David Howells
2024-08-08 11:46       ` [PATCH v2] " David Howells
2024-08-08 21:31       ` [PATCH v3] " David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=845520c7e608c31751506f8162f994b48d235776.camel@venev.name \
    --to=hristo@venev.name \
    --cc=blokos@free.fr \
    --cc=ceph-devel@vger.kernel.org \
    --cc=dan.aloni@vastdata.com \
    --cc=dhowells@redhat.com \
    --cc=idryomov@gmail.com \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=max.kellermann@ionos.com \
    --cc=netfs@lists.linux.dev \
    --cc=trondmy@hammerspace.com \
    --cc=willy@infradead.org \
    --cc=xiubli@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).