btrfs: 하위 볼륨에 마운트 옵션이 적용되지 않는 이유는 무엇입니까?

btrfs: 하위 볼륨에 마운트 옵션이 적용되지 않는 이유는 무엇입니까?

openSUSE Tumbleweed를 실행 중인데 btrfs 하위 볼륨을 마운트할 때 이상한 동작을 발견했습니다. btrfs 파일 시스템에 두 개의 하위 볼륨이 있습니다: @media@migration. 내 /etc/fstab설정은 다음과 같습니다.

UUID=<UUID>       /mnt/media      btrfs   subvol=/@media,noatime,noexec,nodev,nosuid      0       0
UUID=<UUID>       /mnt/migration  btrfs   subvol=/@migration,noatime,noexec,nodev,nosuid  0       0

그러나 실행하면 mount -a다음과 같은 결과가 나타납니다.

/dev/sdb1 on /mnt/media type btrfs (rw,nosuid,nodev,noexec,noatime,space_cache=v2,subvolid=278,subvol=/@media)
/dev/sdb1 on /mnt/migration type btrfs (rw,relatime,space_cache=v2,subvolid=279,subvol=/@migration)

보시다시피 마운트 옵션은 nosuid,nodev,noexec,noatime마운트된 첫 번째 하위 볼륨에만 적용되는 것으로 보입니다. 두 번째만 relatime.

내가 시도할 때다시 설치두 번째 하위 볼륨은 올바르게 표시됩니다.

:~> sudo mount -o remount,noatime /dev/sdb1 /mnt/migration
:~> mount | tail -n 2
/dev/sdb1 on /mnt/media type btrfs (rw,nosuid,nodev,noexec,noatime,space_cache=v2,subvolid=278,subvol=/@media)
/dev/sdb1 on /mnt/migration type btrfs (rw,noatime,space_cache=v2,subvolid=279,subvol=/@migration)

그래서 내 질문은 다음과 같습니다

  1. 후속 하위 볼륨의 마운트 옵션이 중요합니까? (즉, 이것은 단지 시각적인 오류일까요?)
  2. 마운트 옵션이 실제로 적용되는지 확인할 수 있는 방법이 있습니까?

답변1

하위 볼륨 마운트는 실제로 noatime을 따릅니다. 이는 새로운 btrfs 문서에 명시적으로 명시되어 있습니다(불분명하지만).https://btrfs.readthedocs.io/en/latest/btrfs-subvolume.html#mount-options

(그들은 또한 내가 온 목적인 noexec도 지원합니다.)

$ sudo mount -o subvolid=257,noatime /dev/sdd1 test
$ touch -a -t 9001010101 test/foo
$ stat test/foo
Access: 1990-01-01 01:01:00.000000000 -0700
$ cat test/foo # noatime: atime unchanged
$ stat test/foo
Access: 1990-01-01 01:01:00.000000000 -0700
$ sudo umount test
$ sudo mount -o subvolid=257 /dev/sdd1 test
$ cat test/foo # default (relatime): atime changed
$ stat test/foo
Access: 2023-09-20 03:50:37.919732794 -0600

(간결함을 위해 stat의 다른 출력 라인은 잘렸습니다.)

답변2

제 평판이 50 미만이라 스쿼클님의 셀프답변에 대해서는 코멘트를 드릴 수가 없네요. 그러나 테스트에는 결함이 있습니다. touch -aAtime은 마운트 지점 옵션에 관계없이 업데이트됩니다.

/tmp
 32% ❯ sudo mount -t tmpfs -o noatime none noatime

/tmp
 32% ❯ cd noatime/

/tmp/noatime
 32% ❯ touch banana

/tmp/noatime
 32% ❯ stat banana
  File: banana
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 0,116   Inode: 2           Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/vytautas)   Gid: (  100/   users)
Access: 2022-04-14 00:03:14.714042647 +0300
Modify: 2022-04-14 00:03:14.714042647 +0300
Change: 2022-04-14 00:03:14.714042647 +0300
 Birth: -

/tmp/noatime
 32% ❯ cat banana

/tmp/noatime
 32% ❯ stat banana
  File: banana
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 0,116   Inode: 2           Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/vytautas)   Gid: (  100/   users)
Access: 2022-04-14 00:03:14.714042647 +0300
Modify: 2022-04-14 00:03:14.714042647 +0300
Change: 2022-04-14 00:03:14.714042647 +0300
 Birth: -

/tmp/noatime
 32% ❯ touch -a -t 1212121212 banana

/tmp/noatime
 32% ❯ stat banana
  File: banana
  Size: 0               Blocks: 0          IO Block: 4096   regular empty file
Device: 0,116   Inode: 2           Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/vytautas)   Gid: (  100/   users)
Access: 2012-12-12 12:12:00.000000000 +0200
Modify: 2022-04-14 00:03:14.714042647 +0300
Change: 2022-04-14 00:03:39.030547903 +0300
 Birth: -

답변3

나는 btrfs wiki와 몇 가지 간단한 실험을 사용하여 내 질문에 답했습니다.

후속 하위 볼륨의 마운트 옵션이 중요합니까?

아니요.~에 따르면위키피디아:

노트:대부분의 마운트 옵션은 전체 파일 시스템에 적용되며 첫 번째 마운트된 하위 볼륨의 옵션만 적용됩니다. 이는 구현 부족으로 인한 것이며 향후 변경될 수 있습니다. 이는 예를 들어 마운트 옵션을 사용하여 하위 볼륨별로 nodatacow, nodatasum 또는 압축을 설정할 수 없음을 의미합니다. 이 문제는 결국 해결되어야 하지만 Linux VFS 프레임워크 내에서 올바르게 구현하기 어려운 것으로 입증되었습니다.

마운트 옵션이 실제로 적용되는지 확인할 수 있는 방법이 있습니까?

예.나는 atime/ 매개변수를 사용하여 noatime이 작업을 수행했습니다 .

  1. atime옵션 1을 사용하여 하위 볼륨 마운트
  2. noatime옵션 2를 사용하여 하위 볼륨 마운트
  3. 하위 볼륨 2에 테스트 파일 만들기
  4. atime을 임의의 값으로 설정하는 데 사용됩니다 touch(예 touch -a -t 12121212 test_file: )
  5. atime이 테스트 값으로 설정되어 있는지 확인ls -lu

이 실험에서는 하위 볼륨 2가 이 옵션으로 마운트되었지만 해당 atime이 하위 볼륨 2에서 업데이트되었음을 ​​보여줍니다 noatime. 이는 atime이 옵션을 사용하여 하위 볼륨 1이 먼저 마운트 되기 때문입니다 .

관련 정보