lockd: Show pid of lockd for remote locks
Subsystems (2)
PATCH 1/1 lockd: Show pid of lockd for remote locks
Commit 9d5b86ac13c5 ("fs/locks: Remove fl_nspid and use fs-specific l_pid for remote locks") specified that the l_pid returned for F_GETLK on a local file that has a remote lock should be the pid of the lock manager process. That commit, while updating other filesystems, failed to update lockd, such that locks created by lockd had their fl_pid set to that of the remote process holding the lock. Fix that here to be the pid of lockd.
Also, fix the client case so that the returned lock pid is negative, which indicates a remote lock on a remote file.
--- fs/lockd/clntproc.c | 2 +- fs/lockd/xdr.c | 4 ++-- fs/lockd/xdr4.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
fs/lockd/clntproc.c +1 -1
@@ -442,7 +442,7 @@ nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) fl->fl_start = req->a_res.lock.fl.fl_start; fl->fl_end = req->a_res.lock.fl.fl_end; fl->fl_type = req->a_res.lock.fl.fl_type; - fl->fl_pid =0 ; + fl->fl_pid = -req->a_res.lock.fl.fl_pid;break ;default : status =nlm_stat_to_errno (req->a_res.status);
fs/lockd/xdr.c +2 -2
@@ -127,7 +127,7 @@ nlm_decode_lock(__be32 *p, struct nlm_lock *lock)locks_init_lock (fl); fl->fl_owner = current->files; - fl->fl_pid = (pid_t )lock->svid; + fl->fl_pid = current->tgid; fl->fl_flags =FL_POSIX ; fl->fl_type =F_RDLCK ;/* as good as anything else */ start =ntohl (*p++);
@@ -269,7 +269,7 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)memset (lock,0 ,sizeof (*lock));locks_init_lock (&lock->fl); lock->svid = ~(u32 )0 ; - lock->fl.fl_pid = (pid_t )lock->svid; + lock->fl.fl_pid = current->tgid; if (!(p = nlm_decode_cookie(p, &argp->cookie)) || !(p = xdr_decode_string_inplace(p, &lock->caller,
fs/lockd/xdr4.c +2 -2
@@ -119,7 +119,7 @@ nlm4_decode_lock(__be32 *p, struct nlm_lock *lock)locks_init_lock (fl); fl->fl_owner = current->files; - fl->fl_pid = (pid_t )lock->svid; + fl->fl_pid = current->tgid; fl->fl_flags =FL_POSIX ; fl->fl_type =F_RDLCK ;/* as good as anything else */ p =xdr_decode_hyper (p, &start);
@@ -266,7 +266,7 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)memset (lock,0 ,sizeof (*lock));locks_init_lock (&lock->fl); lock->svid = ~(u32 )0 ; - lock->fl.fl_pid = (pid_t )lock->svid; + lock->fl.fl_pid = current->tgid; if (!(p = nlm4_decode_cookie(p, &argp->cookie)) || !(p = xdr_decode_string_inplace(p, &lock->caller,
Signature · 1 line
2.14.3
Quoted 9 lines · Benjamin Coddington
Commit
9d5b86ac13c5("fs/locks: Removefl_nspidand use fs-specificl_pidfor remote locks") specified that thel_pidreturned forF_GETLKon a local file that has a remote lock should be the pid of the lock manager process. That commit, while updating other filesystems, failed to update lockd, such that locks created by lockd had theirfl_pidset to that of the remote process holding the lock. Fix that here to be the pid of lockd.Also, fix the client case so that the returned lock pid is negative, which indicates a remote lock on a remote file.
ACK.
Uh, I guess I'll take this if nobody else speaks up.
--b.
Quoted 70 lines
Fixes 9d5b86ac13c5 ("fs/locks: Remove fl_nspid and use fs-specific...")Signed-off-by Benjamin Coddington <[email protected]>--- fs/lockd/clntproc.c | 2 +- fs/lockd/xdr.c | 4 ++-- fs/lockd/xdr4.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)fs/lockd/clntproc.c +1
-1@@ -442,7 +442,7 @@ nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) fl->fl_start = req->a_res.lock.fl.fl_start; fl->fl_end = req->a_res.lock.fl.fl_end; fl->fl_type = req->a_res.lock.fl.fl_type; - fl->fl_pid =0 ; + fl->fl_pid = -req->a_res.lock.fl.fl_pid;break ;default : status =nlm_stat_to_errno (req->a_res.status);fs/lockd/xdr.c +2
-2@@ -127,7 +127,7 @@ nlm_decode_lock(__be32 *p, struct nlm_lock *lock)locks_init_lock (fl); fl->fl_owner = current->files; - fl->fl_pid = (pid_t )lock->svid; + fl->fl_pid = current->tgid; fl->fl_flags =FL_POSIX ; fl->fl_type =F_RDLCK ;/* as good as anything else */ start =ntohl (*p++);@@ -269,7 +269,7 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)memset (lock,0 ,sizeof (*lock));locks_init_lock (&lock->fl); lock->svid = ~(u32 )0 ; - lock->fl.fl_pid = (pid_t )lock->svid; + lock->fl.fl_pid = current->tgid; if (!(p = nlm_decode_cookie(p, &argp->cookie)) || !(p = xdr_decode_string_inplace(p, &lock->caller,fs/lockd/xdr4.c +2
-2@@ -119,7 +119,7 @@ nlm4_decode_lock(__be32 *p, struct nlm_lock *lock)locks_init_lock (fl); fl->fl_owner = current->files; - fl->fl_pid = (pid_t )lock->svid; + fl->fl_pid = current->tgid; fl->fl_flags =FL_POSIX ; fl->fl_type =F_RDLCK ;/* as good as anything else */ p =xdr_decode_hyper (p, &start);@@ -266,7 +266,7 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)memset (lock,0 ,sizeof (*lock));locks_init_lock (&lock->fl); lock->svid = ~(u32 )0 ; - lock->fl.fl_pid = (pid_t )lock->svid; + lock->fl.fl_pid = current->tgid; if (!(p = nlm4_decode_cookie(p, &argp->cookie)) || !(p = xdr_decode_string_inplace(p, &lock->caller,Signature · 1 line
2.14.3
Quoted 8 lines · J. Bruce Fields
Quoted 7 lines · Benjamin Coddington
Commit
9d5b86ac13c5("fs/locks: Removefl_nspidand use fs-specificl_pidfor remote locks") specified that thel_pidreturned forF_GETLKon a local file that has a remote lock should be the pid of the lock manager process. That commit, while updating other filesystems, failed to update lockd, such that locks created by lockd had theirfl_pidset to that of the remote process holding the lock. Fix that here to be the pid of lockd.
Quoted 6 lines
Quoted 2 lines
Also, fix the client case so that the returned lock pid is negative, which indicates a remote lock on a remote file.
ACK.
Uh, I guess I'll take this if nobody else speaks up.
Applied for 4.21.--b.
Quoted 73 lines
--b.
Quoted 70 lines
Fixes 9d5b86ac13c5 ("fs/locks: Remove fl_nspid and use fs-specific...")Signed-off-by Benjamin Coddington <[email protected]>--- fs/lockd/clntproc.c | 2 +- fs/lockd/xdr.c | 4 ++-- fs/lockd/xdr4.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)fs/lockd/clntproc.c +1
-1@@ -442,7 +442,7 @@ nlmclnt_test(struct nlm_rqst *req, struct file_lock *fl) fl->fl_start = req->a_res.lock.fl.fl_start; fl->fl_end = req->a_res.lock.fl.fl_end; fl->fl_type = req->a_res.lock.fl.fl_type; - fl->fl_pid =0 ; + fl->fl_pid = -req->a_res.lock.fl.fl_pid;break ;default : status =nlm_stat_to_errno (req->a_res.status);fs/lockd/xdr.c +2
-2@@ -127,7 +127,7 @@ nlm_decode_lock(__be32 *p, struct nlm_lock *lock)locks_init_lock (fl); fl->fl_owner = current->files; - fl->fl_pid = (pid_t )lock->svid; + fl->fl_pid = current->tgid; fl->fl_flags =FL_POSIX ; fl->fl_type =F_RDLCK ;/* as good as anything else */ start =ntohl (*p++);@@ -269,7 +269,7 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)memset (lock,0 ,sizeof (*lock));locks_init_lock (&lock->fl); lock->svid = ~(u32 )0 ; - lock->fl.fl_pid = (pid_t )lock->svid; + lock->fl.fl_pid = current->tgid; if (!(p = nlm_decode_cookie(p, &argp->cookie)) || !(p = xdr_decode_string_inplace(p, &lock->caller,fs/lockd/xdr4.c +2
-2@@ -119,7 +119,7 @@ nlm4_decode_lock(__be32 *p, struct nlm_lock *lock)locks_init_lock (fl); fl->fl_owner = current->files; - fl->fl_pid = (pid_t )lock->svid; + fl->fl_pid = current->tgid; fl->fl_flags =FL_POSIX ; fl->fl_type =F_RDLCK ;/* as good as anything else */ p =xdr_decode_hyper (p, &start);@@ -266,7 +266,7 @@ nlm4svc_decode_shareargs(struct svc_rqst *rqstp, __be32 *p)memset (lock,0 ,sizeof (*lock));locks_init_lock (&lock->fl); lock->svid = ~(u32 )0 ; - lock->fl.fl_pid = (pid_t )lock->svid; + lock->fl.fl_pid = current->tgid; if (!(p = nlm4_decode_cookie(p, &argp->cookie)) || !(p = xdr_decode_string_inplace(p, &lock->caller,Signature · 1 line
2.14.3