namei: change filename_parentat() calling conventions
authorDmitry Kadashev <dkadashev@gmail.com>
Thu, 8 Jul 2021 06:34:38 +0000 (13:34 +0700)
committerJens Axboe <axboe@kernel.dk>
Fri, 13 Aug 2021 14:10:36 +0000 (08:10 -0600)
commit9d96ea38873f79ccdc7ba06201c35cb5490f6e10
tree6dc994d0c11dc4f58b40afee689ac326d12e89f4
parent86b975e52fedd374a059b1a9857d136b4fb1c95b
namei: change filename_parentat() calling conventions

Since commit 5c31b6cedb675 ("namei: saner calling conventions for
filename_parentat()") filename_parentat() had the following behavior WRT
the passed in struct filename *:

* On error the name is consumed (putname() is called on it);
* On success the name is returned back as the return value;

Now there is a need for filename_create() and filename_lookup() variants
that do not consume the passed filename, and following the same "consume
the name only on error" semantics is proven to be hard to reason about
and result in confusing code.

Hence this preparation change splits filename_parentat() into two: one
that always consumes the name and another that never consumes the name.
This will allow to implement two filename_create() variants in the same
way, and is a consistent and hopefully easier to reason about approach.

Link: https://lore.kernel.org/io-uring/CAOKbgA7MiqZAq3t-HDCpSGUFfco4hMA9ArAE-74fTpU+EkvKPw@mail.gmail.com/
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dmitry Kadashev <dkadashev@gmail.com>
Link: https://lore.kernel.org/r/20210708063447.3556403-3-dkadashev@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/namei.c