All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paulo Alcantara <pc@manguebit.org>
To: NeilBrown <neil@brown.name>, Al Viro <viro@zeniv.linux.org.uk>
Cc: smfrench@gmail.com, David Howells <dhowells@redhat.com>,
	linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org
Subject: Re: [PATCH 2/2] smb: client: add support for O_TMPFILE
Date: Mon, 06 Apr 2026 22:28:51 -0300	[thread overview]
Message-ID: <98c9845554e2e6a79965d68ba8ae722b@manguebit.org> (raw)
In-Reply-To: <177543319568.1474915.17445767081272255066@noble.neil.brown.name>

NeilBrown <neilb@ownmail.net> writes:

> On Mon, 06 Apr 2026, Al Viro wrote:
>> On Sun, Apr 05, 2026 at 06:18:19PM -0300, Paulo Alcantara wrote:
>> 
>> > @@ -436,17 +457,13 @@ static int cifs_do_create(struct inode *inode, struct dentry *direntry, unsigned
>> >  		goto out_err;
>> >  	}
>> >  
>> > -	if (newinode)
>> > -		if (S_ISDIR(newinode->i_mode)) {
>> > -			rc = -EISDIR;
>> > -			goto out_err;
>> > -		}
>> > +	if (newinode && S_ISDIR(newinode->i_mode)) {
>> > +		rc = -EISDIR;
>> > +		goto out_err;
>> > +	}
>> >  
>> >  	d_drop(direntry);
>> > -	d_add(direntry, newinode);
>> 
>> > +		rc = __cifs_do_create(dir, direntry, full_path, xid,
>> > +				      tlink, oflags, mode, oplock,
>> > +				      fid, buf, &inode);
>> > +		if (!rc)
>> > +			d_add(direntry, inode);
>> 
>> 
>> > +		rc = __cifs_do_create(dir, dentry, path, xid, tlink,
>> > +				      file->f_flags, mode, &oplock,
>> > +				      &fid, NULL, &inode);
>> > +		if (!rc) {
>> > +			set_nlink(inode, 0);
>> > +			mark_inode_dirty(inode);
>> > +			d_mark_tmpfile_name(file, &QSTR_LEN(name, size - 1));
>> > +			d_instantiate(dentry, inode);
>> 
>> I really don't like this "not sure what the state is, d_drop() to
>> get it unhashed" pattern, _especially_ when d_drop() and d_add() or
>> d_instantiate() get separated.
>> 
>> Note, BTW, this d_add() call site is one of the two in the entire kernel
>> that are neither d_splice_alias() in disguise nor pass NULL as inode.
>> The other one is nfs_link(), where we also have this kind of "d_drop()
>> first, then use d_add()" pattern.
>> 
>> Folks, what state can dentry be in cifs_do_create()?  I'd rather see
>> that sorted out, not obfuscated even more.
>
> cifs_do_create() gets call from cifs_atomic_open() which is
> ->atomic_open(), so dentry can be in-lookup or negative-hashed.
>
> If is also called from cifs_create() (->create()) and as cifs_lookup()
> never skips the lookup due to intent (like NFS does) the dentry will
> always be hashed negative.

Thanks Neil for the details!

IIUC, this is what we currently have

* cifs_atomic_open()

  init state: in-lookup or hashed-negative
  [d_drop() + d_add()]
  end state: hashed-positive

* cifs_tmpfile()

  init state: unhashed-negative
  [d_drop() + d_instantiate()]
  end state: unhashed-positive

* cifs_create()

  init state: hashed-negative
  [d_drop() + d_add()]
  end state: hashed-positive

  reply	other threads:[~2026-04-07  1:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=98c9845554e2e6a79965d68ba8ae722b@manguebit.org \
    --to=pc@manguebit.org \
    --cc=dhowells@redhat.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=smfrench@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.