Skip to content

Commit 8fb47a4

Browse files
author
J. Bruce Fields
committed
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: J. Bruce Fields <[email protected]>
1 parent c46556c commit 8fb47a4

File tree

7 files changed

+47
-47
lines changed

7 files changed

+47
-47
lines changed

Documentation/filesystems/Locking

+12-12
Original file line numberDiff line numberDiff line change
@@ -338,21 +338,21 @@ fl_release_private: maybe no
338338

339339
----------------------- lock_manager_operations ---------------------------
340340
prototypes:
341-
int (*fl_compare_owner)(struct file_lock *, struct file_lock *);
342-
void (*fl_notify)(struct file_lock *); /* unblock callback */
343-
int (*fl_grant)(struct file_lock *, struct file_lock *, int);
344-
void (*fl_release_private)(struct file_lock *);
345-
void (*fl_break)(struct file_lock *); /* break_lease callback */
346-
int (*fl_change)(struct file_lock **, int);
341+
int (*lm_compare_owner)(struct file_lock *, struct file_lock *);
342+
void (*lm_notify)(struct file_lock *); /* unblock callback */
343+
int (*lm_grant)(struct file_lock *, struct file_lock *, int);
344+
void (*lm_release_private)(struct file_lock *);
345+
void (*lm_break)(struct file_lock *); /* break_lease callback */
346+
int (*lm_change)(struct file_lock **, int);
347347

348348
locking rules:
349349
file_lock_lock may block
350-
fl_compare_owner: yes no
351-
fl_notify: yes no
352-
fl_grant: no no
353-
fl_release_private: maybe no
354-
fl_break: yes no
355-
fl_change yes no
350+
lm_compare_owner: yes no
351+
lm_notify: yes no
352+
lm_grant: no no
353+
lm_release_private: maybe no
354+
lm_break: yes no
355+
lm_change yes no
356356

357357
--------------------------- buffer_head -----------------------------------
358358
prototypes:

fs/dlm/plock.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static void do_unlock_close(struct dlm_ls *ls, u64 number,
9292
op->info.number = number;
9393
op->info.start = 0;
9494
op->info.end = OFFSET_MAX;
95-
if (fl->fl_lmops && fl->fl_lmops->fl_grant)
95+
if (fl->fl_lmops && fl->fl_lmops->lm_grant)
9696
op->info.owner = (__u64) fl->fl_pid;
9797
else
9898
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,
128128
op->info.number = number;
129129
op->info.start = fl->fl_start;
130130
op->info.end = fl->fl_end;
131-
if (fl->fl_lmops && fl->fl_lmops->fl_grant) {
131+
if (fl->fl_lmops && fl->fl_lmops->lm_grant) {
132132
/* fl_owner is lockd which doesn't distinguish
133133
processes on the nfs client */
134134
op->info.owner = (__u64) fl->fl_pid;
135-
xop->callback = fl->fl_lmops->fl_grant;
135+
xop->callback = fl->fl_lmops->lm_grant;
136136
locks_init_lock(&xop->flc);
137137
locks_copy_lock(&xop->flc, fl);
138138
xop->fl = fl;
@@ -268,7 +268,7 @@ int dlm_posix_unlock(dlm_lockspace_t *lockspace, u64 number, struct file *file,
268268
op->info.number = number;
269269
op->info.start = fl->fl_start;
270270
op->info.end = fl->fl_end;
271-
if (fl->fl_lmops && fl->fl_lmops->fl_grant)
271+
if (fl->fl_lmops && fl->fl_lmops->lm_grant)
272272
op->info.owner = (__u64) fl->fl_pid;
273273
else
274274
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,
327327
op->info.number = number;
328328
op->info.start = fl->fl_start;
329329
op->info.end = fl->fl_end;
330-
if (fl->fl_lmops && fl->fl_lmops->fl_grant)
330+
if (fl->fl_lmops && fl->fl_lmops->lm_grant)
331331
op->info.owner = (__u64) fl->fl_pid;
332332
else
333333
op->info.owner = (__u64)(long) fl->fl_owner;

fs/fuse/file.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock)
14951495
pid_t pid = fl->fl_type != F_UNLCK ? current->tgid : 0;
14961496
int err;
14971497

1498-
if (fl->fl_lmops && fl->fl_lmops->fl_grant) {
1498+
if (fl->fl_lmops && fl->fl_lmops->lm_grant) {
14991499
/* NLM needs asynchronous locks, which we don't support yet */
15001500
return -ENOLCK;
15011501
}

fs/lockd/svclock.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ nlmsvc_cancel_blocked(struct nlm_file *file, struct nlm_lock *lock)
632632

633633
/*
634634
* This is a callback from the filesystem for VFS file lock requests.
635-
* It will be used if fl_grant is defined and the filesystem can not
635+
* It will be used if lm_grant is defined and the filesystem can not
636636
* respond to the request immediately.
637637
* For GETLK request it will copy the reply to the nlm_block.
638638
* 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)
719719
}
720720

721721
const struct lock_manager_operations nlmsvc_lock_operations = {
722-
.fl_compare_owner = nlmsvc_same_owner,
723-
.fl_notify = nlmsvc_notify_blocked,
724-
.fl_grant = nlmsvc_grant_deferred,
722+
.lm_compare_owner = nlmsvc_same_owner,
723+
.lm_notify = nlmsvc_notify_blocked,
724+
.lm_grant = nlmsvc_grant_deferred,
725725
};
726726

727727
/*

fs/locks.c

+17-17
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ void locks_release_private(struct file_lock *fl)
187187
fl->fl_ops = NULL;
188188
}
189189
if (fl->fl_lmops) {
190-
if (fl->fl_lmops->fl_release_private)
191-
fl->fl_lmops->fl_release_private(fl);
190+
if (fl->fl_lmops->lm_release_private)
191+
fl->fl_lmops->lm_release_private(fl);
192192
fl->fl_lmops = NULL;
193193
}
194194

@@ -423,9 +423,9 @@ static void lease_release_private_callback(struct file_lock *fl)
423423
}
424424

425425
static const struct lock_manager_operations lease_manager_ops = {
426-
.fl_break = lease_break_callback,
427-
.fl_release_private = lease_release_private_callback,
428-
.fl_change = lease_modify,
426+
.lm_break = lease_break_callback,
427+
.lm_release_private = lease_release_private_callback,
428+
.lm_change = lease_modify,
429429
};
430430

431431
/*
@@ -478,9 +478,9 @@ static inline int locks_overlap(struct file_lock *fl1, struct file_lock *fl2)
478478
*/
479479
static int posix_same_owner(struct file_lock *fl1, struct file_lock *fl2)
480480
{
481-
if (fl1->fl_lmops && fl1->fl_lmops->fl_compare_owner)
481+
if (fl1->fl_lmops && fl1->fl_lmops->lm_compare_owner)
482482
return fl2->fl_lmops == fl1->fl_lmops &&
483-
fl1->fl_lmops->fl_compare_owner(fl1, fl2);
483+
fl1->fl_lmops->lm_compare_owner(fl1, fl2);
484484
return fl1->fl_owner == fl2->fl_owner;
485485
}
486486

@@ -530,8 +530,8 @@ static void locks_wake_up_blocks(struct file_lock *blocker)
530530
waiter = list_first_entry(&blocker->fl_block,
531531
struct file_lock, fl_block);
532532
__locks_delete_block(waiter);
533-
if (waiter->fl_lmops && waiter->fl_lmops->fl_notify)
534-
waiter->fl_lmops->fl_notify(waiter);
533+
if (waiter->fl_lmops && waiter->fl_lmops->lm_notify)
534+
waiter->fl_lmops->lm_notify(waiter);
535535
else
536536
wake_up(&waiter->fl_wait);
537537
}
@@ -1218,7 +1218,7 @@ int __break_lease(struct inode *inode, unsigned int mode)
12181218
fl->fl_type = future;
12191219
fl->fl_break_time = break_time;
12201220
/* lease must have lmops break callback */
1221-
fl->fl_lmops->fl_break(fl);
1221+
fl->fl_lmops->lm_break(fl);
12221222
}
12231223
}
12241224

@@ -1328,7 +1328,7 @@ int fcntl_getlease(struct file *filp)
13281328
* @arg: type of lease to obtain
13291329
* @flp: input - file_lock to use, output - file_lock inserted
13301330
*
1331-
* The (input) flp->fl_lmops->fl_break function is required
1331+
* The (input) flp->fl_lmops->lm_break function is required
13321332
* by break_lease().
13331333
*
13341334
* Called with file_lock_lock held.
@@ -1354,7 +1354,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
13541354

13551355
time_out_leases(inode);
13561356

1357-
BUG_ON(!(*flp)->fl_lmops->fl_break);
1357+
BUG_ON(!(*flp)->fl_lmops->lm_break);
13581358

13591359
if (arg != F_UNLCK) {
13601360
error = -EAGAIN;
@@ -1396,7 +1396,7 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp)
13961396
goto out;
13971397

13981398
if (my_before != NULL) {
1399-
error = lease->fl_lmops->fl_change(my_before, arg);
1399+
error = lease->fl_lmops->lm_change(my_before, arg);
14001400
if (!error)
14011401
*flp = *my_before;
14021402
goto out;
@@ -1432,7 +1432,7 @@ static int __vfs_setlease(struct file *filp, long arg, struct file_lock **lease)
14321432
* @lease: file_lock to use
14331433
*
14341434
* Call this to establish a lease on the file.
1435-
* The (*lease)->fl_lmops->fl_break operation must be set; if not,
1435+
* The (*lease)->fl_lmops->lm_break operation must be set; if not,
14361436
* break_lease will oops!
14371437
*
14381438
* This will call the filesystem's setlease file method, if
@@ -1730,10 +1730,10 @@ int fcntl_getlk(struct file *filp, struct flock __user *l)
17301730
* To avoid blocking kernel daemons, such as lockd, that need to acquire POSIX
17311731
* locks, the ->lock() interface may return asynchronously, before the lock has
17321732
* been granted or denied by the underlying filesystem, if (and only if)
1733-
* fl_grant is set. Callers expecting ->lock() to return asynchronously
1733+
* lm_grant is set. Callers expecting ->lock() to return asynchronously
17341734
* will only use F_SETLK, not F_SETLKW; they will set FL_SLEEP if (and only if)
17351735
* the request is for a blocking lock. When ->lock() does return asynchronously,
1736-
* it must return FILE_LOCK_DEFERRED, and call ->fl_grant() when the lock
1736+
* it must return FILE_LOCK_DEFERRED, and call ->lm_grant() when the lock
17371737
* request completes.
17381738
* If the request is for non-blocking lock the file system should return
17391739
* 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)
17431743
* grants a lock so the VFS can find out which locks are locally held and do
17441744
* the correct lock cleanup when required.
17451745
* The underlying filesystem must not drop the kernel lock or call
1746-
* ->fl_grant() before returning to the caller with a FILE_LOCK_DEFERRED
1746+
* ->lm_grant() before returning to the caller with a FILE_LOCK_DEFERRED
17471747
* return code.
17481748
*/
17491749
int vfs_lock_file(struct file *filp, unsigned int cmd, struct file_lock *fl, struct file_lock *conf)

fs/nfsd/nfs4state.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2425,8 +2425,8 @@ int nfsd_change_deleg_cb(struct file_lock **onlist, int arg)
24252425
}
24262426

24272427
static const struct lock_manager_operations nfsd_lease_mng_ops = {
2428-
.fl_break = nfsd_break_deleg_cb,
2429-
.fl_change = nfsd_change_deleg_cb,
2428+
.lm_break = nfsd_break_deleg_cb,
2429+
.lm_change = nfsd_change_deleg_cb,
24302430
};
24312431

24322432

include/linux/fs.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -1069,12 +1069,12 @@ struct file_lock_operations {
10691069
};
10701070

10711071
struct lock_manager_operations {
1072-
int (*fl_compare_owner)(struct file_lock *, struct file_lock *);
1073-
void (*fl_notify)(struct file_lock *); /* unblock callback */
1074-
int (*fl_grant)(struct file_lock *, struct file_lock *, int);
1075-
void (*fl_release_private)(struct file_lock *);
1076-
void (*fl_break)(struct file_lock *);
1077-
int (*fl_change)(struct file_lock **, int);
1072+
int (*lm_compare_owner)(struct file_lock *, struct file_lock *);
1073+
void (*lm_notify)(struct file_lock *); /* unblock callback */
1074+
int (*lm_grant)(struct file_lock *, struct file_lock *, int);
1075+
void (*lm_release_private)(struct file_lock *);
1076+
void (*lm_break)(struct file_lock *);
1077+
int (*lm_change)(struct file_lock **, int);
10781078
};
10791079

10801080
struct lock_manager {

0 commit comments

Comments
 (0)