fix handling of nd->depth on LOOKUP_CACHED failures in try_to_unlazy*
authorAl Viro <viro@zeniv.linux.org.uk>
Mon, 15 Feb 2021 17:03:23 +0000 (12:03 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Mon, 15 Feb 2021 17:11:40 +0000 (12:11 -0500)
commit1bef30105aefa3aaa7fb0de046c35d37ad5201aa
treec50d3306e8b5631e194c4b23726205629171bc8b
parent99668f618062816ca7ba639b007eb145b9d3d41e
fix handling of nd->depth on LOOKUP_CACHED failures in try_to_unlazy*

After switching to non-RCU mode, we want nd->depth to match the number
of entries in nd->stack[] that need eventual path_put().
legitimize_links() takes care of that on failures; unfortunately,
failure exits added for LOOKUP_CACHED do not.

We could add the logics for that into those failure exits, both in
try_to_unlazy() and in try_to_unlazy_next(), but since both checks
are immediately followed by legitimize_links() and there's no calls
of legitimize_links() other than those two...  It's easier to
move the check (and required handling of nd->depth on failure) into
legitimize_links() itself.

Fixes: 6c6ec2b0a3e0 "fs: add support for LOOKUP_CACHED"
Tested-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c