From owner-svn-src-head@freebsd.org Mon Aug 7 21:12:34 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B534BDC8FDA; Mon, 7 Aug 2017 21:12:34 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7876C83126; Mon, 7 Aug 2017 21:12:34 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v77LCXof001438; Mon, 7 Aug 2017 21:12:33 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v77LCXcH001437; Mon, 7 Aug 2017 21:12:33 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201708072112.v77LCXcH001437@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Mon, 7 Aug 2017 21:12:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322197 - head/sys/geom/part X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sys/geom/part X-SVN-Commit-Revision: 322197 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Aug 2017 21:12:34 -0000 Author: imp Date: Mon Aug 7 21:12:33 2017 New Revision: 322197 URL: https://svnweb.freebsd.org/changeset/base/322197 Log: Add alias support to gpart. When we're creating new providers for each of the partitions, add aliases to the geom before we create the provider so when geom_dev tastes the provider, the aliases are in place so the proper /dev entries are created. So foo5p6 gets created as an alias for bar5p6 when foo is an alias for bar in the geom we're partitioning with g_part. This also copies aliases from the container geom (eg disk) to the label geom (the disk with GPT partitioning) so that aliases nest properly. Differential Revision: https://reviews.freebsd.org/D11873 Modified: head/sys/geom/part/g_part.c Modified: head/sys/geom/part/g_part.c ============================================================================== --- head/sys/geom/part/g_part.c Mon Aug 7 21:12:28 2017 (r322196) +++ head/sys/geom/part/g_part.c Mon Aug 7 21:12:33 2017 (r322197) @@ -429,6 +429,7 @@ g_part_new_provider(struct g_geom *gp, struct g_part_t struct g_consumer *cp; struct g_provider *pp; struct sbuf *sb; + struct g_geom_alias *gap; off_t offset; cp = LIST_FIRST(&gp->consumer); @@ -439,6 +440,19 @@ g_part_new_provider(struct g_geom *gp, struct g_part_t entry->gpe_offset = offset; if (entry->gpe_pp == NULL) { + /* + * Add aliases to the geom before we create the provider so that + * geom_dev can taste it with all the aliases in place so all + * the aliased dev_t instances get created for each partition + * (eg foo5p7 gets created for bar5p7 when foo is an alias of bar). + */ + LIST_FOREACH(gap, &table->gpt_gp->aliases, ga_next) { + sb = sbuf_new_auto(); + G_PART_FULLNAME(table, entry, sb, gap->ga_alias); + sbuf_finish(sb); + g_geom_add_alias(gp, sbuf_data(sb)); + sbuf_delete(sb); + } sb = sbuf_new_auto(); G_PART_FULLNAME(table, entry, sb, gp->name); sbuf_finish(sb); @@ -1901,6 +1915,7 @@ g_part_taste(struct g_class *mp, struct g_provider *pp struct g_part_entry *entry; struct g_part_table *table; struct root_hold_token *rht; + struct g_geom_alias *gap; int attr, depth; int error; @@ -1913,10 +1928,12 @@ g_part_taste(struct g_class *mp, struct g_provider *pp /* * Create a GEOM with consumer and hook it up to the provider. - * With that we become part of the topology. Optain read access + * With that we become part of the topology. Obtain read access * to the provider. */ gp = g_new_geomf(mp, "%s", pp->name); + LIST_FOREACH(gap, &pp->geom->aliases, ga_next) + g_geom_add_alias(gp, gap->ga_alias); cp = g_new_consumer(gp); cp->flags |= G_CF_DIRECT_SEND | G_CF_DIRECT_RECEIVE; error = g_attach(cp, pp);