1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 11:55:55 +03:00
Commit Graph

213 Commits

Author SHA1 Message Date
Alasdair Kergon
972d37f570 test 2011-05-24 14:00:57 +00:00
Alasdair Kergon
33bd9138fa test 2011-05-24 13:53:26 +00:00
Alasdair Kergon
0b70507434 Add and use dev_open_readonly and variations. 2011-05-24 13:36:57 +00:00
Alasdair Kergon
2c56f60db4 Set pv_min_size to 2048KB to exclude floppy drives.
Previously was 512.
2011-04-28 17:33:34 +00:00
Peter Rajnoha
edcda01a1e Obtain device list from udev by default if LVM2 is compiled with udev support.
Also, add a new 'obtain_device_list_from_udev' setting to lvm.conf with which
we can turn this feature on or off if needed.

If set, the cache of block device nodes with all associated symlinks
will be constructed out of the existing udev database content.
This avoids using and opening any inapplicable non-block devices or
subdirectories found in the device directory. This setting is applied
to udev-managed device directory only, other directories will be scanned
fully. LVM2 needs to be compiled with udev support for this setting to
take effect. N.B. Any device node or symlink not managed by udev in
udev directory will be ignored with this setting on.
2011-04-22 12:05:32 +00:00
Mike Snitzer
fdc8670327 Add "devices/issue_discards" to lvm.conf.
Issue discards on lvremove if enabled and both storage and kernel have support.
2011-04-12 21:59:01 +00:00
Zdenek Kabelac
027a55d0fb Optimise _eat_space and _get_token
Makes the code more readable and has a smaller number of memory
accesses thus it's small optimisation as well.

For _get_token() optimize number parsing. Check for '.' char only
if it's not a digit. Move pointer incrementation into one place.

For _eat_space() check only p->te for '\0' in skipping of comment line.
Avoid check for '\0' when we know it is space. Also master while loop
doesn't need checking p->tb for '\0'. We just need to check p->tb
isn't already at the end of buffer. This could give 'extra' loop cycle
if we are already there - but safes memory access in every other case.
2011-03-10 14:51:35 +00:00
Zdenek Kabelac
36653e8903 Add fall through comments
Add comments to switch case construct.
2011-02-28 19:53:03 +00:00
Alasdair Kergon
92ffcda183 Various changes to the allocation algorithms: Expect some fallout.
There is a lot to test.

Two new config settings added that are intended to make the code behave
closely to the way it did before - worth a try if you find problems.
2011-02-27 00:38:31 +00:00
Zdenek Kabelac
9dd091e4f4 Support 64bit ints in config 2011-02-18 14:08:22 +00:00
Zdenek Kabelac
7f8badfe5e Use memcpy and add error message
strncpy (which check each byte for \0) is not need as we always copy
the length size - so using memcpy is a bit cheaper.

Add missing log_error message for failed allocation.
2011-01-28 10:19:00 +00:00
Zdenek Kabelac
f7e7f3e3ed Add checks for allocation errors in config node clonning.
Add checks for clonning allocation a fail-out when something is
not allocated correctly.

Also move var declaration to the begining of the function
and fix log_error messages.
2010-12-20 13:53:10 +00:00
Zdenek Kabelac
ba96eb24fa Some const cleanups
Minor const warning fixes and internal API updates.
2010-12-20 13:19:13 +00:00
Zdenek Kabelac
760d1fac55 Add more strict const pointers around config tree
To have better control were the config tree could be modified use more
const pointers and very carefully downcast them back to non-const
(for config tree merge).
2010-12-20 13:12:55 +00:00
Zdenek Kabelac
14caa4a2d0 Add missing test for failed pool allocation
Add test for NULL from dm_poll_create.
Reorder dm_pool_destroy() before file close and add label out:.
Avoid leaking file descriptor if the allocation fails.
2010-11-30 22:23:35 +00:00
Zdenek Kabelac
7d11d708d8 Move va_end() so it is also used before error path return 2010-11-23 15:08:57 +00:00
Alasdair Kergon
b83af51668 Add global/metadata_read_only to use unrepaired metadata in read-only cmds. 2010-10-25 11:20:54 +00:00
Petr Rockai
a341cab721 Implement automatic snapshot extension with dmeventd, and add two new options
to lvm.conf in the activation section: 'snapshot_autoextend_threshold' and
'snapshot_autoextend_percent', that define how to handle automatic snapshot
extension. The former defines when the snapshot should be extended: when its
space usage exceeds this many percent. The latter defines how much extra space
should be allocated for the snapshot, in percent of its current size.
2010-10-15 16:28:14 +00:00
Petr Rockai
976b95d929 Limit repeated accesses to broken devices.
Signed-off-by: Takahiro Yasui <takahiro.yasui@hds.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-10-13 15:40:38 +00:00
Alasdair Kergon
ac0252ca07 Add dm_zalloc and use it and dm_pool_zalloc throughout. 2010-09-30 21:06:50 +00:00
Alasdair Kergon
44a31a9c2f Speed up CRC32 calculations by using a larger lookup table.
Use -DDEBUG_CRC32 to revert to old function and check new one gives same result.
2010-09-27 19:09:34 +00:00
Mike Snitzer
7063efe1bd Switch to using configure --with-default-data-alignment=<NUM> to
establish DEFAULT_DATA_ALIGNMENT.  Again, 0=64KiB, 1=1MiB, 2=2MiB

Default is 1.
2010-08-20 22:24:58 +00:00
Mike Snitzer
4efb1d9cbb Update heuristic used for default and detected data alignment.
Add "devices/default_data_alignment" to lvm.conf to control the internal
default that LVM2 uses: 0==64k, 1==1MB, 2==2MB, etc.

If --dataalignment (or lvm.conf's "devices/data_alignment") is specified
then it is always used to align the start of the data area.  This means
the md_chunk_alignment and data_alignment_detection are disabled if set.

(Same now applies to pvcreate --dataalignmentoffset, the specified value
will be used instead of the result from data_alignment_offset_detection)

set_pe_align() still looks to use the determined default alignment
(based on lvm.conf's default_data_alignment) if the default is a
multiple of the MD or topology detected values.
2010-08-20 20:59:05 +00:00
Alasdair Kergon
d1e8046f56 Various small cleanups and fixes related to monitoring. 2010-08-16 22:54:35 +00:00
Mike Snitzer
b123a82d73 Change default alignment of pe_start to 1MB.
The new standard in the storage industry is to default alignment of data
areas to 1MB.  fdisk, parted, and mdadm have all been updated to this
default.

Update LVM to align the PV's data area start (pe_start) to 1MB.  This
provides a more useful default than the previous default of 64K (which
generally ended up being a 192K pe_start once the first metadata area
was created).

Before this patch:
# pvs -o name,vg_mda_size,pe_start
  PV         VMdaSize  1st PE
  /dev/sdd     188.00k 192.00k

After this patch:
# pvs -o name,vg_mda_size,pe_start
  PV         VMdaSize  1st PE
  /dev/sdd    1020.00k   1.00m

The heuristic for setting the default alignment for LVM data areas is:
- If the default value (1MB) is a multiple of the detected alignment
  then just use the default.
- Otherwise, use the detected value.

In practice this means we'll almost always use 1MB -- that is unless:
- the alignment was explicitly specified with --dataalignment
- or MD's full stripe width, or the {minimum,optimal}_io_size exceeds
  1MB
- or the specified/detected value is not a power-of-2
2010-08-12 04:11:48 +00:00
Mike Snitzer
dff224669d Require --restorefile when using pvcreate --uuid.
Introduce --norestorefile to allow user to override the new requirement.

This can also be overridden with "devices/require_restorefile_with_uuid"
in lvm.conf -- however the default is 1.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-08-12 04:08:59 +00:00
Alasdair Kergon
08f1ddea6c Use __attribute__ consistently throughout. 2010-07-09 15:34:40 +00:00
Dave Wysochanski
7985f80c63 Add pvmetadatacopies to lvm.conf and pvcreate man pages. 2010-06-30 12:49:28 +00:00
Dave Wysochanski
a5bf70018b Add --metadataignore to pvcreate.
Allow metadataignore flag to be passed in to pvcreate.
Ideally, more refactoring of the mda allocation / initialization
is warranted, but for now, we just add another parameter to 'add_mda'
to take an existing mda ignored flag.  We need to do this or pv_write
loses the state of the mda 'ignored' flag before copying and writing
to disk.
2010-06-30 12:17:24 +00:00
Dave Wysochanski
88d7dc1af8 Add mda_copies to VG structures and initialization.
Add a field to struct volume_group to later implement metadata
balancing:
- mda_copies: target # of non-ignored mdas in the VG; default 0 (do
not control pv 'ignore mdas' bit.

This patch just adds the parameter to the structures with the default
values but does not modify any commands.  Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:36:37 +00:00
Alasdair Kergon
3399ae320a Add install_system_dirs makefile target.
Add configure options for system and locking directories.
2010-05-20 13:47:21 +00:00
Alasdair Kergon
0693099223 Don't ignore error if resuming any LV fails in resume_lvs.
Skip closing persistent filter cache file if open failed.
2010-04-12 11:52:53 +00:00
Alasdair Kergon
258db3ad8e Change most remaining log_error WARNING messages to log_warn. 2010-04-01 10:34:09 +00:00
Zdenek Kabelac
18b82048e4 mlockall() -> mlock()
This patch adds a new implementation of locking function instead
of mlockall() that may lock way too much memory (>100MB).
New function instead uses mlock() system call and selectively locks
memory areas from /proc/self/maps trying to avoid locking areas
unused during lock-ed state.

Patch also adds struct cmd_context to all memlock() calls to have
access to configuration.

For backward compatibility functionality of mlockall()
is preserved with "activation/use_mlockall" flag.

As a simple check, locking and unlocking counts the amount of memory
and compares whether values are matching.
2010-03-05 14:48:33 +00:00
Peter Rajnoha
cda69e17ef Add activation/udev_rules config option in lvm.conf.
Add dm_tree_add_dev_with_udev_flags to provide wider support for udev flags.
2010-01-07 19:54:21 +00:00
Milan Broz
03984e05a3 Rename mirror_device_fault_policy to mirror_image_fault policy 2010-01-06 13:27:06 +00:00
Mike Snitzer
7a8fa6aaab Add a [--poll {y|n}] flag to vgchange and lvchange to control whether
the background polldaemon is allowed to start.  It can be used
standalone or in conjunction with --refresh or --available y.

Control over when the background polldaemon starts will be particularly
important for snapshot-merge of a root filesystem.

Dracut will be updated to activate all LVs with: --poll n

The lvm2-monitor initscript will start polling with: --poll y

NOTE: Because we currently have no way of knowing if a background
polldaemon is active for a given LV the following limitations exist and
have been deemed acceptable:
1) it is not possible to stop an active polldaemon; so the lvm2-monitor
   initscript doesn't stop running polldaemon(s)
2) redundant polldaemon instances will be started for all specified LVs
   if vgchange or lvchange are repeatedly used with '--poll y'

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 20:56:51 +00:00
Petr Rockai
99a304bc17 Optionally abort on internal errors (and leverage this option in the
testsuite). (This is showing a problem in the pvmove test for me, so I expect
the tests to start failing -- this needs to be fixed separately though.)
2009-11-30 17:17:11 +00:00
Milan Broz
5800aa5c07 Do not allow creating mirrors of more than 8 images.
This is kernel limitation in all kernel versions,
so better detect this early.
2009-11-27 14:35:38 +00:00
Petr Rockai
6ce24f679a Fix the "const discarded" warnings introduced in the unknown segment patch. 2009-10-22 10:38:07 +00:00
Petr Rockai
b4048242f5 Handle metadata with unknown segment types more gracefully. 2009-10-16 17:41:49 +00:00
Alasdair Kergon
cf65a124e6 Correct example.conf to indicate that lvm2 not lvm1 is the default format.
Remove an unused stray LVM1_SUPPORT ifdef.
2009-10-05 12:44:20 +00:00
Alasdair Kergon
95eaa68309 Add global/si_unit_consistency to enable cleaned-up use of units in output.
Add configure --enable-units-compat to set si_unit_consistency off by default.

Use standard output units for 'PE Size' and 'Stripe size' in pv/lvdisplay.
2009-09-28 16:23:44 +00:00
Petr Rockai
74aa6b5620 Implement write lock prioritisation for file locking and make it default. 2009-09-02 14:47:39 +00:00
Alasdair Kergon
cf8235e0aa Add activation/udev_sync to lvm.conf. 2009-08-04 15:36:13 +00:00
Mike Snitzer
2aabcc1c1c Add devices/data_alignment_detection to lvm.conf.
Adds 'data_alignment_detection' config option to the devices section of
lvm.conf.  If your kernel provides topology information in sysfs (linux
>= 2.6.31) for the Physical Volume, the start of data area will be
aligned on a multiple of the ’minimum_io_size’ or ’optimal_io_size’
exposed in sysfs.

minimum_io_size is used if optimal_io_size is undefined (0).  If both
md_chunk_alignment and data_alignment_detection are enabled the result
of data_alignment_detection is used.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-08-01 17:08:43 +00:00
Mike Snitzer
57b660356e Add devices/data_alignment_offset_detection to lvm.conf.
If the pvcreate --dataalignmentoffset option is not specified the start
of a PV's aligned data area will be shifted by the associated
'alignment_offset' exposed in sysfs (unless
devices/data_alignment_offset_detection is disabled in lvm.conf).

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-08-01 17:07:36 +00:00
Dave Wysochanski
9085c301e0 Rename _override_settings into override_config_tree_from_string and move.
Move _override_settings from tools/lvmcmdline.c into lib/config/config.c
and export so we can re-use in liblvm.
2009-07-27 21:01:56 +00:00
Alasdair Kergon
1cc59fa4ac Add global/wait_for_locks to lvm.conf so blocking on locks can be disabled. 2009-07-24 23:28:55 +00:00
Milan Broz
25497e2fa5 Fix confusing metadata syntax error messages.
If there is syntax error in metadata, it now prints messages
like:
  Couldn't read 'start_extent' for segment 'extent_count'.
  Couldn't read all logical volumes for volume group vg_test.

The segment specification is wrong and confusing.

Patch fixes it by introducing "parent" member in config_node which
points to parent section and config_parent_name function, which
provides pointer to node section name.

Also it adds several LV references where possible.
2009-07-09 11:29:00 +00:00
Dave Wysochanski
9af5a142d0 Add defines for default vgcreate parameters. 2009-07-09 10:00:36 +00:00
Milan Broz
c26488d348 Use lvconvert --repair instead of vgreduce in mirror dmeventd DSO (mornfall)
Introduce lvconvert --use_policies (mornfall)
2009-06-04 12:01:15 +00:00
Milan Broz
aa8111b3cd fix some issues when compiling with -D DEBUG_POOL
- fix compilation issues
- fix wrong pool object maipulation (lvm dumpconfig triggers assert)
- second iteration in loop _log_parallel_areas operates on non-existing object
2009-03-26 09:25:18 +00:00
Alasdair Kergon
2c44337bd5 Right, a simple build (without options) is working again. 2008-11-03 22:14:30 +00:00
Alasdair Kergon
8c5bcdabab Improve the way VGs with PVs missing are handled so manual intervention
is required in fewer circumstances.  (mornfall)
2008-09-19 06:42:00 +00:00
Alasdair Kergon
86fb36e2b0 Add device/md_chunk_alignment to lvm.conf 2008-09-19 05:33:37 +00:00
Zdenek Kabelac
74b91fad28 * more strict const 2008-08-07 14:02:32 +00:00
Alasdair Kergon
131bc6f091 Avoid looping forever in _pv_analyze_mda_raw used by pvck. 2008-07-31 13:07:01 +00:00
Alasdair Kergon
1f787aca28 Add --rows to reports. 2008-06-24 22:48:53 +00:00
Alasdair Kergon
30ef4c738a Add --unquoted to reporting tools. 2008-06-24 21:21:04 +00:00
Alasdair Kergon
dcd5353502 Correct config file line numbers in messages when parsing comments. (kabi) 2008-06-03 17:51:04 +00:00
Alasdair Kergon
f419a87150 Add --prefixes to reporting tools for field name prefix output format.
E.g. lvs --prefixes --noheadings --unbuffered --units m --nosuffix

(Used '--prefixes' for now, but I'm looking for a better name.)
2008-04-20 00:15:08 +00:00
Alasdair Kergon
d4ce89d9da Escape double quotes and backslashes in external metadata and config data.
Add functions for escaping double quotes in strings.
Rename count_chars_len to count_chars.
2008-03-12 16:03:22 +00:00
Alasdair Kergon
bcacf9d0e3 Use return_0 in a couple more places.
Correct a function name typo in _line_append error message.
2008-03-10 18:51:27 +00:00
Alasdair Kergon
c51b9fff19 Use stack return macros throughout. 2008-01-30 13:19:47 +00:00
Alasdair Kergon
3650e518e7 fix default extent_size 2008-01-17 15:31:18 +00:00
Dave Wysochanski
b8daca8570 Allow vgcreate options as input to vgsplit when new vg is split destination. 2008-01-14 21:07:58 +00:00
Alasdair Kergon
4d8033dc84 correct field name 2008-01-10 22:21:25 +00:00
Alasdair Kergon
114557c04b Add lv_convert field to default lvs output. 2008-01-10 19:25:07 +00:00
Alasdair Kergon
dd007cfdd5 Append fields to report/pvsegs_cols_verbose.
Permit LV segment fields with PV segment reports.
  Add seg_start_pe and seg_pe_ranges to reports.
2007-12-14 21:53:02 +00:00
Alasdair Kergon
b4068515e8 Enhance the management of readahead settings. 2007-11-09 16:51:54 +00:00
Alasdair Kergon
21bc366486 Clean up numerous compiler warnings that crept in recently.
Remove several unused parameters from _allocate().
2007-08-22 14:38:18 +00:00
Alasdair Kergon
edb3374d32 Clean up mirrorlog argument processing.
Only permit --force, --verbose and --debug arguments to be repeated.
2007-08-21 19:46:36 +00:00
Alasdair Kergon
be6845999b Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1. 2007-08-20 20:55:30 +00:00
Jim Meyering
1a5d6bd23d Detect stream write failure reliably; new fn: lvm_fclose; use dm_fclose
* lib/misc/lvm-file.c (lvm_fclose): New function.
* lib/misc/lvm-file.h (lvm_fclose): Declare it.
* lib/config/config.c (write_config_file): Use the new function to detect
and diagnose unlikely write failure.
* lib/filters/filter-persistent.c (persistent_filter_dump): Likewise.
* lib/format_text/archive.c (archive_vg): Likewise.
* lib/format_text/format-text.c (_vg_write_file): Likewise.
* lib/log/log.c (fin_log): Similar, but use dm_fclose directly.
Include "\n" at end of each fprintf format string.
2007-07-24 17:48:08 +00:00
Jim Meyering
bbcd24607c Use gcc's printf attribute wherever possible.
* daemons/clvmd/clvmd.h (debuglog): Add __attribute__((printf)).
* lib/config/config.c (_line_append): Likewise.
* lib/misc/lvm-string.h (emit_to_buffer): Likewise.
2007-07-20 15:38:19 +00:00
Jim Meyering
e732de541e In _line_append, use "sizeof buf - 1" rather than equivalent "4095"
* lib/config/config.c:
2007-07-20 15:26:39 +00:00
Alasdair Kergon
68c87619bd Fix dumpconfig to use log_print instead of stdout directly. 2007-07-08 22:51:20 +00:00
Dave Wysochanski
7da624db7b Fix a couple benign warnings by adding variable initializations. 2007-06-13 15:11:19 +00:00
Alasdair Kergon
19eb95f72f Fix get_config_uint64() to read a 64-bit value not a 32-bit one. 2007-04-27 20:41:50 +00:00
Dave Wysochanski
867c3249cb Fix warnings on x86_64 involving ptrdiff_t:
config/config.c:493: warning: format '%d' expects type 'int', but argument 5 has type 'long int'

Modified original patch from Jim Meyering <jim@meyering.net>
2007-04-26 16:40:46 +00:00
Dave Wysochanski
084a8bdcbc Add support functions for analysis of config sections,
and hence, on-disk LVM2 metadata.

--
2007-04-25 20:38:39 +00:00
Dave Wysochanski
662e0238f0 Add dev_read_circular, read 2 regions on same device. 2007-04-19 02:10:42 +00:00
Alasdair Kergon
af91456949 Fix two more segfaults if an empty config file section encountered. 2007-03-08 19:22:52 +00:00
Alasdair Kergon
87cec8eb5e Move .cache file into a new /etc/lvm/cache directory by default.
Add devices/cache_dir & devices/cache_file_prefix, deprecating devices/cache.
Create directory in fcntl_lock_file() if required.
2007-02-28 18:27:13 +00:00
Alasdair Kergon
f247a4e76f Add devices/ignore_suspended_devices to ignore suspended dm devices. 2007-01-25 21:22:30 +00:00
Alasdair Kergon
2e1b92e3ea Add some missing close() and fclose() return code checks.
Fix exit statuses of reporting tools (2.02.19).
2007-01-25 14:37:48 +00:00
Alasdair Kergon
6a91a99b1b Fix a segfault if an empty config file section encountered. 2007-01-17 16:22:59 +00:00
Alasdair Kergon
2eeb2a1f54 dumpconfig accepts a list of configuration variables to display.
Change dumpconfig to use --file to redirect output to a file.
2007-01-09 23:22:31 +00:00
Alasdair Kergon
9ce2c9bfc1 fix _find_config_node: null parameter is permitted 2006-11-21 15:13:36 +00:00
Alasdair Kergon
9f7e77099b Warn if certain duplicate config file entries are seen.
(not thoroughly tested)
2006-11-16 17:36:00 +00:00
Alasdair Kergon
c1c16a8f01 Protect .cache manipulations with fcntl locking.
Change .cache timestamp comparisons to use ctime.
2006-11-04 03:34:10 +00:00
Alasdair Kergon
dc4d7417f7 When using local file locking, skip clustered VGs.
Add fallback_to_clustered_locking and fallback_to_local_locking parameters.
2006-09-02 01:18:17 +00:00
Alasdair Kergon
1c792fad4f Change default locking_lib to liblvm2clusterlock.so. 2006-08-31 20:56:33 +00:00
Alasdair Kergon
916490f8bf Add lvm_getpagesize wrapper. 2006-08-17 18:23:44 +00:00
Alasdair Kergon
2293567c8c Fix lvcreate corelog validation.
Add --config for overriding most config file settings from cmdline.
  Quote arguments when printing command line.
  Remove linefeed from 'initialising logging' message.
  Add 'Completed' debug message.
  Don't attempt library exit after reloading config files.
  Always compile with libdevmapper, even if device-mapper is disabled.
2006-05-16 16:48:31 +00:00
Alasdair Kergon
3e3d5d8593 Add --monitor to vgcreate and lvcreate to control dmeventd registration.
Propagate --monitor around cluster.
Filter LCK_NONBLOCK in clvmd lock_vg.
2006-05-12 19:16:48 +00:00
Alasdair Kergon
aeb2c277a8 Add mirror log fault-handling policy. 2006-05-11 19:45:53 +00:00
Alasdair Kergon
2c7fbadeef more coverity fixes 2006-05-10 17:49:25 +00:00
Alasdair Kergon
8b4273d298 missing { 2006-04-28 21:07:19 +00:00