sahlberg / libnfs

NFS client library
Other
525 stars 202 forks source link

Does libNFS support locks, NLM and NLS? #386

Closed ciechowoj closed 2 years ago

ciechowoj commented 2 years ago

Does libNFS support locks, NLM and NLS?

I cannot find it specified anywhere. By the issue:

https://github.com/sahlberg/fuse-nfs/issues/20

it looks like it's not supported. But I see some rudimentary implementation in nlm directory?

What is the status?

sahlberg commented 2 years ago

On Fri, 15 Jul 2022 at 04:42, ciechowoj @.***> wrote:

Does libNFS support locks, NLM and NLS?

Yes. Both lockf() and fcntl() style functions can be used. But only for NFSv4

NLS? Do you mean NSM (NetworkStatusMonitor)?

NFSv3

NLM and NSM are only used for NFSv3 (and v2) and runs on a separate port, even using separate daemons, from nfs. There is a full implementation of NLM and MSN in libnfs but they only provide the low level async RPC interface. These two protocols can not be used with the nfs_context as these two protocols are not really part of the nfs protocol itself. And since they use different ports from nfs they would need a different context.

It is possible to use them but you would need to create separate rpc_context for each one of them and call into these services using the low level rpc interface for nlm and nsm. You can find an example on how to use rpc_contexts in examples/portmap-client.c That example is for portmapper, which is another rpc service that is used with nfs (and other onc-rpc based services)

It would be nice to add the missing plumbing to offer higher level APIs for at least NLM and expose similar to fcntl(F_SETLK) but I don't have much time to work on that. So for the time being, the only way right now to do advisory locking is to use the RPC API, again see portmap-client.c.

NFSv4

Unless you are talking about NFSv4. In NFSv4 there is no NLM or NSM protocol, not even portmapper actually. It is all built into the NFSv4 protocol itself, so here there are no issues with multiple different ports (and callbacks from server back to client)

There is full support for the lockf() API in nfs_lockf_async() There is also support for fcntl() API in nfs_fcntl_async() Both these functions can be used for byte range locking. These functions only work for NFSv4. They are only implemented as async functions. Sync functions should be trivial to add (but don't use the sync api, it is slow and does not scale)

regards ronnie sahlberg

I cannot find it specified anywhere. By the issue:

sahlberg/fuse-nfs#20 https://github.com/sahlberg/fuse-nfs/issues/20

it looks like it's not supported. But I see some rudimentary implementation in nlm directory?

What is the status?

— Reply to this email directly, view it on GitHub https://github.com/sahlberg/libnfs/issues/386, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADY3EATCHELBSM3QM5FB6LVUBNQ5ANCNFSM53TF673Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ciechowoj commented 2 years ago

NLS? Do you mean NSM (NetworkStatusMonitor)? Yeah, I've meant NSM and NFSv3.

Thanks for quick and elaborate answer!