linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com>
To: "frank.li@vivo.com" <frank.li@vivo.com>,
	"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>
Cc: "glaubitz@physik.fu-berlin.de" <glaubitz@physik.fu-berlin.de>,
	"slava@dubeyko.com" <slava@dubeyko.com>,
	"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v4 1/3] hfsplus: fix to update ctime after rename
Date: Wed, 23 Jul 2025 17:58:01 +0000	[thread overview]
Message-ID: <cce1a29f2f55baf679c3fe83269d9bceb3c4fd6c.camel@ibm.com> (raw)
In-Reply-To: <20250723023233.GL2580412@ZenIV>

On Wed, 2025-07-23 at 03:32 +0100, Al Viro wrote:
> On Tue, Jul 22, 2025 at 01:13:45AM -0600, Yangtao Li wrote:
> 
> > @@ -552,9 +553,13 @@ static int hfsplus_rename(struct mnt_idmap *idmap,
> >  	res = hfsplus_rename_cat((u32)(unsigned long)old_dentry->d_fsdata,
> >  				 old_dir, &old_dentry->d_name,
> >  				 new_dir, &new_dentry->d_name);
> > -	if (!res)
> > -		new_dentry->d_fsdata = old_dentry->d_fsdata;
> > -	return res;
> > +	if (res)
> > +		return res;
> > +
> > +	new_dentry->d_fsdata = old_dentry->d_fsdata;
> 
> 	Umm...  Is that assignment (either before or after that patch)
> actually correct?
> 
> 	Note that new_dentry essentially got unlinked here; old_dentry
> is about to have its parent/name changed by the caller of ->rename(),
> so...  that looks very odd.
> 
> 	What is that line about?

So, as far as I can see, the dentry structure [1] has:

void *d_fsdata;			/* fs-specific data */

And HFS+ is using this field to store Catalog File's ID (CNID) of
the file or folder, for example [2]:

static inline void hfsplus_instantiate(struct dentry *dentry,
				       struct inode *inode, u32 cnid)
{
	dentry->d_fsdata = (void *)(unsigned long)cnid;
	d_instantiate(dentry, inode);
}

So, this line simply copies CNID from old_dentry->d_fsdata to
new_dentry->d_fsdata during the rename operation. I assume that
->fs_data should be untouched by generic logic of dentries processing.

Thanks,
Slava.

[1]
https://elixir.bootlin.com/linux/v6.16-rc6/source/include/linux/dcache.h#L108
[2] 
https://elixir.bootlin.com/linux/v6.16-rc7/source/fs/hfsplus/dir.c#L25

  reply	other threads:[~2025-07-23 17:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-22  7:13 [PATCH v4 1/3] hfsplus: fix to update ctime after rename Yangtao Li
2025-07-22  7:13 ` [PATCH v4 2/3] hfs: correct superblock flags Yangtao Li
2025-07-22 19:06   ` Viacheslav Dubeyko
2025-07-22  7:13 ` [PATCH v4 3/3] hfs: fix to update ctime after rename Yangtao Li
2025-07-22 19:26   ` Viacheslav Dubeyko
2025-07-22 18:51 ` [PATCH v4 1/3] hfsplus: " Viacheslav Dubeyko
2025-07-23  2:32 ` Al Viro
2025-07-23 17:58   ` Viacheslav Dubeyko [this message]
2025-07-23 21:25     ` Al Viro
2025-07-24 18:30       ` Viacheslav Dubeyko

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=cce1a29f2f55baf679c3fe83269d9bceb3c4fd6c.camel@ibm.com \
    --to=slava.dubeyko@ibm.com \
    --cc=frank.li@vivo.com \
    --cc=glaubitz@physik.fu-berlin.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=slava@dubeyko.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 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).