Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Fixes: 9d5b86ac13c5 ("fs/locks: Remove fl_nspid and use fs-specific...")
Cc: stable@vger.kernel.org

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>

authored by

Benjamin Coddington and committed by
J. Bruce Fields
b8eee0e9 03b31f48

+5 -5
+1 -1
fs/lockd/clntproc.c
··· 442 442 fl->fl_start = req->a_res.lock.fl.fl_start; 443 443 fl->fl_end = req->a_res.lock.fl.fl_end; 444 444 fl->fl_type = req->a_res.lock.fl.fl_type; 445 - fl->fl_pid = 0; 445 + fl->fl_pid = -req->a_res.lock.fl.fl_pid; 446 446 break; 447 447 default: 448 448 status = nlm_stat_to_errno(req->a_res.status);
+2 -2
fs/lockd/xdr.c
··· 127 127 128 128 locks_init_lock(fl); 129 129 fl->fl_owner = current->files; 130 - fl->fl_pid = (pid_t)lock->svid; 130 + fl->fl_pid = current->tgid; 131 131 fl->fl_flags = FL_POSIX; 132 132 fl->fl_type = F_RDLCK; /* as good as anything else */ 133 133 start = ntohl(*p++); ··· 269 269 memset(lock, 0, sizeof(*lock)); 270 270 locks_init_lock(&lock->fl); 271 271 lock->svid = ~(u32) 0; 272 - lock->fl.fl_pid = (pid_t)lock->svid; 272 + lock->fl.fl_pid = current->tgid; 273 273 274 274 if (!(p = nlm_decode_cookie(p, &argp->cookie)) 275 275 || !(p = xdr_decode_string_inplace(p, &lock->caller,
+2 -2
fs/lockd/xdr4.c
··· 119 119 120 120 locks_init_lock(fl); 121 121 fl->fl_owner = current->files; 122 - fl->fl_pid = (pid_t)lock->svid; 122 + fl->fl_pid = current->tgid; 123 123 fl->fl_flags = FL_POSIX; 124 124 fl->fl_type = F_RDLCK; /* as good as anything else */ 125 125 p = xdr_decode_hyper(p, &start); ··· 266 266 memset(lock, 0, sizeof(*lock)); 267 267 locks_init_lock(&lock->fl); 268 268 lock->svid = ~(u32) 0; 269 - lock->fl.fl_pid = (pid_t)lock->svid; 269 + lock->fl.fl_pid = current->tgid; 270 270 271 271 if (!(p = nlm4_decode_cookie(p, &argp->cookie)) 272 272 || !(p = xdr_decode_string_inplace(p, &lock->caller,