patch-2.4.0-test10 linux/fs/nfs/file.c

Next file: linux/fs/nfs/nfs2xdr.c
Previous file: linux/fs/nfs/dir.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.0-test9/linux/fs/nfs/file.c linux/fs/nfs/file.c
@@ -176,11 +176,16 @@
  */
 static int nfs_sync_page(struct page *page)
 {
-	struct inode	*inode = (struct inode *)page->mapping->host;
+	struct address_space *mapping;
+	struct inode	*inode;
 	unsigned long	index = page_index(page);
 	unsigned int	rpages, wpages;
 	int		result;
 
+	mapping = page->mapping;
+	if (!mapping)
+		return 0;
+	inode = (struct inode *)mapping->host;
 	if (!inode)
 		return 0;
 
@@ -281,7 +286,9 @@
 	 * Flush all pending writes before doing anything
 	 * with locks..
 	 */
+	down(&filp->f_dentry->d_inode->i_sem);
 	status = nfs_wb_all(inode);
+	up(&filp->f_dentry->d_inode->i_sem);
 	if (status < 0)
 		return status;
 
@@ -296,8 +303,10 @@
 	 */
  out_ok:
 	if ((cmd == F_SETLK || cmd == F_SETLKW) && fl->fl_type != F_UNLCK) {
+		down(&filp->f_dentry->d_inode->i_sem);
 		nfs_wb_all(inode);      /* we may have slept */
 		nfs_zap_caches(inode);
+		up(&filp->f_dentry->d_inode->i_sem);
 	}
 	return status;
 }

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