← Documents Documentation/filesystems/automount-support.rst GitHub 원문 ↗

Linux 6.18.37 · Filesystems

Automount Support

커널 내부 automount와 두 단계 vfsmount 만료 API를 설명하는 전문 번역입니다.

Source pathDocumentation/filesystems/automount-support.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

automount-support.rst:1-98

파일시스템은 VFS automount 지원으로 `d_automount`에서 새 vfsmount를 만들고 `mnt_set_expiry()` 목록에 등록할 수 있습니다. `mark_mounts_for_expiry()`와 `MNT_EXPIRE`는 모두 접근 이후 두 번째 요청에서 만료하는 방식을 사용해 사용 중인 마운트가 갑자기 사라지는 일을 막습니다.

automount 생성과 만료
마운트 트랩 접근`d_automount`에서 vfsmount 생성`mnt_set_expiry()`로 만료 목록 등록첫 만료 요청으로 표시추가 접근이 없으면 두 번째 요청에서 언마운트

커널 내부 마운트의 전체 수명 주기입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 =================
4 Automount Support
5 =================
6
7
8 Support is available for filesystems that wish to do automounting
9 support (such as kAFS which can be found in fs/afs/ and NFS in
10 fs/nfs/). This facility includes allowing in-kernel mounts to be
11 performed and mountpoint degradation to be requested. The latter can
12 also be requested by userspace.
13
14
15 In-Kernel Automounting
16 ======================
17
18 See section "Mount Traps" of Documentation/filesystems/autofs.rst
19
20 Then from userspace, you can just do something like::
21
22 [root@andromeda root]# mount -t afs \#root.afs. /afs
23 [root@andromeda root]# ls /afs
24 asd cambridge cambridge.redhat.com grand.central.org
25 [root@andromeda root]# ls /afs/cambridge
26 afsdoc
27 [root@andromeda root]# ls /afs/cambridge/afsdoc/
28 ChangeLog html LICENSE pdf RELNOTES-1.2.2
29
30 And then if you look in the mountpoint catalogue, you'll see something like::
31
32 [root@andromeda root]# cat /proc/mounts
33 ...
34 #root.afs. /afs afs rw 0 0
35 #root.cell. /afs/cambridge.redhat.com afs rw 0 0
36 #afsdoc. /afs/cambridge.redhat.com/afsdoc afs rw 0 0
37
38
39 Automatic Mountpoint Expiry
40 ===========================
41
42 Automatic expiration of mountpoints is easy, provided you've mounted the
43 mountpoint to be expired in the automounting procedure outlined separately.
44
45 To do expiration, you need to follow these steps:
46
47 (1) Create at least one list off which the vfsmounts to be expired can be
48 hung.
49
50 (2) When a new mountpoint is created in the ->d_automount method, add
51 the mnt to the list using mnt_set_expiry()::
52
53 mnt_set_expiry(newmnt, &afs_vfsmounts);
54
55 (3) When you want mountpoints to be expired, call mark_mounts_for_expiry()
56 with a pointer to this list. This will process the list, marking every
57 vfsmount thereon for potential expiry on the next call.
58
59 If a vfsmount was already flagged for expiry, and if its usage count is 1
60 (it's only referenced by its parent vfsmount), then it will be deleted
61 from the namespace and thrown away (effectively unmounted).
62
63 It may prove simplest to simply call this at regular intervals, using
64 some sort of timed event to drive it.
65
66 The expiration flag is cleared by calls to mntput. This means that expiration
67 will only happen on the second expiration request after the last time the
68 mountpoint was accessed.
69
70 If a mountpoint is moved, it gets removed from the expiration list. If a bind
71 mount is made on an expirable mount, the new vfsmount will not be on the
72 expiration list and will not expire.
73
74 If a namespace is copied, all mountpoints contained therein will be copied,
75 and the copies of those that are on an expiration list will be added to the
76 same expiration list.
77
78
79 Userspace Driven Expiry
80 =======================
81
82 As an alternative, it is possible for userspace to request expiry of any
83 mountpoint (though some will be rejected - the current process's idea of the
84 rootfs for example). It does this by passing the MNT_EXPIRE flag to
85 umount(). This flag is considered incompatible with MNT_FORCE and MNT_DETACH.
86
87 If the mountpoint in question is in referenced by something other than
88 umount() or its parent mountpoint, an EBUSY error will be returned and the
89 mountpoint will not be marked for expiration or unmounted.
90
91 If the mountpoint was not already marked for expiry at that time, an EAGAIN
92 error will be given and it won't be unmounted.
93
94 Otherwise if it was already marked and it wasn't referenced, unmounting will
95 take place as usual.
96
97 Again, the expiration flag is cleared every time anything other than umount()
98 looks at a mountpoint.
99

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

지원 범위

1-14

kAFS(`fs/afs/`)나 NFS(`fs/nfs/`)처럼 자동 마운트를 구현하려는 파일시스템을 위한 지원 기능이 있습니다. 이 기능은 커널 내부에서 마운트를 수행하고 마운트 지점의 degradation을 요청할 수 있게 하며, 후자의 요청은 사용자 공간에서도 보낼 수 있습니다.

automount 지원 기능
기능요청 주체목적
커널 내부 automount파일시스템경로 접근에 따라 새 vfsmount 생성
마운트 지점 degradation커널 또는 사용자 공간사용하지 않는 마운트의 만료 준비

파일시스템과 사용자 공간이 사용할 수 있는 핵심 기능입니다.

.. SPDX-License-Identifier: GPL-2.0

=================
Automount Support
=================


Support is available for filesystems that wish to do automounting
support (such as kAFS which can be found in fs/afs/ and NFS in
fs/nfs/). This facility includes allowing in-kernel mounts to be
performed and mountpoint degradation to be requested. The latter can
also be requested by userspace.

커널 내부 automount

15-38

기본 동작은 `Documentation/filesystems/autofs.rst`의 "Mount Traps" 절을 참고하십시오.

사용자 공간에서는 예시처럼 `mount -t afs #root.afs. /afs`로 AFS 루트를 마운트한 뒤 `/afs`, `/afs/cambridge`, `/afs/cambridge/afsdoc/`를 차례로 조회할 수 있습니다. 각 경로 접근이 필요한 하위 AFS 볼륨의 자동 마운트를 유발합니다.

그 뒤 `/proc/mounts`를 확인하면 `#root.afs.`가 `/afs`에, `#root.cell.`이 `/afs/cambridge.redhat.com`에, `#afsdoc.`이 `/afs/cambridge.redhat.com/afsdoc`에 각각 마운트된 것을 볼 수 있습니다. 즉 최초 루트 마운트 아래의 경로 탐색으로 하위 마운트가 커널 내부에서 만들어집니다.

kAFS automount 예시
`#root.afs.`를 `/afs`에 마운트`ls /afs`로 셀 이름 조회`ls /afs/cambridge`로 셀 볼륨 자동 마운트`ls .../afsdoc`로 문서 볼륨 자동 마운트`/proc/mounts`에서 세 단계 vfsmount 확인

경로 접근이 하위 볼륨 마운트로 확장되는 순서입니다.

In-Kernel Automounting
======================

See section "Mount Traps" of  Documentation/filesystems/autofs.rst

Then from userspace, you can just do something like::

        [root@andromeda root]# mount -t afs \#root.afs. /afs
        [root@andromeda root]# ls /afs
        asd  cambridge  cambridge.redhat.com  grand.central.org
        [root@andromeda root]# ls /afs/cambridge
        afsdoc
        [root@andromeda root]# ls /afs/cambridge/afsdoc/
        ChangeLog  html  LICENSE  pdf  RELNOTES-1.2.2

And then if you look in the mountpoint catalogue, you'll see something like::

        [root@andromeda root]# cat /proc/mounts
        ...
        #root.afs. /afs afs rw 0 0
        #root.cell. /afs/cambridge.redhat.com afs rw 0 0
        #afsdoc. /afs/cambridge.redhat.com/afsdoc afs rw 0 0

자동 마운트 지점 만료

39-78

별도로 설명된 automount 절차로 만료 대상 마운트 지점을 만들었다면 자동 만료 구현은 간단합니다.

첫째, 만료시킬 vfsmount를 연결할 목록을 하나 이상 만듭니다. 둘째, `->d_automount` 메서드에서 새 마운트 지점을 만들 때 `mnt_set_expiry(newmnt, &afs_vfsmounts)`처럼 `mnt_set_expiry()`로 해당 mnt를 목록에 추가합니다.

셋째, 마운트 지점을 만료시키려는 시점에 목록 포인터를 `mark_mounts_for_expiry()`에 전달합니다. 이 함수는 목록을 처리하면서 모든 vfsmount를 다음 호출에서 만료할 잠재적 대상으로 표시합니다.

vfsmount가 이미 만료 대상으로 표시되어 있고 사용 횟수가 1, 즉 부모 vfsmount에서만 참조 중이면 네임스페이스에서 제거하고 폐기하여 사실상 언마운트합니다. 타이머 사건 같은 것으로 이 함수를 일정 간격마다 호출하는 방식이 가장 단순할 수 있습니다.

`mntput` 호출은 만료 플래그를 지웁니다. 따라서 마운트 지점에 마지막으로 접근한 뒤 두 번째 만료 요청에서만 실제 만료가 일어납니다.

마운트 지점을 이동하면 만료 목록에서 제거됩니다. 만료 가능한 마운트 위에 bind 마운트를 만들면 새 vfsmount는 만료 목록에 포함되지 않아 만료되지 않습니다.

네임스페이스를 복사하면 안의 모든 마운트 지점도 복사됩니다. 원본이 만료 목록에 있었다면 그 복사본도 같은 만료 목록에 추가됩니다.

커널 자동 만료의 두 단계
만료용 vfsmount 목록 생성`d_automount`에서 `mnt_set_expiry()`로 새 mnt 등록첫 `mark_mounts_for_expiry()`가 만료 후보 표시중간 접근의 `mntput`이 표시를 지움접근 없이 두 번째 호출, 참조 수가 1이면 네임스페이스에서 제거

첫 호출은 표시하고, 접근이 없을 때 다음 호출이 제거합니다.

Automatic Mountpoint Expiry
===========================

Automatic expiration of mountpoints is easy, provided you've mounted the
mountpoint to be expired in the automounting procedure outlined separately.

To do expiration, you need to follow these steps:

 (1) Create at least one list off which the vfsmounts to be expired can be
     hung.

 (2) When a new mountpoint is created in the ->d_automount method, add
     the mnt to the list using mnt_set_expiry()::

             mnt_set_expiry(newmnt, &afs_vfsmounts);

 (3) When you want mountpoints to be expired, call mark_mounts_for_expiry()
     with a pointer to this list. This will process the list, marking every
     vfsmount thereon for potential expiry on the next call.

     If a vfsmount was already flagged for expiry, and if its usage count is 1
     (it's only referenced by its parent vfsmount), then it will be deleted
     from the namespace and thrown away (effectively unmounted).

     It may prove simplest to simply call this at regular intervals, using
     some sort of timed event to drive it.

The expiration flag is cleared by calls to mntput. This means that expiration
will only happen on the second expiration request after the last time the
mountpoint was accessed.

If a mountpoint is moved, it gets removed from the expiration list. If a bind
mount is made on an expirable mount, the new vfsmount will not be on the
expiration list and will not expire.

If a namespace is copied, all mountpoints contained therein will be copied,
and the copies of those that are on an expiration list will be added to the
same expiration list.

사용자 공간 주도 만료

79-98

다른 방법으로 사용자 공간이 임의의 마운트 지점 만료를 요청할 수 있습니다. 다만 현재 프로세스가 인식하는 rootfs 같은 일부 대상은 거부됩니다. `umount()`에 `MNT_EXPIRE` 플래그를 전달하며, 이 플래그는 `MNT_FORCE` 및 `MNT_DETACH`와 함께 사용할 수 없습니다.

대상 마운트 지점을 `umount()` 또는 부모 마운트 지점 이외의 무언가가 참조하고 있으면 `EBUSY`를 반환하고, 만료 대상으로 표시하지도 언마운트하지도 않습니다.

그 시점에 마운트 지점이 아직 만료 대상으로 표시되지 않았다면 `EAGAIN`을 반환하고 언마운트하지 않습니다. 이미 표시되어 있고 다른 참조가 없다면 일반적인 언마운트가 진행됩니다.

`umount()` 이외의 어떤 동작이든 마운트 지점을 조회할 때마다 만료 플래그가 다시 지워집니다.

`MNT_EXPIRE` 결과
상태결과
다른 참조가 존재`EBUSY`, 표시와 언마운트 모두 수행하지 않음
아직 만료 표시 없음`EAGAIN`, 표시만 설정하고 언마운트하지 않음
이미 표시됨, 다른 참조 없음일반 언마운트 수행
두 요청 사이에 다른 접근만료 표시가 지워져 다시 첫 단계부터 시작

사용자 공간의 두 단계 만료 요청이 반환하는 상태입니다.

Userspace Driven Expiry
=======================

As an alternative, it is possible for userspace to request expiry of any
mountpoint (though some will be rejected - the current process's idea of the
rootfs for example). It does this by passing the MNT_EXPIRE flag to
umount(). This flag is considered incompatible with MNT_FORCE and MNT_DETACH.

If the mountpoint in question is in referenced by something other than
umount() or its parent mountpoint, an EBUSY error will be returned and the
mountpoint will not be marked for expiration or unmounted.

If the mountpoint was not already marked for expiry at that time, an EAGAIN
error will be given and it won't be unmounted.

Otherwise if it was already marked and it wasn't referenced, unmounting will
take place as usual.

Again, the expiration flag is cleared every time anything other than umount()
looks at a mountpoint.