From owner-svn-src-stable-8@FreeBSD.ORG Fri Jun 10 09:12:10 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6CDFD1065670; Fri, 10 Jun 2011 09:12:10 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5AE468FC13; Fri, 10 Jun 2011 09:12:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p5A9CAFE018431; Fri, 10 Jun 2011 09:12:10 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p5A9CAkd018421; Fri, 10 Jun 2011 09:12:10 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201106100912.p5A9CAkd018421@svn.freebsd.org> From: Alexander Motin Date: Fri, 10 Jun 2011 09:12:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r222920 - in stable/8/sys/geom: . concat journal mirror raid3 shsec stripe virstor X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jun 2011 09:12:10 -0000 Author: mav Date: Fri Jun 10 09:12:09 2011 New Revision: 222920 URL: http://svn.freebsd.org/changeset/base/222920 Log: MFC r221101: Implement relaxed comparision for hardcoded provider names to make it ignore adX/adaY difference in both directions to simplify migration to the CAM-based ATA or back. Modified: stable/8/sys/geom/concat/g_concat.c stable/8/sys/geom/geom.h stable/8/sys/geom/geom_subr.c stable/8/sys/geom/journal/g_journal.c stable/8/sys/geom/mirror/g_mirror.c stable/8/sys/geom/raid3/g_raid3.c stable/8/sys/geom/shsec/g_shsec.c stable/8/sys/geom/stripe/g_stripe.c stable/8/sys/geom/virstor/g_virstor.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/geom/concat/g_concat.c ============================================================================== --- stable/8/sys/geom/concat/g_concat.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/concat/g_concat.c Fri Jun 10 09:12:09 2011 (r222920) @@ -675,7 +675,8 @@ g_concat_taste(struct g_class *mp, struc if (md.md_version < 4) md.md_provsize = pp->mediasize; - if (md.md_provider[0] != '\0' && strcmp(md.md_provider, pp->name) != 0) + if (md.md_provider[0] != '\0' && + !g_compare_names(md.md_provider, pp->name)) return (NULL); if (md.md_provsize != pp->mediasize) return (NULL); Modified: stable/8/sys/geom/geom.h ============================================================================== --- stable/8/sys/geom/geom.h Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/geom.h Fri Jun 10 09:12:09 2011 (r222920) @@ -231,6 +231,7 @@ void g_waitidlelock(void); /* geom_subr.c */ int g_access(struct g_consumer *cp, int nread, int nwrite, int nexcl); int g_attach(struct g_consumer *cp, struct g_provider *pp); +int g_compare_names(const char *namea, const char *nameb); void g_destroy_consumer(struct g_consumer *cp); void g_destroy_geom(struct g_geom *pp); void g_destroy_provider(struct g_provider *pp); Modified: stable/8/sys/geom/geom_subr.c ============================================================================== --- stable/8/sys/geom/geom_subr.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/geom_subr.c Fri Jun 10 09:12:09 2011 (r222920) @@ -1016,6 +1016,43 @@ g_getattr__(const char *attr, struct g_c return (0); } +static int +g_get_device_prefix_len(const char *name) +{ + int len; + + if (strncmp(name, "ada", 3) == 0) + len = 3; + else if (strncmp(name, "ad", 2) == 0) + len = 2; + else + return (0); + if (name[len] < '0' || name[len] > '9') + return (0); + do { + len++; + } while (name[len] >= '0' && name[len] <= '9'); + return (len); +} + +int +g_compare_names(const char *namea, const char *nameb) +{ + int deva, devb; + + if (strcmp(namea, nameb) == 0) + return (1); + deva = g_get_device_prefix_len(namea); + if (deva == 0) + return (0); + devb = g_get_device_prefix_len(nameb); + if (devb == 0) + return (0); + if (strcmp(namea + deva, nameb + devb) == 0) + return (1); + return (0); +} + #if defined(DIAGNOSTIC) || defined(DDB) /* * This function walks the mesh and returns a non-zero integer if it Modified: stable/8/sys/geom/journal/g_journal.c ============================================================================== --- stable/8/sys/geom/journal/g_journal.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/journal/g_journal.c Fri Jun 10 09:12:09 2011 (r222920) @@ -2526,7 +2526,8 @@ g_journal_taste(struct g_class *mp, stru return (NULL); gp = NULL; - if (md.md_provider[0] != '\0' && strcmp(md.md_provider, pp->name) != 0) + if (md.md_provider[0] != '\0' && + !g_compare_names(md.md_provider, pp->name)) return (NULL); if (md.md_provsize != 0 && md.md_provsize != pp->mediasize) return (NULL); Modified: stable/8/sys/geom/mirror/g_mirror.c ============================================================================== --- stable/8/sys/geom/mirror/g_mirror.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/mirror/g_mirror.c Fri Jun 10 09:12:09 2011 (r222920) @@ -3006,7 +3006,8 @@ g_mirror_taste(struct g_class *mp, struc return (NULL); gp = NULL; - if (md.md_provider[0] != '\0' && strcmp(md.md_provider, pp->name) != 0) + if (md.md_provider[0] != '\0' && + !g_compare_names(md.md_provider, pp->name)) return (NULL); if (md.md_provsize != 0 && md.md_provsize != pp->mediasize) return (NULL); Modified: stable/8/sys/geom/raid3/g_raid3.c ============================================================================== --- stable/8/sys/geom/raid3/g_raid3.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/raid3/g_raid3.c Fri Jun 10 09:12:09 2011 (r222920) @@ -3328,7 +3328,8 @@ g_raid3_taste(struct g_class *mp, struct return (NULL); gp = NULL; - if (md.md_provider[0] != '\0' && strcmp(md.md_provider, pp->name) != 0) + if (md.md_provider[0] != '\0' && + !g_compare_names(md.md_provider, pp->name)) return (NULL); if (md.md_provsize != 0 && md.md_provsize != pp->mediasize) return (NULL); Modified: stable/8/sys/geom/shsec/g_shsec.c ============================================================================== --- stable/8/sys/geom/shsec/g_shsec.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/shsec/g_shsec.c Fri Jun 10 09:12:09 2011 (r222920) @@ -670,7 +670,8 @@ g_shsec_taste(struct g_class *mp, struct if (md.md_version < 1) md.md_provsize = pp->mediasize; - if (md.md_provider[0] != '\0' && strcmp(md.md_provider, pp->name) != 0) + if (md.md_provider[0] != '\0' && + !g_compare_names(md.md_provider, pp->name)) return (NULL); if (md.md_provsize != pp->mediasize) return (NULL); Modified: stable/8/sys/geom/stripe/g_stripe.c ============================================================================== --- stable/8/sys/geom/stripe/g_stripe.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/stripe/g_stripe.c Fri Jun 10 09:12:09 2011 (r222920) @@ -949,7 +949,8 @@ g_stripe_taste(struct g_class *mp, struc if (md.md_version < 3) md.md_provsize = pp->mediasize; - if (md.md_provider[0] != '\0' && strcmp(md.md_provider, pp->name) != 0) + if (md.md_provider[0] != '\0' && + !g_compare_names(md.md_provider, pp->name)) return (NULL); if (md.md_provsize != pp->mediasize) return (NULL); Modified: stable/8/sys/geom/virstor/g_virstor.c ============================================================================== --- stable/8/sys/geom/virstor/g_virstor.c Fri Jun 10 08:59:30 2011 (r222919) +++ stable/8/sys/geom/virstor/g_virstor.c Fri Jun 10 09:12:09 2011 (r222920) @@ -807,10 +807,9 @@ g_virstor_taste(struct g_class *mp, stru /* If the provider name is hardcoded, use the offered provider only * if it's been offered with its proper name (the one used in * the label command). */ - if (md.provider[0] != '\0') { - if (strcmp(md.provider, pp->name) != 0) - return (NULL); - } + if (md.provider[0] != '\0' && + !g_compare_names(md.provider, pp->name)) + return (NULL); /* Iterate all geoms this class already knows about to see if a new * geom instance of this class needs to be created (in case the provider