Module Name:    src
Committed By:   mlelstv
Date:           Wed Dec 31 08:24:51 UTC 2014

Modified Files:
        src/sys/dev: vnd.c
        src/sys/dev/dkwedge: dk.c
        src/sys/dev/dm: device-mapper.c
        src/sys/dev/raidframe: rf_netbsdkintf.c
        src/sys/dev/scsipi: sd.c
        src/sys/kern: subr_disk.c

Log Message:
disk_blocksize and disk_set_info relay the same information
to the disk subsystem.

Make disk_set_info also set blocksize shift values.
Remove every call to disk_blocksize.

Keep disk_blocksize for ABI compatibility, make it also set dg_secsize.


To generate a diff of this commit:
cvs rdiff -u -r1.235 -r1.236 src/sys/dev/vnd.c
cvs rdiff -u -r1.76 -r1.77 src/sys/dev/dkwedge/dk.c
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/dm/device-mapper.c
cvs rdiff -u -r1.317 -r1.318 src/sys/dev/raidframe/rf_netbsdkintf.c
cvs rdiff -u -r1.310 -r1.311 src/sys/dev/scsipi/sd.c
cvs rdiff -u -r1.105 -r1.106 src/sys/kern/subr_disk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/vnd.c
diff -u src/sys/dev/vnd.c:1.235 src/sys/dev/vnd.c:1.236
--- src/sys/dev/vnd.c:1.235	Mon Dec 29 13:13:20 2014
+++ src/sys/dev/vnd.c	Wed Dec 31 08:24:50 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnd.c,v 1.235 2014/12/29 13:13:20 mlelstv Exp $	*/
+/*	$NetBSD: vnd.c,v 1.236 2014/12/31 08:24:50 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.235 2014/12/29 13:13:20 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vnd.c,v 1.236 2014/12/31 08:24:50 mlelstv Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_vnd.h"
@@ -1350,7 +1350,6 @@ vndioctl(dev_t dev, u_long cmd, void *da
 
 		/* Attach the disk. */
 		disk_attach(&vnd->sc_dkdev);
-		disk_blocksize(&vnd->sc_dkdev, vnd->sc_geom.vng_secsize);
 
 		/* Initialize the xfer and buffer pools. */
 		pool_init(&vnd->sc_vxpool, sizeof(struct vndxfer), 0,

Index: src/sys/dev/dkwedge/dk.c
diff -u src/sys/dev/dkwedge/dk.c:1.76 src/sys/dev/dkwedge/dk.c:1.77
--- src/sys/dev/dkwedge/dk.c:1.76	Mon Dec  8 17:45:12 2014
+++ src/sys/dev/dkwedge/dk.c	Wed Dec 31 08:24:50 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: dk.c,v 1.76 2014/12/08 17:45:12 mlelstv Exp $	*/
+/*	$NetBSD: dk.c,v 1.77 2014/12/31 08:24:50 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.76 2014/12/08 17:45:12 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.77 2014/12/31 08:24:50 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_dkwedge.h"
@@ -258,22 +258,22 @@ dkwedge_array_expand(void)
 }
 
 static void
-dk_set_geometry(struct dkwedge_softc *sc)
+dk_set_geometry(struct dkwedge_softc *sc, struct disk *pdk)
 {
-	struct disk *disk = &sc->sc_dk;
-	struct disk_geom *dg = &disk->dk_geom;
+	struct disk *dk = &sc->sc_dk;
+	struct disk_geom *dg = &dk->dk_geom;
 
 	memset(dg, 0, sizeof(*dg));
 
-	dg->dg_secperunit = sc->sc_size >> disk->dk_blkshift;
-	dg->dg_secsize = DEV_BSIZE << disk->dk_blkshift;
+	dg->dg_secperunit = sc->sc_size >> pdk->dk_blkshift;
+	dg->dg_secsize = DEV_BSIZE << pdk->dk_blkshift;
 
 	/* fake numbers, 1 cylinder is 1 MB with default sector size */
 	dg->dg_nsectors = 32;
 	dg->dg_ntracks = 64;
 	dg->dg_ncylinders = dg->dg_secperunit / (dg->dg_nsectors * dg->dg_ntracks);
 
-	disk_set_info(sc->sc_dev, disk, NULL);
+	disk_set_info(sc->sc_dev, dk, NULL);
 }
 
 /*
@@ -455,8 +455,7 @@ dkwedge_add(struct dkwedge_info *dkw)
 	 */
 
 	disk_init(&sc->sc_dk, device_xname(sc->sc_dev), NULL);
-	disk_blocksize(&sc->sc_dk, DEV_BSIZE << pdk->dk_blkshift);
-	dk_set_geometry(sc);
+	dk_set_geometry(sc, pdk);
 	disk_attach(&sc->sc_dk);
 
 	/* Disk wedge is ready for use! */

Index: src/sys/dev/dm/device-mapper.c
diff -u src/sys/dev/dm/device-mapper.c:1.35 src/sys/dev/dm/device-mapper.c:1.36
--- src/sys/dev/dm/device-mapper.c:1.35	Thu Oct  2 21:01:38 2014
+++ src/sys/dev/dm/device-mapper.c	Wed Dec 31 08:24:50 2014
@@ -1,4 +1,4 @@
-/*        $NetBSD: device-mapper.c,v 1.35 2014/10/02 21:01:38 justin Exp $ */
+/*        $NetBSD: device-mapper.c,v 1.36 2014/12/31 08:24:50 mlelstv Exp $ */
 
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -686,6 +686,4 @@ dmgetproperties(struct disk *disk, dm_ta
 	dg->dg_ntracks = 64;
 
 	disk_set_info(NULL, disk, "ESDI");
-
-	disk_blocksize(disk, secsize);
 }

Index: src/sys/dev/raidframe/rf_netbsdkintf.c
diff -u src/sys/dev/raidframe/rf_netbsdkintf.c:1.317 src/sys/dev/raidframe/rf_netbsdkintf.c:1.318
--- src/sys/dev/raidframe/rf_netbsdkintf.c:1.317	Sun Dec 21 17:04:12 2014
+++ src/sys/dev/raidframe/rf_netbsdkintf.c	Wed Dec 31 08:24:50 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_netbsdkintf.c,v 1.317 2014/12/21 17:04:12 taca Exp $	*/
+/*	$NetBSD: rf_netbsdkintf.c,v 1.318 2014/12/31 08:24:50 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2008-2011 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  ***********************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.317 2014/12/21 17:04:12 taca Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_netbsdkintf.c,v 1.318 2014/12/31 08:24:50 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -2019,17 +2019,16 @@ raidinit(struct raid_softc *rs)
 
 	disk_init(&rs->sc_dkdev, rs->sc_xname, &rf_dkdriver);
 	disk_attach(&rs->sc_dkdev);
-	disk_blocksize(&rs->sc_dkdev, raidPtr->bytesPerSector);
 
 	/* XXX There may be a weird interaction here between this, and
 	 * protectedSectors, as used in RAIDframe.  */
 
 	rs->sc_size = raidPtr->totalSectors;
 
-	dkwedge_discover(&rs->sc_dkdev);
-
 	rf_set_geometry(rs, raidPtr);
 
+	dkwedge_discover(&rs->sc_dkdev);
+
 }
 #if (RF_INCLUDE_PARITY_DECLUSTERING_DS > 0)
 /* wake up the daemon & tell it to get us a spare table

Index: src/sys/dev/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.310 src/sys/dev/scsipi/sd.c:1.311
--- src/sys/dev/scsipi/sd.c:1.310	Tue Nov  4 07:51:55 2014
+++ src/sys/dev/scsipi/sd.c	Wed Dec 31 08:24:50 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.310 2014/11/04 07:51:55 mlelstv Exp $	*/
+/*	$NetBSD: sd.c,v 1.311 2014/12/31 08:24:50 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.310 2014/11/04 07:51:55 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.311 2014/12/31 08:24:50 mlelstv Exp $");
 
 #include "opt_scsi.h"
 
@@ -2145,7 +2145,7 @@ sd_get_parms(struct sd_softc *sd, struct
 	if (sd->type == T_SIMPLE_DIRECT) {
 		error = sd_get_simplifiedparms(sd, dp, flags);
 		if (!error)
-			disk_blocksize(&sd->sc_dk, dp->blksize);
+			goto setprops;
 		return (error);
 	}
 
@@ -2153,8 +2153,6 @@ sd_get_parms(struct sd_softc *sd, struct
 	if (error)
 		return (error);
 
-	disk_blocksize(&sd->sc_dk, dp->blksize);
-
 	if (sd->type == T_OPTICAL)
 		goto page0;
 

Index: src/sys/kern/subr_disk.c
diff -u src/sys/kern/subr_disk.c:1.105 src/sys/kern/subr_disk.c:1.106
--- src/sys/kern/subr_disk.c:1.105	Mon Dec 29 18:54:19 2014
+++ src/sys/kern/subr_disk.c	Wed Dec 31 08:24:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_disk.c,v 1.105 2014/12/29 18:54:19 mlelstv Exp $	*/
+/*	$NetBSD: subr_disk.c,v 1.106 2014/12/31 08:24:51 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.105 2014/12/29 18:54:19 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.106 2014/12/31 08:24:51 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -181,6 +181,7 @@ disk_find(const char *name)
 void
 disk_init(struct disk *diskp, const char *name, const struct dkdriver *driver)
 {
+	u_int blocksize = DEV_BSIZE;
 
 	/*
 	 * Initialize the wedge-related locks and other fields.
@@ -190,7 +191,8 @@ disk_init(struct disk *diskp, const char
 	LIST_INIT(&diskp->dk_wedges);
 	diskp->dk_nwedges = 0;
 	diskp->dk_labelsector = LABELSECTOR;
-	disk_blocksize(diskp, DEV_BSIZE);
+	diskp->dk_blkshift = DK_BSIZE2BLKSHIFT(blocksize);
+	diskp->dk_byteshift = DK_BSIZE2BYTESHIFT(blocksize);
 	diskp->dk_name = name;
 	diskp->dk_driver = driver;
 }
@@ -311,6 +313,7 @@ disk_blocksize(struct disk *diskp, int b
 
 	diskp->dk_blkshift = DK_BSIZE2BLKSHIFT(blocksize);
 	diskp->dk_byteshift = DK_BSIZE2BYTESHIFT(blocksize);
+	diskp->dk_geom.dg_secsize = DEV_BSIZE << diskp->dk_blkshift;
 }
 
 /*
@@ -555,6 +558,9 @@ disk_set_info(device_t dev, struct disk 
 		dg->dg_secsize = DEV_BSIZE;
 	}
 
+	dk->dk_blkshift = DK_BSIZE2BLKSHIFT(dg->dg_secsize);
+	dk->dk_byteshift = DK_BSIZE2BYTESHIFT(dg->dg_secsize);
+
 	prop_dictionary_t disk_info, odisk_info, geom;
 
 	disk_info = prop_dictionary_create();

Reply via email to