locks: New ops in lock_manager_operations for get/put owner
authorKinglong Mee <kinglongmee@gmail.com>
Fri, 22 Aug 2014 14:18:43 +0000 (10:18 -0400)
committerJeff Layton <jlayton@primarydata.com>
Tue, 9 Sep 2014 20:01:09 +0000 (16:01 -0400)
NFSD or other lockmanager may increase the owner's reference,
so adds two new options for copying and releasing owner.

v5: change order from 2/6 to 3/6
v4: rename lm_copy_owner/lm_release_owner to lm_get_owner/lm_put_owner

Reviewed-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
fs/locks.c
include/linux/fs.h

index ec9becd02d3d79495ba7fdbe3031bf37cb23544c..5e83f3a993775517039e1ad0af596335bac9ccc0 100644 (file)
@@ -230,8 +230,12 @@ void locks_release_private(struct file_lock *fl)
                        fl->fl_ops->fl_release_private(fl);
                fl->fl_ops = NULL;
        }
-       fl->fl_lmops = NULL;
 
+       if (fl->fl_lmops) {
+               if (fl->fl_lmops->lm_put_owner)
+                       fl->fl_lmops->lm_put_owner(fl);
+               fl->fl_lmops = NULL;
+       }
 }
 EXPORT_SYMBOL_GPL(locks_release_private);
 
@@ -274,8 +278,12 @@ static void locks_copy_private(struct file_lock *new, struct file_lock *fl)
                        fl->fl_ops->fl_copy_lock(new, fl);
                new->fl_ops = fl->fl_ops;
        }
-       if (fl->fl_lmops)
+
+       if (fl->fl_lmops) {
+               if (fl->fl_lmops->lm_get_owner)
+                       fl->fl_lmops->lm_get_owner(new, fl);
                new->fl_lmops = fl->fl_lmops;
+       }
 }
 
 /*
index 5ab86f44b697262165dc505bdb606ee9883197bc..3b07ce2698deb52f64b49091937d0c414c604d6c 100644 (file)
@@ -868,6 +868,8 @@ struct file_lock_operations {
 struct lock_manager_operations {
        int (*lm_compare_owner)(struct file_lock *, struct file_lock *);
        unsigned long (*lm_owner_key)(struct file_lock *);
+       void (*lm_get_owner)(struct file_lock *, struct file_lock *);
+       void (*lm_put_owner)(struct file_lock *);
        void (*lm_notify)(struct file_lock *);  /* unblock callback */
        int (*lm_grant)(struct file_lock *, int);
        void (*lm_break)(struct file_lock *);