From: David Howells <dhowells@redhat.com>
To: Christian Brauner <christian@brauner.io>
Cc: David Howells <dhowells@redhat.com>,
Paulo Alcantara <pc@manguebit.org>,
netfs@lists.linux.dev, linux-afs@lists.infradead.org,
linux-cifs@vger.kernel.org, ceph-devel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Marc Dionne <marc.dionne@auristor.com>
Subject: [PATCH 3/4] afs: Fix afs_get_link() to take validate_lock around afs_read_single()
Date: Thu, 23 Apr 2026 23:22:06 +0100 [thread overview]
Message-ID: <20260423222209.3054909-4-dhowells@redhat.com> (raw)
In-Reply-To: <20260423222209.3054909-1-dhowells@redhat.com>
Fix afs_get_link() to take the validate_lock around afs_read_single() to
prevent races between multiple ->get_link() calls.
Fixes: eae9e78951bb ("afs: Use netfslib for symlinks, allowing them to be cached")
Closes: https://sashiko.dev/#/patchset/20260326104544.509518-1-dhowells%40redhat.com
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
---
fs/afs/inode.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 06e25e1b12df..5207c4a003f6 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -78,10 +78,19 @@ const char *afs_get_link(struct dentry *dentry, struct inode *inode,
goto good;
fetch:
- ret = afs_read_single(vnode, NULL);
- if (ret < 0)
- return ERR_PTR(ret);
- set_bit(AFS_VNODE_DIR_READ, &vnode->flags);
+ if (down_write_killable(&vnode->validate_lock) < 0)
+ return ERR_PTR(-ERESTARTSYS);
+ if (test_and_clear_bit(AFS_VNODE_ZAP_DATA, &vnode->flags) ||
+ !test_bit(AFS_VNODE_DIR_READ, &vnode->flags)) {
+ ret = afs_read_single(vnode, NULL);
+ if (ret < 0) {
+ up_write(&vnode->validate_lock);
+ return ERR_PTR(ret);
+ }
+ set_bit(AFS_VNODE_DIR_READ, &vnode->flags);
+ }
+
+ up_write(&vnode->validate_lock);
good:
folio = folioq_folio(vnode->directory, 0);
next prev parent reply other threads:[~2026-04-23 22:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-23 22:22 [PATCH 0/4] netfs: Yet further miscellaneous fixes David Howells
2026-04-23 22:22 ` [PATCH 1/4] netfs: Fix wrong return from netfs_read_sizes() on 32-bit SMP arches David Howells
2026-04-23 22:22 ` [PATCH 2/4] netfs: Fix missing barriers when accessing stream->subrequests locklessly David Howells
2026-04-23 22:22 ` David Howells [this message]
2026-04-23 22:22 ` [PATCH 4/4] afs: Fix RCU handling of symlinks in RCU pathwalk 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=20260423222209.3054909-4-dhowells@redhat.com \
--to=dhowells@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=christian@brauner.io \
--cc=linux-afs@lists.infradead.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.dionne@auristor.com \
--cc=netfs@lists.linux.dev \
--cc=pc@manguebit.org \
/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