Project

General

Profile

Feature #23

fcntl/flock advisory lock support

Added by Sage Weil over 9 years ago. Updated almost 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
-
Target version:
Start date:
04/19/2010
Due date:
% Done:

0%

Spent time:
Source:
Tags:
Backport:
Reviewed:
Affected Versions:

History

#1 Updated by Greg Farnum over 9 years ago

  • Assignee set to Greg Farnum

#2 Updated by Greg Farnum over 9 years ago

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

#3 Updated by Greg Farnum over 9 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.

#4 Updated by Greg Farnum over 9 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".

#5 Updated by Greg Farnum over 9 years ago

  • Status changed from Resolved to In Progress

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

#6 Updated by Greg Farnum over 9 years ago

  • Status changed from In Progress to Feedback

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.

#7 Updated by Sage Weil over 9 years ago

  • Target version changed from v2.6.35 to v2.6.36

#8 Updated by Sage Weil about 9 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));

#9 Updated by Greg Farnum about 9 years ago

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

#10 Updated by Greg Farnum about 9 years ago

  • Status changed from Feedback to Resolved

This stuff got pushed into unstable yesterday.

Also available in: Atom PDF