All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Rockai <prockai@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH 01/17] Add pvid parameter to create_instance function.
Date: Tue, 25 Jan 2011 13:54:31 +0100	[thread overview]
Message-ID: <87y669rvnc.fsf@twilight.int.mornfall.net.> (raw)
In-Reply-To: <1295867048-21558-2-git-send-email-prajnoha@redhat.com> (Peter Rajnoha's message of "Mon, 24 Jan 2011 12:03:52 +0100")

Peter Rajnoha <prajnoha@redhat.com> writes:
> The format instance holds the information about current metadata areas and it
> is a snapshot of what we have in the cache at the moment of the instance
> creation. Through the command exection, we use this instance to modify, set
> and access modified metadata areas (like we use it to support the
> --metadataignore and we store the metadata areas that are in use and the
> ones that are ignored).
>
> But to support modifying metadata areas fully (with add/remove metadata
> area support), we need to be able to create format instances for PVs as well.
> Hence, add the pvid parameter for the create_instance function.

> The rules we will follow:
>
>  - the format instance is VG-based or PV-based, but *never both*
>    at the same time,
>
>  - when a PV (structure) is alone, not part of any VG, we will have
>    a PV based format_instance attached to the PV structure,
>
>  - when a PV is part of the VG, any existing PV-based format_instance
>    is destroyed and the PV strucutre will reference VG based format
>    instance instead.
>
>  - whatever we need change for mdas, we'll use the format_instance,
>    we don't touch the cache directly! This will be synchronized with the
>    format instance after pv_write automatically.

Sounds sane. Implementation looks OK too.

> Signed-off-by: Peter Rajnoha <prajnoha@redhat.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>

> ---
>  lib/cache/lvmcache.c          |    2 +-
>  lib/format1/format1.c         |    1 +
>  lib/format_pool/format_pool.c |    1 +
>  lib/format_text/archive.c     |    2 +-
>  lib/format_text/archiver.c    |    8 ++++----
>  lib/format_text/format-text.c |   20 +++++++++++---------
>  lib/metadata/metadata.c       |   10 +++++-----
>  lib/metadata/metadata.h       |    5 +++--
>  8 files changed, 27 insertions(+), 22 deletions(-)
>
> diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
> index 0e9cae1..476b176 100644
> --- a/lib/cache/lvmcache.c
> +++ b/lib/cache/lvmcache.c
> @@ -653,7 +653,7 @@ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
>  		return NULL;
>  
>  	if (!(fid = vginfo->fmt->ops->create_instance(vginfo->fmt,
> -						      vginfo->vgname,
> +						      NULL, vginfo->vgname,
>  						      vgid, NULL)))
>  		return_NULL;
>  
> diff --git a/lib/format1/format1.c b/lib/format1/format1.c
> index fc14444..13b757d 100644
> --- a/lib/format1/format1.c
> +++ b/lib/format1/format1.c
> @@ -522,6 +522,7 @@ static struct metadata_area_ops _metadata_format1_ops = {
>  };
>  
>  static struct format_instance *_format1_create_instance(const struct format_type *fmt,
> +						const char *pvid __attribute__((unused)),
>  						const char *vgname __attribute__((unused)),
>  						const char *vgid __attribute__((unused)),
>  						void *private __attribute__((unused)))
> diff --git a/lib/format_pool/format_pool.c b/lib/format_pool/format_pool.c
> index 730da87..814d80c 100644
> --- a/lib/format_pool/format_pool.c
> +++ b/lib/format_pool/format_pool.c
> @@ -249,6 +249,7 @@ static struct metadata_area_ops _metadata_format_pool_ops = {
>  /* *INDENT-ON* */
>  
>  static struct format_instance *_pool_create_instance(const struct format_type *fmt,
> +						const char *pvid __attribute__((unused)),
>  						const char *vgname __attribute__((unused)),
>  						const char *vgid __attribute__((unused)),
>  						void *private __attribute__((unused)))
> diff --git a/lib/format_text/archive.c b/lib/format_text/archive.c
> index 43425dc..760153c 100644
> --- a/lib/format_text/archive.c
> +++ b/lib/format_text/archive.c
> @@ -309,7 +309,7 @@ static void _display_archive(struct cmd_context *cmd, struct archive_file *af)
>  
>  	if (!(context = create_text_context(cmd, af->path, NULL)) ||
>  	    !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, NULL,
> -							 NULL, context))) {
> +							 NULL, NULL, context))) {
>  		log_error("Couldn't create text instance object.");
>  		return;
>  	}
> diff --git a/lib/format_text/archiver.c b/lib/format_text/archiver.c
> index e0212a2..b7dcad9 100644
> --- a/lib/format_text/archiver.c
> +++ b/lib/format_text/archiver.c
> @@ -278,7 +278,7 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,
>  	if (!(context = create_text_context(cmd, file,
>  					    cmd->cmd_line)) ||
>  	    !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, NULL,
> -							 NULL, context))) {
> +							 NULL, NULL, context))) {
>  		log_error("Couldn't create text format object.");
>  		return NULL;
>  	}
> @@ -306,8 +306,8 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
>  	 */
>  
>  	/* Attempt to write out using currently active format */
> -	if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, vg->name,
> -						       NULL, NULL))) {
> +	if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, NULL,
> +						vg->name, NULL, NULL))) {
>  		log_error("Failed to allocate format instance");
>  		return 0;
>  	}
> @@ -398,7 +398,7 @@ int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
>  
>  	if (!(context = create_text_context(cmd, file, desc)) ||
>  	    !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, NULL,
> -							 NULL, context))) {
> +							 NULL, NULL, context))) {
>  		log_error("Couldn't create backup object.");
>  		return 0;
>  	}
> diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
> index c186757..fda8255 100644
> --- a/lib/format_text/format-text.c
> +++ b/lib/format_text/format-text.c
> @@ -37,10 +37,11 @@
>  #include <dirent.h>
>  #include <ctype.h>
>  
> -static struct format_instance *_text_create_text_instance(const struct format_type
> -						     *fmt, const char *vgname,
> -						     const char *vgid,
> -						     void *context);
> +static struct format_instance *_text_create_text_instance(const struct format_type *fmt,
> +							  const char *pvid,
> +							  const char *vgname,
> +							  const char *vgid,
> +							  void *context);
>  
>  struct text_fid_context {
>  	char *raw_metadata_buf;
> @@ -1085,7 +1086,7 @@ static int _scan_file(const struct format_type *fmt, const char *vgname)
>  
>  				/* FIXME stat file to see if it's changed */
>  				fid = _text_create_text_instance(fmt, NULL, NULL,
> -							    NULL);
> +								 NULL, NULL);
>  				if ((vg = _vg_read_file_name(fid, scanned_vgname,
>  							     path))) {
>  					/* FIXME Store creation host in vg */
> @@ -1912,10 +1913,11 @@ static int _text_pv_setup(const struct format_type *fmt,
>  }
>  
>  /* NULL vgname means use only the supplied context e.g. an archive file */
> -static struct format_instance *_text_create_text_instance(const struct format_type
> -						     *fmt, const char *vgname,
> -						     const char *vgid,
> -						     void *context)
> +static struct format_instance *_text_create_text_instance(const struct format_type*fmt,
> +							  const char *pvid,
> +							  const char *vgname,
> +							  const char *vgid,
> +							  void *context)
>  {
>  	struct format_instance *fid;
>  	struct text_fid_context *fidtc;
> diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
> index 771cdb0..fd1948a 100644
> --- a/lib/metadata/metadata.c
> +++ b/lib/metadata/metadata.c
> @@ -974,8 +974,8 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name)
>  	/* initialize removed_pvs list */
>  	dm_list_init(&vg->removed_pvs);
>  
> -	if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, vg_name,
> -						       NULL, NULL))) {
> +	if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, NULL,
> +						vg_name, NULL, NULL))) {
>  		log_error("Failed to create format instance");
>  		goto bad;
>  	}
> @@ -2629,7 +2629,7 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
>  	}
>  
>  	/* create format instance with appropriate metadata area */
> -	if (!(vg->fid = vginfo->fmt->ops->create_instance(vginfo->fmt,
> +	if (!(vg->fid = vginfo->fmt->ops->create_instance(vginfo->fmt, NULL,
>  							  orphan_vgname, NULL,
>  							  NULL))) {
>  		log_error("Failed to create format instance");
> @@ -2808,7 +2808,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
>  		use_precommitted = 0;
>  
>  	/* create format instance with appropriate metadata area */
> -	if (!(fid = fmt->ops->create_instance(fmt, vgname, vgid, NULL))) {
> +	if (!(fid = fmt->ops->create_instance(fmt, NULL, vgname, vgid, NULL))) {
>  		log_error("Failed to create format instance");
>  		return NULL;
>  	}
> @@ -2962,7 +2962,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
>  			use_precommitted = 0;
>  
>  		/* create format instance with appropriate metadata area */
> -		if (!(fid = fmt->ops->create_instance(fmt, vgname, vgid, NULL))) {
> +		if (!(fid = fmt->ops->create_instance(fmt, NULL, vgname, vgid, NULL))) {
>  			log_error("Failed to create format instance");
>  			return NULL;
>  		}
> diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
> index c0f9148..ab7cff0 100644
> --- a/lib/metadata/metadata.h
> +++ b/lib/metadata/metadata.h
> @@ -279,8 +279,9 @@ struct format_handler {
>  	/*
>  	 * Create format instance with a particular metadata area
>  	 */
> -	struct format_instance *(*create_instance) (const struct format_type *
> -						    fmt, const char *vgname,
> +	struct format_instance *(*create_instance) (const struct format_type *fmt,
> +						    const char *pvid,
> +						    const char *vgname,
>  						    const char *vgid,
>  						    void *context);



  reply	other threads:[~2011-01-25 12:54 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-24 11:03 [PATCH 00/17] Add interface to support adding and removing metadata areas on demand (v2) Peter Rajnoha
2011-01-24 11:03 ` [PATCH 01/17] Add pvid parameter to create_instance function Peter Rajnoha
2011-01-25 12:54   ` Petr Rockai [this message]
2011-01-24 11:03 ` [PATCH 02/17] Add supporting functions for metadata areas stored in format instance Peter Rajnoha
2011-01-25 13:16   ` Petr Rockai
2011-01-26 10:38     ` Peter Rajnoha
2011-01-26 13:59       ` Petr Rockai
2011-01-26 14:06       ` Petr Rockai
2011-01-24 11:03 ` [PATCH 03/17] Add struct format_instance *fid field to struct physical_volume Peter Rajnoha
2011-01-25 13:03   ` Petr Rockai
2011-01-24 11:03 ` [PATCH 04/17] Add format_instance support for pv_read Peter Rajnoha
2011-01-25 13:30   ` Petr Rockai
2011-01-26 11:05     ` Peter Rajnoha
2011-01-26 11:12       ` Peter Rajnoha
2011-01-24 11:03 ` [PATCH 05/17] Add attach_existing_mdas parameter to create_instance fn Peter Rajnoha
2011-01-25 14:43   ` Petr Rockai
2011-01-26 13:24     ` Peter Rajnoha
2011-01-24 11:03 ` [PATCH 06/17] Remove useless mdas parameter from PV read functions Peter Rajnoha
2011-01-25 14:44   ` Petr Rockai
2011-01-24 11:03 ` [PATCH 07/17] Add pv_add_metadata_area fn to support adding metadata areas on demand Peter Rajnoha
2011-01-25 14:48   ` Petr Rockai
2011-01-24 11:03 ` [PATCH 08/17] Add pv_remove_metadata_area fn to support removing " Peter Rajnoha
2011-01-28 15:31   ` Petr Rockai
2011-01-24 11:04 ` [PATCH 09/17] Add pv_initialise fn to format_handler interface Peter Rajnoha
2011-01-28 16:31   ` Petr Rockai
2011-01-24 11:04 ` [PATCH 10/17] Add pe_start_locked parameter to pv_create fn Peter Rajnoha
2011-01-28 16:39   ` Petr Rockai
2011-01-24 11:04 ` [PATCH 11/17] Refactor pv_setup to not include the PV initialisation code Peter Rajnoha
2011-01-24 11:04 ` [PATCH 12/17] Remove unused _mda_setup code Peter Rajnoha
2011-01-24 11:04 ` [PATCH 13/17] Cleanup pv_write code to use recent changes in metadata handling interface Peter Rajnoha
2011-01-24 11:04 ` [PATCH 14/17] Use new metadata handling interface to provide better support for PV resize Peter Rajnoha
2011-01-24 11:04 ` [PATCH 15/17] Change vg_convert code to actually work with recent changes in metadata handling interface Peter Rajnoha
2011-01-24 11:04 ` [PATCH 16/17] Fix pvchange -u to " Peter Rajnoha
2011-01-24 16:04   ` Peter Rajnoha
2011-01-24 11:04 ` [PATCH 17/17] Fix pvchange --metadataignore " Peter Rajnoha
2011-01-24 11:12 ` [PATCH 00/17] Add interface to support adding and removing metadata areas on demand (v2) Peter Rajnoha

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=87y669rvnc.fsf@twilight.int.mornfall.net. \
    --to=prockai@redhat.com \
    --cc=lvm-devel@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.