Hi!, On 02/06/2015 02:44 PM, John Spray wrote: > You should let the caller pass in the owner ID. For example, if you > were using libcephfs to implement a filesystem interface, it would be > up to that interface to work out the unique ID from the calling layer > above it. So you can pass it through libcephfs, no logic needed. Thanks. I assume the locking depends on the (pid, owner) tuple in this case ? >> Thanks in advance for any hints! By the way - would this new feature (flock()) make sense ? > Definitely, the flock support in the userspace client is new, and the > libcephfs bindings just didn't catch up yet: it was added in October: Not sure if my patch looks sane enough to be submitted, but here it is. Please advise me if there is a more suitable way than posting patches here :) [ Note that I did not ran extensive tests now, but this is only an interface to the existing Client interface one, and the very minimalistic test sample below seems to be working fine. ] ////////// Sample test ////////// #include #include #include #include #include #include #include #include static bool check(const char *name, int code) { if (code >= 0) { fprintf(stderr, "%s: OK\n", name); return true; } else { errno = -code; perror(name); fprintf(stderr, "%s: ERROR\n", name); return false; } } int main(int argc, char **argv) { int success = EXIT_FAILURE; struct ceph_mount_info *cmount = NULL; int fd; if (check("ceph_create", ceph_create(&cmount, "admin")) && check("ceph_conf_set(keyfile)", ceph_conf_set(cmount, "keyfile", "ceph.admin.key")) && check("ceph_conf_set(mon_host)", ceph_conf_set(cmount, "mon_host", "10.42.42.42")) && check("ceph_conf_set(log_to_stderr)", ceph_conf_set(cmount, "log_to_stderr", "true")) && check("ceph_mount", ceph_mount(cmount, NULL)) && check("ceph_open", fd = ceph_open(cmount, "/test.lock", O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO)) ) { if (check("ceph_flock", ceph_flock(cmount, fd, LOCK_EX, 42))) { success = EXIT_SUCCESS; } fd >= 0 && check("ceph_close", ceph_close(cmount, fd)); } cmount != NULL && check("ceph_unmount", ceph_unmount(cmount)); return success; }