<html><body><div style="font-family: times new roman,new york,times,serif; font-size: 12pt; color: #000000"><div>Hi,<br></div><div><br></div><div>Brief Background:<br></div><div>============<br></div><div>For the below two features, we need ligfapi to take 2 other parameters from the applications for most number of fops.<br></div><div><a href="http://review.gluster.org/#/c/12014/">http://review.gluster.org/#/c/12014/</a></div><div><a href="http://review.gluster.org/#/c/11980/">http://review.gluster.org/#/c/11980/</a></div><div><br></div><div>For leases to work as explained in the above doc, every file data read/write fop needs to be associated with a lease ID. This is specially required for Samba and NFS-Ganesha as they inturn serve other clients who request for leases. For Gluster to identify the end client (which is not Samba/NFS Ganesha) we need lease ID to be filled by Samba/NFS Ganesha.<br></div><div><br></div><div>For mandatory locks feature to work as explained, every file data read/write fop needs to be associated with a lk_owner. In linux Kernel VFS takes care of filling the lk_ownere for the file system. In libgfapi case, the applications calling into libgfapi should be providing lk_owner with every fop. This is again required mainly for Samba and NFS Ganesha, as they serve multiple clients.<br></div><div><br></div><div>Possible solutions:<br></div><div>=============<br></div><div>1.&nbsp; Modify all the required APIs to take 2 other parameter, lease ID and lk_owner. But that would mean backward compatibility issues and is a programming overhead for applications not interested in Leases and mandatory lock feature.<br></div><div>2.&nbsp; Add an API called glfs_set_fop_attrs (lease ID, lk_owner) which works similar to glfs_set_uid(uid). The API sets a thread local storage (pthread_key) with the values provided, the further fops on that thread will pick the lease ID and lk_owner from the thread local storage (pthread_key). There are few minor details that needs to be worked out: </div><div>- In case of async API will end up using lease ID and lk_owner from wrong thread.<br></div><div>- unset lease ID and lk_owner after every fop to ensure there is no stale lease ID or lk_owner set?<br></div><div>- For fd based fops we can store the lease ID and lk_owner in glfd, so that the application writed need not set it for every fop. But for handle based fops lease ID and lk_owner needs to be set explicitly every-time.<br></div><div><br></div><div>Solution 2 is more preferable except for that it adds overhead of calling another API, for the libgfapi users who intends to use these features.<br></div><div>A prototype of solution 2 can be found at <a href="http://review.gluster.org/#/c/12876/">http://review.gluster.org/#/c/12876/</a><br></div><div><br></div><div>Please let me know if you have any suggestions.<br></div><div><br></div><div>Thanks,<br></div><div>Poorninma<br></div><div><br></div></div></body></html>