]> sourceware.org Git - lvm2.git/commitdiff
Thin pool now support chunk size as well
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 21 Oct 2011 09:55:07 +0000 (09:55 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 21 Oct 2011 09:55:07 +0000 (09:55 +0000)
Use chunksize option to specify data_block_size for thin pool target.
Drop low_water_mark to zero.

lib/metadata/lv_manip.c
lib/thin/thin.c
man/lvcreate.8.in
tools/lvcreate.c

index 0799d1ce281da35b449858a9e527f6edcd59d770..927eed9aa396cfe333ab3f19493522bb815736f1 100644 (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);
index c3f8438b5c3ee9b935e426535892c681e184daf9..3daaf756afbfe4a4da5eec7e935e443776105b97 100644 (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);
index 21f138c8b5148fc2f96c8aafffdbcc6a30f22267..8052bb7572ffa41b88e5881f784ed3b2d4becbc6 100644 (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
index 89e0191c7e8a2a5f18ce5f30bf8b7be034847449..9b55fd0631c78d2b9c3be074f59a74b01f9674aa 100644 (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;
This page took 0.045483 seconds and 5 git commands to generate.