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

Thin pool now support chunk size as well

Use chunksize option to specify data_block_size for thin pool target.
Drop low_water_mark to zero.
This commit is contained in:
Zdenek Kabelac 2011-10-21 09:55:07 +00:00
parent 4d83891a67
commit 3bc417488d
4 changed files with 31 additions and 19 deletions

View File

@ -4160,9 +4160,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
seg_is_thin_volume(lp) ? lp->pool : NULL, lp->pvh, lp->alloc))
return_NULL;
if (seg_is_thin_pool(lp) && lp->zero)
first_seg(lv)->zero_new_blocks = 1;
else if (seg_is_thin_volume(lp)) {
if (seg_is_thin_pool(lp)) {
first_seg(lv)->zero_new_blocks = lp->zero ? 1 : 0;
first_seg(lv)->data_block_size = lp->chunk_size;
/* FIXME: use lowwatermark via lvm.conf global for all thinpools ? */
first_seg(lv)->low_water_mark = 0;
} else if (seg_is_thin_volume(lp)) {
pool_lv = first_seg(lv)->pool_lv;
if (!(first_seg(lv)->device_id =
@ -4184,13 +4187,6 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
*/
}
if (seg_is_thin_pool(lp)) {
/* FIXME: add lvcreate params - maybe -c/--chunksize?,
* use lowwatermark via lvm.conf global for all thinpools ?*/
first_seg(lv)->data_block_size = 128;
first_seg(lv)->low_water_mark = 4096;
}
if (lp->log_count &&
!seg_is_raid(first_seg(lv)) && seg_is_mirrored(first_seg(lv))) {
if (!add_mirror_log(cmd, lv, lp->log_count,
@ -4217,7 +4213,9 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg, struct l
if (seg_is_thin_pool(lp)) {
/* FIXME: skipping in test mode is not going work */
if (!activate_lv_excl(cmd, first_seg(lv)->pool_metadata_lv) ||
/* First 4KB of metadata device must be cleared. */
/* Clear 4KB of metadata device for new thin-pool. */
// FIXME: maybe -zero n should allow to recreate same thin pool
// and different option should be used for zero_new_blocks
!set_lv(cmd, first_seg(lv)->pool_metadata_lv, UINT64_C(0), 0)) {
log_error("Aborting. Failed to wipe pool metadata %s.",
lv->name);

View File

@ -155,7 +155,7 @@ static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter
outf(f, "pool = \"%s\"", seg_lv(seg, 0)->name);
outf(f, "metadata = \"%s\"", seg->pool_metadata_lv->name);
outf(f, "transaction_id = %" PRIu64, seg->transaction_id);
outf(f, "data_block_size = %d", seg->data_block_size);
outf(f, "data_block_size = %u", seg->data_block_size);
if (seg->low_water_mark)
outf(f, "low_water_mark = %" PRIu64, seg->low_water_mark);

View File

@ -132,6 +132,8 @@ on one node and \fB-a\fIly\fR will activate only on the local node.
Power of 2 chunk size in sector units (512b).
For snapshot logical volume the value must be between 8 (4KB) and 1024 (512KB)
and the default value is 8.
For thin pool logical volume the value must be between 128 (64KB) and
2097152 (1MB) and the default value is 128.
.TP
.BR \-C ", " \-\-contiguous " {" \fIy | \fIn }
Sets or resets the contiguous allocation policy for

View File

@ -690,14 +690,26 @@ static int _lvcreate_params(struct lvcreate_params *lp,
log_error("Negative chunk size is invalid");
return 0;
}
lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
(lp->chunk_size & (lp->chunk_size - 1))) {
log_error("Chunk size must be a power of 2 in the "
"range 4K to 512K");
return 0;
if (lp->snapshot) {
lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, 8);
if (lp->chunk_size < 8 || lp->chunk_size > 1024 ||
(lp->chunk_size & (lp->chunk_size - 1))) {
log_error("Chunk size must be a power of 2 in the "
"range 4K to 512K");
return 0;
}
} else {
lp->chunk_size = arg_uint_value(cmd, chunksize_ARG, DM_THIN_MIN_DATA_BLOCK_SIZE);
if ((lp->chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE) ||
(lp->chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE) ||
(lp->chunk_size & (lp->chunk_size - 1))) {
log_error("Chunk size must be a power of 2 in the "
"range %uK to %uK", (DM_THIN_MIN_DATA_BLOCK_SIZE / 2),
(DM_THIN_MIN_DATA_BLOCK_SIZE / 2));
return 0;
}
}
log_verbose("Setting chunksize to %d sectors.", lp->chunk_size);
log_verbose("Setting chunksize to %u sectors.", lp->chunk_size);
if (!lp->thin && lp->snapshot && !(lp->segtype = get_segtype_from_string(cmd, "snapshot")))
return_0;