Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755030AbbEFCnG (ORCPT ); Tue, 5 May 2015 22:43:06 -0400 Received: from cantor2.suse.de ([195.135.220.15]:49127 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751127AbbEFCnF (ORCPT ); Tue, 5 May 2015 22:43:05 -0400 Date: Wed, 6 May 2015 12:42:54 +1000 From: NeilBrown To: Al Viro Cc: Linus Torvalds , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 47/79] namei: move link/cookie pairs into nameidata Message-ID: <20150506124254.5c28e4c6@notabene.brown> In-Reply-To: <1430803373-4948-47-git-send-email-viro@ZenIV.linux.org.uk> References: <20150505052205.GS889@ZenIV.linux.org.uk> <1430803373-4948-47-git-send-email-viro@ZenIV.linux.org.uk> X-Mailer: Claws Mail 3.10.1-162-g4d0ed6 (GTK+ 2.24.25; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/UMYmK.07nFOSuDxeXOPRjcv"; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3354 Lines: 106 --Sig_/UMYmK.07nFOSuDxeXOPRjcv Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Tue, 5 May 2015 06:22:21 +0100 Al Viro wrote: > From: Al Viro >=20 > Array of MAX_NESTED_LINKS + 1 elements put into nameidata; > what used to be a local array in link_path_walk() occupies > entries 1 .. MAX_NESTED_LINKS in it, link and cookie from > the trailing symlink handling loops - entry 0. >=20 > This is _not_ the final arrangement; just an easily verified > incremental step. >=20 > Signed-off-by: Al Viro > --- > fs/namei.c | 35 ++++++++++++++++++----------------- > 1 file changed, 18 insertions(+), 17 deletions(-) >=20 > diff --git a/fs/namei.c b/fs/namei.c > index 38ff968..e6d54ec 100644 > --- a/fs/namei.c > +++ b/fs/namei.c > @@ -505,6 +505,11 @@ struct nameidata { > int last_type; > unsigned depth; > struct file *base; > + struct saved { > + struct path link; > + void *cookie; > + const char *name; > + } stack[MAX_NESTED_LINKS + 1]; > }; > =20 > /* > @@ -1703,11 +1708,7 @@ static inline u64 hash_name(const char *name) > */ > static int link_path_walk(const char *name, struct nameidata *nd) > { > - struct saved { > - struct path link; > - void *cookie; > - const char *name; > - } stack[MAX_NESTED_LINKS], *last =3D stack + nd->depth - 1; > + struct saved *last =3D nd->stack; This looks wrong. 'last' used to be dependent on nd->depth, now it isn't. Three patches later we have: +const char *get_link(struct nameidata *nd) { - struct dentry *dentry =3D link->dentry; + struct saved *last =3D nd->stack + nd->depth; + struct dentry *dentry =3D nd->link.dentry; struct inode *inode =3D dentry->d_inode; and=20 static int link_path_walk(const char *name, struct nameidata *nd) { - struct saved *last =3D nd->stack; int err; .... - last->link =3D nd->link; - s =3D get_link(&last->link, nd, &last->cookie); + s =3D get_link(nd); so the nd->depth offset is restored in get_link() so the next result appears correct, but the intermediate states appear to be wrong. NeilBrown --Sig_/UMYmK.07nFOSuDxeXOPRjcv Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIVAwUBVUl/rznsnt1WYoG5AQJjtA/7BTmml6fESGOi8hS/rH8GOoppddMyggCe gY7KtNaejpBoy0bNWD71zGZm9jZ5qZd2d9J6ZgenTrP5KvAY5kmzH7yFkzO1ltRf xGw9QIt2rWBEfCTBP1JiXQlgmtT70mwNmo72YIKdDrqEUpOENded280JeSWT1CxA 48sOTnnTI4caR7LHds9mlgiW0TYto/9rrD9n+mcmRzycRSz3whyvxCgal+dbX3jM yUuRK9ghQBWme26y4zFFmzNaUjYrMS2+92vKGP/RK5QdlSSax7ONu1/ZpS2+gXCH de1fO6WtSTMT3NyBnpLYGUYLLEjxXVR07zDM2KHQhIYyau8QqwRWgOOuanyAS+ny DZ784QD8g8wMVsLsGs+bcCYE/ByUT8/MGahosHA6DzsxS6qtfgax8zew/AyDS9vC TvhQiD/ha5e1wAT1R453w3dskgDMGHRAWTvAGKsMyJ6Nkz3pFGnXVr0mLuT4rquF HZq5oQ5tgBcWV+RuiXWNnquQeGJK9Lb6o57hL0mCHIJEmn6njM5Q3eddrwPKlYNt +h5oBVaOrG3n/wFPgROHcQNa1GFqZt3b8sj4BYkRaSUFs55OIau9sjyHG/R4i1d4 N7Wdlwh+SBmnolMx13laFAOGYN2Ku4V6S6n04ng+y67iMI+1tWmqJxouQMPelxN3 w7X533+oRzg= =IXMJ -----END PGP SIGNATURE----- --Sig_/UMYmK.07nFOSuDxeXOPRjcv-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/