summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2016-03-06 19:15:23 +0000
committermpi <mpi@openbsd.org>2016-03-06 19:15:23 +0000
commit427674adb592a841bdc31a54b9cf9b5cfa6e3cc5 (patch)
tree60041be13aef6bdabb2185935a9a89e3d176a6db
parentMerge db_elf_sym_values() into db_symbol_values(). (diff)
downloadwireguard-openbsd-427674adb592a841bdc31a54b9cf9b5cfa6e3cc5.tar.xz
wireguard-openbsd-427674adb592a841bdc31a54b9cf9b5cfa6e3cc5.zip
Do not fetch the same block multiple times if it is already present
in the buffer cache. When the Dynamic Buffer Cache has been introduced bread_cluster() became the replacement of cluster_read(). However this function did not consider the B_CACHE flag of the first buffer of a cluster like its predecessor did. This improves a lot read operations on MSDOSFS while reducing the number of DMA operations. ok beck@
-rw-r--r--sys/kern/vfs_bio.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c
index aeb9c4121f4..774fbe03b00 100644
--- a/sys/kern/vfs_bio.c
+++ b/sys/kern/vfs_bio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_bio.c,v 1.171 2015/11/28 21:52:02 beck Exp $ */
+/* $OpenBSD: vfs_bio.c,v 1.172 2016/03/06 19:15:23 mpi Exp $ */
/* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */
/*
@@ -461,13 +461,19 @@ bread_cluster(struct vnode *vp, daddr_t blkno, int size, struct buf **rbpp)
*rbpp = bio_doread(vp, blkno, size, 0);
+ /*
+ * If the buffer is in the cache skip any I/O operation.
+ */
+ if (ISSET((*rbpp)->b_flags, B_CACHE))
+ goto out;
+
if (size != round_page(size))
goto out;
if (VOP_BMAP(vp, blkno + 1, NULL, &sblkno, &maxra))
goto out;
- maxra++;
+ maxra++;
if (sblkno == -1 || maxra < 2)
goto out;