Skip to contentSkip to conversation

overlayfs.rst: clarify the scope of file locks taken through the overlay

PATCH In review Tao Cui 3 participants 3 messages Sep 3 – Nov 18

Subsystems (3)
lore
Share & tools
lore

Tao Cui

author
#0 lore raw

PATCH v2 1/1 overlayfs.rst: clarify the scope of file locks taken through the overlay

From: Tao Cui <[email protected]>

File locks and leases taken on files through the overlay mount are only meaningful between tasks that access the files through the same overlay mount; they do not conflict with anything that changes the underlying filesystems directly. Add a short note to "Changes to underlying filesystems" stating this scope.

---
Changes since v1:
- minimal note within "Changes to underlying filesystems" instead of a separate section, per review (Amir Goldstein)

---
 Documentation/filesystems/overlayfs.rst | 9 +++++++++
 1 file changed, 9 insertions(+)
Documentation/filesystems/overlayfs.rst +9 -0
index 16c35b491dad..11af5bc73e32 100644
@@ -671,6 +671,15 @@ filesystem are not allowed.  If the underlying filesystem is changed,
 the behavior of the overlay is undefined, though it will not result in
 a crash or deadlock.
 
+Note that file locks and leases taken on files through the overlay
+mount only provide mutual exclusion between tasks that access the
+files through the same overlay mount, and a lease taken through the
+overlay is broken by opens through that overlay.  They do not
+conflict with locks taken on the same files by anything that changes
+the underlying filesystems directly, so file locking cannot be relied
+on for mutual exclusion between overlay users and such direct
+changes.
+
 Offline changes, when the overlay is not mounted, are allowed to the
 upper tree.  Offline changes to the lower tree are only allowed if the
 "metacopy", "index", "xino" and "redirect_dir" features
Signature · 1 line
2.43.0
maintainer Reviewed-by on v2 1/1
#1 lore raw
Quoted 39 lines · Tao Cui

From: Tao Cui <[email protected]>

File locks and leases taken on files through the overlay mount are only meaningful between tasks that access the files through the same overlay mount; they do not conflict with anything that changes the underlying filesystems directly. Add a short note to "Changes to underlying filesystems" stating this scope.

---
Changes since v1:
- minimal note within "Changes to underlying filesystems" instead of a separate section, per review (Amir Goldstein)

---
 Documentation/filesystems/overlayfs.rst | 9 +++++++++
 1 file changed, 9 insertions(+)
Documentation/filesystems/overlayfs.rst +9 -1
index 16c35b491dad..11af5bc73e32 100644
@@ -671,6 +671,15 @@ filesystem are not allowed.  If the underlying filesystem is changed,
 the behavior of the overlay is undefined, though it will not result in
 a crash or deadlock.
 
+Note that file locks and leases taken on files through the overlay
+mount only provide mutual exclusion between tasks that access the
+files through the same overlay mount, and a lease taken through the
+overlay is broken by opens through that overlay.  They do not
+conflict with locks taken on the same files by anything that changes
+the underlying filesystems directly, so file locking cannot be relied
+on for mutual exclusion between overlay users and such direct
+changes.
+
 Offline changes, when the overlay is not mounted, are allowed to the
 upper tree.  Offline changes to the lower tree are only allowed if the
 "metacopy", "index", "xino" and "redirect_dir" features
--
Quoted 2 lines

2.43.0

I'd like to wait for Miklos to comment before merging this.

Thanks,
Amir.

maintainer
#2 lore raw
Quoted 11 lines · Amir Goldstein

Documentation/filesystems/overlayfs.rst filesystem are not allowed. If the underlying filesystem is changed, · line 681

Quoted 8 lines · Tao Cui
Documentation/filesystems/overlayfs.rst +8 -0
+Note that file locks and leases taken on files through the overlay
+mount only provide mutual exclusion between tasks that access the
+files through the same overlay mount, and a lease taken through the
+overlay is broken by opens through that overlay.  They do not
+conflict with locks taken on the same files by anything that changes
+the underlying filesystems directly, so file locking cannot be relied
+on for mutual exclusion between overlay users and such direct
+changes.

Locks: completely agree.

Leases: independence on overlay and backing is not guaranteed, as open and read/write/etc. may trigger an open on the real file, which checks for conflicting leases.

Thanks,
Miklos