Project

General

Profile

Actions

Feature #23

closed

fcntl/flock advisory lock support

Added by Sage Weil about 14 years ago. Updated over 13 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
% Done:

0%

Spent time:
Source:
Tags:
Backport:
Reviewed:
Affected Versions:
Actions #1

Updated by Greg Farnum about 14 years ago

  • Assignee set to Greg Farnum
Actions #2

Updated by Greg Farnum almost 14 years ago

  • Status changed from New to In Progress
  • Start date changed from 04/13/2010 to 04/19/2010
Actions #3

Updated by Greg Farnum almost 14 years ago

All right, designed a basic interface between the client and the MDS. Going to implement the MDS and messaging parts for an MDS-only solution.

Actions #4

Updated by Greg Farnum almost 14 years ago

  • Status changed from In Progress to Resolved

It should support flock and fcntl locks now. Currently there are no caps for this, so all locking requests are routed through the MDS. It's been tested using the xfstests locktests test, with some additions. It appears to recover properly from a dead MDS.

flock locks haven't been tested, though, since I couldn't find a good test for them. Since the infrastructure is the same as for fcntl locks, though, they should be good to go.

The userspace stuff is in branch "locks" and the kernel client is in branch "flock".

Actions #5

Updated by Greg Farnum almost 14 years ago

  • Status changed from Resolved to In Progress

Found some issues with recovery after all; working on them now.

Actions #6

Updated by Greg Farnum almost 14 years ago

  • Status changed from In Progress to 4

Ahah, file_lock's fl_nspid pointer isn't filled in before calling the filesystem's lock handlers. I've fixed that so it is now.

Actions #7

Updated by Sage Weil almost 14 years ago

  • Target version changed from v2.6.35 to v2.6.36
Actions #8

Updated by Sage Weil almost 14 years ago

BTW these should all be __le32 etc. if the values go over the wire. And the kclient code that uses them needs to use cpu_to_le##, le##_to_cpu (userspace does the endian conversion magically).

+       struct {
+               __u8 rule; /* currently fcntl or flock */
+               __u8 type; /* shared, exclusive, remove*/
+               __u64 pid; /* process id requesting the lock */
+               __u64 pid_namespace;
+               __u64 start; /* initial location to lock */
+               __u64 length; /* num bytes to lock from start */
+               __u8 wait; /* will caller wait for lock to become available? */
+       } __attribute__ ((packed)) filelock_change;
 } __attribute__ ((packed));

 #define CEPH_MDS_FLAG_REPLAY        1  /* this is a replayed op */
@@ -481,6 +494,23 @@ struct ceph_mds_reply_dirfrag {
        __le32 dist[];
 } __attribute__ ((packed));

...

+struct ceph_filelock {
+       __u64 start;/* file offset to start lock at */
+       __u64 length; /* num bytes to lock; 0 for all following start */
+       __s64 client; /* which client holds the lock */
+       __u64 pid; /* process id holding the lock on the client */
+       __u64 pid_namespace;
+       __u8 type; /* shared lock, exclusive lock, or unlock */
+} __attribute__ ((packed));
Actions #9

Updated by Greg Farnum almost 14 years ago

Hmm, this was halfway done before but it's in properly now.

Actions #10

Updated by Greg Farnum over 13 years ago

  • Status changed from 4 to Resolved

This stuff got pushed into unstable yesterday.

Actions

Also available in: Atom PDF