On Mon, Aug 25, 2025 at 05:43:22AM +0100, Al Viro wrote: > 1) checking that location we want to move does point to root of some mount > can be done before anything else; that property is not going to change > and having it already verified simplifies the analysis. > > 2) checking the type agreement between what we are trying to move and what > we are trying to move it onto also belongs in the very beginning - > do_lock_mount() might end up switching new_path to something that overmounts > the original location, but... the same type agreement applies to overmounts, > so we could just as well check against the original location. > > 3) since we know that old_path->dentry is the root of old_path->mnt, there's > no point bothering with path_is_overmounted() in can_move_mount_beneath(); > it's simply a check for the mount we are trying to move having non-NULL > ->overmount. And with that, we can switch can_move_mount_beneath() to > taking old instead of old_path, leaving no uses of old_path past the original > checks. > > Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx> > --- Reviewed-by: Christian Brauner <brauner@xxxxxxxxxx>