Re: [PATCH] fs: introduce is_dot_dotdot helper for cleanup
From: Matthew Wilcox
Date: Mon Dec 02 2019 - 21:47:13 EST
On Tue, Dec 03, 2019 at 10:07:41AM +0800, Tiezhu Yang wrote:
> On 12/03/2019 04:03 AM, Matthew Wilcox wrote:
> > On Mon, Dec 02, 2019 at 06:10:13PM +0800, Tiezhu Yang wrote:
> > > There exists many similar and duplicate codes to check "." and "..",
> > > so introduce is_dot_dotdot helper to make the code more clean.
> > The idea is good. The implementation is, I'm afraid, badly chosen.
> > Did you benchmark this change at all? In general, you should prefer the
>
> Thanks for your reply and suggestion. I measured the
> performance with the test program, the following
> implementation is better for various of test cases:
>
> bool is_dot_dotdot(const struct qstr *str)
> {
> if (unlikely(str->name[0] == '.')) {
> if (str->len < 2 || (str->len == 2 && str->name[1] == '.'))
> return true;
> }
>
> return false;
> }
>
> I will send a v2 patch used with this implementation.
Well, hang on. If you haven't done any benchmarking, please do so
before sending a v2. In particular, you've now moved this to being a
function call. That might slow things down, or it might speed things up.
I also don't know if passing a qstr is going to be the right API --
let's hear from the filesystems affected by the API change that they're
OK with this change.