patch-2.1.56 linux/mm/filemap.c

Next file: linux/mm/mmap.c
Previous file: linux/kernel/exit.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.55/linux/mm/filemap.c linux/mm/filemap.c
@@ -1173,9 +1173,11 @@
 };
 
 /* This is used for a general mmap of a disk file */
-int generic_file_mmap(struct inode * inode, struct file * file, struct vm_area_struct * vma)
+
+int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
 {
 	struct vm_operations_struct * ops;
+	struct inode *inode = file->f_dentry->d_inode;
 
 	if ((vma->vm_flags & VM_SHARED) && (vma->vm_flags & VM_MAYWRITE)) {
 		ops = &file_shared_mmap;
@@ -1211,11 +1213,16 @@
 	if (vma->vm_ops->sync) {
 		int error;
 		error = vma->vm_ops->sync(vma, start, end-start, flags);
-		if (error)
-			return error;
-		if (flags & MS_SYNC)
-			return file_fsync(vma->vm_dentry->d_inode, NULL);
-		return 0;
+		if (!error && (flags & MS_SYNC)) {
+			struct dentry * dentry = vma->vm_dentry;
+			if (dentry) {
+				struct inode * inode = dentry->d_inode;
+				down(&inode->i_sem);
+				error = file_fsync(NULL,dentry);
+				up(&inode->i_sem);
+			}
+		}
+		return error;
 	}
 	return 0;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov