cvs commit: src/sys/fs/msdosfs msdosfs_vfsops.c

David Schultz das at FreeBSD.ORG
Mon Jun 30 04:55:42 PDT 2003


On Sat, Jun 28, 2003, Tim J. Robbins wrote:
>   Fixes lockup when creating files on msdosfs mounts that have been
>   mounted read-only then upgraded to read-write. The exact cause of
>   the lockup is not known, but it is likely to be the kernel getting
>   stuck in an infinite loop trying to write dirty buffers to a device
>   without write permission.

If this is the problem I think it is, then not quite.  After a
failed write, msdosfs_readdir() gets into an infinite loop because
bread() returns a buffer with a b_resid of 0.  Partial fix:

Index: sys/fs/msdosfs/msdosfs_vnops.c
===================================================================
RCS file: /cvs/src/sys/fs/msdosfs/msdosfs_vnops.c,v
retrieving revision 1.138
diff -u -r1.138 msdosfs_vnops.c
--- sys/fs/msdosfs/msdosfs_vnops.c	15 Jun 2003 18:52:57 -0000	1.138
+++ sys/fs/msdosfs/msdosfs_vnops.c	30 Jun 2003 11:49:09 -0000
@@ -1571,6 +1571,10 @@
 			return (error);
 		}
 		n = min(n, blsize - bp->b_resid);
+		if (n == 0) {
+			brelse(bp);
+			return (EIO);
+		}
 
 		/*
 		 * Convert from dos directory entries to fs-independent


I call this a partial fix because instead of locking up, readdir()
reports that the directory is empty, and I have't bothered to
track that part down.  See also kern/37035.

There is a not-so-tight infinite loop for writing, where the
system tries to push the failed buffer out again every 5 seconds
or so, but that's really a separate issue, and a harder one to
solve (unless you believe phk ;-).  There was a discussion about
it last October, in the thread ``Patch to allow a driver to report
unrecoverable write errors to the buf layer''.


More information about the cvs-src mailing list