Warn the user if we are not going to use whole provider space.

Requested by:	Michael Handler <handler@grendel.net>
This commit is contained in:
Pawel Jakub Dawidek 2004-08-28 02:34:10 +00:00
parent f792f1d865
commit 08249e9e6e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=134420
2 changed files with 21 additions and 9 deletions

View File

@ -149,8 +149,8 @@ raid3_label(struct gctl_req *req)
char param[16];
int *hardcode, *nargs, *noautosync, *round_robin, *verify;
int error, i;
unsigned sectorsize;
off_t mediasize;
unsigned sectorsize, ssize;
off_t mediasize, msize;
nargs = gctl_get_paraml(req, "nargs", sizeof(*nargs));
if (nargs == NULL) {
@ -222,9 +222,6 @@ raid3_label(struct gctl_req *req)
mediasize = 0;
sectorsize = 0;
for (i = 1; i < *nargs; i++) {
unsigned ssize;
off_t msize;
snprintf(param, sizeof(param), "arg%u", i);
str = gctl_get_asciiparam(req, param);
@ -268,6 +265,13 @@ raid3_label(struct gctl_req *req)
snprintf(param, sizeof(param), "arg%u", i);
str = gctl_get_asciiparam(req, param);
msize = g_get_mediasize(str) - g_get_sectorsize(str);
if (mediasize < msize) {
fprintf(stderr,
"warning: %s: only %jd bytes from %jd bytes used.\n",
str, (intmax_t)mediasize, (intmax_t)msize);
}
md.md_no = i - 1;
if (!*hardcode)
bzero(md.md_provider, sizeof(md.md_provider));

View File

@ -338,6 +338,7 @@ g_raid3_ctl_insert(struct gctl_req *req, struct g_class *mp)
struct g_consumer *cp;
const char *name;
u_char *sector;
off_t compsize;
intmax_t *no;
int *hardcode, *nargs, error;
@ -390,16 +391,23 @@ g_raid3_ctl_insert(struct gctl_req *req, struct g_class *mp)
gctl_error(req, "Invalid provider.");
return;
}
if ((sc->sc_mediasize / (sc->sc_ndisks - 1)) > pp->mediasize) {
gctl_error(req, "Provider %s too small.", pp->name);
return;
}
if (((sc->sc_sectorsize / (sc->sc_ndisks - 1)) % pp->sectorsize) != 0) {
gctl_error(req,
"Cannot insert provider %s, because of its sector size.",
pp->name);
return;
}
compsize = sc->sc_mediasize / (sc->sc_ndisks - 1);
if (compsize > pp->mediasize - pp->sectorsize) {
gctl_error(req, "Provider %s too small.", pp->name);
return;
}
if (compsize < pp->mediasize - pp->sectorsize) {
gctl_error(req,
"warning: %s: only %jd bytes from %jd bytes used.",
pp->name, (intmax_t)compsize,
(intmax_t)(pp->mediasize - pp->sectorsize));
}
gp = g_new_geomf(mp, "raid3:insert");
gp->orphan = g_raid3_ctl_insert_orphan;
cp = g_new_consumer(gp);