summaryrefslogtreecommitdiffstats
path: root/sys/fs/ntfs
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2003-06-20 14:52:52 +0000
committertjr <tjr@FreeBSD.org>2003-06-20 14:52:52 +0000
commit3d49bbe5fee06a1bee3f2129d39b72c8fbbcff8c (patch)
tree5d99382276dacd9b8d69efdcae5db21d55558e14 /sys/fs/ntfs
parent97c9bf2fb9193b783ad196c3698b173bb547d2fe (diff)
downloadFreeBSD-src-3d49bbe5fee06a1bee3f2129d39b72c8fbbcff8c.zip
FreeBSD-src-3d49bbe5fee06a1bee3f2129d39b72c8fbbcff8c.tar.gz
Merge from NetBSD src/sys/ntfs/ntfs_subr.c 1.5 & 1.30 (jdolecek):
- Avoid calling bread() with different sizes on the same blkno. Although the buffer cache is designed to handle differing size buffers, it erroneously tries to write the incorrectly-sized buffer buffer back to disk before reading the correctly-sized one, even when it's not dirty. This behaviour caused a panic for read-only NTFS mounts when INVARIANTS was enabled ("bundirty: buffer x still on queue y"), reported by NAKAJI Hiroyuki. - Fix a bug in the code handling holes: a variable was incremented instead of decremented, which could cause an infinite loop.
Diffstat (limited to 'sys/fs/ntfs')
-rw-r--r--sys/fs/ntfs/ntfs_subr.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/fs/ntfs/ntfs_subr.c b/sys/fs/ntfs/ntfs_subr.c
index 68f654f..814a91e 100644
--- a/sys/fs/ntfs/ntfs_subr.c
+++ b/sys/fs/ntfs/ntfs_subr.c
@@ -1544,6 +1544,20 @@ ntfs_readntvattr_plain(
min(ntfs_cntob(ccl) - off,
MAXBSIZE - off));
cl = ntfs_btocl(tocopy + off);
+
+ /*
+ * If 'off' pushes us to next
+ * block, don't attempt to read whole
+ * 'tocopy' at once. This is to avoid
+ * bread() with varying 'size' for
+ * same 'blkno', which is not good.
+ */
+ if (cl > ntfs_btocl(tocopy)) {
+ tocopy -=
+ ntfs_btocnoff(tocopy + off);
+ cl--;
+ }
+
ddprintf(("ntfs_readntvattr_plain: " \
"read: cn: 0x%x cl: %d, " \
"off: %d len: %d, left: %d\n",
@@ -1587,7 +1601,7 @@ ntfs_readntvattr_plain(
off = 0;
if (uio) {
size_t remains = tocopy;
- for(; remains; remains++)
+ for(; remains; remains--)
uiomove("", 1, uio);
} else
bzero(data, tocopy);
OpenPOWER on IntegriCloud