public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] vfs: introduce d_mark_tmpfile_name()
@ 2026-04-05 21:18 Paulo Alcantara
  2026-04-05 21:18 ` [PATCH 2/2] smb: client: add support for O_TMPFILE Paulo Alcantara
  2026-04-06  3:23 ` [PATCH 1/2] vfs: introduce d_mark_tmpfile_name() Matthew Wilcox
  0 siblings, 2 replies; 9+ messages in thread
From: Paulo Alcantara @ 2026-04-05 21:18 UTC (permalink / raw)
  To: viro, smfrench
  Cc: Paulo Alcantara (Red Hat), Christian Brauner, Jan Kara,
	David Howells, linux-fsdevel, linux-cifs

CIFS requires O_TMPFILE dentries to have names of newly created
delete-on-close files in the server so it can build full pathnames
from the root of the share when performing operations on them.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: David Howells <dhowells@redhat.com>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-cifs@vger.kernel.org
---
 fs/dcache.c            | 19 +++++++++++++++++++
 include/linux/dcache.h |  1 +
 2 files changed, 20 insertions(+)

diff --git a/fs/dcache.c b/fs/dcache.c
index 7ba1801d8132..c20a9c9e921c 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -3196,6 +3196,25 @@ void d_mark_tmpfile(struct file *file, struct inode *inode)
 }
 EXPORT_SYMBOL(d_mark_tmpfile);
 
+void d_mark_tmpfile_name(struct file *file, const struct qstr *name)
+{
+	struct dentry *dentry = file->f_path.dentry;
+	char *dname = dentry->d_shortname.string;
+
+	BUG_ON(dname_external(dentry) ||
+	       d_really_is_positive(dentry) ||
+	       !d_unlinked(dentry) ||
+	       name->len > DNAME_INLINE_LEN - 1);
+	spin_lock(&dentry->d_parent->d_lock);
+	spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED);
+	dentry->__d_name.len = name->len;
+	memcpy(dname, name->name, name->len);
+	dname[name->len] = '\0';
+	spin_unlock(&dentry->d_lock);
+	spin_unlock(&dentry->d_parent->d_lock);
+}
+EXPORT_SYMBOL(d_mark_tmpfile_name);
+
 void d_tmpfile(struct file *file, struct inode *inode)
 {
 	struct dentry *dentry = file->f_path.dentry;
diff --git a/include/linux/dcache.h b/include/linux/dcache.h
index 898c60d21c92..f60819dcfebd 100644
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -264,6 +264,7 @@ extern void d_invalidate(struct dentry *);
 extern struct dentry * d_make_root(struct inode *);
 
 extern void d_mark_tmpfile(struct file *, struct inode *);
+void d_mark_tmpfile_name(struct file *file, const struct qstr *name);
 extern void d_tmpfile(struct file *, struct inode *);
 
 extern struct dentry *d_find_alias(struct inode *);
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-04-08 13:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-05 21:18 [PATCH 1/2] vfs: introduce d_mark_tmpfile_name() Paulo Alcantara
2026-04-05 21:18 ` [PATCH 2/2] smb: client: add support for O_TMPFILE Paulo Alcantara
2026-04-05 23:32   ` Al Viro
2026-04-05 23:53     ` NeilBrown
2026-04-07  1:28       ` Paulo Alcantara
2026-04-08  6:57         ` Al Viro
2026-04-08 13:48           ` Paulo Alcantara
2026-04-06  3:23 ` [PATCH 1/2] vfs: introduce d_mark_tmpfile_name() Matthew Wilcox
2026-04-07  1:29   ` Paulo Alcantara

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox