linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Apparent mount behaviour change in 6.15
@ 2025-05-15  4:06 Allison Karlitskaya
  2025-05-15 11:25 ` Christian Brauner
  0 siblings, 1 reply; 11+ messages in thread
From: Allison Karlitskaya @ 2025-05-15  4:06 UTC (permalink / raw)
  To: Christian Brauner; +Cc: linux-fsdevel

hi,

The CI in the composefs-rs project picked up an interesting issue with
the recent mount API changes in the latest 6.15-rc kernels.  I've
managed to produce a minimal reproducer.

==> test.sh <==
#!/bin/sh

set -eux

uname -a
umount --recursive tmp/mnt || true
rm -rf tmp/mnt tmp/new
mkdir -p tmp/mnt tmp/new tmp/new/old
touch tmp/mnt/this-is-old
touch tmp/new/this-is-new
./swapmnt tmp/new tmp/mnt
find tmp/mnt

==> swapmnt.c <==
// Replace [old] with a clone of [new], moving [old] to [new]/"old"

#define _GNU_SOURCE
#include <err.h>
#include <fcntl.h>
#include <linux/mount.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <unistd.h>

int
main (int argc, char **argv) {
  if (argc != 3) {
    fprintf(stderr, "usage: %s [new] [old]", argv[0]);
    return 1;
  }

  const char *new = argv[1];
  const char *old = argv[2];

  int oldfd = syscall(SYS_open_tree, AT_FDCWD, old,
OPEN_TREE_CLONE|OPEN_TREE_CLOEXEC);
  if (oldfd == -1)
    err(EXIT_FAILURE, "open_tree('%s', OPEN_TREE_CLONE)", old);

  int newfd = syscall(SYS_open_tree, AT_FDCWD, new,
OPEN_TREE_CLONE|OPEN_TREE_CLOEXEC);
  if (newfd == -1)
    err(EXIT_FAILURE, "open_tree('%s', OPEN_TREE_CLONE)", new);

  if (syscall(SYS_move_mount, newfd, "", AT_FDCWD, old,
MOVE_MOUNT_F_EMPTY_PATH))
    err(EXIT_FAILURE, "move_mount('%s' -> '%s')", new, old);

  if (syscall(SYS_move_mount, oldfd, "", newfd, "old", MOVE_MOUNT_F_EMPTY_PATH))
    err(EXIT_FAILURE, "move_mount('%s' -> (new)'%s'/old)", old, old);

  return 0;
}

On 6.14 (Fedora 42) this looks like:

[root@fedora-bls-efi-127-0-0-2-2201 tmp]# sh test.sh
+ uname -a
Linux fedora-bls-efi-127-0-0-2-2201 6.14.5-300.fc42.x86_64 #1 SMP
PREEMPT_DYNAMIC Fri May  2 14:16:46 UTC 2025 x86_64 GNU/Linux
+ umount --recursive tmp/mnt
umount: tmp/mnt: not found
+ true
+ rm -rf tmp/mnt tmp/new
+ mkdir -p tmp/mnt tmp/new tmp/new/old
+ touch tmp/mnt/this-is-old
+ touch tmp/new/this-is-new
+ ./swapmnt tmp/new tmp/mnt
+ find tmp/mnt
tmp/mnt
tmp/mnt/this-is-new
tmp/mnt/old
tmp/mnt/old/this-is-old
[root@fedora-bls-efi-127-0-0-2-2201 tmp]#

On 6.15 from yesterday (9f35e33144ae, via @kernel-vanilla/mainline
copr, on rawhide):

[root@fedora tmp]# sh test.sh
+ uname -a
Linux fedora 6.15.0-0.rc6.20250514.9f35e331.450.vanilla.fc43.x86_64 #1
SMP PREEMPT_DYNAMIC Wed May 14 04:18:35 UTC 2025 x86_64 GNU/Linux
+ umount --recursive tmp/mnt
umount: tmp/mnt: not mounted
+ true
+ rm -rf tmp/mnt tmp/new
+ mkdir -p tmp/mnt tmp/new tmp/new/old
+ touch tmp/mnt/this-is-old
+ touch tmp/new/this-is-new
+ ./swapmnt tmp/new tmp/mnt
+ find tmp/mnt
tmp/mnt
tmp/mnt/this-is-new
find: File system loop detected; ‘tmp/mnt/old’ is part of the same
file system loop as ‘tmp/mnt’.
[root@fedora tmp]#

Otherwise, I gotta say I'm loving all of the new mount work this cycle!

Thanks,

lis


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-05-26 21:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-15  4:06 Apparent mount behaviour change in 6.15 Allison Karlitskaya
2025-05-15 11:25 ` Christian Brauner
2025-05-23  6:32   ` Al Viro
2025-05-23  8:41     ` Christian Brauner
2025-05-23 21:29       ` Al Viro
2025-05-23 21:37         ` Al Viro
2025-05-23 23:22           ` Al Viro
2025-05-26  4:47             ` Christian Brauner
2025-05-26 21:32               ` Al Viro
2025-05-26  7:18             ` Allison Karlitskaya
2025-05-26  8:00               ` Allison Karlitskaya

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).