patch-2.2.19 linux/fs/lockd/svcsubs.c

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

diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.18/fs/lockd/svcsubs.c linux/fs/lockd/svcsubs.c
@@ -44,6 +44,10 @@
  * Note that we open the file O_RDONLY even when creating write locks.
  * This is not quite right, but for now, we assume the client performs
  * the proper R/W checking.
+ *
+ * BEWARE:
+ * The cast to struct knfs_fh in this routine, imposes an alignment
+ * requirement on (struct nfs_fh)->data for some platforms.
  */
 u32
 nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result,
@@ -63,8 +67,7 @@
 	down(&nlm_file_sema);
 
 	for (file = nlm_files[hash]; file; file = file->f_next) {
-		if (file->f_handle.fh_dcookie == fh->fh_dcookie &&
-		    !memcmp(&file->f_handle, fh, sizeof(*fh)))
+		if (!memcmp(&file->f_handle, fh, sizeof(*fh)))
 			goto found;
 	}
 
@@ -147,6 +150,7 @@
 	struct inode	 *inode = nlmsvc_file_inode(file);
 	struct file_lock *fl;
 	struct nlm_host	 *lockhost;
+	int		 status = 0;
 
 again:
 	file->f_locks = 0;
@@ -157,29 +161,27 @@
 		/* update current lock count */
 		file->f_locks++;
 		lockhost = (struct nlm_host *) fl->fl_owner;
+		if (host && lockhost != host)
+			continue;
 		if (action == NLM_ACT_MARK)
 			lockhost->h_inuse = 1;
 		else if (action == NLM_ACT_CHECK)
-			return 1;
+			status = 1;
 		else if (action == NLM_ACT_UNLOCK) {
-			struct file_lock lock = *fl;
-
-			if (host && lockhost != host)
-				continue;
+			struct file_lock lock;
 
+			lock = *fl;
 			lock.fl_type  = F_UNLCK;
-			lock.fl_start = 0;
-			lock.fl_end   = NLM_OFFSET_MAX;
 			if (posix_lock_file(&file->f_file, &lock, 0) < 0) {
 				printk("lockd: unlock failure in %s:%d\n",
 						__FILE__, __LINE__);
-				return 1;
-			}
-			goto again;
+				status = 1;
+			} else
+				goto again;
 		}
 	}
 
-	return 0;
+	return status;
 }
 
 /*
@@ -208,6 +210,7 @@
 {
 	struct nlm_file	*file, **fp;
 	int		i;
+	int		res = 0;
 
 	down(&nlm_file_sema);
 	for (i = 0; i < FILE_NRHASH; i++) {
@@ -215,24 +218,21 @@
 		while ((file = *fp) != NULL) {
 			/* Traverse locks, blocks and shares of this file
 			 * and update file->f_locks count */
-			if (nlm_inspect_file(host, file, action)) {
-				up(&nlm_file_sema);
-				return 1;
-			}
+			if (nlm_inspect_file(host, file, action))
+				res = 1;
 
-			/* No more references to this file. Let go of it. */
-			if (!file->f_blocks && !file->f_locks
-			 && !file->f_shares && !file->f_count) {
-				*fp = file->f_next;
-				nlmsvc_ops->fclose(&file->f_file);
-				kfree(file);
-			} else {
+			if (file->f_blocks || file->f_locks
+			    || file->f_shares || file->f_count) {
 				fp = &file->f_next;
+				continue;
 			}
+			*fp = file->f_next;
+			nlmsvc_ops->fclose(&file->f_file);
+			kfree(file);
 		}
 	}
 	up(&nlm_file_sema);
-	return 0;
+	return res;
 }
 
 /*
@@ -298,7 +298,7 @@
 	if ((host = nlm_lookup_host(clnt, NULL, 0, 0)) != NULL) {
 		dprintk("lockd: invalidating client for %s\n", host->h_name);
 		nlmsvc_free_host_resources(host);
-		host->h_expires = 0;
+		host->h_expires = jiffies;
 		nlm_release_host(host);
 	}
 }

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