From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CFAC3D813F for ; Mon, 15 Jun 2026 09:26:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781515571; cv=none; b=NYY9fKck6A+jwpLJSX/1dset1+JlRWEFlTOpUFiOxEVbNJ7E2Jmh14uHgtib9yckAQTtGPsvMPkStHEaKUJ7+iw/6RsGNBx5ul8IsNRoiy539rFSvCrDxgrucFgXcwv7t8nlKsi4fGF12oG86GmDjwsk+uU2v2IzWIAnCYFcLEA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781515571; c=relaxed/simple; bh=pjslUZjcfb0ZawJ5LtHVTFQIPSn+wxqqZlQ8udQvycU=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IRPUvbqMzyjTEmdl6jw5VKc7iaB3rVSCNF9c/iexlGod/S8qNEC1Tm882ITYaE7POc7MHqWgN5Q1WPqwxPBbDDv5kU4LmvV4gPeznLSHYyAi5330z9Z5fEGgX0my7IypKawi1vu7LylN+2NQgZxnvmiUacQcgPaBhxplYBFqfV0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=O6lthsim; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O6lthsim" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-45fd45e596cso1695544f8f.1 for ; Mon, 15 Jun 2026 02:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781515569; x=1782120369; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=MCYaIHNjMNsiMHrKpS1J2bSbUWKjV/eTWEkh6ujIVgk=; b=O6lthsimO7oDrDITgoeAftnvEkNvgGsuboHq3GFjRC9fGLy5aGJGYGOqauUIuLW858 m6C5dpsvVHn/RikvdG3GUid+HC85BVxkS8+uLho89vx6apui6X5rQPkG8FVw1bQsWgAW Cq+PEkhh6JxYWqQU32tW8BlWo/91ZmnJ++OTKIQ1TeHNhCD3OomFoxfUTiKl1t6qbSRg xYb2PCMmMaxFhMb14QCyGXIMVKtaI1TP/9rBJbK0fx2vtRw4CYpd438/5wu+lBs9MzC4 6O3hhR7OsHgaFK5MZZR6t5uAk3GGtwmWPn9WMKEd5FbnL/o39QLr7ZQXEEuVRw1Hxcac gPJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781515569; x=1782120369; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=MCYaIHNjMNsiMHrKpS1J2bSbUWKjV/eTWEkh6ujIVgk=; b=psPPQ+C45SPKg2hw64gc7OQLEAiEU6qc+kvy80BQsd2xny3GbU/UCXod5fzwCStJ3L t46U5YJswPw6XjYnSwgQUY3Z1XJh59zGv49VCxAyhtvR1iKCB8soYwcJtDi0rpwVKfVj o4tFuDHj6FbRX0A2mQ+F6FG5I4mil+dfyZRQa9Mnr7c+o/Q7BSObMWcMWmyWVu/lDZY8 5YH1Q0YzcZTwEQHpIIBSnZ8/gQPdKrLzlnHnZWwywa7JP6zPvDRzXa2XRcK27Wdy5CUR VGRjwql578d/Xp1m9kBlGAqLdDZi/oVdViV6BRa8BLp4wP0doHzb5hjlSExtMz2mKEH9 RP8A== X-Forwarded-Encrypted: i=1; AFNElJ+ce9aYvrswPnA/c0vfnRHwBdRll26oMm6L615YZ2eNWvNMDL6gSNHGRguxDMU8S17fz0UOEo+hhKwX+Fc=@vger.kernel.org X-Gm-Message-State: AOJu0YxmQJtYDrBVN1/fqPF5PI47R98nbN0loV5f1Z3Bkgu3pSiLX/IE M+j4Hl+ZNj5sRaGXXRTyXe5L0POPwB0BU66B9ITgojzlD7luGc6SMWZZ1Wb+0Kt/ X-Gm-Gg: Acq92OGIX2j9eOcpt2BnAOHBQnX3E/FDAcVu1aqwZWyEjkEdJI7zOx91AQUggGHMivu WOU7CopgWh/VG9xfhTYMjvo7mkWCNACIfJAkJaSB38eJ/jrGy3j3F7xnqvxfi3n+eqTRbzz9nG8 P2f3Vr+2AhM4bewvhv8zCuY9XyXan2nccNkaaafpiho1knvcJ2mbE6zJof02kvxTzrLs3NWqqt6 qTTByREULBZVV79QUAZWU9SlqDmDElXZzCMHvXdwcHY5yKaAnMr+7HZRPsVb6edFMv5a16pvn+o mTduD93oewZA6P6BevrAJU32ogOSsgmMqZllKR//B+KCqEuTC6uoPvt19U/GYBJ6aiZfH4/rQbN WOfLCh4utMJK8F2ldX8hiStWryIwj5uohMsapxQkavUFEajsMD9dt7/OFuGC9FIl1D9AcqaL2Rf nz7i12HiaxCYaB954UiDP08v6R7dPxmDXNQ7dsdw5eAPgl46Ru8URMD3CIy7P3 X-Received: by 2002:a05:6000:2995:10b0:452:6aa0:1d11 with SMTP id ffacd0b85a97d-4606da6d614mr13965634f8f.19.1781515568626; Mon, 15 Jun 2026 02:26:08 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4606f2b0c35sm33697256f8f.22.2026.06.15.02.26.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jun 2026 02:26:08 -0700 (PDT) Date: Mon, 15 Jun 2026 10:26:06 +0100 From: David Laight To: Jori Koolstra Cc: Christian Brauner , Jan Kara , Al Viro , NeilBrown , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/12] fs/namei.c: use trailing_slashes() Message-ID: <20260615102606.0d7befa2@pumpkin> In-Reply-To: <20260614164438.2980769-2-jkoolstra@xs4all.nl> References: <20260614164438.2980769-1-jkoolstra@xs4all.nl> <20260614164438.2980769-2-jkoolstra@xs4all.nl> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 14 Jun 2026 18:44:27 +0200 Jori Koolstra wrote: > There are several places in fs/namei.c that can use the > trailing_slashes() function to improve intent. I'm not sure it does anything for the readability. > > Signed-off-by: Jori Koolstra > --- > fs/namei.c | 26 +++++++++++++------------- > 1 file changed, 13 insertions(+), 13 deletions(-) > > diff --git a/fs/namei.c b/fs/namei.c > index 4787244ca4a7..64b91ed9efb7 100644 > --- a/fs/namei.c > +++ b/fs/namei.c > @@ -2777,9 +2777,14 @@ static const char *path_init(struct nameidata *nd, unsigned flags) > return s; > } > > +static inline bool trailing_slashes(const struct qstr last) You are passing a struct by value. If the function isn't inlined then you've blown the stack. David > +{ > + return (bool)last.name[last.len]; > +} > + > static inline const char *lookup_last(struct nameidata *nd) > { > - if (nd->last_type == LAST_NORM && nd->last.name[nd->last.len]) > + if (nd->last_type == LAST_NORM && trailing_slashes(nd->last)) > nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; > > return walk_component(nd, WALK_TRAILING); > @@ -4524,17 +4529,12 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, > return ERR_PTR(error); > } > > -static inline bool trailing_slashes(struct nameidata *nd) > -{ > - return (bool)nd->last.name[nd->last.len]; > -} > - > static struct dentry *lookup_fast_for_open(struct nameidata *nd, int open_flag) > { > struct dentry *dentry; > > if (open_flag & O_CREAT) { > - if (trailing_slashes(nd)) > + if (trailing_slashes(nd->last)) > return ERR_PTR(-EISDIR); > > /* Don't bother on an O_EXCL create */ > @@ -4542,7 +4542,7 @@ static struct dentry *lookup_fast_for_open(struct nameidata *nd, int open_flag) > return NULL; > } > > - if (trailing_slashes(nd)) > + if (trailing_slashes(nd->last)) > nd->flags |= LOOKUP_FOLLOW | LOOKUP_DIRECTORY; > > dentry = lookup_fast(nd); > @@ -4945,7 +4945,7 @@ static struct dentry *filename_create(int dfd, struct filename *name, > * Do the final lookup. Suppress 'create' if there is a trailing > * '/', and a directory wasn't requested. > */ > - if (last.name[last.len] && !want_dir) > + if (trailing_slashes(last) && !want_dir) > create_flags &= ~LOOKUP_CREATE; > dentry = start_dirop(path->dentry, &last, reval_flag | create_flags); > if (IS_ERR(dentry)) > @@ -5562,7 +5562,7 @@ int filename_unlinkat(int dfd, struct filename *name) > goto exit_drop_write; > > /* Why not before? Because we want correct error value */ > - if (unlikely(last.name[last.len])) { > + if (unlikely(trailing_slashes(last))) { > if (d_is_dir(dentry)) > error = -EISDIR; > else > @@ -6161,16 +6161,16 @@ int filename_renameat2(int olddfd, struct filename *from, > if (flags & RENAME_EXCHANGE) { > if (!d_is_dir(rd.new_dentry)) { > error = -ENOTDIR; > - if (new_last.name[new_last.len]) > + if (trailing_slashes(new_last)) > goto exit_unlock; > } > } > /* unless the source is a directory trailing slashes give -ENOTDIR */ > if (!d_is_dir(rd.old_dentry)) { > error = -ENOTDIR; > - if (old_last.name[old_last.len]) > + if (trailing_slashes(old_last)) > goto exit_unlock; > - if (!(flags & RENAME_EXCHANGE) && new_last.name[new_last.len]) > + if (!(flags & RENAME_EXCHANGE) && trailing_slashes(new_last)) > goto exit_unlock; > } >