aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorEugene Grosbein <eugen@FreeBSD.org>2018-10-27 16:14:42 +0000
committerEugene Grosbein <eugen@FreeBSD.org>2018-10-27 16:14:42 +0000
commit6d305ab0b289686aeab9774cae15ef1e2da5c7be (patch)
tree8495463a7d64559836d52c4c61404b80ee46dad9 /sys
parent37136b849f71d99bc28b5c04d21794b3291936f1 (diff)
downloadsrc-6d305ab0b289686aeab9774cae15ef1e2da5c7be.tar.gz
src-6d305ab0b289686aeab9774cae15ef1e2da5c7be.zip
Extend stripeoffset and stripesize of GEOMs from u_int to off_t
GEOM's stripeoffset overflows at 4 gigabyte margin (2^32) because of its u_int type. This leads to incorrect data in the output generated by "sysctl kern.geom.confxml" command, "graid list" etc. when GEOM array has volumes larger than 4G, for example. This change does not affect ABI but changes KBI. No MFC planned. Differential Revision: https://reviews.freebsd.org/D13426
Notes
Notes: svn path=/head/; revision=339815
Diffstat (limited to 'sys')
-rw-r--r--sys/geom/geom.h4
-rw-r--r--sys/geom/geom_disk.h7
-rw-r--r--sys/geom/geom_dump.c8
-rw-r--r--sys/geom/geom_redboot.c6
-rw-r--r--sys/geom/geom_subr.c4
-rw-r--r--sys/geom/nop/g_nop.c4
-rw-r--r--sys/geom/part/g_part.c6
-rw-r--r--sys/geom/raid/g_raid.c2
-rw-r--r--sys/geom/stripe/g_stripe.c23
-rw-r--r--sys/geom/stripe/g_stripe.h2
-rw-r--r--sys/geom/uzip/g_uzip.c6
11 files changed, 37 insertions, 35 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h
index 25282805e292..d7744b01daf4 100644
--- a/sys/geom/geom.h
+++ b/sys/geom/geom.h
@@ -215,8 +215,8 @@ struct g_provider {
TAILQ_ENTRY(g_provider) orphan;
off_t mediasize;
u_int sectorsize;
- u_int stripesize;
- u_int stripeoffset;
+ off_t stripesize;
+ off_t stripeoffset;
struct devstat *stat;
u_int nstart, nend;
u_int flags;
diff --git a/sys/geom/geom_disk.h b/sys/geom/geom_disk.h
index fc7cc9818b44..fe5831a061c7 100644
--- a/sys/geom/geom_disk.h
+++ b/sys/geom/geom_disk.h
@@ -109,8 +109,8 @@ struct disk {
u_int d_fwheads;
u_int d_maxsize;
off_t d_delmaxsize;
- u_int d_stripeoffset;
- u_int d_stripesize;
+ off_t d_stripeoffset;
+ off_t d_stripesize;
char d_ident[DISK_IDENT_SIZE];
char d_descr[DISK_IDENT_SIZE];
uint16_t d_hba_vendor;
@@ -151,7 +151,8 @@ void disk_add_alias(struct disk *disk, const char *);
#define DISK_VERSION_03 0x5856105c
#define DISK_VERSION_04 0x5856105d
#define DISK_VERSION_05 0x5856105e
-#define DISK_VERSION DISK_VERSION_05
+#define DISK_VERSION_06 0x5856105f
+#define DISK_VERSION DISK_VERSION_06
#endif /* _KERNEL */
#endif /* _GEOM_GEOM_DISK_H_ */
diff --git a/sys/geom/geom_dump.c b/sys/geom/geom_dump.c
index 7ecfadc6c010..0a4551c9fbfc 100644
--- a/sys/geom/geom_dump.c
+++ b/sys/geom/geom_dump.c
@@ -64,8 +64,8 @@ g_confdot_provider(struct sbuf *sb, struct g_provider *pp)
{
sbuf_printf(sb, "z%p [shape=hexagon,label=\"%s\\nr%dw%de%d\\nerr#%d\\n"
- "sector=%u\\nstripe=%u\"];\n", pp, pp->name, pp->acr, pp->acw,
- pp->ace, pp->error, pp->sectorsize, pp->stripesize);
+ "sector=%u\\nstripe=%ju\"];\n", pp, pp->name, pp->acr, pp->acw,
+ pp->ace, pp->error, pp->sectorsize, (uintmax_t)pp->stripesize);
}
static void
@@ -216,8 +216,8 @@ g_conf_provider(struct sbuf *sb, struct g_provider *pp)
sbuf_printf(sb, "\t <mediasize>%jd</mediasize>\n",
(intmax_t)pp->mediasize);
sbuf_printf(sb, "\t <sectorsize>%u</sectorsize>\n", pp->sectorsize);
- sbuf_printf(sb, "\t <stripesize>%u</stripesize>\n", pp->stripesize);
- sbuf_printf(sb, "\t <stripeoffset>%u</stripeoffset>\n", pp->stripeoffset);
+ sbuf_printf(sb, "\t <stripesize>%ju</stripesize>\n", (uintmax_t)pp->stripesize);
+ sbuf_printf(sb, "\t <stripeoffset>%ju</stripeoffset>\n", (uintmax_t)pp->stripeoffset);
if (pp->flags & G_PF_WITHER)
sbuf_printf(sb, "\t <wither/>\n");
else if (pp->geom->flags & G_GEOM_WITHER)
diff --git a/sys/geom/geom_redboot.c b/sys/geom/geom_redboot.c
index 029d105414f0..febee5bd8377 100644
--- a/sys/geom/geom_redboot.c
+++ b/sys/geom/geom_redboot.c
@@ -246,7 +246,7 @@ g_redboot_taste(struct g_class *mp, struct g_provider *pp, int insist)
int error, sectorsize, i;
struct fis_image_desc *fd, *head;
uint32_t offmask;
- u_int blksize; /* NB: flash block size stored as stripesize */
+ off_t blksize; /* NB: flash block size stored as stripesize */
u_char *buf;
off_t offset;
const char *value;
@@ -283,9 +283,9 @@ g_redboot_taste(struct g_class *mp, struct g_provider *pp, int insist)
else
offmask = 0xffffffff; /* XXX */
if (bootverbose)
- printf("%s: mediasize %ld secsize %d blksize %d offmask 0x%x\n",
+ printf("%s: mediasize %ld secsize %d blksize %ju offmask 0x%x\n",
__func__, (long) cp->provider->mediasize, sectorsize,
- blksize, offmask);
+ (uintmax_t)blksize, offmask);
if (sectorsize < sizeof(struct fis_image_desc) ||
(sectorsize % sizeof(struct fis_image_desc)))
return (NULL);
diff --git a/sys/geom/geom_subr.c b/sys/geom/geom_subr.c
index 91369cc93177..f703e3473ab3 100644
--- a/sys/geom/geom_subr.c
+++ b/sys/geom/geom_subr.c
@@ -1409,8 +1409,8 @@ db_show_geom_provider(int indent, struct g_provider *pp)
gprintln(" geom: %s (%p)", pp->geom->name, pp->geom);
gprintln(" mediasize: %jd", (intmax_t)pp->mediasize);
gprintln(" sectorsize: %u", pp->sectorsize);
- gprintln(" stripesize: %u", pp->stripesize);
- gprintln(" stripeoffset: %u", pp->stripeoffset);
+ gprintln(" stripesize: %ju", (uintmax_t)pp->stripesize);
+ gprintln(" stripeoffset: %ju", (uintmax_t)pp->stripeoffset);
gprintln(" access: r%dw%de%d", pp->acr, pp->acw,
pp->ace);
gprintln(" flags: %s (0x%04x)",
diff --git a/sys/geom/nop/g_nop.c b/sys/geom/nop/g_nop.c
index 23a06cda34fd..4e8ab8f771fd 100644
--- a/sys/geom/nop/g_nop.c
+++ b/sys/geom/nop/g_nop.c
@@ -187,7 +187,7 @@ g_nop_access(struct g_provider *pp, int dr, int dw, int de)
static int
g_nop_create(struct gctl_req *req, struct g_class *mp, struct g_provider *pp,
int ioerror, u_int rfailprob, u_int wfailprob, off_t offset, off_t size,
- u_int secsize, u_int stripesize, u_int stripeoffset, const char *physpath)
+ u_int secsize, off_t stripesize, off_t stripeoffset, const char *physpath)
{
struct g_nop_softc *sc;
struct g_geom *gp;
@@ -464,7 +464,7 @@ g_nop_ctl_create(struct gctl_req *req, struct g_class *mp)
*rfailprob == -1 ? 0 : (u_int)*rfailprob,
*wfailprob == -1 ? 0 : (u_int)*wfailprob,
(off_t)*offset, (off_t)*size, (u_int)*secsize,
- (u_int)*stripesize, (u_int)*stripeoffset,
+ (off_t)*stripesize, (off_t)*stripeoffset,
physpath) != 0) {
return;
}
diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c
index 41523c6830e8..0148f4ebb740 100644
--- a/sys/geom/part/g_part.c
+++ b/sys/geom/part/g_part.c
@@ -367,9 +367,9 @@ g_part_check_integrity(struct g_part_table *table, struct g_consumer *cp)
offset = e1->gpe_offset;
if ((offset + pp->stripeoffset) % pp->stripesize) {
DPRINTF("partition %d on (%s, %s) is not "
- "aligned on %u bytes\n", e1->gpe_index,
+ "aligned on %ju bytes\n", e1->gpe_index,
pp->name, table->gpt_scheme->name,
- pp->stripesize);
+ (uintmax_t)pp->stripesize);
/* Don't treat this as a critical failure */
}
}
@@ -820,7 +820,7 @@ g_part_ctl_add(struct gctl_req *req, struct g_part_parms *gpp)
G_PART_FULLNAME(table, entry, sb, gp->name);
if (pp->stripesize > 0 && entry->gpe_pp->stripeoffset != 0)
sbuf_printf(sb, " added, but partition is not "
- "aligned on %u bytes\n", pp->stripesize);
+ "aligned on %ju bytes\n", (uintmax_t)pp->stripesize);
else
sbuf_cat(sb, " added\n");
sbuf_finish(sb);
diff --git a/sys/geom/raid/g_raid.c b/sys/geom/raid/g_raid.c
index 46748bba15cf..77b6bbf3ef17 100644
--- a/sys/geom/raid/g_raid.c
+++ b/sys/geom/raid/g_raid.c
@@ -2423,7 +2423,7 @@ g_raid_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
sbuf_printf(sb, "r%d(%s):%d@%ju",
sd->sd_volume->v_global_id,
sd->sd_volume->v_name,
- sd->sd_pos, sd->sd_offset);
+ sd->sd_pos, (uintmax_t)sd->sd_offset);
if (TAILQ_NEXT(sd, sd_next))
sbuf_printf(sb, ", ");
}
diff --git a/sys/geom/stripe/g_stripe.c b/sys/geom/stripe/g_stripe.c
index 0ac90dd61529..8dc32ee2c9f1 100644
--- a/sys/geom/stripe/g_stripe.c
+++ b/sys/geom/stripe/g_stripe.c
@@ -249,7 +249,7 @@ static void
g_stripe_copy(struct g_stripe_softc *sc, char *src, char *dst, off_t offset,
off_t length, int mode)
{
- u_int stripesize;
+ off_t stripesize;
size_t len;
stripesize = sc->sc_stripesize;
@@ -265,8 +265,8 @@ g_stripe_copy(struct g_stripe_softc *sc, char *src, char *dst, off_t offset,
}
length -= len;
KASSERT(length >= 0,
- ("Length < 0 (stripesize=%zu, offset=%jd, length=%jd).",
- (size_t)stripesize, (intmax_t)offset, (intmax_t)length));
+ ("Length < 0 (stripesize=%ju, offset=%ju, length=%jd).",
+ (uintmax_t)stripesize, (uintmax_t)offset, (intmax_t)length));
if (length > stripesize)
len = stripesize;
else
@@ -307,10 +307,11 @@ static int
g_stripe_start_fast(struct bio *bp, u_int no, off_t offset, off_t length)
{
TAILQ_HEAD(, bio) queue = TAILQ_HEAD_INITIALIZER(queue);
- u_int nparts = 0, stripesize;
struct g_stripe_softc *sc;
char *addr, *data = NULL;
struct bio *cbp;
+ off_t stripesize;
+ u_int nparts = 0;
int error;
sc = bp->bio_to->geom->softc;
@@ -436,7 +437,7 @@ g_stripe_start_economic(struct bio *bp, u_int no, off_t offset, off_t length)
{
TAILQ_HEAD(, bio) queue = TAILQ_HEAD_INITIALIZER(queue);
struct g_stripe_softc *sc;
- uint32_t stripesize;
+ off_t stripesize;
struct bio *cbp;
char *addr;
int error;
@@ -571,9 +572,9 @@ g_stripe_flush(struct g_stripe_softc *sc, struct bio *bp)
static void
g_stripe_start(struct bio *bp)
{
- off_t offset, start, length, nstripe;
+ off_t offset, start, length, nstripe, stripesize;
struct g_stripe_softc *sc;
- u_int no, stripesize;
+ u_int no;
int error, fast = 0;
sc = bp->bio_to->geom->softc;
@@ -1044,7 +1045,7 @@ g_stripe_ctl_create(struct gctl_req *req, struct g_class *mp)
struct g_stripe_softc *sc;
struct g_geom *gp;
struct sbuf *sb;
- intmax_t *stripesize;
+ off_t *stripesize;
const char *name;
char param[16];
int *nargs;
@@ -1076,7 +1077,7 @@ g_stripe_ctl_create(struct gctl_req *req, struct g_class *mp)
gctl_error(req, "No '%s' argument.", "stripesize");
return;
}
- md.md_stripesize = *stripesize;
+ md.md_stripesize = (uint32_t)*stripesize;
bzero(md.md_provider, sizeof(md.md_provider));
/* This field is not important here. */
md.md_provsize = 0;
@@ -1243,8 +1244,8 @@ g_stripe_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp,
(u_int)cp->index);
} else {
sbuf_printf(sb, "%s<ID>%u</ID>\n", indent, (u_int)sc->sc_id);
- sbuf_printf(sb, "%s<Stripesize>%u</Stripesize>\n", indent,
- (u_int)sc->sc_stripesize);
+ sbuf_printf(sb, "%s<Stripesize>%ju</Stripesize>\n", indent,
+ (uintmax_t)sc->sc_stripesize);
sbuf_printf(sb, "%s<Type>", indent);
switch (sc->sc_type) {
case G_STRIPE_TYPE_AUTOMATIC:
diff --git a/sys/geom/stripe/g_stripe.h b/sys/geom/stripe/g_stripe.h
index 21b6ea666a42..beef7fe24116 100644
--- a/sys/geom/stripe/g_stripe.h
+++ b/sys/geom/stripe/g_stripe.h
@@ -76,7 +76,7 @@ struct g_stripe_softc {
uint32_t sc_id; /* stripe unique ID */
struct g_consumer **sc_disks;
uint16_t sc_ndisks;
- uint32_t sc_stripesize;
+ off_t sc_stripesize;
uint32_t sc_stripebits;
struct mtx sc_lock;
};
diff --git a/sys/geom/uzip/g_uzip.c b/sys/geom/uzip/g_uzip.c
index ab38d18bd3f2..6c29e946d0a8 100644
--- a/sys/geom/uzip/g_uzip.c
+++ b/sys/geom/uzip/g_uzip.c
@@ -849,9 +849,9 @@ g_uzip_taste(struct g_class *mp, struct g_provider *pp, int flags)
g_error_provider(pp2, 0);
g_access(cp, -1, 0, 0);
- DPRINTF(GUZ_DBG_INFO, ("%s: taste ok (%d, %jd), (%d, %d), %x\n",
- gp->name, pp2->sectorsize, (intmax_t)pp2->mediasize,
- pp2->stripeoffset, pp2->stripesize, pp2->flags));
+ DPRINTF(GUZ_DBG_INFO, ("%s: taste ok (%d, %ju), (%ju, %ju), %x\n",
+ gp->name, pp2->sectorsize, (uintmax_t)pp2->mediasize,
+ (uintmax_t)pp2->stripeoffset, (uintmax_t)pp2->stripesize, pp2->flags));
DPRINTF(GUZ_DBG_INFO, ("%s: %u x %u blocks\n", gp->name, sc->nblocks,
sc->blksz));
return (gp);