locks: move flock locks to file_lock_context
authorJeff Layton <jlayton@primarydata.com>
Fri, 16 Jan 2015 20:05:55 +0000 (15:05 -0500)
committerJeff Layton <jeff.layton@primarydata.com>
Fri, 16 Jan 2015 20:09:25 +0000 (15:09 -0500)
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Acked-by: Christoph Hellwig <hch@lst.de>
fs/ceph/locks.c
fs/locks.c
fs/nfs/delegation.c
fs/nfs/nfs4state.c
fs/nfs/pagelist.c
fs/nfs/write.c

index 366dc24..917656e 100644 (file)
@@ -239,14 +239,16 @@ int ceph_flock(struct file *file, int cmd, struct file_lock *fl)
        return err;
 }
 
-/**
- * Must be called with lock_flocks() already held. Fills in the passed
- * counter variables, so you can prepare pagelist metadata before calling
- * ceph_encode_locks.
+/*
+ * Fills in the passed counter variables, so you can prepare pagelist metadata
+ * before calling ceph_encode_locks.
+ *
+ * FIXME: add counters to struct file_lock_context so we don't need to do this?
  */
 void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count)
 {
        struct file_lock *lock;
+       struct file_lock_context *ctx;
 
        *fcntl_count = 0;
        *flock_count = 0;
@@ -255,7 +257,11 @@ void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count)
        for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
                if (lock->fl_flags & FL_POSIX)
                        ++(*fcntl_count);
-               else if (lock->fl_flags & FL_FLOCK)
+       }
+
+       ctx = inode->i_flctx;
+       if (ctx) {
+               list_for_each_entry(lock, &ctx->flc_flock, fl_list)
                        ++(*flock_count);
        }
        spin_unlock(&inode->i_lock);
@@ -273,6 +279,7 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
                                int num_fcntl_locks, int num_flock_locks)
 {
        struct file_lock *lock;
+       struct file_lock_context *ctx;
        int err = 0;
        int seen_fcntl = 0;
        int seen_flock = 0;
@@ -295,8 +302,10 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
                        ++l;
                }
        }
-       for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
-               if (lock->fl_flags & FL_FLOCK) {
+
+       ctx = inode->i_flctx;
+       if (ctx) {
+               list_for_each_entry(lock, &ctx->flc_flock, fl_list) {
                        ++seen_flock;
                        if (seen_flock > num_flock_locks) {
                                err = -ENOSPC;
diff --cc fs/locks.c
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc fs/nfs/write.c
Simple merge