1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

More striping support & fixes.

This commit is contained in:
Alasdair Kergon 2001-12-03 16:27:16 +00:00
parent c0ca88c287
commit 7a61472a0a
4 changed files with 42 additions and 44 deletions

View File

@ -11,11 +11,18 @@
#define _LVM_METADATA_H #define _LVM_METADATA_H
#include <sys/types.h> #include <sys/types.h>
#include <asm/page.h>
#include "dev-cache.h" #include "dev-cache.h"
#include "list.h" #include "list.h"
#include "uuid.h" #include "uuid.h"
#define NAME_LEN 128 #define NAME_LEN 128
#define MAX_STRIPES 128
#define SECTOR_SIZE 512
#define STRIPE_SIZE_DEFAULT 16 /* 16KB */
#define STRIPE_SIZE_MIN ( PAGE_SIZE/SECTOR_SIZE) /* PAGESIZE in sectors */
#define STRIPE_SIZE_MAX ( 512L * 1024 / SECTOR_SIZE) /* 512 KB in sectors */
/* Various flags */ /* Various flags */
/* Note that the bits no longer necessarily correspond to LVM1 disk format */ /* Note that the bits no longer necessarily correspond to LVM1 disk format */

View File

@ -111,6 +111,11 @@ static void _insert_area(struct list *head, struct pv_area *a)
struct list *pvah; struct list *pvah;
struct pv_area *pva; struct pv_area *pva;
if (list_empty(head)) {
list_add(head, &a->list);
return;
}
list_iterate (pvah, head) { list_iterate (pvah, head) {
pva = list_item(pvah, struct pv_area); pva = list_item(pvah, struct pv_area);
@ -118,10 +123,8 @@ static void _insert_area(struct list *head, struct pv_area *a)
break; break;
} }
a->list.n = &pva->list; list_add_h(&pva->list, &a->list);
a->list.p = pva->list.p; return;
pva->list.p->n = &a->list;
pva->list.p = &a->list;
} }
static int _create_single_area(struct pool *mem, struct pv_map *pvm, static int _create_single_area(struct pool *mem, struct pv_map *pvm,

View File

@ -18,6 +18,7 @@ int lvcreate(int argc, char **argv)
int opt = 0; int opt = 0;
uint32_t status = 0; uint32_t status = 0;
uint32_t size = 0; uint32_t size = 0;
uint32_t size_rest;
uint32_t extents = 0; uint32_t extents = 0;
struct volume_group *vg; struct volume_group *vg;
struct logical_volume *lv; struct logical_volume *lv;
@ -51,20 +52,24 @@ int lvcreate(int argc, char **argv)
zero = strcmp(arg_str_value(zero_ARG, "y"), "n"); zero = strcmp(arg_str_value(zero_ARG, "y"), "n");
if (arg_count(stripes_ARG)) { if (arg_count(stripes_ARG)) {
log_print("Stripes not yet implemented in LVM2. Ignoring.");
stripes = arg_int_value(stripes_ARG, 1); stripes = arg_int_value(stripes_ARG, 1);
if (stripes == 1) if (stripes == 1)
log_print("Redundant stripes argument: default is 1"); log_print("Redundant stripes argument: default is 1");
} }
if (arg_count(stripesize_ARG)) if (arg_count(stripesize_ARG))
stripesize = arg_int_value(stripesize_ARG, 0); stripesize = 2 * arg_int_value(stripesize_ARG, 0);
if (stripes == 1 && stripesize) { if (stripes == 1 && stripesize) {
log_print("Ignoring stripesize argument with single stripe"); log_print("Ignoring stripesize argument with single stripe");
stripesize = 0; stripesize = 0;
} }
if (stripes > 1 && !stripesize) {
stripesize = 2 * STRIPE_SIZE_DEFAULT;
log_print("Using default stripesize %dKB", stripesize / 2);
}
if (arg_count(permission_ARG)) if (arg_count(permission_ARG))
status |= arg_int_value(permission_ARG, 0); status |= arg_int_value(permission_ARG, 0);
else else
@ -157,44 +162,31 @@ int lvcreate(int argc, char **argv)
pvh = &vg->pvs; pvh = &vg->pvs;
} }
/********* FIXME Move default choice (0) into format1 if (argc && argc < stripes ) {
log_print("Using default stripe size of %lu KB", log_error("Too few physical volumes on "
LVM_DEFAULT_STRIPE_SIZE);
***********/
if (argc && argc != stripes) {
log_error("Incorrect number of physical volumes on "
"command line for %d-way striping", stripes); "command line for %d-way striping", stripes);
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
/******** FIXME Inside lv_create stripes if (stripes < 1 || stripes > MAX_STRIPES) {
log_verbose("checking stripe count"); log_error("Number of stripes (%d) must be between %d and %d",
if (stripes < 1 || stripes > LVM_MAX_STRIPES) { stripes, 1, MAX_STRIPES);
log_error("Invalid number of stripes: %d", stripes);
log_error("must be between %d and %d", 1, LVM_MAX_STRIPES);
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
log_verbose("checking stripe size"); if (stripes > 1 && (stripesize < STRIPE_SIZE_MIN ||
if (stripesize > 0 && lv_check_stripesize(stripesize) < 0) { stripesize > STRIPE_SIZE_MAX ||
log_error("invalid stripe size %d", stripesize); stripesize & (stripesize - 1))) {
log_error("Invalid stripe size %d", stripesize);
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }
*********/
stripesize *= 2; if (stripesize > vg->extent_size) {
log_error("Setting stripe size %d KB to physical extent "
/******** FIXME Stripes "size %u KB",
log_verbose stripesize / 2, vg->extent_size / 2);
("checking stripe size against volume group physical extent size"); stripesize = vg->extent_size;
if (stripesize > vg_core->pe_size) {
log_error
("setting stripe size %d KB to physical extent size %u KB",
stripesize / 2, vg_core->pe_size / 2);
stripesize = vg_core->pe_size;
} }
**********/
if (size) { if (size) {
/* No of 512-byte sectors */ /* No of 512-byte sectors */
@ -212,16 +204,12 @@ int lvcreate(int argc, char **argv)
extents /= vg->extent_size; extents /= vg->extent_size;
} }
/******* FIXME Stripes if ((size_rest = extents % stripes)) {
size_rest = size % (stripes * vg_core->pe_size); log_print("Rounding size (%d extents) up to stripe boundary "
if (size_rest != 0) { "size (%d extents)", extents,
log_print("rounding %d KB to stripe boundary size ", extents - size_rest + stripes);
size / 2); extents = extents - size_rest + stripes;
size = size - size_rest + stripes * vg_core->pe_size;
printf("%d KB / %u PE\n", size / 2,
size / vg_core->pe_size);
} }
*************/
if (!(lv = lv_create(lv_name, status, stripes, stripesize, extents, if (!(lv = lv_create(lv_name, status, stripes, stripesize, extents,
vg, pvh))) return ECMD_FAILED; vg, pvh))) return ECMD_FAILED;

View File

@ -178,7 +178,7 @@ int lvresize(int argc, char **argv)
/* If extending, find stripes, stripesize & size of last segment */ /* If extending, find stripes, stripesize & size of last segment */
if (extents > lv->le_count && if (extents > lv->le_count &&
!(stripes == 1 || stripes > 1 && stripesize)) { !(stripes == 1 || (stripes > 1 && stripesize))) {
list_iterate(segh, &lv->segments) { list_iterate(segh, &lv->segments) {
struct stripe_segment *seg; struct stripe_segment *seg;
uint32_t sz, str; uint32_t sz, str;