程序的本质是这样的,作者本质上只会附加到文件中.在作者完成并调用fflush之前,读者永远不会访问新添加的信息.
NFSv4是否支持这种情况?
或者是否有更好的方法来实现这种并发NFSv4文件访问?
解决方法 NFS v4确实支持文件的字节范围锁定(如 RFC 3530 “NFS version 4 protocol”摘录中所述):1.4.5. file locking
With the NFS version 4 protocol,the support for byte range file locking is part of the NFS protocol. The file locking support is structured so that an RPC callback mechanism is not required. This is a departure from the prevIoUs versions of the NFS file locking protocol,Network Lock Manager (NLM). The state associated with file locks is maintained at the server under a lease-based model. The server defines a single lease period for all state held by a NFS clIEnt. If the clIEnt does not renew its lease within the defined period,all state associated with the clIEnt’s lease may be released by the server. The clIEnt may renew its lease with use of the
RENEW
operation or implicitly by use of other operations (primarilyREAD
).
有关锁定和基于租约的模型的更多详细信息,请参阅同一RFC的第8节.
您的程序需要使用fcntl来管理锁定.我的建议是编写一个测试来检查EFS提供的NFS v4的实际实现是否支持按预期进行锁定(某些方面在规范中是可选的).您可以参考this lock testing suite的源代码,它支持多客户端测试.
总结以上是内存溢出为你收集整理的nfsv4 linux c中的并发文件访问全部内容,希望文章能够帮你解决nfsv4 linux c中的并发文件访问所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)