summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2009-01-08 19:13:34 +0000
committertrasz <trasz@FreeBSD.org>2009-01-08 19:13:34 +0000
commitd72b8ba20f3993d4517a73171cb5e4a269b103a6 (patch)
tree3a343d123f6d1ffdec38b4ab848f38089c1beb2c
parentfa4df0b07e913c64e1a41505b9a10843bc12f773 (diff)
downloadFreeBSD-src-d72b8ba20f3993d4517a73171cb5e4a269b103a6.zip
FreeBSD-src-d72b8ba20f3993d4517a73171cb5e4a269b103a6.tar.gz
Don't panic with "vinvalbuf: dirty bufs" when the mounted device that was
being written to goes away. Reviewed by: kib, scottl Approved by: rwatson (mentor) Sponsored by: FreeBSD Foundation
-rw-r--r--sys/fs/devfs/devfs_vnops.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
index e0672da..3d9a164 100644
--- a/sys/fs/devfs/devfs_vnops.c
+++ b/sys/fs/devfs/devfs_vnops.c
@@ -540,12 +540,28 @@ devfs_close_f(struct file *fp, struct thread *td)
return (error);
}
-/* ARGSUSED */
static int
devfs_fsync(struct vop_fsync_args *ap)
{
- if (!vn_isdisk(ap->a_vp, NULL))
+ int error;
+ struct bufobj *bo;
+ struct devfs_dirent *de;
+
+ if (!vn_isdisk(ap->a_vp, &error)) {
+ bo = &ap->a_vp->v_bufobj;
+ de = ap->a_vp->v_data;
+ if (error == ENXIO && bo->bo_dirty.bv_cnt > 0) {
+ printf("Device %s went missing before all of the data "
+ "could be written to it; expect data loss.\n",
+ de->de_dirent->d_name);
+
+ error = vop_stdfsync(ap);
+ if (bo->bo_dirty.bv_cnt != 0 || error != 0)
+ panic("devfs_fsync: vop_stdfsync failed.");
+ }
+
return (0);
+ }
return (vop_stdfsync(ap));
}
OpenPOWER on IntegriCloud