linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Lukasz Trabinski <lukasz@hq.nawigator.pl>
To: linux-lvm@sistina.com
Subject: Re: [linux-lvm] Problems with vgscan
Date: Sat, 10 Mar 2001 01:36:38 +0100 (CET)	[thread overview]
Message-ID: <Pine.LNX.4.30.0103100129080.12825-201000@hq.nawigator.pl> (raw)
In-Reply-To: <200103100004.f2A04kO26602@webber.adilger.int>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 296 bytes --]

On Fri, 9 Mar 2001, Andreas Dilger wrote:
>
> Please run "vgscan -v -d" and post the output (compressed if very long).

OK. There is gzipped output from vgscan -v -d
I'm posting patched pv_read_all_pv_of_vg.c, too verify it.


-- 
*[ �ukasz Tr�bi�ski ]*
SysAdmin @polvoice.com


[-- Attachment #2: Type: TEXT/PLAIN, Size: 6406 bytes --]

/*
 * tools/lib/pv_read_all_pv_of_vg.c
 *
 * Copyright (C) 1997 - 2000  Heinz Mauelshagen, Sistina Software
 *
 * March-May,October-November 1997
 * May,August,November 1998
 * January,March,April,September,October 2000
 *
 *
 * This LVM library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This LVM library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this LVM library; if not, write to the Free
 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 * MA 02111-1307, USA
 *
 */

/*
 * Changelog
 *
 *    03/02/2000 - use debug_enter()/debug_leave()
 *    04/04/2000 - enhanced to find physical volumes on UUID base
 *                 rather than on device special name
 *    20/09/2000 - WORKAROUND: avoid dual access pathes for now (2.4.0-test8)
 *    30/10/2000 - reworked to fix UUID related bug
 *
 */

#include <liblvm.h>


int pv_read_all_pv_of_vg ( char *vg_name, pv_t ***pv, int reread) {
   int i = 0;
   int id = 0;
   int p = 0;
   int pp = 0;
   int np = 0;
   int pv_number = 0;
   int ret = 0;
   int uuids = 0;
   static int first = 0;
   char *pv_uuid_list = NULL;
   static char vg_name_sav[NAME_LEN] = { 0, };
   pv_t **pv_tmp = NULL;
   static pv_t **pv_this = NULL;
   pv_t **pv_this_sav = NULL;
   
#ifdef DEBUG
   debug_enter ( "pv_read_all_pv_of_vg -- CALLED with vg_name: \"%s\"\n",
                 vg_name);
#endif

   if ( pv == NULL || vg_name == NULL ||
        ( reread != TRUE && reread != FALSE) ||
        vg_check_name ( vg_name) < 0) {
      ret = -LVM_EPARAM;
      goto pv_read_all_pv_of_vg_end;
   }

   *pv = NULL;

   if ( strcmp ( vg_name_sav, vg_name) != 0) {
      strcpy ( vg_name_sav, vg_name);
      reread = TRUE;
   }

   if ( reread == TRUE) {
      if ( pv_this != NULL) {
         free ( pv_this);
         pv_this = NULL;
      }
      first = 0;
   }

   if ( first == 0) {
      if ( ( ret = pv_read_all_pv ( &pv_tmp, FALSE)) < 0)
         goto pv_read_all_pv_of_vg_end;
   
      /* first physical volume who's volume group name fits
         starts work on PV UUID list */
      for ( p = 0; pv_tmp[p] != NULL; p++) {
         if ( strcmp ( pv_tmp[p]->vg_name, vg_name) == 0 &&
              pv_check_consistency ( pv_tmp[p]) == 0) {
            uuids = pv_read_uuidlist ( pv_tmp[p]->pv_name, &pv_uuid_list);
            break;
         }
      }

      /* pass to find the number of PVs in this group  anid
         to prefil the pointer array */
      for ( p = 0; pv_tmp[p] != NULL; p++) {
         if ( strncmp ( pv_tmp[p]->vg_name, vg_name, NAME_LEN) == 0) {
            pv_this_sav = pv_this;
            if ( ( pv_this = realloc ( pv_this,
                                       ( np + 2) * sizeof ( pv_t*))) == NULL) {
               fprintf ( stderr, "realloc error in %s [line %d]\n",
                                 __FILE__, __LINE__);
               ret = -LVM_EPV_READ_ALL_PV_OF_VG_MALLOC;
               if ( pv_this_sav != NULL) free ( pv_this_sav);
               goto pv_read_all_pv_of_vg_end;
            }
            pv_this[np] = pv_tmp[p];
            pv_this[np+1] = NULL;
            np++;
         }
      }
#if 0
      /* in case this PV already holds a uuid list: check against this list */
      if ( uuids > 0) {
         for ( p = 0; pv_this[p] != NULL; p++) {
            for ( id = 0; id < uuids; id++) {
               if ( memcmp ( pv_this[p]->pv_uuid,
                             &pv_uuid_list[id*NAME_LEN],
                             UUID_LEN) == 0) goto uuid_check_end;
            }
            pv_this[p] = NULL;
uuid_check_end:
         }
         for ( pp = 0; pp < p - 2; pp++) {
            if ( pv_this[pp] == NULL) {
               pv_this[pp] = pv_this[pp+1];
               pv_this[pp+1] = NULL;
            }
         }
         np = 0;
         while ( pv_this[np] != NULL) np++;
      }
#endif
      /* avoid multiple access pathes */
      for ( p = 0; pv_this[p] != NULL; p++) {
            /* avoid multiple access pathes for now (2.4.0-test8)
               and MD covered pathes as well */
         for ( i = 0; i < np; i++) {
            if ( p != i &&
                 strncmp ( pv_this[p]->vg_name, vg_name, NAME_LEN) == 0) {
               if ( pv_this[i]->pv_number == pv_this[p]->pv_number &&
                    memcmp ( pv_this[i]->pv_uuid, pv_this[p]->pv_uuid,
                             UUID_LEN) == 0) {
                  if ( MAJOR ( pv_this[p]->pv_dev) == MD_MAJOR) pp = i;
                  pv_this[pp] = NULL;
               }
            }
         }
         for ( pp = 0; pp < p - 2; pp++) {
            if ( pv_this[pp] == NULL) {
               pv_this[pp] = pv_this[pp+1];
               pv_this[pp+1] = NULL;
            }
         }
         np = 0;
         while ( pv_this[np] != NULL) np++;
      }

      /* no we only have pointers to single access path PVs
         in pv_this belonging to this VG */

      if ( np == 0) {
         ret = -LVM_EPV_READ_ALL_PV_OF_VG_NP;
         goto pv_read_all_pv_of_vg_end;
      }

      /* pass to find highest pv_number */
      for ( p = 0; pv_this[p] != NULL; p++) {
         if ( pv_number < pv_this[p]->pv_number)
            pv_number = pv_this[p]->pv_number;
      }

      if ( pv_number != np) {
         ret = -LVM_EPV_READ_ALL_PV_OF_VG_PV_NUMBER;
         goto pv_read_all_pv_of_vg_end;
      }

      /* Check for contiguous PV array */
      for ( p = 0; pv_this[p] != NULL; p++)
         if ( pv_this[p] == NULL && p < np)
            ret = -LVM_EPV_READ_ALL_PV_OF_VG_NP_SORT;

      first = 1;
   }

   if ( ret == 0) *pv = pv_this;

pv_read_all_pv_of_vg_end:

#ifdef DEBUG
   debug_leave ( "pv_read_all_pv_of_vg -- LEAVING with ret: %d\n", ret);
#endif
   return ret;
} /* pv_read_all_pv_of_vg() */

[-- Attachment #3: Type: APPLICATION/x-gzip, Size: 4076 bytes --]

  reply	other threads:[~2001-03-10  0:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-09 23:31 [linux-lvm] Problems with vgscan Lukasz Trabinski
2001-03-10  0:04 ` Andreas Dilger
2001-03-10  0:36   ` Lukasz Trabinski [this message]
2001-03-12 14:16     ` Lukasz Trabinski
2001-03-12 18:25     ` Andreas Dilger
  -- strict thread matches above, loose matches on Subject: below --
2000-03-24 19:00 [linux-lvm] problems " jorg de jong
2000-03-25 14:03 ` Heinz Mauelshagen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.30.0103100129080.12825-201000@hq.nawigator.pl \
    --to=lukasz@hq.nawigator.pl \
    --cc=linux-lvm@sistina.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).