From 2aee763bde004bfb950ba9eb3ec05ace0b8a0210 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Tue, 21 Feb 2006 18:46:56 +0000 Subject: [PATCH] bioops.io_start() was being called in a situation where the buffer could be brelse()'d afterwords instead of I/O being initiated. When this occurs, the buffer may contain softupdates-modified data which is never reverted, resulting in serious filesystem corruption. When io_start is called on a buffer, I/O MUST be initiated and terminated with a biodone() or the buffer's data may not be properly reverted. Solve the problem by moving the io_start() call a little further on in the code, after the potential brelse(). There is a possibility that this bug is responsible for the 'dirbad' panics often reported in DragonFly and FreeBSD circles. --- sys/kern/vfs_cluster.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index 2fe26b07e6..710d1b9cde 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -34,7 +34,7 @@ * * @(#)vfs_cluster.c 8.7 (Berkeley) 2/13/94 * $FreeBSD: src/sys/kern/vfs_cluster.c,v 1.92.2.9 2001/11/18 07:10:59 dillon Exp $ - * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.15 2006/02/17 19:18:06 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.16 2006/02/21 18:46:56 dillon Exp $ */ #include "opt_debug_cluster.h" @@ -864,12 +864,6 @@ cluster_wbuild(struct vnode *vp, long size, daddr_t start_lbn, int len) crit_exit(); } /* end of code for non-first buffers only */ - /* - * check for latent dependencies to be handled - */ - if (LIST_FIRST(&tbp->b_dep) != NULL && bioops.io_start) - (*bioops.io_start)(tbp); - /* * If the IO is via the VM then we do some * special VM hackery (yuck). Since the buffer's @@ -913,6 +907,13 @@ cluster_wbuild(struct vnode *vp, long size, daddr_t start_lbn, int len) crit_exit(); BUF_KERNPROC(tbp); cluster_append(&bp->b_bio1, tbp); + + /* + * check for latent dependencies to be handled + */ + if (LIST_FIRST(&tbp->b_dep) != NULL && bioops.io_start) + (*bioops.io_start)(tbp); + } finishcluster: pmap_qenter(trunc_page((vm_offset_t) bp->b_data), -- 2.41.0