~ubuntu-branches/debian/sid/lvm2/sid

« back to all changes in this revision

Viewing changes to .pc/monitoring-default-off.patch/tools/toollib.c

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2014-08-19 15:37:06 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20140819153706-i1gaio8lg534dara
Tags: 2.02.109-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
 * Strip dev_dir if present
107
107
 */
108
108
const char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
109
 
                   unsigned *dev_dir_found)
 
109
                         unsigned *dev_dir_found)
110
110
{
111
111
        const char *dmdir = dm_dir();
112
112
        size_t dmdir_len = strlen(dmdir), vglv_sz;
293
293
 
294
294
        struct dm_list *tags_arg;
295
295
        struct dm_list *vgnames;        /* VGs to process */
296
 
        struct str_list *sll, *strl;
 
296
        struct dm_str_list *sll, *strl;
297
297
        struct cmd_vg *cvl_vg;
298
298
        struct dm_list cmd_vgs;
299
299
        struct dm_list failed_lvnames;
621
621
        int opt = 0;
622
622
        int ret_max = ECMD_PROCESSED;
623
623
 
624
 
        struct str_list *sl;
 
624
        struct dm_str_list *sl;
625
625
        struct dm_list *vgnames, *vgids;
626
626
        struct dm_list arg_vgnames, tagsl;
627
627
 
803
803
        struct physical_volume *pv;
804
804
        struct dm_list *pvslist = NULL, *vgnames;
805
805
        struct dm_list tagsl;
806
 
        struct str_list *sll;
 
806
        struct dm_str_list *sll;
807
807
        char *at_sign, *tagname;
808
808
        struct device *dev;
809
809
 
1431
1431
int lv_refresh(struct cmd_context *cmd, struct logical_volume *lv)
1432
1432
{
1433
1433
        if (!cmd->partial_activation && (lv->status & PARTIAL_LV)) {
1434
 
                log_error("Refusing refresh of partial LV %s. Use --partial to override.",
 
1434
                log_error("Refusing refresh of partial LV %s."
 
1435
                          " Use '--activationmode partial' to override.",
1435
1436
                          lv->name);
1436
1437
                return 0;
1437
1438
        }
1455
1456
         * - fortunately: polldaemon will immediately shutdown if the
1456
1457
         *   origin doesn't have a status with a snapshot percentage
1457
1458
         */
1458
 
        if (background_polling() && lv_is_merging_origin(lv))
 
1459
        if (background_polling() && lv_is_merging_origin(lv) && lv_is_active_locally(lv))
1459
1460
                lv_spawn_background_polling(cmd, lv);
1460
1461
 
1461
1462
        return 1;
1649
1650
        return 1;
1650
1651
}
1651
1652
 
 
1653
/*
 
1654
 * Read pool options from cmdline
 
1655
 */
1652
1656
int get_pool_params(struct cmd_context *cmd,
1653
 
                    struct profile *profile,
 
1657
                    const struct segment_type *segtype,
1654
1658
                    int *passed_args,
1655
 
                    int *chunk_size_calc_method,
 
1659
                    uint64_t *pool_metadata_size,
 
1660
                    int *pool_metadata_spare,
1656
1661
                    uint32_t *chunk_size,
1657
1662
                    thin_discards_t *discards,
1658
 
                    uint64_t *pool_metadata_size,
1659
1663
                    int *zero)
1660
1664
{
1661
 
        int cache_pool = 0;
1662
 
 
1663
 
        if (!strcmp("cache-pool", arg_str_value(cmd, type_ARG, "none")))
1664
 
                cache_pool = 1;
1665
 
 
1666
 
        if (!cache_pool && !arg_count(cmd, thinpool_ARG)) {
1667
 
                /* Check for arguments that should only go with pools */
1668
 
                if (arg_count(cmd, poolmetadata_ARG)) {
1669
 
                        log_error("'--poolmetadata' argument is only valid when"
1670
 
                                  " converting to pool LVs.");
1671
 
                        return_0;
1672
 
                }
1673
 
        }
1674
 
 
1675
1665
        *passed_args = 0;
1676
 
        if (!cache_pool && arg_count(cmd, zero_ARG)) {
1677
 
                *passed_args |= PASS_ARG_ZERO;
1678
 
                *zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
1679
 
                log_very_verbose("Setting pool zeroing: %u", *zero);
1680
 
        }
1681
 
 
1682
 
        if (!cache_pool && arg_count(cmd, discards_ARG)) {
1683
 
                *passed_args |= PASS_ARG_DISCARDS;
1684
 
                *discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, 0);
1685
 
                log_very_verbose("Setting pool discards: %s",
1686
 
                                 get_pool_discards_name(*discards));
 
1666
 
 
1667
        if (segtype_is_thin_pool(segtype) || segtype_is_thin(segtype)) {
 
1668
                if (arg_count(cmd, zero_ARG)) {
 
1669
                        *passed_args |= PASS_ARG_ZERO;
 
1670
                        *zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n");
 
1671
                        log_very_verbose("Setting pool zeroing: %u", *zero);
 
1672
                }
 
1673
 
 
1674
                if (arg_count(cmd, discards_ARG)) {
 
1675
                        *passed_args |= PASS_ARG_DISCARDS;
 
1676
                        *discards = (thin_discards_t) arg_uint_value(cmd, discards_ARG, 0);
 
1677
                        log_very_verbose("Setting pool discards: %s",
 
1678
                                         get_pool_discards_name(*discards));
 
1679
                }
1687
1680
        }
1688
1681
 
1689
1682
        if (arg_count(cmd, chunksize_ARG)) {
1691
1684
                        log_error("Negative chunk size is invalid.");
1692
1685
                        return 0;
1693
1686
                }
 
1687
 
1694
1688
                *passed_args |= PASS_ARG_CHUNK_SIZE;
1695
 
                *chunk_size = arg_uint_value(cmd, chunksize_ARG, cache_pool ?
1696
 
                                             DM_CACHE_MIN_DATA_BLOCK_SIZE :
1697
 
                                             DM_THIN_MIN_DATA_BLOCK_SIZE);
 
1689
                *chunk_size = arg_uint_value(cmd, chunksize_ARG, 0);
1698
1690
                log_very_verbose("Setting pool chunk size: %s",
1699
1691
                                 display_size(cmd, *chunk_size));
1700
1692
        }
1701
1693
 
1702
 
        if (cache_pool) {
1703
 
                //FIXME: add cache_pool support to update_profilable_pool_params
1704
 
                if (!(*passed_args & PASS_ARG_CHUNK_SIZE))
1705
 
                        *chunk_size = DEFAULT_CACHE_POOL_CHUNK_SIZE * 2;
1706
 
        } else if (!update_profilable_pool_params(cmd, profile, *passed_args,
1707
 
                                                  chunk_size_calc_method,
1708
 
                                                  chunk_size, discards, zero))
1709
 
                return_0;
1710
 
 
1711
1694
        if (arg_count(cmd, poolmetadatasize_ARG)) {
1712
1695
                if (arg_sign_value(cmd, poolmetadatasize_ARG, SIGN_NONE) == SIGN_MINUS) {
1713
1696
                        log_error("Negative pool metadata size is invalid.");
1714
1697
                        return 0;
1715
1698
                }
 
1699
 
 
1700
                if (arg_count(cmd, poolmetadata_ARG)) {
 
1701
                        log_error("Please specify either metadata logical volume or its size.");
 
1702
                        return 0;
 
1703
                }
 
1704
 
1716
1705
                *passed_args |= PASS_ARG_POOL_METADATA_SIZE;
1717
 
        }
1718
 
        *pool_metadata_size = arg_uint64_value(cmd, poolmetadatasize_ARG,
1719
 
                                               UINT64_C(0));
 
1706
                *pool_metadata_size = arg_uint64_value(cmd, poolmetadatasize_ARG,
 
1707
                                                       UINT64_C(0));
 
1708
        } else if (arg_count(cmd, poolmetadata_ARG))
 
1709
                *passed_args |= PASS_ARG_POOL_METADATA_SIZE; /* fixed size */
 
1710
 
 
1711
        /* TODO: default in lvm.conf ? */
 
1712
        *pool_metadata_spare = arg_int_value(cmd, poolmetadataspare_ARG,
 
1713
                                             DEFAULT_POOL_METADATA_SPARE);
1720
1714
 
1721
1715
        return 1;
1722
1716
}
1772
1766
                        return 0;
1773
1767
                }
1774
1768
 
1775
 
                if(arg_uint64_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT * 2) {
 
1769
                if (arg_uint64_value(cmd, stripesize_ARG, 0) > STRIPE_SIZE_LIMIT * 2) {
1776
1770
                        log_error("Stripe size cannot be larger than %s",
1777
1771
                                  display_size(cmd, (uint64_t) STRIPE_SIZE_LIMIT));
1778
1772
                        return 0;