lkml.org 
[lkml]   [2002]   [Dec]   [20]   [last100]   RSS-feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
Complete thread (EXPERIMENTAL)
Patch in this message
/
DateFri, 20 Dec 2002 18:59:28 +0000 (GMT)
FromHugh Dickins <>
Subject[PATCH] tmpfs read hang
Digg This
Mikael <mikael.starvik@axis.com> reports that LTP read02 EFAULT test hangs uninterruptibly on 2.4 when the testfile is on tmpfs. I seem to have fixed this unconsciously in 2.5, when aligning do_shmem_file_read's loop with do_generic_file_read's loop, so here is that fix. But the bug actually came from having two "nr"s, one outside and one inside the loop.
Patch below applies to 2.4.21-pre2, and with offset to 2.4.20-ac2 and everything back to 2.4.4: please apply. I would like to prepare more backports from 2.5 (and -ac) in due course: for example, Alan has long had tighter large offset checking in shmem_file_write; but this read hang is bad enough to single out for immediate fix.
Thank you, Mikael!
Hugh


[view this diff only]
--- 2.4.21-pre2/mm/shmem.c	Thu Nov 28 23:53:15 2002
+++ linux/mm/shmem.c	Fri Dec 20 17:39:41 2002
@@ -919,14 +919,13 @@
 	struct inode *inode = filp->f_dentry->d_inode;
 	struct address_space *mapping = inode->i_mapping;
 	unsigned long index, offset;
-	int nr = 1;
 
 	index = *ppos >> PAGE_CACHE_SHIFT;
 	offset = *ppos & ~PAGE_CACHE_MASK;
 
-	while (nr && desc->count) {
+	for (;;) {
 		struct page *page;
-		unsigned long end_index, nr;
+		unsigned long end_index, nr, ret;
 
 		end_index = inode->i_size >> PAGE_CACHE_SHIFT;
 		if (index > end_index)
@@ -956,12 +955,14 @@
 		 * "pos" here (the actor routine has to update the user buffer
 		 * pointers and the remaining count).
 		 */
-		nr = file_read_actor(desc, page, offset, nr);
-		offset += nr;
+		ret = file_read_actor(desc, page, offset, nr);
+		offset += ret;
 		index += offset >> PAGE_CACHE_SHIFT;
 		offset &= ~PAGE_CACHE_MASK;
 	
 		page_cache_release(page);
+		if (ret != nr || !desc->count)
+			break;
 	}
 
 	*ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset;
\
ISP Services
Valid XHTML 1.0!\ /
Valid CSS! Last update: 2005-03-22 12:31    [W:0.736 / U:0.000 seconds]
©2003-2005 Jasper Spaans