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

Configure Feed

Select the types of activity you want to include in your feed.

lockd: Introduce nlm__int__deadlock

The use of CONFIG_LOCKD_V4 in combination with a later cast_status()
in the NLMv3 code is difficult to reason about. Instead, replace the
use of nlm_deadlock with an implementation-defined status value that
version-specific code translates appropriately.

The new approach establishes a translation boundary: generic lockd
code returns nlm__int__deadlock when posix_lock_file() yields
-EDEADLK. Version-specific handlers (svc4proc.c for NLMv4,
svcproc.c for NLMv3) translate this internal status to the
appropriate wire protocol value. NLMv4 maps to nlm4_deadlock;
NLMv3 maps to nlm_lck_denied (since NLMv3 lacks a deadlock-specific
status code).

Later this modification will also remove the need to include NLMv4
headers in NLMv3 and generic code.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

+13 -10
+8 -2
fs/lockd/svc4proc.c
··· 148 148 resp->status = nlmsvc_lock(rqstp, file, host, &argp->lock, 149 149 argp->block, &argp->cookie, 150 150 argp->reclaim); 151 - if (resp->status == nlm__int__drop_reply) 151 + switch (resp->status) { 152 + case nlm__int__drop_reply: 152 153 rc = rpc_drop_reply; 153 - else 154 + break; 155 + case nlm__int__deadlock: 156 + resp->status = nlm4_deadlock; 157 + fallthrough; 158 + default: 154 159 dprintk("lockd: LOCK status %d\n", ntohl(resp->status)); 160 + } 155 161 156 162 nlmsvc_release_lockowner(&argp->lock); 157 163 nlmsvc_release_host(host);
+1 -7
fs/lockd/svclock.c
··· 33 33 34 34 #define NLMDBG_FACILITY NLMDBG_SVCLOCK 35 35 36 - #ifdef CONFIG_LOCKD_V4 37 - #define nlm_deadlock nlm4_deadlock 38 - #else 39 - #define nlm_deadlock nlm_lck_denied 40 - #endif 41 - 42 36 static void nlmsvc_release_block(struct nlm_block *block); 43 37 static void nlmsvc_insert_block(struct nlm_block *block, unsigned long); 44 38 static void nlmsvc_remove_block(struct nlm_block *block); ··· 583 589 goto out; 584 590 case -EDEADLK: 585 591 nlmsvc_remove_block(block); 586 - ret = nlm_deadlock; 592 + ret = nlm__int__deadlock; 587 593 goto out; 588 594 default: /* includes ENOLCK */ 589 595 nlmsvc_remove_block(block);
+3 -1
fs/lockd/svcproc.c
··· 27 27 case nlm_lck_denied_grace_period: 28 28 case nlm__int__drop_reply: 29 29 break; 30 - case nlm4_deadlock: 30 + case nlm__int__deadlock: 31 31 status = nlm_lck_denied; 32 32 break; 33 33 default: ··· 39 39 #else 40 40 static inline __be32 cast_status(__be32 status) 41 41 { 42 + if (status == nlm__int__deadlock) 43 + status = nlm_lck_denied; 42 44 return status; 43 45 } 44 46 #endif
+1
include/linux/lockd/lockd.h
··· 43 43 * Version handlers translate these to appropriate wire values. 44 44 */ 45 45 #define nlm__int__drop_reply cpu_to_be32(30000) 46 + #define nlm__int__deadlock cpu_to_be32(30001) 46 47 47 48 /* 48 49 * Lockd host handle (used both by the client and server personality).