Commit 8fb47a4f authored by J. Bruce Fields's avatar J. Bruce Fields

locks: rename lock-manager ops

Both the filesystem and the lock manager can associate operations with a
lock.  Confusingly, one of them (fl_release_private) actually has the
same name in both operation structures.

It would save some confusion to give the lock-manager ops different
names.
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
parent c46556c6
...@@ -338,21 +338,21 @@ fl_release_private: maybe no ...@@ -338,21 +338,21 @@ fl_release_private: maybe no
----------------------- lock_manager_operations --------------------------- ----------------------- lock_manager_operations ---------------------------
prototypes: prototypes:
int (*fl_compare_owner)(struct file_lock *, struct file_lock *); int (*lm_compare_owner)(struct file_lock *, struct file_lock *);
void (*fl_notify)(struct file_lock *); /* unblock callback */ void (*lm_notify)(struct file_lock *); /* unblock callback */
int (*fl_grant)(struct file_lock *, struct file_lock *, int); int (*lm_grant)(struct file_lock *, struct file_lock *, int);
void (*fl_release_private)(struct file_lock *); void (*lm_release_private)(struct file_lock *);
void (*fl_break)(struct file_lock *); /* break_lease callback */ void (*lm_break)(struct file_lock *); /* break_lease callback */
int (*fl_change)(struct file_lock **, int); int (*lm_change)(struct file_lock **, int);
locking rules: locking rules:
file_lock_lock may block file_lock_lock may block
fl_compare_owner: yes no lm_compare_owner: yes no
fl_notify: yes no lm_notify: yes no
fl_grant: no no lm_grant: no no
fl_release_private: maybe no lm_release_private: maybe no
fl_break: yes no lm_break: yes no
fl_change yes no lm_change yes no
--------------------------- buffer_head ----------------------------------- --------------------------- buffer_head -----------------------------------
prototypes: prototypes:
......
...@@ -92,7 +92,7 @@ static void do_unlock_close(struct dlm_ls *ls, u64 number, ...@@ -92,7 +92,7 @@ static void do_unlock_close(struct dlm_ls *ls, u64 number,
op->info.number = number; op->info.number = number;
op->info.start = 0; op->info.start = 0;
op->info.end = OFFSET_MAX; op->info.end = OFFSET_MAX;
if (fl->fl_lmops && fl->fl_lmops->fl_grant) if (fl->fl_lmops && fl->fl_lmops->lm_grant)
op->info.owner = (__u64) fl->fl_pid; op->info.owner = (__u64) fl->fl_pid;
else else
op->info.owner = (__u64)(long) fl->fl_owner; op->info.owner = (__u64)(long) fl->fl_owner;
...@@ -128,11 +128,11 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file, ...@@ -128,11 +128,11 @@ int dlm_posix_lock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
op->info.number = number; op->info.number = number;
op->info.start = fl->fl_start; op->info.start = fl->fl_start;
op->info.end = fl->fl_end; op->info.end = fl->fl_end;
if (fl->fl_lmops && fl->fl_lmops->fl_grant) { if (fl->fl_lmops && fl->fl_lmops->lm_grant) {
/* fl_owner is lockd which doesn't distinguish /* fl_owner is lockd which doesn't distinguish
processes on the nfs client */ processes on the nfs client */
op->info.owner = (__u64) fl->fl_pid; op->info.owner = (__u64) fl->fl_pid;
xop->callback = fl->fl_lmops->fl_grant; xop->callback = fl->fl_lmops->lm_grant;
locks_init_lock(&xop->flc); locks_init_lock(&xop->flc);
locks_copy_lock(&xop->flc, fl); locks_copy_lock(&xop->flc, fl);
xop->fl = fl; xop->fl = fl;
...@@ -268,7 +268,7 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file, ...@@ -268,7 +268,7 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
op->info.number = number; op->info.number = number;
op->info.start = fl->fl_start; op->info.start = fl->fl_start;
op->info.end = fl->fl_end; op->info.end = fl->fl_end;
if (fl->fl_lmops && fl->fl_lmops->fl_grant) if (fl->fl_lmops && fl->fl_lmops->lm_grant)
op->info.owner = (__u64) fl->fl_pid; op->info.owner = (__u64) fl->fl_pid;
else else
op->info.owner = (__u64)(long) fl->fl_owner; op->info.owner = (__u64)(long) fl->fl_owner;
...@@ -327,7 +327,7 @@ int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file, ...@@ -327,7 +327,7 @@ int dlm_posix_get(dlm_lockspace_t *lockspace, u64 number, struct file *file,
op->info.number = number; op->info.number = number;
op->info.start = fl->fl_start; op->info.start = fl->fl_start;
op->info.end = fl->fl_end; op->info.end = fl->fl_end;
if (fl->fl_lmops && fl->fl_lmops->fl_grant) if (fl->fl_lmops && fl->fl_lmops->lm_grant)
op->info.owner = (__u64) fl->fl_pid; op->info.owner = (__u64) fl->fl_pid;
else else
op->info.owner = (__u64)(long) fl->fl_owner; op->info.owner = (__u64)(long) fl->fl_owner;
......
...@@ -1495,7 +1495,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock) ...@@ -1495,7 +1495,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock)
pid_t pid = fl->fl_type != F_UNLCK ? current->tgid : 0; pid_t pid = fl->fl_type != F_UNLCK ? current->tgid : 0;
int err; int err;
if (fl->fl_lmops && fl->fl_lmops->fl_grant) { if (fl->fl_lmops && fl->fl_lmops->lm_grant) {
/* NLM needs asynchronous locks, which we don't support yet */ /* NLM needs asynchronous locks, which we don't support yet */
return -ENOLCK; return -ENOLCK;
} }
......
...@@ -632,7 +632,7 @@ nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock) ...@@ -632,7 +632,7 @@ nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock)
/* /*
* This is a callback from the filesystem for VFS file lock requests. * This is a callback from the filesystem for VFS file lock requests.
* It will be used if fl_grant is defined and the filesystem can not * It will be used if lm_grant is defined and the filesystem can not
* respond to the request immediately. * respond to the request immediately.
* For GETLK request it will copy the reply to the nlm_block. * For GETLK request it will copy the reply to the nlm_block.
* For SETLK or SETLKW request it will get the local posix lock. * For SETLK or SETLKW request it will get the local posix lock.
...@@ -719,9 +719,9 @@ static int nlmsvc_same_owner(struct file_lock *fl1, struct file_lock *fl2) ...@@ -719,9 +719,9 @@ static int nlmsvc_same_owner(struct file_lock *fl1, struct file_lock *fl2)
} }
const struct lock_manager_operations nlmsvc_lock_operations = { const struct lock_manager_operations nlmsvc_lock_operations = {
.fl_compare_owner = nlmsvc_same_owner, .lm_compare_owner = nlmsvc_same_owner,
.fl_notify = nlmsvc_notify_blocked, .lm_notify = nlmsvc_notify_blocked,
.fl_grant = nlmsvc_grant_deferred, .lm_grant = nlmsvc_grant_deferred,
}; };
/* /*
......
...@@ -187,8 +187,8 @@ void locks_release_private(struct file_lock *fl) ...@@ -187,8 +187,8 @@ void locks_release_private(struct file_lock *fl)
fl->fl_ops = NULL; fl->fl_ops = NULL;
} }
if (fl->fl_lmops) { if (fl->fl_lmops) {
if (fl->fl_lmops->fl_release_private) if (fl->fl_lmops->lm_release_private)
fl->fl_lmops->fl_release_private(fl); fl->fl_lmops->lm_release_private(fl);
fl->fl_lmops = NULL; fl->fl_lmops = NULL;
} }
...@@ -423,9 +423,9 @@ static void lease_release_private_callback(struct file_lock *fl) ...@@ -423,9 +423,9 @@ static void lease_release_private_callback(struct file_lock *fl)
} }
static const struct lock_manager_operations lease_manager_ops = { static const struct lock_manager_operations lease_manager_ops = {
.fl_break = lease_break_callback, .lm_break = lease_break_callback,
.fl_release_private = lease_release_private_callback, .lm_release_private = lease_release_private_callback,
.fl_change = lease_modify, .lm_change = lease_modify,
}; };
/* /*
...@@ -478,9 +478,9 @@ static inline int locks_overlap(struct file_lock *fl1, struct file_lock *fl2) ...@@ -478,9 +478,9 @@ static inline int locks_overlap(struct file_lock *fl1, struct file_lock *fl2)
*/ */
static int posix_same_owner(struct file_lock *fl1, struct file_lock *fl2) static int posix_same_owner(struct file_lock *fl1, struct file_lock *fl2)
{ {
if (fl1->fl_lmops && fl1->fl_lmops->fl_compare_owner) if (fl1->fl_lmops && fl1->fl_lmops->lm_compare_owner)
return fl2->fl_lmops == fl1->fl_lmops && return fl2->fl_lmops == fl1->fl_lmops &&
fl1->fl_lmops->fl_compare_owner(fl1, fl2); fl1->fl_lmops->lm_compare_owner(fl1, fl2);
return fl1->fl_owner == fl2->fl_owner; return fl1->fl_owner == fl2->fl_owner;
} }
...@@ -530,8 +530,8 @@ static void locks_wake_up_blocks(struct file_lock *blocker) ...@@ -530,8 +530,8 @@ static void locks_wake_up_blocks(struct file_lock *blocker)
waiter = list_first_entry(&blocker->fl_block, waiter = list_first_entry(&blocker->fl_block,
struct file_lock, fl_block); struct file_lock, fl_block);
__locks_delete_block(waiter); __locks_delete_block(waiter);
if (waiter->fl_lmops && waiter->fl_lmops->fl_notify) if (waiter->fl_lmops && waiter->fl_lmops->lm_notify)
waiter->fl_lmops->fl_notify(waiter); waiter->fl_lmops->lm_notify(waiter);
else else
wake_up(&waiter->fl_wait); wake_up(&waiter->fl_wait);
} }
...@@ -1218,7 +1218,7 @@ int __break_lease(struct inode *inode, unsigned int mode) ...@@ -1218,7 +1218,7 @@ int __break_lease(struct inode *inode, unsigned int mode)
fl->fl_type = future; fl->fl_type = future;
fl->fl_break_time = break_time; fl->fl_break_time = break_time;
/* lease must have lmops break callback */ /* lease must have lmops break callback */
fl->fl_lmops->fl_break(fl); fl->fl_lmops->lm_break(fl);
} }
} }
...@@ -1328,7 +1328,7 @@ int fcntl_getlease(struct file *filp) ...@@ -1328,7 +1328,7 @@ int fcntl_getlease(struct file *filp)
* @arg: type of lease to obtain * @arg: type of lease to obtain
* @flp: input - file_lock to use, output - file_lock inserted * @flp: input - file_lock to use, output - file_lock inserted
* *
* The (input) flp->fl_lmops->fl_break function is required * The (input) flp->fl_lmops->lm_break function is required
* by break_lease(). * by break_lease().
* *
* Called with file_lock_lock held. * Called with file_lock_lock held.
...@@ -1354,7 +1354,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp) ...@@ -1354,7 +1354,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
time_out_leases(inode); time_out_leases(inode);
BUG_ON(!(*flp)->fl_lmops->fl_break); BUG_ON(!(*flp)->fl_lmops->lm_break);
if (arg != F_UNLCK) { if (arg != F_UNLCK) {
error = -EAGAIN; error = -EAGAIN;
...@@ -1396,7 +1396,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp) ...@@ -1396,7 +1396,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
goto out; goto out;
if (my_before != NULL) { if (my_before != NULL) {
error = lease->fl_lmops->fl_change(my_before, arg); error = lease->fl_lmops->lm_change(my_before, arg);
if (!error) if (!error)
*flp = *my_before; *flp = *my_before;
goto out; goto out;
...@@ -1432,7 +1432,7 @@ static int __vfs_setlease(struct file *filp, long arg, struct file_lock **lease) ...@@ -1432,7 +1432,7 @@ static int __vfs_setlease(struct file *filp, long arg, struct file_lock **lease)
* @lease: file_lock to use * @lease: file_lock to use
* *
* Call this to establish a lease on the file. * Call this to establish a lease on the file.
* The (*lease)->fl_lmops->fl_break operation must be set; if not, * The (*lease)->fl_lmops->lm_break operation must be set; if not,
* break_lease will oops! * break_lease will oops!
* *
* This will call the filesystem's setlease file method, if * This will call the filesystem's setlease file method, if
...@@ -1730,10 +1730,10 @@ int fcntl_getlk(struct file *filp, struct flock __user *l) ...@@ -1730,10 +1730,10 @@ int fcntl_getlk(struct file *filp, struct flock __user *l)
* To avoid blocking kernel daemons, such as lockd, that need to acquire POSIX * To avoid blocking kernel daemons, such as lockd, that need to acquire POSIX
* locks, the ->lock() interface may return asynchronously, before the lock has * locks, the ->lock() interface may return asynchronously, before the lock has
* been granted or denied by the underlying filesystem, if (and only if) * been granted or denied by the underlying filesystem, if (and only if)
* fl_grant is set. Callers expecting ->lock() to return asynchronously * lm_grant is set. Callers expecting ->lock() to return asynchronously
* will only use F_SETLK, not F_SETLKW; they will set FL_SLEEP if (and only if) * will only use F_SETLK, not F_SETLKW; they will set FL_SLEEP if (and only if)
* the request is for a blocking lock. When ->lock() does return asynchronously, * the request is for a blocking lock. When ->lock() does return asynchronously,
* it must return FILE_LOCK_DEFERRED, and call ->fl_grant() when the lock * it must return FILE_LOCK_DEFERRED, and call ->lm_grant() when the lock
* request completes. * request completes.
* If the request is for non-blocking lock the file system should return * If the request is for non-blocking lock the file system should return
* FILE_LOCK_DEFERRED then try to get the lock and call the callback routine * FILE_LOCK_DEFERRED then try to get the lock and call the callback routine
...@@ -1743,7 +1743,7 @@ int fcntl_getlk(struct file *filp, struct flock __user *l) ...@@ -1743,7 +1743,7 @@ int fcntl_getlk(struct file *filp, struct flock __user *l)
* grants a lock so the VFS can find out which locks are locally held and do * grants a lock so the VFS can find out which locks are locally held and do
* the correct lock cleanup when required. * the correct lock cleanup when required.
* The underlying filesystem must not drop the kernel lock or call * The underlying filesystem must not drop the kernel lock or call
* ->fl_grant() before returning to the caller with a FILE_LOCK_DEFERRED * ->lm_grant() before returning to the caller with a FILE_LOCK_DEFERRED
* return code. * return code.
*/ */
int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf) int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf)
......
...@@ -2425,8 +2425,8 @@ int nfsd_change_deleg_cb(struct file_lock **onlist, int arg) ...@@ -2425,8 +2425,8 @@ int nfsd_change_deleg_cb(struct file_lock **onlist, int arg)
} }
static const struct lock_manager_operations nfsd_lease_mng_ops = { static const struct lock_manager_operations nfsd_lease_mng_ops = {
.fl_break = nfsd_break_deleg_cb, .lm_break = nfsd_break_deleg_cb,
.fl_change = nfsd_change_deleg_cb, .lm_change = nfsd_change_deleg_cb,
}; };
......
...@@ -1069,12 +1069,12 @@ struct file_lock_operations { ...@@ -1069,12 +1069,12 @@ struct file_lock_operations {
}; };
struct lock_manager_operations { struct lock_manager_operations {
int (*fl_compare_owner)(struct file_lock *, struct file_lock *); int (*lm_compare_owner)(struct file_lock *, struct file_lock *);
void (*fl_notify)(struct file_lock *); /* unblock callback */ void (*lm_notify)(struct file_lock *); /* unblock callback */
int (*fl_grant)(struct file_lock *, struct file_lock *, int); int (*lm_grant)(struct file_lock *, struct file_lock *, int);
void (*fl_release_private)(struct file_lock *); void (*lm_release_private)(struct file_lock *);
void (*fl_break)(struct file_lock *); void (*lm_break)(struct file_lock *);
int (*fl_change)(struct file_lock **, int); int (*lm_change)(struct file_lock **, int);
}; };
struct lock_manager { struct lock_manager {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment