From: NeilBrown <neilb@ownmail.net>
To: Paulo Alcantara <pc@manguebit.org>,
Namjae Jeon <linkinjeon@kernel.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>
Cc: Jeff Layton <jlayton@kernel.org>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/3] smb/client: use d_alloc_trylock in cifs_silly_fullpath()
Date: Mon, 28 Sep 2026 11:25:03 +1000 [thread overview]
Message-ID: <20260928012812.2890035-3-neilb@ownmail.net> (raw)
In-Reply-To: <20260928012812.2890035-1-neilb@ownmail.net>
From: NeilBrown <neil@brown.name>
Rather than performing a normal lookup (which will be awkward with future
locking changes) use d_alloc_trylock() to find a dentry for an
unused name, and use an open-coded lookup_slow() to see if it is free on
the server.
Signed-off-by: NeilBrown <neil@brown.name>
---
fs/smb/client/dir.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
index 88fff65320f5..2faac93c6758 100644
--- a/fs/smb/client/dir.c
+++ b/fs/smb/client/dir.c
@@ -1183,23 +1183,34 @@ char *cifs_silly_fullpath(struct dentry *dentry)
unsigned char name[CIFS_SILLYNAME_LEN + 1];
int retries = 0, max_retries = 16;
size_t namesize = sizeof(name);
- struct dentry *sdentry = NULL;
+ struct dentry *sdentry = NULL, *alias;
char *path;
do {
dput(sdentry);
scnprintf(name, namesize, CIFS_SILLYNAME_PREFIX "%x",
atomic_inc_return(&cifs_sillycounter));
- sdentry = lookup_noperm(&QSTR(name), dentry->d_parent);
+ sdentry = d_alloc_trylock(dentry->d_parent, &QSTR(name));
+ if (sdentry == ERR_PTR(-EWOULDBLOCK)) {
+ sdentry = NULL;
+ continue;
+ }
if (IS_ERR(sdentry))
return ERR_CAST(sdentry);
- if (d_is_negative(sdentry)) {
- dput(sdentry);
- path = alloc_parent_path(dentry, CIFS_SILLYNAME_LEN);
- if (!IS_ERR(path))
- strcat(path, name);
- return path;
+ if (!d_in_lookup(sdentry))
+ continue;
+ alias = cifs_lookup(sdentry->d_parent->d_inode, sdentry, 0);
+ d_lookup_done(sdentry);
+ if (alias || d_is_positive(dentry)) {
+ if (!IS_ERR(alias))
+ dput(alias);
+ continue;
}
+ dput(sdentry);
+ path = alloc_parent_path(dentry, CIFS_SILLYNAME_LEN);
+ if (!IS_ERR(path))
+ strcat(path, name);
+ return path;
} while (++retries < max_retries);
dput(sdentry);
return ERR_PTR(-EBUSY);
--
2.50.0.107.gf914562f5916.dirty
next prev parent reply other threads:[~2026-09-28 1:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 1:25 [PATCH 0/3] smb/client(cifs): prepare for locking changes NeilBrown
2026-09-28 1:25 ` [PATCH 1/3] smb/client: don't unhash and rehash to prevent new opens NeilBrown
2026-10-21 15:30 ` Tom Talpey
2026-09-28 1:25 ` NeilBrown [this message]
2026-09-28 1:25 ` [PATCH 3/3] smb/client: Use d_alloc_trylock() in cifs_prime_dcache() NeilBrown
2026-10-21 9:55 ` [PATCH 0/3] smb/client(cifs): prepare for locking changes Christian Brauner
2026-10-21 15:31 ` Tom Talpey
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=20260928012812.2890035-3-neilb@ownmail.net \
--to=neilb@ownmail.net \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=jlayton@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neil@brown.name \
--cc=pc@manguebit.org \
--cc=viro@zeniv.linux.org.uk \
/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
all inboxes | Powered by JetHome®