Date: Wed, 17 May 2017 05:21:03 +0000 (UTC) From: Marcelo Araujo <araujo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r318394 - in stable/11: sbin/geom/class/label sys/geom/part Message-ID: <201705170521.v4H5L34Y039031@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: araujo Date: Wed May 17 05:21:03 2017 New Revision: 318394 URL: https://svnweb.freebsd.org/changeset/base/318394 Log: MFC r315112, r315196 r315112: Add the capability to refresh the gpart(8) label without need a reboot. gpart(8) has functionality to change the label of an GPT partition. This functionality works like it should, however, after a label change the /dev/gpt/ entries remain unchanged. glabel(8) status output remains unchanged. The change only takes effect after a reboot. PR: 162690 Submitted by: sub.mesa@gmail, Ben RUBSON <ben.rubson@gmail.com>, ae Reviewed by: allanjude, bapt, bcr Differential Revision: https://reviews.freebsd.org/D9935 r315196: After r315112 I broke the tests with eli, instead to pass 0, I should pass M_NOWAIT to g_media_changed() that will call g_post_event() with this flag. Reported by: lwhsu, ngie and ae Modified: stable/11/sbin/geom/class/label/geom_label.c stable/11/sbin/geom/class/label/glabel.8 stable/11/sys/geom/part/g_part.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sbin/geom/class/label/geom_label.c ============================================================================== --- stable/11/sbin/geom/class/label/geom_label.c Wed May 17 02:40:06 2017 (r318393) +++ stable/11/sbin/geom/class/label/geom_label.c Wed May 17 05:21:03 2017 (r318394) @@ -53,6 +53,7 @@ static void label_main(struct gctl_req * static void label_clear(struct gctl_req *req); static void label_dump(struct gctl_req *req); static void label_label(struct gctl_req *req); +static void label_refresh(struct gctl_req *req); struct g_command PUBSYM(class_commands)[] = { { "clear", G_FLAG_VERBOSE, label_main, G_NULL_OPTS, @@ -74,6 +75,9 @@ struct g_command PUBSYM(class_commands)[ { "label", G_FLAG_VERBOSE | G_FLAG_LOADKLD, label_main, G_NULL_OPTS, "[-v] name dev" }, + { "refresh", 0, label_main, G_NULL_OPTS, + "dev ..." + }, { "stop", G_FLAG_VERBOSE, NULL, { { 'f', "force", NULL, G_TYPE_BOOL }, @@ -105,6 +109,8 @@ label_main(struct gctl_req *req, unsigne label_clear(req); else if (strcmp(name, "dump") == 0) label_dump(req); + else if (strcmp(name, "refresh") == 0) + label_refresh(req); else gctl_error(req, "Unknown command: %s.", name); } @@ -223,3 +229,28 @@ label_dump(struct gctl_req *req) printf("\n"); } } + +static void +label_refresh(struct gctl_req *req) +{ + const char *name; + int i, nargs, fd; + + nargs = gctl_get_int(req, "nargs"); + if (nargs < 1) { + gctl_error(req, "Too few arguments."); + return; + } + + for (i = 0; i < nargs; i++) { + name = gctl_get_ascii(req, "arg%d", i); + fd = g_open(name, 1); + if (fd == -1) { + printf("Can't refresh metadata from %s: %s.\n", + name, strerror(errno)); + } else { + printf("Metadata from %s refreshed.\n", name); + (void)g_close(fd); + } + } +} Modified: stable/11/sbin/geom/class/label/glabel.8 ============================================================================== --- stable/11/sbin/geom/class/label/glabel.8 Wed May 17 02:40:06 2017 (r318393) +++ stable/11/sbin/geom/class/label/glabel.8 Wed May 17 05:21:03 2017 (r318394) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 22, 2013 +.Dd March 12, 2017 .Dt GLABEL 8 .Os .Sh NAME @@ -57,6 +57,9 @@ .Cm dump .Ar dev ... .Nm +.Cm refresh +.Ar dev ... +.Nm .Cm list .Nm .Cm status @@ -186,6 +189,8 @@ Same as Clear metadata on the given devices. .It Cm dump Dump metadata stored on the given devices. +.It Cm refresh +Refresh / rediscover metadata from the given devices. .It Cm list See .Xr geom 8 . Modified: stable/11/sys/geom/part/g_part.c ============================================================================== --- stable/11/sys/geom/part/g_part.c Wed May 17 02:40:06 2017 (r318393) +++ stable/11/sys/geom/part/g_part.c Wed May 17 05:21:03 2017 (r318394) @@ -884,6 +884,10 @@ g_part_ctl_commit(struct gctl_req *req, LIST_FOREACH_SAFE(entry, &table->gpt_entry, gpe_entry, tmp) { if (!entry->gpe_deleted) { + /* Notify consumers that provider might be changed. */ + if (entry->gpe_modified && ( + entry->gpe_pp->acw + entry->gpe_pp->ace) == 0) + g_media_changed(entry->gpe_pp, M_NOWAIT); entry->gpe_created = 0; entry->gpe_modified = 0; continue;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201705170521.v4H5L34Y039031>