Module Name: src
Committed By: msaitoh
Date: Wed Aug 27 14:39:19 UTC 2014
Modified Files:
src/sbin/ccdconfig [netbsd-6]: ccdconfig.c
src/sys/dev [netbsd-6]: ccd.c ccdvar.h
Log Message:
Pull up following revision(s) (requested by sborrill in ticket #1113):
sbin/ccdconfig/ccdconfig.c 1.54 via patch
sys/dev/ccd.c 1.152 via patch
sys/dev/ccdvar.h 1.34 via patch
Switch size_t to uint64_t in appropriate places to ensure that ccd(4)
works with component and total sizes of > 2TB.
Make kernel print device information when a ccd configured.
Fix some typos in comments.
To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.51.4.1 src/sbin/ccdconfig/ccdconfig.c
cvs rdiff -u -r1.143 -r1.143.6.1 src/sys/dev/ccd.c
cvs rdiff -u -r1.32 -r1.32.10.1 src/sys/dev/ccdvar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/ccdconfig/ccdconfig.c
diff -u src/sbin/ccdconfig/ccdconfig.c:1.51 src/sbin/ccdconfig/ccdconfig.c:1.51.4.1
--- src/sbin/ccdconfig/ccdconfig.c:1.51 Sat Aug 27 16:29:51 2011
+++ src/sbin/ccdconfig/ccdconfig.c Wed Aug 27 14:39:19 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ccdconfig.c,v 1.51 2011/08/27 16:29:51 joerg Exp $ */
+/* $NetBSD: ccdconfig.c,v 1.51.4.1 2014/08/27 14:39:19 msaitoh Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1996, 1997\
The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: ccdconfig.c,v 1.51 2011/08/27 16:29:51 joerg Exp $");
+__RCSID("$NetBSD: ccdconfig.c,v 1.51.4.1 2014/08/27 14:39:19 msaitoh Exp $");
#endif
#include <sys/param.h>
@@ -310,7 +310,7 @@ do_single(int argc, char **argv, int act
ui == 0 ? '(' : ' ', cp2,
ui == ccio.ccio_ndisks - 1 ? ')' : ',');
}
- printf(", %ld blocks ", (long)ccio.ccio_size);
+ printf(", %ju blocks ", (uintmax_t)ccio.ccio_size);
if (ccio.ccio_ileave != 0)
printf("interleaved at %d blocks\n", ccio.ccio_ileave);
else
Index: src/sys/dev/ccd.c
diff -u src/sys/dev/ccd.c:1.143 src/sys/dev/ccd.c:1.143.6.1
--- src/sys/dev/ccd.c:1.143 Sun Nov 13 23:02:46 2011
+++ src/sys/dev/ccd.c Wed Aug 27 14:39:19 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ccd.c,v 1.143 2011/11/13 23:02:46 christos Exp $ */
+/* $NetBSD: ccd.c,v 1.143.6.1 2014/08/27 14:39:19 msaitoh Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -88,7 +88,11 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.143 2011/11/13 23:02:46 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ccd.c,v 1.143.6.1 2014/08/27 14:39:19 msaitoh Exp $");
+
+#if defined(_KERNEL_OPT)
+#include "opt_compat_netbsd.h"
+#endif
#include <sys/param.h>
#include <sys/systm.h>
@@ -399,6 +403,22 @@ ccdinit(struct ccd_softc *cs, char **cpa
ccg->ccg_ntracks = 1;
ccg->ccg_nsectors = 1024 * (1024 / ccg->ccg_secsize);
ccg->ccg_ncylinders = cs->sc_size / ccg->ccg_nsectors;
+
+ if (cs->sc_ileave > 0)
+ aprint_normal("%s: Interleaving %d component%s "
+ "(%d block interleave)\n", cs->sc_xname,
+ cs->sc_nccdisks, (cs->sc_nccdisks != 0 ? "s" : ""),
+ cs->sc_ileave);
+ else
+ aprint_normal("%s: Concatenating %d component%s\n",
+ cs->sc_xname,
+ cs->sc_nccdisks, (cs->sc_nccdisks != 0 ? "s" : ""));
+ for (ix = 0; ix < cs->sc_nccdisks; ix++) {
+ ci = &cs->sc_cinfo[ix];
+ aprint_normal("%s: %s (%ju blocks)\n", cs->sc_xname,
+ ci->ci_path, (uintmax_t)ci->ci_size);
+ }
+ aprint_normal("%s: total %ju blocks\n", cs->sc_xname, cs->sc_size);
/*
* Create thread to handle deferred I/O.
@@ -1029,6 +1049,46 @@ ccdioctl(dev_t dev, u_long cmd, void *da
cs = &ccd_softc[unit];
uc = kauth_cred_get();
+/*
+ * Compat code must not be called if on a platform where
+ * sizeof (size_t) == sizeof (uint64_t) as CCDIOCSET will
+ * be the same as CCDIOCSET_60
+ */
+#ifndef _LP64
+ switch (cmd) {
+ case CCDIOCSET_60: {
+ struct ccd_ioctl ccionew;
+ struct ccd_ioctl_60 *ccio60 =
+ (struct ccd_ioctl_60 *)data;
+ ccionew.ccio_disks = ccio->ccio_disks;
+ ccionew.ccio_ndisks = ccio->ccio_ndisks;
+ ccionew.ccio_ileave = ccio->ccio_ileave;
+ ccionew.ccio_flags = ccio->ccio_flags;
+ ccionew.ccio_unit = ccio->ccio_unit;
+ error = ccdioctl(dev, CCDIOCSET, &ccionew, flag, l);
+ if (!error) {
+ /* Copy data back, adjust types if necessary */
+ ccio60->ccio_disks = ccionew.ccio_disks;
+ ccio60->ccio_ndisks = ccionew.ccio_ndisks;
+ ccio60->ccio_ileave = ccionew.ccio_ileave;
+ ccio60->ccio_flags = ccionew.ccio_flags;
+ ccio60->ccio_unit = ccionew.ccio_unit;
+ ccio60->ccio_size = (size_t)ccionew.ccio_size;
+ }
+ return error;
+ }
+ break;
+
+ case CCDIOCCLR_60:
+ /*
+ * ccio_size member not used, so existing struct OK
+ * drop through to existing non-compat version
+ */
+ cmd = CCDIOCCLR;
+ break;
+ }
+#endif /* !_LP64*/
+
/* Must be open for writes for these commands... */
switch (cmd) {
case CCDIOCSET:
@@ -1096,7 +1156,7 @@ ccdioctl(dev_t dev, u_long cmd, void *da
/*
* Allocate space for and copy in the array of
- * componet pathnames and device numbers.
+ * component pathnames and device numbers.
*/
cpp = kmem_alloc(ccio->ccio_ndisks * sizeof(*cpp), KM_SLEEP);
vpp = kmem_alloc(ccio->ccio_ndisks * sizeof(*vpp), KM_SLEEP);
@@ -1235,7 +1295,9 @@ ccdioctl(dev_t dev, u_long cmd, void *da
kmem_free(cs->sc_itable, (cs->sc_nccdisks + 1) *
sizeof(struct ccdiinfo));
- /* Detatch the disk. */
+ aprint_normal("%s: detached\n", cs->sc_xname);
+
+ /* Detach the disk. */
disk_detach(&cs->sc_dkdev);
bufq_free(cs->sc_bufq);
break;
@@ -1460,15 +1522,16 @@ ccdgetdisklabel(dev_t dev)
*/
if (lp->d_secperunit != cs->sc_size)
printf("WARNING: %s: "
- "total sector size in disklabel (%d) != "
- "the size of ccd (%lu)\n", cs->sc_xname,
- lp->d_secperunit, (u_long)cs->sc_size);
+ "total sector size in disklabel (%ju) != "
+ "the size of ccd (%ju)\n", cs->sc_xname,
+ (uintmax_t)lp->d_secperunit,
+ (uintmax_t)cs->sc_size);
for (i = 0; i < lp->d_npartitions; i++) {
pp = &lp->d_partitions[i];
if (pp->p_offset + pp->p_size > cs->sc_size)
printf("WARNING: %s: end of partition `%c' "
- "exceeds the size of ccd (%lu)\n",
- cs->sc_xname, 'a' + i, (u_long)cs->sc_size);
+ "exceeds the size of ccd (%ju)\n",
+ cs->sc_xname, 'a' + i, (uintmax_t)cs->sc_size);
}
}
Index: src/sys/dev/ccdvar.h
diff -u src/sys/dev/ccdvar.h:1.32 src/sys/dev/ccdvar.h:1.32.10.1
--- src/sys/dev/ccdvar.h:1.32 Tue Feb 8 20:20:26 2011
+++ src/sys/dev/ccdvar.h Wed Aug 27 14:39:19 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: ccdvar.h,v 1.32 2011/02/08 20:20:26 rmind Exp $ */
+/* $NetBSD: ccdvar.h,v 1.32.10.1 2014/08/27 14:39:19 msaitoh Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 1999, 2007, 2009 The NetBSD Foundation, Inc.
@@ -93,9 +93,10 @@ struct ccd_ioctl {
int ccio_ileave; /* interleave (DEV_BSIZE blocks) */
int ccio_flags; /* see sc_flags below */
int ccio_unit; /* unit number: use varies */
- size_t ccio_size; /* (returned) size of ccd */
+ uint64_t ccio_size; /* (returned) size of ccd */
};
+
/*
* Component info table.
* Describes a single component of a concatenated disk.
@@ -103,7 +104,7 @@ struct ccd_ioctl {
struct ccdcinfo {
struct vnode *ci_vp; /* device's vnode */
dev_t ci_dev; /* XXX: device's dev_t */
- size_t ci_size; /* size */
+ uint64_t ci_size; /* size */
char *ci_path; /* path to component */
size_t ci_pathlen; /* length of component path */
};
@@ -159,7 +160,7 @@ struct ccdbuf;
*/
struct ccd_softc {
int sc_flags; /* flags */
- size_t sc_size; /* size of ccd */
+ uint64_t sc_size; /* size of ccd */
int sc_ileave; /* interleave */
u_int sc_nccdisks; /* number of components */
#define CCD_MAXNDISKS 65536
@@ -203,4 +204,20 @@ struct ccd_softc {
#define CCDIOCSET _IOWR('F', 16, struct ccd_ioctl) /* enable ccd */
#define CCDIOCCLR _IOW('F', 17, struct ccd_ioctl) /* disable ccd */
+#ifndef _LP64
+/*
+ * Old version with incorrect ccio_size
+ */
+struct ccd_ioctl_60 {
+ char **ccio_disks; /* pointer to component paths */
+ u_int ccio_ndisks; /* number of disks to concatenate */
+ int ccio_ileave; /* interleave (DEV_BSIZE blocks) */
+ int ccio_flags; /* see sc_flags below */
+ int ccio_unit; /* unit number: use varies */
+ size_t ccio_size; /* (returned) size of ccd */
+};
+
+#define CCDIOCSET_60 _IOWR('F', 16, struct ccd_ioctl_60) /* enable ccd */
+#define CCDIOCCLR_60 _IOW('F', 17, struct ccd_ioctl_60) /* disable ccd */
+#endif /* !LP64*/
#endif /* _DEV_CCDVAR_H_ */