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

150 Commits

Author SHA1 Message Date
Zdenek Kabelac
fbf6b89a84 Using enum types for enums
alloc_policy_t, dm_string_mangling_t, percent_range_t, sign_t
2012-02-28 14:24:57 +00:00
Zdenek Kabelac
cd4c26a27f Set status for error path
Do not leave status unitialized, since in some cases, it's tested,
when the function returns error.
2012-02-08 10:56:17 +00:00
Zdenek Kabelac
6336898318 Thin updated support for thin pool percent
Support to check also for metadata percent
(By checking whether seg pointer is set)
2012-01-19 15:25:37 +00:00
Zdenek Kabelac
7afa7b079c Check for error code in _adjust_policy_params
If error is detected in _adjust_policy_params, break further command processing.
2012-01-09 12:31:52 +00:00
Zdenek Kabelac
4fbde0143a Support rounding of percentage upward
We want to keep this logic -
when LV is extend - extend the LV by at least given amount,
when LV is reduced - reduce the LV by at most given amount.

So for this the rounding needs to be used.
Current logic which seems to satisfy give rule is to round up all
extent values for LV resize upward except for values with '-' sign
that are round downward.

This patch also fixes the problem when  lvextend --use-polices tried
to extend LV the by i.e. 20% - but the resulting 20% were smaller
the extent size thus before this patch no extension happened.
2012-01-05 15:38:18 +00:00
Zdenek Kabelac
0e0f706f2e Thin automatic policy based extension 2011-12-21 13:10:52 +00:00
Jonathan Earl Brassow
d34991ed97 Don't allow size change of RAID LV that is tracking changes for a split image
Don't allow size change of RAID sub-LVs independently
2011-12-01 00:13:16 +00:00
Zdenek Kabelac
6b58c79603 Thin ensure pool table is update after resize
Always make sure table gets reloaded.
For now activate and deactivate pool volume if it's not active.

FIXME: we could do this only if we are sure some thin volume is alive.
2011-11-08 12:19:53 +00:00
Zdenek Kabelac
87371d48cc Thin revert code for exclusive pool activation
There are no limits on thin-pool activation now.
Revert code that is no longer needed.
2011-11-07 10:58:13 +00:00
Zdenek Kabelac
4079a8f298 Avoid lvextend to overflow
Add extra check to extent_count overflow.
Use internal define MAX_EXTENT_COUNT instead UINT32_MAX.
2011-11-04 22:49:53 +00:00
Zdenek Kabelac
daa10ad0fd Thin pool resize support for data LV
Support for extension of pool data LV.

TODO: figure out thin volume for suspend/resume in cluster.
2011-10-28 20:31:01 +00:00
Jonathan Earl Brassow
a80192b6a7 Allow 'nosync' extension of mirrors.
This patch allows a mirror to be extended without an initial resync of the
extended portion.  It compliments the existing '--nosync' option to lvcreate.
This action can be done implicitly if the mirror was created with the '--nosync'
option, or explicitly if the '--nosync' option is used when extending the device.

Here are the operational criteria:
1) A mirror created with '--nosync' should extend with 'nosync' implicitly
[EXAMPLE]# lvs vg; lvextend -L +5G vg/lv ; lvs vg
  LV   VG   Attr     LSize Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   Mwi-a-m- 5.00g                         lv_mlog 100.00
  Extending 2 mirror images.
  Extending logical volume lv to 10.00 GiB
  Logical volume lv successfully resized
  LV   VG   Attr     LSize  Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   Mwi-a-m- 10.00g                         lv_mlog 100.00

2) The 'M' attribute ('M' signifies a mirror created with '--nosync', while 'm'
signifies a mirror created w/o '--nosync') must be preserved when extending a
mirror created with '--nosync'.  See #1 for example of 'M' attribute.

3) A mirror created without '--nosync' should extend with 'nosync' only when
'--nosync' is explicitly used when extending.
[EXAMPLE]# lvs vg; lvextend -L +5G vg/lv; lvs vg
  LV   VG   Attr     LSize  Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   mwi-a-m- 20.00m                         lv_mlog 100.00
  Extending 2 mirror images.
  Extending logical volume lv to 5.02 GiB
  Logical volume lv successfully resized
  LV   VG   Attr     LSize Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   mwi-a-m- 5.02g                         lv_mlog   0.39
vs.
[EXAMPLE]# lvs vg; lvextend -L +5G vg/lv --nosync; lvs vg
  LV   VG   Attr     LSize  Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   mwi-a-m- 20.00m                         lv_mlog 100.00
  Extending 2 mirror images.
  Extending logical volume lv to 5.02 GiB
  Logical volume lv successfully resized
  LV   VG   Attr     LSize Pool Origin Snap%  Move Log     Copy%  Convert
  lv   vg   Mwi-a-m- 5.02g                         lv_mlog 100.00

4) The 'm' attribute must change to 'M' when extending a mirror created without
'--nosync' is extended with the '--nosync' option.  (See #3 examples above.)

5) An inactive mirror's sync percent cannot be determined definitively, so it
must not be allowed to skip resync.  Instead, the extend should ask the user if
they want to extend while performing a resync.
[EXAMPLE]# lvchange -an vg/lv
[EXAMPLE]# lvextend -L +5G vg/lv
  Extending 2 mirror images.
  Extending logical volume lv to 10.00 GiB
  vg/lv is not active.  Unable to get sync percent.
Do full resync of extended portion of vg/lv?  [y/n]: y
  Logical volume lv successfully resized

6) A mirror that is performing recovery (as opposed to an initial sync) - like
after a failure - is not allowed to extend with either an implicit or
explicit nosync option.  [You can simulate this with a 'corelog' mirror because
when it is reactivated, it must be recovered every time.]
[EXAMPLE]# lvcreate -m1 -L 5G -n lv vg --nosync --corelog
  WARNING: New mirror won't be synchronised. Don't read what you didn't write!
  Logical volume "lv" created
[EXAMPLE]# lvs vg
  LV   VG   Attr     LSize Pool Origin Snap%  Move Log Copy%  Convert
  lv   vg   Mwi-a-m- 5.00g                             100.00
[EXAMPLE]# lvchange -an vg/lv; lvchange -ay vg/lv; lvs vg
  LV   VG   Attr     LSize Pool Origin Snap%  Move Log Copy%  Convert
  lv   vg   Mwi-a-m- 5.00g                               0.08
[EXAMPLE]# lvextend -L +5G vg/lv
  Extending 2 mirror images.
  Extending logical volume lv to 10.00 GiB
  vg/lv cannot be extended while it is recovering.

7) If 'no' is selected in #5 or if the condition in #6 is hit, it should not
result in the mirror being resized or the 'm/M' attribute being changed.


NOTE:  A mirror created with '--nosync' behaves differently than one created
without it when performing an extension.  The former cannot be extended when
the mirror is recovering (unless in-active), while the latter can.  This is
a reasonable thing to do since recovery of a mirror doesn't take long (at
least in the case of an on-disk log) and it would cause far more time in
degraded mode if the extension w/o '--nosync' was allowed.  It might be
reasonable to add the ability to force the operation in the future.  This
should /not/ force a nosync extension, but rather force a sync'ed extension.
IOW, the user would be saying, "Yes, yes... I know recovery won't take long
and that I'll be adding significantly to the time spent in degraded mode, but
I need the extra space right now!".
2011-10-06 15:32:26 +00:00
Zdenek Kabelac
da1350d420 Add missing log_error() to lvresize command when fsadm tool fails
Also add test case
2011-09-21 10:39:47 +00:00
Petr Rockai
44dfb51f2a When resizing LVs, always round in the safe direction, regardless of whether we
were called as lvresize or lvreduce.
2011-09-15 18:51:11 +00:00
Milan Broz
b18e1fd50e Fix possible overflow of size if %FREE or %VG is used.
https://bugzilla.redhat.com/show_bug.cgi?id=737087
2011-09-15 15:26:40 +00:00
Alasdair Kergon
9ac61d2ba2 lvcreate parsing for thin provisioning.
The rest is incomplete so this isn't usable yet.
2011-09-06 00:26:42 +00:00
Zdenek Kabelac
077a6755ff Replace free_vg with release_vg
Move the free_vg() to  vg.c  and replace free_vg  with release_vg
and make the _free_vg internal.

Patch is needed for sharing VG in vginfo cache so the release_vg function name
is a better fit here.
2011-08-10 20:25:29 +00:00
Milan Broz
6f14cd22fd Fix lvreduce stripe rounding up from previous commit. 2011-06-15 10:56:52 +00:00
Milan Broz
f4ba9c5d1e Fix mirrored stripe reduction.
Patch adds check for stripe not only in direct
LV segment but also in mirror image segment.

This prevents bugs like:

# lvcreate -i2 -l10 -n lv vg_test
# lvconvert -m1 -i1 vg_test/lv

# lvreduce -f -l1 vg_test/lv
  WARNING: Reducing active logical volume to 4.00 MiB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
  Reducing logical volume lv to 4.00 MiB
  Segment extent reduction 9 not divisible by #stripes 2
  Logical volume lv successfully resized

# lvremove -f vg_test
  Segment extent reduction 1 not divisible by #stripes 2
  LV segment lv:0-4294967295 is incorrectly listed as being used by LV lv_mimage_0
  Internal error: LV segments corrupted in lv_mimage_0.
2011-06-09 19:38:56 +00:00
Milan Broz
851b1a9606 Fix extent rounding for striped segments.
We should never remove more extents than requested by user,
so round up to next stripe boundary during lvreduce.

Also this fixes round to zero sized LV bug:

# lvcreate -i2 -I 64k -l10 -n lvs vg_test
# lvreduce -f -l1 vg_test/lvs
  Rounding size (1 extents) down to stripe boundary size for segment (0 extents)
  WARNING: Reducing active logical volume to 0
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
  Reducing logical volume lvs to 0
  Failed to suspend lvs
2011-06-09 19:34:49 +00:00
Jonathan Earl Brassow
fe93c99ad9 This patch adds the ability to extend 0 length layered LVs. This
allows us to allocate all images of a mirror (or RAID array) at one
time during create.

The current mirror implementation still requires a separate allocation
for the log, however.
2011-04-06 21:32:20 +00:00
Milan Broz
301c2b8822 Use 64bit unsigned value for maximum stripe size test.
While STRIPE_SIZE_LIMIT * 2 is basically UINT_MAX, 32bit integer
value can already overflow durin arg size parsing.

(This really happens in test where --stripesize 4294967291 is used,
in s390x uint overflow and this test is ineffective.)
2011-03-02 16:56:06 +00:00
Zdenek Kabelac
b1b38215ba Add exec_cmd paramater sync_needed
As sync_local_dev_names() cannot be called within activation context,
add new parametr which allows to select if the sync call is needed
before executing new command.
2011-01-13 14:51:32 +00:00
Alasdair Kergon
2b82bd79f5 Rename vg_release to free_vg. 2010-12-08 20:50:48 +00:00
Petr Rockai
8191fe4f4a Refactor the percent (mirror sync, snapshot usage) handling code to use
fixed-point values instead of a combination of a float value and an enum.
2010-11-30 11:53:31 +00:00
Zdenek Kabelac
2955b913ea Use new status code from fsadm check
Patch updates exec_cmd() and adds 3rd parameter with pointer for
status value, so caller might examine returned status code.
If the passed pointer is NULL, behavior is unmodified.

Patch allows to confinue with lvresize if the failure from fsadm check is
caused by mounted filesystem as many of filesystem resize tools do support
online filesystem resize. (originally user had to use flag '-n' to bypass
this filesystem check)
2010-11-01 14:17:35 +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
Alasdair Kergon
2d6fcbf67d Allow internal suspend and resume of origin without its snapshots. 2010-08-17 16:25:32 +00:00
Alasdair Kergon
54d7741a3e Remove no-longer-used arg_ptr_value.
Fix -M and --type to use strings not pointers that change on config refresh.
2010-04-29 01:38:12 +00:00
Alasdair Kergon
1485ce69c4 Permit mimage LVs to be striped in lvcreate and lvresize. 2010-04-09 01:00:10 +00:00
Mike Snitzer
fd817ff34a Don't allow resizing of internal logical volumes.
Prevent lvresize from being able to resize internal LVs: mirror legs
(*_mimage_*), mirror log (*_mlog), snapshot placeholder LVs (snapshot*)
and others.  Resizing these would leads to unexpected metadata and
sometimes crashes (in case of growing snapshot*).
2010-03-20 03:44:04 +00:00
Mike Snitzer
5bc2af2688 Add %ORIGIN support to lv{create,extend,reduce,resize} --extents option
Allow the number of logical extents to be expressed (for a snapshot) as
a percentage of the total space in the Origin Logical Volume with the
suffix %ORIGIN.

Update the relevant man pages accordingly.  Eliminate inconsistencies
between the man pages and tools/commands.h

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-02-03 03:58:08 +00:00
Mike Snitzer
df13cf08d5 Add missing 'stack;' for all suspend_lv and resume_lv callers.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 21:07:31 +00:00
Milan Broz
fec4de9563 Fix tools to report error when stopped by user.
(And do not produce internal error message.)
2009-12-03 19:18:33 +00:00
Milan Broz
ba3851fda6 Fix lvcreate processing of %PVS argument.
- fix missing unlocking of VG
lvcreate -l 100%PVS -n lv1 vg_test
  Please specify physical volume(s) with %PVS
  Internal error: Volume Group vg_test was not unlocked

- if no PVS specified, use all available

Fix segfault if %PVS in lvresize without PVs list.
2009-11-04 14:47:27 +00:00
Alasdair Kergon
a8fb89adaf Tidy some uses of arg_count and introduce arg_is_set. 2009-11-03 15:50:42 +00:00
Dave Wysochanski
4c611a220a Fix vg_read() error paths to properly release upon vg_read_error().
Fix vg_read() error paths to properly release upon vg_read_error().
Note that in the iterator paths (process_each_*()), we release
inside the iterator so no individual cleanup is needed.  However there
are a number of other places we missed the cleanup.  Proper cleanup
when vg_read_error() is true should be calling vg_release(vg), since
there should be no locks held if we get an error (except in certain
special cases, which IMO we should work to remove from the code).

Unfortunately the testsuite is unable to detect these types of memory
leaks.  Most of them can be easily seen if you try an operation
(e.g. lvcreate) with a volume group that does not exist.  Error
message looks like this:
  Volume group "vg2" not found
  You have a memory leak (not released memory pool):
   [0x1975eb8]
  You have a memory leak (not released memory pool):
   [0x1975eb8]


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-07 01:18:35 +00:00
Dave Wysochanski
b8b3508c59 Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).
Sun May  3 11:40:51 CEST 2009  Petr Rockai <me@mornfall.net>
  * Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).

Rebased 6/26/09 by Dave W.
2009-07-01 16:59:37 +00:00
Alasdair Kergon
f7c76e3878 revert last patch - let's do a release first 2009-06-26 10:55:57 +00:00
Dave Wysochanski
96d0004d12 Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).
Sun May  3 11:40:51 CEST 2009  Petr Rockai <me@mornfall.net>
  * Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).


Author: Petr Rockai <prockai@redhat.com>
Committer: Dave Wysochanski <dwysocha@redhat.com>
2009-06-26 09:47:36 +00:00
Alasdair Kergon
2f5a1df42c Abort if automatic metadata correction fails when reading VG to update it. 2009-06-26 09:19:13 +00:00
Alasdair Kergon
25a2e7b80e Pre-release cleanups. 2009-05-21 03:04:52 +00:00
Milan Broz
eb91c4eee3 Use suspend with flush when device size was changed during table preload.
This allows online mirror resize, also removes condition to preventing
code to do this.
2009-05-20 09:52:37 +00:00
Milan Broz
8f3fd69ffa Move metadata backup call after vg_commit.
The backup() call store metadata from memory.

But in cluster backup() call performs
remote nodes metadata backup and it reads data from disk.

For metadata backup consistency,
patch moves all backup() calls after vg_commit.

(Moreover, some tools already do that this way.)
2009-04-21 14:31:57 +00:00
Milan Broz
043b13625b Properly release VG memory pool in all CLI tools. 2009-04-10 10:01:38 +00:00
Alasdair Kergon
2b23864219 . 2009-02-28 19:43:42 +00:00
Alasdair Kergon
ed82bfd2ba Attempt cleanup in child before execing new binary in exec_cmd() 2009-02-28 00:54:06 +00:00
Alasdair Kergon
8a4e6cac0a . 2009-02-27 23:55:15 +00:00
Alasdair Kergon
bc175d2870 fsadm cleanups & release prep 2009-02-27 23:40:11 +00:00
Zdenek Kabelac
c8669f6b13 Fixed bug where lvresize option -t was not properly passed to fsadm.
Using argv[] list in exec_cmd() to allow more params for external commands.
Fsadm does not allow checking mounted filesystem.
Fsadm no longer accepts 'any other key' as 'no' answer to y/n.
Fsadm improved handling of command line options.
2009-02-24 15:48:00 +00:00