From: Li GuiFu via Linux-erofs <linux-erofs@lists.ozlabs.org>
To: Gao Xiang <hsiangkao@redhat.com>
Cc: linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH] erofs-utils: update i_nlink stat for directories
Date: Sat, 5 Dec 2020 17:05:35 +0800 [thread overview]
Message-ID: <e3594931-7cf2-b91e-cd0c-76c1d1750ab0@aliyun.com> (raw)
In-Reply-To: <20201205084303.GB2333547@xiangao.remote.csb>
On 2020/12/5 16:43, Gao Xiang wrote:
> On Sat, Dec 05, 2020 at 04:38:37PM +0800, Gao Xiang wrote:
>> On Sat, Dec 05, 2020 at 04:32:44PM +0800, Li GuiFu via Linux-erofs wrote:
>>
>> ...
>>
>>>
>>>> @@ -957,6 +974,10 @@ struct erofs_inode *erofs_mkfs_build_tree(struct erofs_inode *dir)
>>>> ret = PTR_ERR(d);
>>>> goto err_closedir;
>>>> }
>>>> +
>>>> + /* to count i_nlink for directories */
>>>> + d->type = (dp->d_type == DT_DIR ?
>>>> + EROFS_FT_DIR : EROFS_FT_UNKNOWN);
>>>> }
>>>>
>>> It's confused that d->type was set to EROFS_FT_UNKNOWN when not a dir
>>> It's not clearness whether the program goes wrong or get the wrong data
>>> Actually it's a correct procedure
>>
>> It's just set temporarily, since only dirs are useful when counting subdirs, so
>> only needs to differ dirs and non-dirs here. (Previously d->type is unused
>> at this time.)
>
> btw, I once tried to set up d->type via dp->d_type here, but it increases a
> lot of code and seems unnecessary (since deriving from i_mode is enough).
> So again, here we only cares about dir and non-dirs (we don't care much about
> the specific kind of non-dirs here).
>
> Thanks,
> Gao Xiang
>
>>
>> ...
>>
>>>> - d->type = erofs_type_by_mode[d->inode->i_mode >> S_SHIFT];
>>>> + ftype = erofs_mode_to_ftype(d->inode->i_mode);
>>>> + DBG_BUGON(d->type != EROFS_FT_UNKNOWN && d->type != ftype);
>>>> + d->type = ftype;
>>
>> The real on-disk d->type will be set here rather than the above.
Yes, what it makes confused is here, EROFS_FT_UNKNOWN is just temporary.
So how about change to ASSERT at EROFS_FT_DIR
DBG_BUGON(d->type == EROFS_FT_DIR && ftype != EROFS_FT_DIR);
next prev parent reply other threads:[~2020-12-05 9:07 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20201205055732.14276-1-hsiangkao.ref@aol.com>
2020-12-05 5:57 ` [PATCH] erofs-utils: update i_nlink stat for directories Gao Xiang via Linux-erofs
2020-12-05 8:32 ` Li GuiFu via Linux-erofs
2020-12-05 8:38 ` Gao Xiang
2020-12-05 8:43 ` Gao Xiang
2020-12-05 9:05 ` Li GuiFu via Linux-erofs [this message]
2020-12-05 9:09 ` Gao Xiang
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=e3594931-7cf2-b91e-cd0c-76c1d1750ab0@aliyun.com \
--to=linux-erofs@lists.ozlabs.org \
--cc=bluce.lee@aliyun.com \
--cc=hsiangkao@redhat.com \
/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.