[PATCH v2 01/31] Documentation: document EXPORT_OP_NOLOCKS

Jeff Layton posted 31 patches 2 weeks, 5 days ago
[PATCH v2 01/31] Documentation: document EXPORT_OP_NOLOCKS
Posted by Jeff Layton 2 weeks, 5 days ago
This got missed when the flag was added. Document it properly.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 Documentation/filesystems/nfs/exporting.rst | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/Documentation/filesystems/nfs/exporting.rst b/Documentation/filesystems/nfs/exporting.rst
index de64d2d002a204c5460980c898d4ec41fd43d47a..0583a0516b1e3a3e6a10af95ff88506cf02f7df4 100644
--- a/Documentation/filesystems/nfs/exporting.rst
+++ b/Documentation/filesystems/nfs/exporting.rst
@@ -238,3 +238,9 @@ following flags are defined:
     all of an inode's dirty data on last close. Exports that behave this
     way should set EXPORT_OP_FLUSH_ON_CLOSE so that NFSD knows to skip
     waiting for writeback when closing such files.
+
+  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Some
+    filesystems cannot properly support file locking as implemented by
+    nfsd. A case in point is reexport of NFS itself, which can't be done
+    safely without coordinating the grace period handling. Other clustered
+    and networked filesystems can be problematic here as well.

-- 
2.52.0
Re: [PATCH v2 01/31] Documentation: document EXPORT_OP_NOLOCKS
Posted by Christoph Hellwig 2 weeks, 5 days ago
On Mon, Jan 19, 2026 at 11:26:18AM -0500, Jeff Layton wrote:
> +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Some
> +    filesystems cannot properly support file locking as implemented by
> +    nfsd. A case in point is reexport of NFS itself, which can't be done
> +    safely without coordinating the grace period handling. Other clustered
> +    and networked filesystems can be problematic here as well.

I'm not sure this is very useful.  It really needs to document what
locking semantics nfs expects, because otherwise no reader will know
if they set this or not.
Re: [PATCH v2 01/31] Documentation: document EXPORT_OP_NOLOCKS
Posted by Jeff Layton 2 weeks, 5 days ago
On Mon, 2026-01-19 at 23:44 -0800, Christoph Hellwig wrote:
> On Mon, Jan 19, 2026 at 11:26:18AM -0500, Jeff Layton wrote:
> > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Some
> > +    filesystems cannot properly support file locking as implemented by
> > +    nfsd. A case in point is reexport of NFS itself, which can't be done
> > +    safely without coordinating the grace period handling. Other clustered
> > +    and networked filesystems can be problematic here as well.
> 
> I'm not sure this is very useful.  It really needs to document what
> locking semantics nfs expects, because otherwise no reader will know
> if they set this or not.

Fair point. I'll see if I can draft something better. Suggestions
welcome.
-- 
Jeff Layton <jlayton@kernel.org>
Re: [PATCH v2 01/31] Documentation: document EXPORT_OP_NOLOCKS
Posted by Jeff Layton 2 weeks, 4 days ago
On Tue, 2026-01-20 at 08:20 -0500, Jeff Layton wrote:
> On Mon, 2026-01-19 at 23:44 -0800, Christoph Hellwig wrote:
> > On Mon, Jan 19, 2026 at 11:26:18AM -0500, Jeff Layton wrote:
> > > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Some
> > > +    filesystems cannot properly support file locking as implemented by
> > > +    nfsd. A case in point is reexport of NFS itself, which can't be done
> > > +    safely without coordinating the grace period handling. Other clustered
> > > +    and networked filesystems can be problematic here as well.
> > 
> > I'm not sure this is very useful.  It really needs to document what
> > locking semantics nfs expects, because otherwise no reader will know
> > if they set this or not.
> 
> Fair point. I'll see if I can draft something better. Suggestions
> welcome.

How about this?

+  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Filesystems
+    that want to support locking over NFS must support POSIX file locking
+    semantics and must handle lock recovery requests from clients after a
+    reboot. Most local disk, RAM, or pseudo-filesystems use the generic POSIX
+    locking support in the kernel and naturally provide this capability. Network
+    or clustered filesystems usually need special handling to do this properly.

-- 
Jeff Layton <jlayton@kernel.org>
Re: [PATCH v2 01/31] Documentation: document EXPORT_OP_NOLOCKS
Posted by Jeff Layton 2 weeks, 4 days ago
On Tue, 2026-01-20 at 09:12 -0500, Jeff Layton wrote:
> On Tue, 2026-01-20 at 08:20 -0500, Jeff Layton wrote:
> > On Mon, 2026-01-19 at 23:44 -0800, Christoph Hellwig wrote:
> > > On Mon, Jan 19, 2026 at 11:26:18AM -0500, Jeff Layton wrote:
> > > > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Some
> > > > +    filesystems cannot properly support file locking as implemented by
> > > > +    nfsd. A case in point is reexport of NFS itself, which can't be done
> > > > +    safely without coordinating the grace period handling. Other clustered
> > > > +    and networked filesystems can be problematic here as well.
> > > 
> > > I'm not sure this is very useful.  It really needs to document what
> > > locking semantics nfs expects, because otherwise no reader will know
> > > if they set this or not.
> > 
> > Fair point. I'll see if I can draft something better. Suggestions
> > welcome.
> 
> How about this?
> 
> +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Filesystems
> +    that want to support locking over NFS must support POSIX file locking
> +    semantics and must handle lock recovery requests from clients after a
> +    reboot. Most local disk, RAM, or pseudo-filesystems use the generic POSIX
> +    locking support in the kernel and naturally provide this capability. Network
> +    or clustered filesystems usually need special handling to do this properly.

Even better, I think?

+
+  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Filesystems
+    that want to support locking over NFS must support POSIX file locking
+    semantics. When the server reboots, the clients will issue requests to
+    recover their locks, which nfsd will issue to the filesystem as new lock
+    requests. Those must succeed in order for lock recovery to work. Most
+    local disk, RAM, or pseudo-filesystems use the generic POSIX locking
+    support in the kernel and naturally provide this capability. Network or
+    clustered filesystems usually need special handling to do this properly.
+    Set this flag on filesystems that can't guarantee the proper semantics
+    (e.g. reexported NFS).

-- 
Jeff Layton <jlayton@kernel.org>
Re: [PATCH v2 01/31] Documentation: document EXPORT_OP_NOLOCKS
Posted by NeilBrown 2 weeks, 4 days ago
On Wed, 21 Jan 2026, Jeff Layton wrote:
> On Tue, 2026-01-20 at 09:12 -0500, Jeff Layton wrote:
> > On Tue, 2026-01-20 at 08:20 -0500, Jeff Layton wrote:
> > > On Mon, 2026-01-19 at 23:44 -0800, Christoph Hellwig wrote:
> > > > On Mon, Jan 19, 2026 at 11:26:18AM -0500, Jeff Layton wrote:
> > > > > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Some
> > > > > +    filesystems cannot properly support file locking as implemented by
> > > > > +    nfsd. A case in point is reexport of NFS itself, which can't be done
> > > > > +    safely without coordinating the grace period handling. Other clustered
> > > > > +    and networked filesystems can be problematic here as well.
> > > > 
> > > > I'm not sure this is very useful.  It really needs to document what
> > > > locking semantics nfs expects, because otherwise no reader will know
> > > > if they set this or not.
> > > 
> > > Fair point. I'll see if I can draft something better. Suggestions
> > > welcome.
> > 
> > How about this?
> > 
> > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Filesystems
> > +    that want to support locking over NFS must support POSIX file locking
> > +    semantics and must handle lock recovery requests from clients after a
> > +    reboot. Most local disk, RAM, or pseudo-filesystems use the generic POSIX
> > +    locking support in the kernel and naturally provide this capability. Network
> > +    or clustered filesystems usually need special handling to do this properly.
> 
> Even better, I think?
> 
> +
> +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Filesystems
> +    that want to support locking over NFS must support POSIX file locking
> +    semantics. When the server reboots, the clients will issue requests to
> +    recover their locks, which nfsd will issue to the filesystem as new lock
> +    requests. Those must succeed in order for lock recovery to work. Most
> +    local disk, RAM, or pseudo-filesystems use the generic POSIX locking
> +    support in the kernel and naturally provide this capability. Network or
> +    clustered filesystems usually need special handling to do this properly.
> +    Set this flag on filesystems that can't guarantee the proper semantics
> +    (e.g. reexported NFS).

I think this is quite thorough, which it good ...  maybe too good :-) It
reminds me that for true NFS compatibility the fs shouldn't allow local
locks (or file opens!) until the grace period has passed.  I don't think
any local filesystems enforce that - it would have to be locks.c that
does I expect.  I doubt there would be much appetite for doing that
though.

Reviewed-by: NeilBrown <neil@brown.name>

Thanks,
NeilBrown
Re: [PATCH v2 01/31] Documentation: document EXPORT_OP_NOLOCKS
Posted by Jeff Layton 2 weeks, 4 days ago
On Wed, 2026-01-21 at 20:58 +1100, NeilBrown wrote:
> On Wed, 21 Jan 2026, Jeff Layton wrote:
> > On Tue, 2026-01-20 at 09:12 -0500, Jeff Layton wrote:
> > > On Tue, 2026-01-20 at 08:20 -0500, Jeff Layton wrote:
> > > > On Mon, 2026-01-19 at 23:44 -0800, Christoph Hellwig wrote:
> > > > > On Mon, Jan 19, 2026 at 11:26:18AM -0500, Jeff Layton wrote:
> > > > > > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Some
> > > > > > +    filesystems cannot properly support file locking as implemented by
> > > > > > +    nfsd. A case in point is reexport of NFS itself, which can't be done
> > > > > > +    safely without coordinating the grace period handling. Other clustered
> > > > > > +    and networked filesystems can be problematic here as well.
> > > > > 
> > > > > I'm not sure this is very useful.  It really needs to document what
> > > > > locking semantics nfs expects, because otherwise no reader will know
> > > > > if they set this or not.
> > > > 
> > > > Fair point. I'll see if I can draft something better. Suggestions
> > > > welcome.
> > > 
> > > How about this?
> > > 
> > > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Filesystems
> > > +    that want to support locking over NFS must support POSIX file locking
> > > +    semantics and must handle lock recovery requests from clients after a
> > > +    reboot. Most local disk, RAM, or pseudo-filesystems use the generic POSIX
> > > +    locking support in the kernel and naturally provide this capability. Network
> > > +    or clustered filesystems usually need special handling to do this properly.
> > 
> > Even better, I think?
> > 
> > +
> > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Filesystems
> > +    that want to support locking over NFS must support POSIX file locking
> > +    semantics. When the server reboots, the clients will issue requests to
> > +    recover their locks, which nfsd will issue to the filesystem as new lock
> > +    requests. Those must succeed in order for lock recovery to work. Most
> > +    local disk, RAM, or pseudo-filesystems use the generic POSIX locking
> > +    support in the kernel and naturally provide this capability. Network or
> > +    clustered filesystems usually need special handling to do this properly.
> > +    Set this flag on filesystems that can't guarantee the proper semantics
> > +    (e.g. reexported NFS).
> 
> I think this is quite thorough, which it good ...  maybe too good :-) It
> reminds me that for true NFS compatibility the fs shouldn't allow local
> locks (or file opens!) until the grace period has passed.  I don't think
> any local filesystems enforce that - it would have to be locks.c that
> does I expect.  I doubt there would be much appetite for doing that
> though.
> 

Yeah, I don't see us ever doing that. It'd be a tricky chicken-and-egg
problem, given the demand-driven way that the mountd upcalls work
today. We don't even know that anything is exported until something
asks for it.

> Reviewed-by: NeilBrown <neil@brown.name>
> 

Thanks!
-- 
Jeff Layton <jlayton@kernel.org>
Re: [PATCH v2 01/31] Documentation: document EXPORT_OP_NOLOCKS
Posted by NeilBrown 2 weeks, 3 days ago
On Wed, 21 Jan 2026, Jeff Layton wrote:
> On Wed, 2026-01-21 at 20:58 +1100, NeilBrown wrote:
> > On Wed, 21 Jan 2026, Jeff Layton wrote:
> > > On Tue, 2026-01-20 at 09:12 -0500, Jeff Layton wrote:
> > > > On Tue, 2026-01-20 at 08:20 -0500, Jeff Layton wrote:
> > > > > On Mon, 2026-01-19 at 23:44 -0800, Christoph Hellwig wrote:
> > > > > > On Mon, Jan 19, 2026 at 11:26:18AM -0500, Jeff Layton wrote:
> > > > > > > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Some
> > > > > > > +    filesystems cannot properly support file locking as implemented by
> > > > > > > +    nfsd. A case in point is reexport of NFS itself, which can't be done
> > > > > > > +    safely without coordinating the grace period handling. Other clustered
> > > > > > > +    and networked filesystems can be problematic here as well.
> > > > > > 
> > > > > > I'm not sure this is very useful.  It really needs to document what
> > > > > > locking semantics nfs expects, because otherwise no reader will know
> > > > > > if they set this or not.
> > > > > 
> > > > > Fair point. I'll see if I can draft something better. Suggestions
> > > > > welcome.
> > > > 
> > > > How about this?
> > > > 
> > > > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Filesystems
> > > > +    that want to support locking over NFS must support POSIX file locking
> > > > +    semantics and must handle lock recovery requests from clients after a
> > > > +    reboot. Most local disk, RAM, or pseudo-filesystems use the generic POSIX
> > > > +    locking support in the kernel and naturally provide this capability. Network
> > > > +    or clustered filesystems usually need special handling to do this properly.
> > > 
> > > Even better, I think?
> > > 
> > > +
> > > +  EXPORT_OP_NOLOCKS - Disable file locking on this filesystem. Filesystems
> > > +    that want to support locking over NFS must support POSIX file locking
> > > +    semantics. When the server reboots, the clients will issue requests to
> > > +    recover their locks, which nfsd will issue to the filesystem as new lock
> > > +    requests. Those must succeed in order for lock recovery to work. Most
> > > +    local disk, RAM, or pseudo-filesystems use the generic POSIX locking
> > > +    support in the kernel and naturally provide this capability. Network or
> > > +    clustered filesystems usually need special handling to do this properly.
> > > +    Set this flag on filesystems that can't guarantee the proper semantics
> > > +    (e.g. reexported NFS).
> > 
> > I think this is quite thorough, which it good ...  maybe too good :-) It
> > reminds me that for true NFS compatibility the fs shouldn't allow local
> > locks (or file opens!) until the grace period has passed.  I don't think
> > any local filesystems enforce that - it would have to be locks.c that
> > does I expect.  I doubt there would be much appetite for doing that
> > though.
> > 
> 
> Yeah, I don't see us ever doing that. It'd be a tricky chicken-and-egg
> problem, given the demand-driven way that the mountd upcalls work
> today. We don't even know that anything is exported until something
> asks for it.

statd keeps state in /var/lib/nfs/sm, and nfsd keeps v4 state elsewhere
in /var/lib/nfs.  This state effectively records if any NFS client might
try to recover a lock.
I think the v4 state is granular enough to identify the filesystem.
lockd could be enhanced to use the same state I suspect.

We would need to generalise that state and load it at mount time and
block new state creation accordingly.

i.e. this would have to be a vfs-level thing which nfsd makes use of.

Possibly, but there are other things better worth our time.

NeilBrown
Re: [PATCH v2 01/31] Documentation: document EXPORT_OP_NOLOCKS
Posted by Christoph Hellwig 2 weeks, 4 days ago
On Tue, Jan 20, 2026 at 09:35:48AM -0500, Jeff Layton wrote:
> Even better, I think?

This sounds great, thanks!