]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - fs/ceph/locks.c
locks: convert posix locks to file_lock_context
[mirror_ubuntu-artful-kernel.git] / fs / ceph / locks.c
index 917656ea8dcf8a0bcaf9209d41ae77aec1d0346e..19beeed832337838fd72b8c0e67e28cd5227ed76 100644 (file)
@@ -253,18 +253,15 @@ void ceph_count_locks(struct inode *inode, int *fcntl_count, int *flock_count)
        *fcntl_count = 0;
        *flock_count = 0;
 
-       spin_lock(&inode->i_lock);
-       for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
-               if (lock->fl_flags & FL_POSIX)
-                       ++(*fcntl_count);
-       }
-
        ctx = inode->i_flctx;
        if (ctx) {
+               spin_lock(&inode->i_lock);
+               list_for_each_entry(lock, &ctx->flc_posix, fl_list)
+                       ++(*fcntl_count);
                list_for_each_entry(lock, &ctx->flc_flock, fl_list)
                        ++(*flock_count);
+               spin_unlock(&inode->i_lock);
        }
-       spin_unlock(&inode->i_lock);
        dout("counted %d flock locks and %d fcntl locks",
             *flock_count, *fcntl_count);
 }
@@ -279,7 +276,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;
+       struct file_lock_context *ctx = inode->i_flctx;
        int err = 0;
        int seen_fcntl = 0;
        int seen_flock = 0;
@@ -288,34 +285,31 @@ int ceph_encode_locks_to_buffer(struct inode *inode,
        dout("encoding %d flock and %d fcntl locks", num_flock_locks,
             num_fcntl_locks);
 
+       if (!ctx)
+               return 0;
+
        spin_lock(&inode->i_lock);
-       for (lock = inode->i_flock; lock != NULL; lock = lock->fl_next) {
-               if (lock->fl_flags & FL_POSIX) {
-                       ++seen_fcntl;
-                       if (seen_fcntl > num_fcntl_locks) {
-                               err = -ENOSPC;
-                               goto fail;
-                       }
-                       err = lock_to_ceph_filelock(lock, &flocks[l]);
-                       if (err)
-                               goto fail;
-                       ++l;
+       list_for_each_entry(lock, &ctx->flc_flock, fl_list) {
+               ++seen_fcntl;
+               if (seen_fcntl > num_fcntl_locks) {
+                       err = -ENOSPC;
+                       goto fail;
                }
+               err = lock_to_ceph_filelock(lock, &flocks[l]);
+               if (err)
+                       goto fail;
+               ++l;
        }
-
-       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;
-                               goto fail;
-                       }
-                       err = lock_to_ceph_filelock(lock, &flocks[l]);
-                       if (err)
-                               goto fail;
-                       ++l;
+       list_for_each_entry(lock, &ctx->flc_flock, fl_list) {
+               ++seen_flock;
+               if (seen_flock > num_flock_locks) {
+                       err = -ENOSPC;
+                       goto fail;
                }
+               err = lock_to_ceph_filelock(lock, &flocks[l]);
+               if (err)
+                       goto fail;
+               ++l;
        }
 fail:
        spin_unlock(&inode->i_lock);