Date: Sat, 13 Apr 2002 04:17:46 -0700 (PDT) From: David Schultz <dschultz@uclink.Berkeley.EDU> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/37035: [PATCH] msdosfs_readdir() freezes after failed write Message-ID: <200204131117.g3DBHkR21118@HAL9000.wox.org>
next in thread | raw e-mail | index | archive | help
>Number: 37035 >Category: kern >Synopsis: [PATCH] msdosfs_readdir() freezes after failed write >Confidential: no >Severity: serious >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Apr 13 04:20:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: David Schultz >Release: FreeBSD 4.5-RELEASE-p2 i386 >Organization: >Environment: Problem affects all versions of FreeBSD from at least 4.0-RELEASE. to 5.0-CURRENT >Description: After an attempt to write a buffer to a write-protected or otherwise bad floppy, attempts to bread() the same block return success, but the resulting buffer has b_count == b_resid. Unlike the UFS code, which correctly handles this situation, msdosfs_readdir() goes into an infinite loop. >How-To-Repeat: Mount a write-protected DOS floppy, then... /flp# cat > foo (error) /flp# ls (lockup) >Fix: This patch causes msdosfs_readdir() to give up in the case where it would otherwise spin forever. There is still room for improvement; for example, the buffer cache ought to give up when the floppy is forcibly unmounted. However, this solves the actual lockup that many people complain about. Index: msdosfs_vnops.c =================================================================== RCS file: /home/ncvs/src/sys/fs/msdosfs/msdosfs_vnops.c,v retrieving revision 1.119 diff -u -r1.119 msdosfs_vnops.c --- msdosfs_vnops.c 2002/04/05 14:01:04 1.119 +++ msdosfs_vnops.c 2002/04/12 23:12:27 @@ -1603,7 +1603,16 @@ brelse(bp); return (error); } + + /* + * If a short read occurred, the buffer may contain + * less valid data than expected. + */ n = min(n, blsize - bp->b_resid); + if (n == 0) { + brelse(bp); + break; + } /* * Convert from dos directory entries to fs-independent >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204131117.g3DBHkR21118>