Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2765560pxj; Mon, 10 May 2021 10:13:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyXErKZx4+RE/aIbbzjaiUraMgnSmIVoBIEWqWfA/pyAywtLlX/Gn2xxFyWVSF7U/uzLbh1 X-Received: by 2002:a92:c7a1:: with SMTP id f1mr22107817ilk.33.1620666805741; Mon, 10 May 2021 10:13:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620666805; cv=none; d=google.com; s=arc-20160816; b=X/+30f/upfq/hDPnq7evGVaaHzPhhsAsFUcMEeRq19Dfmod8kpvQLoIL1w7ZejW1LN voJpvacQp8fkhnZmfZ47Ygrz2HWKpIxPchLWSEZRLHQzl92mYQA0tRKrUFnbBmdJiv8H CmCwGjvl4bDBSycylhORaZ+xAO+4CdFBP1QB4DeNwlxhuiW7ZHeIF73N6x6yPmcYhI25 B4edkfPzvR7qSdjTijuzmcJfM9w34a24xzvgA/SIP33tixDE3uVl2IYMzN+wy8Cy3LZd Dx5snE0NQezlsxXKI/hdFRJIIqUr59EUtHFPBH7rTpCfnrtWSx3WFvJS0krYao8qD8XE eQng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=M1eiob8yefqeM/4lQ3qAm9Yi0Ncpt48q5ul29v+Xq2c=; b=Bsq52qNjIjIxGLUSzRtywQb+oPk+GYgXOoqqCuYNBshuksom9C+lhaYJmKkkilt1o1 ipSU/DD5BUg8PqwNM40NWMgoq8hJjPX3q1ECMOZTUtZSYRZqPA9rpbTcZZGx4ylFztiK MkDNOisbRopP3/43+NfTtD3wDhy53FexmOGDNXPyjzTDZGMA9iRAevW1RBAiFHaM3bCB DDPqe5h7j750W6aUJKrjG91d04eDD32XGgx62uc7HanI7LgtablQrzU+Zpo7QMi/MvGl DMZAh+3rgT2lNP/Dsepu04SK/3sJQVnC1mPx+tseWaT8KzAFjQPIHmCUM0DJEmuuy0YF 6LAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=F5KPsThm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e196si17111903jac.30.2021.05.10.10.13.13; Mon, 10 May 2021 10:13:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=F5KPsThm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232437AbhEJRMz (ORCPT + 99 others); Mon, 10 May 2021 13:12:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232326AbhEJRMx (ORCPT ); Mon, 10 May 2021 13:12:53 -0400 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B8AFC061574 for ; Mon, 10 May 2021 10:11:48 -0700 (PDT) Received: by mail-ed1-x52b.google.com with SMTP id v5so8526329edc.8 for ; Mon, 10 May 2021 10:11:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=M1eiob8yefqeM/4lQ3qAm9Yi0Ncpt48q5ul29v+Xq2c=; b=F5KPsThm+B/hNJwfEfSsphP6+tJzOvUUoyRJDzDPpWJ5+M81YHmp5q6kc3NHXwI+NX Mc6fNZ9gODek4bDptwj3D+Ka+Ar0jPnltod+iKxngn/yVax6lIBjujOZoyRHkKXW1rdK ijaTUd6bNrV69ZmFpNnh7JIb7M++aRgC7xK14= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=M1eiob8yefqeM/4lQ3qAm9Yi0Ncpt48q5ul29v+Xq2c=; b=kZSowbbxhgGRrMHvQHIZ2bRgDcWsrZywfZDaSVt58eR2IQqbbANSBAWpY3B/GRSdoL Kt4MsVdJpYarlGMlr0wqWVse2RcvsnxmkFwGXTOb16Ye8IYVW13BKL9yypL0GtWnvdtK v0llmcTGMvPvSlRMjQ8x0P9QSi9Or+ja4wFdIuMO+JKg9IjjrDrSl83DN88/6pfnKcN3 nEDUHp/sD1iTZF1JCobvmB3f2tQtkxor1mC6kseA54V5AGV3F3qPkG58Cr8niokMyKCM N5m9Hs2AnUeO2nBowOozXVM+XWtfGgHqrFEnD0hoMG+/ToaM8rjZXY0wiM+NJKZmYPqX r4qg== X-Gm-Message-State: AOAM531yMlGfb0/RKkfKE7LE9WhwCRw01A7lINkn2uLXmEyefFLsssle WIaKJ7jb2W8ZYRvMHmEi77tMa7DJQGeCffqHmUY= X-Received: by 2002:aa7:c782:: with SMTP id n2mr31225360eds.77.1620666707203; Mon, 10 May 2021 10:11:47 -0700 (PDT) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com. [209.85.221.41]) by smtp.gmail.com with ESMTPSA id i8sm7945875ejj.68.2021.05.10.10.11.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 May 2021 10:11:47 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id l13so17379792wru.11 for ; Mon, 10 May 2021 10:11:47 -0700 (PDT) X-Received: by 2002:a05:6512:374b:: with SMTP id a11mr17210794lfs.377.1620666218738; Mon, 10 May 2021 10:03:38 -0700 (PDT) MIME-Version: 1.0 References: <20210508122530.1971-1-justin.he@arm.com> <20210508122530.1971-2-justin.he@arm.com> In-Reply-To: From: Linus Torvalds Date: Mon, 10 May 2021 10:03:22 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RFC 1/3] fs: introduce helper d_path_fast() To: Justin He Cc: Al Viro , Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , Jonathan Corbet , Al Viro , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , "Eric W . Biederman" , "Darrick J. Wong" , "Peter Zijlstra (Intel)" , Ira Weiny , Eric Biggers , "Ahmed S. Darwish" , "open list:DOCUMENTATION" , Linux Kernel Mailing List , linux-s390 , linux-fsdevel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 10, 2021 at 8:08 AM Justin He wrote: > > > > > char *dentry_path(const struct dentry *dentry, char *buf, int buflen) > > { > >- char *p = NULL; > >+ struct prepend_buffer b = { buf + buflen, buflen }; > > char *retval; > >+ char *p = NULL; > > > > if (d_unlinked(dentry)) { > >- p = buf + buflen; > >- if (prepend(&p, &buflen, "//deleted", 10) != 0) > >+ if (prepend(&b, "//deleted", 10) != 0) > > goto Elong; > >- buflen++; > >+ > >+ // save away beginning of "//deleted" string > >+ // and let "__dentry_path()" overwrite one byte > >+ // with the terminating NUL that we'll restore > >+ // below. > >+ p = b.ptr; > >+ b.ptr++; > >+ b.len++; > > } > >- retval = __dentry_path(dentry, buf, buflen); > >+ retval = __dentry_path(dentry, b.ptr, b.len); > > I didn't quite understand the logic here. Seems it is not equal to > the previous. Should it be s/b.ptr/buf here? Otherwise, in __dentry_path, > it will use the range [b.ptr, b.ptr+b.len] instead of [buf, buf+b.len]. > Am I missing anything here? No, you're right. That __dentry_path() call should get "buf, b.len" as arguments. I knew it was squirrelly, but didn't think it through. I actually wanted to change "__dentry_path()" to take a "struct prepend_buffer", and not add the NUL at the end (so that the caller would have to do it first), because that would have made the logic much more straightforward (and made the semantics the same as the other internal helpers). And that would have fixed that bug of mine too. But then I didn't do it, and just mentioned it as a later cleanup. Good catch. Linus