From: Hengyu Liang <hengyul@cs.unc.edu>
To: slava@dubeyko.com
Cc: glaubitz@physik.fu-berlin.de, frank.li@vivo.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] hfs: avoid reusing occupied CNIDs after deletion
Date: Thu, 22 Oct 2026 08:06:57 -0400 [thread overview]
Message-ID: <20261022120658.1328124-1-hengyul@cs.unc.edu> (raw)
In-Reply-To: <1797b66dee80c9553748d4a961470894c917bf5f.camel@dubeyko.com>
Hi Slava,
On Wed, Oct 21, 2026 at 03:26:10PM -0700, Viacheslav Dubeyko wrote:
> I think I see your point. So, I think that fix is much simpler. We need
> to add the thread records processing here [1]:
[...]
> The current logic simply misses the HFS_CDR_THD and HFS_CDR_FTH cases
> processing.
Thanks. I tried this in KVM on a804c5742bff. It fixes the example from
my last mail only in part, for two reasons.
First, a thread record's own CNID is in its key. rec.thread.ParID is
the CNID of the parent. In the example, a's thread is (17, "") with
ParID 2, so taking rec.thread.ParID sets next_id to 16, and the next
create fails with -EEXIST on z. Taking the CNID from the key gives 18,
which is right.
Second, even with the key, the scan still stops at the first record it
finds, and the last record need not hold the largest CNID:
operation allocated CNID
create a 16
mkdir y 17
create b 18
mv a y/
rm b
The last records are now (17, "") for y's thread and (17, "a") for a's
file record, with CNID 16. The scan stops at (17, "a") and sets next_id
to 17, which y still uses, so the next create fails with -EEXIST.
File threads are also optional (HFS_FIL_THD; hfs_cat_move() already
handles files without one). If a (CNID 17) in the example has no
thread, the next create gets CNID 17 as well, without an error, because
hfs_cat_create() only checks for an existing thread.
Result of creating the next file in each case:
unpatched thread ParID thread key patch
example (z, a, b) -EEXIST -EEXIST 18 18
mv a into y -EEXIST -EEXIST -EEXIST 18
a without thread 17 (dup) -EEXIST 17 (dup) 18
So the scan needs the largest CNID over all records, not the first one
it finds. This is what the patch does; the cnid - 1 lookup only avoids
the full scan in the common case.
If this looks right to you, I will send v2 without the != change.
Thanks,
Hengyu
next prev parent reply other threads:[~2026-10-22 12:07 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 11:01 Hengyu Liang
2026-10-15 19:58 ` Viacheslav Dubeyko
2026-10-16 2:31 ` Hengyu Liang
2026-10-17 22:35 ` Viacheslav Dubeyko
2026-10-19 23:29 ` Viacheslav Dubeyko
2026-10-21 15:31 ` Hengyu Liang
2026-10-21 22:26 ` Viacheslav Dubeyko
2026-10-22 12:06 ` Hengyu Liang [this message]
2026-10-22 22:40 ` 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=20261022120658.1328124-1-hengyul@cs.unc.edu \
--to=hengyul@cs.unc.edu \
--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=stable@vger.kernel.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
all inboxes | Powered by JetHome®