geom_virstor: Remove wholly unnecessary g_metadata_store copy

Just code cleanup.  No functional change.

Sponsored by:	Dell EMC Isilon
This commit is contained in:
Conrad Meyer 2017-09-08 15:38:02 +00:00
parent 0bd816f211
commit 985f4b3eb5

View File

@ -140,62 +140,6 @@ virstor_main(struct gctl_req *req, unsigned flags)
*/
}
static void
pathgen(const char *name, char *path, size_t size)
{
if (strncmp(name, _PATH_DEV, sizeof(_PATH_DEV) - 1) != 0)
snprintf(path, size, "%s%s", _PATH_DEV, name);
else
strlcpy(path, name, size);
}
static int
my_g_metadata_store(const char *name, u_char *md, size_t size)
{
char path[MAXPATHLEN];
unsigned sectorsize;
off_t mediasize;
u_char *sector;
int error, fd;
pathgen(name, path, sizeof(path));
sector = NULL;
error = 0;
fd = open(path, O_RDWR);
if (fd == -1)
return (errno);
mediasize = g_get_mediasize(name);
if (mediasize == 0) {
error = errno;
goto out;
}
sectorsize = g_get_sectorsize(name);
if (sectorsize == 0) {
error = errno;
goto out;
}
assert(sectorsize >= size);
sector = malloc(sectorsize);
if (sector == NULL) {
error = ENOMEM;
goto out;
}
bcopy(md, sector, size);
bzero(sector + size, sectorsize - size);
if (pwrite(fd, sector, sectorsize, mediasize - sectorsize) !=
(ssize_t)sectorsize) {
error = errno;
goto out;
}
out:
if (sector != NULL)
free(sector);
close(fd);
return (error);
}
/*
* Labels a new geom Meaning: parses and checks the parameters, calculates &
* writes metadata to the relevant providers so when the next round of
@ -465,7 +409,7 @@ virstor_label(struct gctl_req *req)
err(1, "Cannot allocate sector of %zu bytes", ssize);
bzero(sect, ssize);
virstor_metadata_encode(&md, sect);
error = my_g_metadata_store(name, sect, ssize);
error = g_metadata_store(name, sect, ssize);
free(sect);
if (error != 0) {
if (verbose)