Skip to content

Commit 646d73e

Browse files
bcodding-rhJ. Bruce Fields
authored andcommitted
lockd: Show pid of lockd for remote locks
Use the pid of lockd instead of the remote lock's svid for the fl_pid for local POSIX locks. This allows proper enumeration of which local process owns which lock. The svid is meaningless to local lock readers. Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 9adfac6 commit 646d73e

5 files changed

Lines changed: 4 additions & 6 deletions

File tree

‎fs/lockd/svc4proc.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ nlm4svc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
4646

4747
/* Set up the missing parts of the file_lock structure */
4848
lock->fl.fl_file = file->f_file;
49+
lock->fl.fl_pid = current->tgid;
4950
lock->fl.fl_lmops = &nlmsvc_lock_operations;
5051
nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid);
5152
if (!lock->fl.fl_owner) {

‎fs/lockd/svclock.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static int nlmsvc_setgrantargs(struct nlm_rqst *call, struct nlm_lock *lock)
432432

433433
/* set default data area */
434434
call->a_args.lock.oh.data = call->a_owner;
435-
call->a_args.lock.svid = lock->fl.fl_pid;
435+
call->a_args.lock.svid = ((struct nlm_lockowner *)lock->fl.fl_owner)->pid;
436436

437437
if (lock->oh.len > NLMCLNT_OHSIZE) {
438438
void *data = kmalloc(lock->oh.len, GFP_KERNEL);
@@ -634,7 +634,7 @@ nlmsvc_testlock(struct svc_rqst *rqstp, struct nlm_file *file,
634634
conflock->caller = "somehost"; /* FIXME */
635635
conflock->len = strlen(conflock->caller);
636636
conflock->oh.len = 0; /* don't return OH info */
637-
conflock->svid = lock->fl.fl_pid;
637+
conflock->svid = ((struct nlm_lockowner *)lock->fl.fl_owner)->pid;
638638
conflock->fl.fl_type = lock->fl.fl_type;
639639
conflock->fl.fl_start = lock->fl.fl_start;
640640
conflock->fl.fl_end = lock->fl.fl_end;

‎fs/lockd/svcproc.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct nlm_args *argp,
7676

7777
/* Set up the missing parts of the file_lock structure */
7878
lock->fl.fl_file = file->f_file;
79+
lock->fl.fl_pid = current->tgid;
7980
lock->fl.fl_lmops = &nlmsvc_lock_operations;
8081
nlmsvc_locks_init_private(&lock->fl, host, (pid_t)lock->svid);
8182
if (!lock->fl.fl_owner) {

‎fs/lockd/xdr.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ nlm_decode_lock(__be32 *p, struct nlm_lock *lock)
126126
lock->svid = ntohl(*p++);
127127

128128
locks_init_lock(fl);
129-
fl->fl_pid = (pid_t)lock->svid;
130129
fl->fl_flags = FL_POSIX;
131130
fl->fl_type = F_RDLCK; /* as good as anything else */
132131
start = ntohl(*p++);
@@ -268,7 +267,6 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
268267
memset(lock, 0, sizeof(*lock));
269268
locks_init_lock(&lock->fl);
270269
lock->svid = ~(u32) 0;
271-
lock->fl.fl_pid = (pid_t)lock->svid;
272270

273271
if (!(p = nlm_decode_cookie(p, &argp->cookie))
274272
|| !(p = xdr_decode_string_inplace(p, &lock->caller,

‎fs/lockd/xdr4.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ nlm4_decode_lock(__be32 *p, struct nlm_lock *lock)
118118
lock->svid = ntohl(*p++);
119119

120120
locks_init_lock(fl);
121-
fl->fl_pid = (pid_t)lock->svid;
122121
fl->fl_flags = FL_POSIX;
123122
fl->fl_type = F_RDLCK; /* as good as anything else */
124123
p = xdr_decode_hyper(p, &start);
@@ -265,7 +264,6 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)
265264
memset(lock, 0, sizeof(*lock));
266265
locks_init_lock(&lock->fl);
267266
lock->svid = ~(u32) 0;
268-
lock->fl.fl_pid = (pid_t)lock->svid;
269267

270268
if (!(p = nlm4_decode_cookie(p, &argp->cookie))
271269
|| !(p = xdr_decode_string_inplace(p, &lock->caller,

0 commit comments

Comments
 (0)