From: prajnoha@sourceware.org <prajnoha@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW lib/format_text/export.c lib/ ...
Date: 20 Sep 2010 14:23:42 -0000 [thread overview]
Message-ID: <20100920142342.16058.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: prajnoha at sourceware.org 2010-09-20 14:23:20
Modified files:
. : WHATS_NEW
lib/format_text: export.c import-export.h tags.c
Log message:
Use dynamic allocation for metadata's tag buffer (removes 4096 char. limit).
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1729&r2=1.1730
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import-export.h.diff?cvsroot=lvm2&r1=1.24&r2=1.25
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/tags.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8
--- LVM2/WHATS_NEW 2010/09/09 13:13:12 1.1729
+++ LVM2/WHATS_NEW 2010/09/20 14:23:20 1.1730
@@ -1,5 +1,6 @@
Version 2.02.74 -
==================================
+ Use dynamic allocation for metadata's tag buffer (removes 4096 char. limit).
Add random suffix to archive file names to prevent races when being created.
Reinitialize archive and backup handling on toolcontext refresh.
Fix opprobriously slow I/O to cluster mirrors created with --nosync.
--- LVM2/lib/format_text/export.c 2010/07/09 15:34:44 1.77
+++ LVM2/lib/format_text/export.c 2010/09/20 14:23:20 1.78
@@ -366,6 +366,7 @@
static int _print_vg(struct formatter *f, struct volume_group *vg)
{
char buffer[4096];
+ char *tag_buffer = NULL;
if (!id_write_format(&vg->id, buffer, sizeof(buffer)))
return_0;
@@ -378,9 +379,10 @@
return_0;
if (!dm_list_empty(&vg->tags)) {
- if (!print_tags(&vg->tags, buffer, sizeof(buffer)))
+ if (!(tag_buffer = alloc_printed_tags(&vg->tags)))
return_0;
- outf(f, "tags = %s", buffer);
+ outf(f, "tags = %s", tag_buffer);
+ dm_free(tag_buffer);
}
if (vg->system_id && *vg->system_id)
@@ -426,7 +428,7 @@
struct pv_list *pvl;
struct physical_volume *pv;
char buffer[4096];
- char *buf;
+ char *buf, *tag_buffer = NULL;
const char *name;
outf(f, "physical_volumes {");
@@ -461,9 +463,10 @@
return_0;
if (!dm_list_empty(&pv->tags)) {
- if (!print_tags(&pv->tags, buffer, sizeof(buffer)))
+ if (!(tag_buffer = alloc_printed_tags(&pv->tags)))
return_0;
- outf(f, "tags = %s", buffer);
+ outf(f, "tags = %s", tag_buffer);
+ dm_free(tag_buffer);
}
outsize(f, pv->size, "dev_size = %" PRIu64, pv->size);
@@ -484,7 +487,7 @@
static int _print_segment(struct formatter *f, struct volume_group *vg,
int count, struct lv_segment *seg)
{
- char buffer[4096];
+ char *tag_buffer = NULL;
outf(f, "segment%u {", count);
_inc_indent(f);
@@ -497,9 +500,10 @@
outf(f, "type = \"%s\"", seg->segtype->name);
if (!dm_list_empty(&seg->tags)) {
- if (!print_tags(&seg->tags, buffer, sizeof(buffer)))
+ if (!(tag_buffer = alloc_printed_tags(&seg->tags)))
return_0;
- outf(f, "tags = %s", buffer);
+ outf(f, "tags = %s", tag_buffer);
+ dm_free(tag_buffer);
}
if (seg->segtype->ops->text_export &&
@@ -553,6 +557,7 @@
{
struct lv_segment *seg;
char buffer[4096];
+ char *tag_buffer = NULL;
int seg_count;
outnl(f);
@@ -569,9 +574,10 @@
return_0;
if (!dm_list_empty(&lv->tags)) {
- if (!print_tags(&lv->tags, buffer, sizeof(buffer)))
+ if (!(tag_buffer = alloc_printed_tags(&lv->tags)))
return_0;
- outf(f, "tags = %s", buffer);
+ outf(f, "tags = %s", tag_buffer);
+ dm_free(tag_buffer);
}
if (lv->alloc != ALLOC_INHERIT)
--- LVM2/lib/format_text/import-export.h 2010/03/17 02:11:19 1.24
+++ LVM2/lib/format_text/import-export.h 2010/09/20 14:23:20 1.25
@@ -61,7 +61,7 @@
int print_flags(uint64_t status, int type, char *buffer, size_t size);
int read_flags(uint64_t *status, int type, struct config_value *cv);
-int print_tags(struct dm_list *tags, char *buffer, size_t size);
+char *alloc_printed_tags(struct dm_list *tags);
int read_tags(struct dm_pool *mem, struct dm_list *tags, struct config_value *cv);
int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp);
--- LVM2/lib/format_text/tags.c 2008/11/03 22:14:28 1.7
+++ LVM2/lib/format_text/tags.c 2010/09/20 14:23:20 1.8
@@ -19,29 +19,46 @@
#include "str_list.h"
#include "lvm-string.h"
-int print_tags(struct dm_list *tags, char *buffer, size_t size)
+char *alloc_printed_tags(struct dm_list *tags)
{
struct str_list *sl;
int first = 1;
+ size_t size = 0;
+ char *buffer, *buf;
- if (!emit_to_buffer(&buffer, &size, "["))
- return_0;
+ dm_list_iterate_items(sl, tags)
+ /* '"' + tag + '"' + ',' + ' ' */
+ size += strlen(sl->str) + 4;
+ /* '[' + ']' + '\0' */
+ size += 3;
+
+ if (!(buffer = buf = dm_malloc(size))) {
+ log_error("Could not allocate memory for tag list buffer.");
+ return NULL;
+ }
+
+ if (!emit_to_buffer(&buf, &size, "["))
+ goto bad;
dm_list_iterate_items(sl, tags) {
if (!first) {
- if (!emit_to_buffer(&buffer, &size, ", "))
- return_0;
+ if (!emit_to_buffer(&buf, &size, ", "))
+ goto bad;
} else
first = 0;
- if (!emit_to_buffer(&buffer, &size, "\"%s\"", sl->str))
- return_0;
+ if (!emit_to_buffer(&buf, &size, "\"%s\"", sl->str))
+ goto bad;
}
- if (!emit_to_buffer(&buffer, &size, "]"))
- return_0;
+ if (!emit_to_buffer(&buf, &size, "]"))
+ goto bad;
- return 1;
+ return buffer;
+
+bad:
+ dm_free(buffer);
+ return_NULL;
}
int read_tags(struct dm_pool *mem, struct dm_list *tags, struct config_value *cv)
next reply other threads:[~2010-09-20 14:23 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-20 14:23 prajnoha [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-01-19 15:31 LVM2 ./WHATS_NEW lib/format_text/export.c lib/ zkabelac
2010-01-07 14:45 zkabelac
2010-01-07 14:40 zkabelac
2008-07-10 11:30 mornfall
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=20100920142342.16058.qmail@sourceware.org \
--to=prajnoha@sourceware.org \
--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.