diff --git a/sys/dev/dkwedge/dk.c b/sys/dev/dkwedge/dk.c index 06881ef21efb..30908654b143 100644 --- a/sys/dev/dkwedge/dk.c +++ b/sys/dev/dkwedge/dk.c @@ -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 -__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! */ diff --git a/sys/dev/dm/device-mapper.c b/sys/dev/dm/device-mapper.c index 8ac1a1254277..046ebc4636f9 100644 --- a/sys/dev/dm/device-mapper.c +++ b/sys/dev/dm/device-mapper.c @@ -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_table_head_t *head) dg->dg_ntracks = 64; disk_set_info(NULL, disk, "ESDI"); - - disk_blocksize(disk, secsize); } diff --git a/sys/dev/raidframe/rf_netbsdkintf.c b/sys/dev/raidframe/rf_netbsdkintf.c index 2c30e2cb81f9..6a40097a1d60 100644 --- a/sys/dev/raidframe/rf_netbsdkintf.c +++ b/sys/dev/raidframe/rf_netbsdkintf.c @@ -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 -__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 diff --git a/sys/dev/scsipi/sd.c b/sys/dev/scsipi/sd.c index aeda3d7641d1..658969cd398f 100644 --- a/sys/dev/scsipi/sd.c +++ b/sys/dev/scsipi/sd.c @@ -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 -__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 disk_parms *dp, int flags) 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 disk_parms *dp, int flags) if (error) return (error); - disk_blocksize(&sd->sc_dk, dp->blksize); - if (sd->type == T_OPTICAL) goto page0; diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c index c7cd4db242f2..f581901a6694 100644 --- a/sys/dev/vnd.c +++ b/sys/dev/vnd.c @@ -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 -__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 *data, int flag, struct lwp *l) /* 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, diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 50bedb857e73..74c8a3024deb 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -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 -__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 #include @@ -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 *name, const struct dkdriver *driver) 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 blocksize) 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 *dk, const char *type) 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();