Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Dedup the conversion of bioc_disk and bioc_vol to en...
details: https://anonhg.NetBSD.org/src/rev/b520bfd2cd91
branches: trunk
changeset: 806854:b520bfd2cd91
user: christos <christos%NetBSD.org@localhost>
date: Thu Mar 12 15:33:10 2015 +0000
description:
Dedup the conversion of bioc_disk and bioc_vol to envsys_data_t
diffstat:
sys/dev/bio.c | 66 +++++++++++++++++++++++++++++++++++++++++++-
sys/dev/biovar.h | 6 +++-
sys/dev/ic/cac.c | 40 +++-----------------------
sys/dev/ic/ciss.c | 39 +++----------------------
sys/dev/ic/mfi.c | 32 +++------------------
sys/dev/pci/arcmsr.c | 77 +++++++--------------------------------------------
sys/dev/pci/mpii.c | 30 ++-----------------
7 files changed, 99 insertions(+), 191 deletions(-)
diffs (truncated from 440 to 300 lines):
diff -r 90ef8a176bf7 -r b520bfd2cd91 sys/dev/bio.c
--- a/sys/dev/bio.c Thu Mar 12 15:28:16 2015 +0000
+++ b/sys/dev/bio.c Thu Mar 12 15:33:10 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bio.c,v 1.11 2014/07/25 08:10:35 dholland Exp $ */
+/* $NetBSD: bio.c,v 1.12 2015/03/12 15:33:10 christos Exp $ */
/* $OpenBSD: bio.c,v 1.9 2007/03/20 02:35:55 marco Exp $ */
/*
@@ -28,7 +28,7 @@
/* A device controller ioctl tunnelling device. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bio.c,v 1.11 2014/07/25 08:10:35 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bio.c,v 1.12 2015/03/12 15:33:10 christos Exp $");
#include "opt_compat_netbsd.h"
@@ -45,6 +45,7 @@
#include <sys/kauth.h>
#include <dev/biovar.h>
+#include <dev/sysmon/sysmonvar.h>
struct bio_mapping {
LIST_ENTRY(bio_mapping) bm_link;
@@ -302,3 +303,64 @@
return bm->bm_ioctl(bm->bm_dev, cmd, addr);
}
+
+void
+bio_disk_to_envsys(envsys_data_t *edata, const struct bioc_disk *bd)
+{
+ switch (bd->bd_status) {
+ case BIOC_SDONLINE:
+ edata->value_cur = ENVSYS_DRIVE_ONLINE;
+ edata->state = ENVSYS_SVALID;
+ break;
+ case BIOC_SDOFFLINE:
+ edata->value_cur = ENVSYS_DRIVE_OFFLINE;
+ edata->state = ENVSYS_SCRITICAL;
+ break;
+ default:
+ edata->value_cur = ENVSYS_DRIVE_FAIL;
+ edata->state = ENVSYS_SCRITICAL;
+ break;
+ }
+}
+
+void
+bio_vol_to_envsys(envsys_data_t *edata, const struct bioc_vol *bv)
+{
+ switch (bv->bv_status) {
+ case BIOC_SVOFFLINE:
+ edata->value_cur = ENVSYS_DRIVE_OFFLINE;
+ edata->state = ENVSYS_SCRITICAL;
+ break;
+ case BIOC_SVDEGRADED:
+ edata->value_cur = ENVSYS_DRIVE_PFAIL;
+ edata->state = ENVSYS_SCRITICAL;
+ break;
+ case BIOC_SVBUILDING:
+ edata->value_cur = ENVSYS_DRIVE_BUILD;
+ edata->state = ENVSYS_SVALID;
+ break;
+ case BIOC_SVMIGRATING:
+ edata->value_cur = ENVSYS_DRIVE_MIGRATING;
+ edata->state = ENVSYS_SVALID;
+ break;
+ case BIOC_SVCHECKING:
+ edata->value_cur = ENVSYS_DRIVE_CHECK;
+ edata->state = ENVSYS_SVALID;
+ break;
+ case BIOC_SVREBUILD:
+ edata->value_cur = ENVSYS_DRIVE_REBUILD;
+ edata->state = ENVSYS_SCRITICAL;
+ break;
+ case BIOC_SVSCRUB:
+ case BIOC_SVONLINE:
+ edata->value_cur = ENVSYS_DRIVE_ONLINE;
+ edata->state = ENVSYS_SVALID;
+ break;
+ case BIOC_SVINVALID:
+ /* FALLTHROUGH */
+ default:
+ edata->value_cur = ENVSYS_DRIVE_EMPTY; /* unknown state */
+ edata->state = ENVSYS_SINVALID;
+ break;
+ }
+}
diff -r 90ef8a176bf7 -r b520bfd2cd91 sys/dev/biovar.h
--- a/sys/dev/biovar.h Thu Mar 12 15:28:16 2015 +0000
+++ b/sys/dev/biovar.h Thu Mar 12 15:33:10 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: biovar.h,v 1.8 2009/05/07 12:15:33 cegger Exp $ */
+/* $NetBSD: biovar.h,v 1.9 2015/03/12 15:33:10 christos Exp $ */
/* $OpenBSD: biovar.h,v 1.26 2007/03/19 03:02:08 marco Exp $ */
/*
@@ -256,4 +256,8 @@
int bc_volid; /* volume id to be created/removed */
};
+struct envsys_data;
+void bio_disk_to_envsys(struct envsys_data *, const struct bioc_disk *);
+void bio_vol_to_envsys(struct envsys_data *, const struct bioc_vol *) ;
+
#endif /* ! _DEV_BIOVAR_H_ */
diff -r 90ef8a176bf7 -r b520bfd2cd91 sys/dev/ic/cac.c
--- a/sys/dev/ic/cac.c Thu Mar 12 15:28:16 2015 +0000
+++ b/sys/dev/ic/cac.c Thu Mar 12 15:33:10 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cac.c,v 1.54 2012/10/27 17:18:19 chs Exp $ */
+/* $NetBSD: cac.c,v 1.55 2015/03/12 15:33:10 christos Exp $ */
/*-
* Copyright (c) 2000, 2006, 2007 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cac.c,v 1.54 2012/10/27 17:18:19 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cac.c,v 1.55 2015/03/12 15:33:10 christos Exp $");
#include "bio.h"
@@ -723,40 +723,10 @@
memset(&bv, 0, sizeof(bv));
bv.bv_volid = edata->sensor;
s = splbio();
- if (cac_ioctl_vol(sc, &bv)) {
- splx(s);
- return;
- }
+ if (cac_ioctl_vol(sc, &bv))
+ bv.bv_status = BIOC_SVINVALID;
splx(s);
- switch(bv.bv_status) {
- case BIOC_SVOFFLINE:
- edata->value_cur = ENVSYS_DRIVE_FAIL;
- edata->state = ENVSYS_SCRITICAL;
- break;
-
- case BIOC_SVDEGRADED:
- edata->value_cur = ENVSYS_DRIVE_PFAIL;
- edata->state = ENVSYS_SCRITICAL;
- break;
-
- case BIOC_SVSCRUB:
- case BIOC_SVONLINE:
- edata->value_cur = ENVSYS_DRIVE_ONLINE;
- edata->state = ENVSYS_SVALID;
- break;
-
- case BIOC_SVREBUILD:
- case BIOC_SVBUILDING:
- edata->value_cur = ENVSYS_DRIVE_REBUILD;
- edata->state = ENVSYS_SVALID;
- break;
-
- case BIOC_SVINVALID:
- /* FALLTRHOUGH */
- default:
- edata->value_cur = 0; /* unknown */
- edata->state = ENVSYS_SINVALID;
- }
+ bio_vol_to_envsys(edata, &bv);
}
#endif /* NBIO > 0 */
diff -r 90ef8a176bf7 -r b520bfd2cd91 sys/dev/ic/ciss.c
--- a/sys/dev/ic/ciss.c Thu Mar 12 15:28:16 2015 +0000
+++ b/sys/dev/ic/ciss.c Thu Mar 12 15:33:10 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ciss.c,v 1.32 2013/10/17 21:24:24 christos Exp $ */
+/* $NetBSD: ciss.c,v 1.33 2015/03/12 15:33:10 christos Exp $ */
/* $OpenBSD: ciss.c,v 1.68 2013/05/30 16:15:02 deraadt Exp $ */
/*
@@ -19,7 +19,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ciss.c,v 1.32 2013/10/17 21:24:24 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ciss.c,v 1.33 2015/03/12 15:33:10 christos Exp $");
#include "bio.h"
@@ -1541,38 +1541,9 @@
memset(&bv, 0, sizeof(bv));
bv.bv_volid = edata->sensor;
- if (ciss_ioctl_vol(sc, &bv)) {
- return;
- }
-
- switch(bv.bv_status) {
- case BIOC_SVOFFLINE:
- edata->value_cur = ENVSYS_DRIVE_FAIL;
- edata->state = ENVSYS_SCRITICAL;
- break;
-
- case BIOC_SVDEGRADED:
- edata->value_cur = ENVSYS_DRIVE_PFAIL;
- edata->state = ENVSYS_SCRITICAL;
- break;
+ if (ciss_ioctl_vol(sc, &bv))
+ bv.bv_status = BIOC_SVINVALID;
- case BIOC_SVSCRUB:
- case BIOC_SVONLINE:
- edata->value_cur = ENVSYS_DRIVE_ONLINE;
- edata->state = ENVSYS_SVALID;
- break;
-
- case BIOC_SVREBUILD:
- case BIOC_SVBUILDING:
- edata->value_cur = ENVSYS_DRIVE_REBUILD;
- edata->state = ENVSYS_SVALID;
- break;
-
- case BIOC_SVINVALID:
- /* FALLTRHOUGH */
- default:
- edata->value_cur = 0; /* unknown */
- edata->state = ENVSYS_SINVALID;
- }
+ bio_vol_to_envsys(edata, &bv);
}
#endif /* NBIO > 0 */
diff -r 90ef8a176bf7 -r b520bfd2cd91 sys/dev/ic/mfi.c
--- a/sys/dev/ic/mfi.c Thu Mar 12 15:28:16 2015 +0000
+++ b/sys/dev/ic/mfi.c Thu Mar 12 15:33:10 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mfi.c,v 1.55 2014/08/21 15:43:35 christos Exp $ */
+/* $NetBSD: mfi.c,v 1.56 2015/03/12 15:33:10 christos Exp $ */
/* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
/*
@@ -73,7 +73,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.55 2014/08/21 15:43:35 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.56 2015/03/12 15:33:10 christos Exp $");
#include "bio.h"
@@ -2638,31 +2638,9 @@
splx(s);
KERNEL_UNLOCK_ONE(curlwp);
if (error)
- return;
-
- switch(bv.bv_status) {
- case BIOC_SVOFFLINE:
- edata->value_cur = ENVSYS_DRIVE_FAIL;
- edata->state = ENVSYS_SCRITICAL;
- break;
-
- case BIOC_SVDEGRADED:
- edata->value_cur = ENVSYS_DRIVE_PFAIL;
- edata->state = ENVSYS_SCRITICAL;
- break;
-
- case BIOC_SVSCRUB:
- case BIOC_SVONLINE:
- edata->value_cur = ENVSYS_DRIVE_ONLINE;
- edata->state = ENVSYS_SVALID;
- break;
-
- case BIOC_SVINVALID:
- /* FALLTRHOUGH */
- default:
- edata->value_cur = 0; /* unknown */
- edata->state = ENVSYS_SINVALID;
- }
+ bv.bv_status = BIOC_SVINVALID;
+
+ bio_vol_to_envsys(edata, &bv);
}
#endif /* NBIO > 0 */
diff -r 90ef8a176bf7 -r b520bfd2cd91 sys/dev/pci/arcmsr.c
--- a/sys/dev/pci/arcmsr.c Thu Mar 12 15:28:16 2015 +0000
+++ b/sys/dev/pci/arcmsr.c Thu Mar 12 15:33:10 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arcmsr.c,v 1.31 2014/03/29 19:28:24 christos Exp $ */
+/* $NetBSD: arcmsr.c,v 1.32 2015/03/12 15:33:10 christos Exp $ */
/* $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */
/*
@@ -21,7 +21,7 @@
#include "bio.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.31 2014/03/29 19:28:24 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.32 2015/03/12 15:33:10 christos Exp $");
Home |
Main Index |
Thread Index |
Old Index