patch-2.4.13 linux/fs/lockd/svclock.c

Next file: linux/fs/lockd/svcproc.c
Previous file: linux/fs/lockd/svc.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.12/linux/fs/lockd/svclock.c linux/fs/lockd/svclock.c
@@ -31,9 +31,14 @@
 #include <linux/lockd/nlm.h>
 #include <linux/lockd/lockd.h>
 
-
 #define NLMDBG_FACILITY		NLMDBG_SVCLOCK
 
+#ifdef CONFIG_LOCKD_V4
+#define nlm_deadlock	nlm4_deadlock
+#else
+#define nlm_deadlock	nlm_lck_denied
+#endif
+
 static void	nlmsvc_insert_block(struct nlm_block *block, unsigned long);
 static int	nlmsvc_remove_block(struct nlm_block *block);
 static void	nlmsvc_grant_callback(struct rpc_task *task);
@@ -330,12 +335,7 @@
 		case 0:
 			return nlm_granted;
 		case EDEADLK:
-#ifdef CONFIG_LOCKD_V4
-			return nlm4_deadlock; /* will be downgraded to lck_deined if this
-					       * is a NLMv1,3 request */
-#else
-			/* no applicable NLM status */
-#endif
+			return nlm_deadlock;
 		case EAGAIN:
 			return nlm_lck_denied;
 		default:			/* includes ENOLCK */
@@ -346,6 +346,11 @@
 	if (!wait) {
 		up(&file->f_sema);
 		return nlm_lck_denied;
+	}
+
+	if (posix_locks_deadlock(&lock->fl, conflock)) {
+		up(&file->f_sema);
+		return nlm_deadlock;
 	}
 
 	/* If we don't have a block, create and initialize it. Then

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)