From 79e6fcac8313f173531b83f17d169f847343d8a2 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Tue, 25 Oct 2011 07:44:10 +0000 Subject: [PATCH] Simplify eli_resize() function. MFC after: 3 days --- sbin/geom/class/eli/geom_eli.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/sbin/geom/class/eli/geom_eli.c b/sbin/geom/class/eli/geom_eli.c index 11c8ce0827f8..ca0c80be8bde 100644 --- a/sbin/geom/class/eli/geom_eli.c +++ b/sbin/geom/class/eli/geom_eli.c @@ -1480,18 +1480,12 @@ eli_resize(struct gctl_req *req) * it back to the correct place on the provider. */ md.md_provsize = mediasize; - eli_metadata_encode(&md, sector); - if (pwrite(provfd, sector, secsize, mediasize - secsize) != secsize) { - gctl_error(req, "Cannot write metadata: %s.", strerror(errno)); - goto out; - } - (void)g_flush(provfd); - + /* Write metadata to the provider. */ + (void)eli_metadata_store(req, prov, &md); /* Now trash the old metadata. */ - if (eli_trash_metadata(req, prov, provfd, oldsize - secsize) == -1) - goto out; + (void)eli_trash_metadata(req, prov, provfd, oldsize - secsize); out: - if (provfd >= 0) + if (provfd != -1) (void)g_close(provfd); if (sector != NULL) { bzero(sector, secsize);