The Problem:
In order to use VFS leases to implement NFSv4 file delegations, we need to support breaking file leases on unlink, rename, chown, etc. To do so safely, we need a way to disable lease-granting for the duration of those operations in order to avoid races between the lease-breaking and lease-granting.

Currently, file leases are broken only when a file is opened or truncated. We need an approach that allows for lease-breaking without bad race conditions (e.g., the existing break-on-truncate and -open code has races), that won't cause lease-breakers to block while holding locks, and that won't add a lot of overhead to high-traffic code paths.

Samba also uses VFS leases to implement OPLOCK support; however, the existing lease subsystem doesn't actually break OPLOCK-leases all the times it "should" -- scroll to the bottom of the page for commentary and links.

Assuming we can disable lease-granting per-inode, how is it used?:



Summary of some possible solutions for disabling lease-granting per-inode:




idea 1: abuse struct inode


idea 2: create a lease-blocking struct file_lock

idea 3: abuse struct file_lock and a couple i_mutexes


unfiled / maybe applicable to all?

samba