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

205 Commits

Author SHA1 Message Date
Zdenek Kabelac
b66b72b115 get_alloc_string: compare only enum
Instead of possibly checking for cling_by_tags string twice,
just compare resulting alloc number from search loop.
2024-10-30 12:57:34 +01:00
Zdenek Kabelac
39b7d1ba8f cleanup: typos in comments
Collection of typos in code comments.
Should have no runtime effect.
2024-08-30 16:51:15 +02:00
Zdenek Kabelac
0bcf2c6514 const: use arrays of strings
Such string is stored directly in '.rodata' section.
2024-05-04 01:01:57 +02:00
Zdenek Kabelac
960df88621 cov: validate i before underflow
Although it can't happen in this code, ensure 'i' is not 0
before decrementing it.
2024-03-29 01:34:22 +01:00
Zdenek Kabelac
5ce236a691 gcc: correct signess comparation
Compare int to int and unsigned to unsigned...
2023-07-13 21:31:18 +02:00
Zdenek Kabelac
178df1c8f4 gcc-fanalyzer: helping understand answer is not null
gcc can't easily see pointer 'answer' is only being checked once 'ret > 0'.
2021-09-21 21:03:47 +02:00
Leo Yan
ef1c57e68f lib: locking: Add new type "idm"
We can consider the drive firmware a server to handle the locking
request from nodes, this essentially is a client-server model.
DLM uses the kernel as a central place to manage locks, so it also
complies with client-server model for locking operations.  This is
why IDM and DLM are similar with each other for their wrappers.

This patch largely works by generalizing the DLM code paths and then
providing degeneralized functions as wrappers for both IDM and DLM.

Signed-off-by: Leo Yan <leo.yan@linaro.org>
2021-05-20 16:01:05 -05:00
Zdenek Kabelac
14008ead2a lvdisplay: fix show of merged thin snapshot
When lvdisplay was executed and thin snaphost has be merged to
thin origin and the operation has been postponed till devices
are closed, command crashed.

Check LV is COW before trying to check snapshot percentage.
2021-02-17 11:21:35 +01:00
Heinz Mauelshagen
f08ef23856 lvdisplay: enhance LV status output for raid(0)
In case legs of a raid0 LV are removed, the lvdisplay command still
reports 'available' though raid0 is not providing any resilience
compared to the other raid levels.

Also lvdisplay does not display '(partial)' in case of missing raid0
legs as oposed to the lvs command.

Enhance lvdisplay to report "NOT available" for any RaidLV type in case
too many legs are inaccessible hence causing data loss.  I.e. any leg
for raid0, all for raid1, more than 1 for raid4/5, more than 2 for raid6
and in case of completely lost mirror groups for raid10.

Add test/shell/lvdisplay-raid.sh.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1872678
2021-01-27 16:56:22 +01:00
Zdenek Kabelac
7bafae48bb gcc: cleanup warns from older gcc 2020-10-26 13:06:53 +01:00
Zdenek Kabelac
4de6f58085 thin: use lv_status_thin and lv_status_thin_pool
Introduce structures lv_status_thin_pool and
lv_status_thin  (pair to lv_status_cache, lv_status_vdo)

Convert lv_thin_percent() -> lv_thin_status()
and  lv_thin_pool_percent() + lv_thin_pool_transaction_id() ->
lv_thin_pool_status().

This way a function user can see not only percentages, but also
other important status info about thin-pool.

TODO:
This patch tries to not change too many other things,
but pool_below_threshold() now uses new thin-pool info to return
failure if thin-pool cannot be actually modified.
This should be handle separately in a better way.
2020-09-29 10:43:56 +02:00
David Teigland
9a88a9c4ce Revert "lvdisplay: dispaly correct status when underlying devs missing"
This reverts commit 1d0dc74f91.

We should avoid adding anything new to lvdisplay and report
new information via lvs reporting fields.
2020-08-28 13:28:15 -05:00
Zhao Heming
1d0dc74f91 lvdisplay: dispaly correct status when underlying devs missing
reproducible steps:
1. vgcreate vg1 /dev/sda /dev/sdb
2. lvcreate --type raid0 -l 100%FREE -n raid0lv vg1
3. do remove the /dev/sdb action
4. lvdisplay show wrong 'LV Status'

After removing raid0 type LV underlying dev, lvdisplay still display
'available'. This is wrong status for raid0.

This patch add a new function raid_is_available(), which will handle
all raid case.

With this patch, lvdisplay will show
from:
  LV Status              available
to:
  LV Status              NOT available (partial)

Reviewed-by: Enzo Matsumiya <ematsumiya@suse.com>
Signed-off-by: Zhao Heming <heming.zhao@suse.com>
2020-08-24 09:47:04 -05:00
Zdenek Kabelac
98419e0667 display: try to show status for inactive vdopool
Since we now support activation of 'vdo' volume
without explicit activation of 'vdopool' it's now possible
to have active layer vdopool (-vpool) volume and
having vdopool itself inactive - yet still in this
case we can show available stats for this volume.
But we need to show correct activation status and other
standard info.
2019-10-04 17:31:55 +02:00
Zdenek Kabelac
cb5f0bdba9 cache: report for succesful status 2019-10-04 17:31:55 +02:00
Zdenek Kabelac
5807993bbf display: basic vdo segment lvdisplay and lvs support
Print some basic info about vdo segment.

'lvdisplay -m' ATM shows the most.
lvs  shows usage percentage.
2018-07-09 15:28:35 +02:00
Joe Thornber
7f97c7ea9a build: Don't generate symlinks in include/ dir
As we start refactoring the code to break dependencies (see doc/refactoring.txt),
I want us to use full paths in the includes (eg, #include "base/data-struct/list.h").
This makes it more obvious when we're breaking abstraction boundaries, eg, including a file in
metadata/ from base/
2018-05-14 10:30:20 +01:00
David Teigland
c1cd18f21e Remove lvm1 and pool disk formats
There are likely more bits of code that can be removed,
e.g. lvm1/pool-specific bits of code that were identified
using FMT flags.

The vgconvert command can likely be reduced further.

The lvm1-specific config settings should probably have
some other fields set for proper deprecation.
2018-04-30 16:55:02 -05:00
Zdenek Kabelac
275fc2d45b coverity: validate retval from get_only_segment_using_this_lv 2017-06-27 00:27:36 +02:00
Zdenek Kabelac
1bd4b0059b cleanup: use display_percent
Replace occurence of %.2f with call of display_percent function.
2017-06-24 17:44:42 +02:00
Zdenek Kabelac
07eec06f5d display: add display_percent function
Add universal function to print dm_percent_t values via single
code path.

TODO: extend with configurale precision of printed values.
2017-06-24 17:44:42 +02:00
Zdenek Kabelac
52935b5834 cache: enhance lvdisplay for cache volumes
Better support for lvdisplay.
By default info about running (in kernel) cache status is printed.
To get 'segtype' info, user runs: 'lvdisplay -m',  example:

  --- Logical volume ---
  LV Path                /dev/vg/lvol0
  LV Name                lvol0
  VG Name                vg
  LV UUID                Y4uWuN-TBGk-duer-aPWl-yBWn-iFFR-RU1gg1
  LV Write Access        read/write
  LV Creation host, time linux, 2017-03-01 20:52:39 +0100
  LV Cache pool name     lvol2
  LV Cache origin name   lvol0_corig
  LV Status              available
  # open                 0
  LV Size                12,00 MiB
  Cache used blocks      10,42%
  Cache metadata blocks  0,49%
  Cache dirty blocks     0,00%
  Cache read hits/misses 112 / 34
  Cache wrt hits/misses  133 / 0
  Cache demotions        0
  Cache promotions       20
  Current LE             3
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Segments ---
  Logical extents 0 to 2:
    Type		cache
    Chunk size		64,00 KiB
    Metadata format	1
    Mode		writethrough
    Policy		smq
      Setting		migration_threshold=100000
2017-03-10 19:33:01 +01:00
Zdenek Kabelac
37a33d7414 cleanup: warns from older gcc 2016-07-01 00:44:48 +02:00
Zdenek Kabelac
35612bd27c display: yes no prompt improvement
Original code missed to catch all apperances of SIGINT.
Also enhance logging when running in shell without tty.
Accept this regex as valid input:
'^[ ^t]*([Yy]([Ee]([Ss]|)|)|[Nn]([Oo]|))[ ^t]*$'
2016-06-10 16:00:31 +02:00
Alasdair G Kergon
0778d2e985 display: Avoid internal snapshot LV names in msgs.
vg/snapshotN should not appear anywhere.

No code should be showing this, but it was noticed in some logs last
week and we can deal with it in display_lvname().
2016-04-21 00:30:17 +01:00
Peter Rajnoha
b114b4d723 commands: lvdisplay: recognize -H|--history switch 2016-03-04 10:27:45 +01:00
Peter Rajnoha
28f96d5ab6 report: display lv_name,lv_uuid,vg_name,lv_time and new lv_time_removed for historical LVs 2016-03-03 13:49:14 +01:00
Zdenek Kabelac
fcbef05aae doc: change fsf address
Hmm rpmlint suggest fsf is using a different address these days,
so lets keep it up-to-date
2016-01-21 12:11:37 +01:00
Alasdair G Kergon
af1c7bf0c7 libdm: Add dm_size_to_string to libdevmapper.
Moved out from lib/display and a little documentation added.
It's tuned to LVM's requirements historically and its behaviour
might not always be what you would expect.
2015-07-27 21:30:20 +01:00
David Teigland
fe70b03de2 Add lvmlockd 2015-07-02 15:42:26 -05:00
Zdenek Kabelac
7f63fff9c4 display: missed to count with 0
dm_snprintf() returns upon success the number of characters printed
(excluding the null byte used to end output to strings).

So add extra byte to preserve \0.
This fixes regression when displaying more then a single lv name.
2015-07-02 00:10:38 +02:00
Peter Rajnoha
125cd06698 conf: make time format configurable
Make it possible to define format for time that is displayed.
The way the format is defined is equal to the way that is used
for strftime function, although not all formatting options as
used in strftime are available for LVM2 - the set is restricted
(e.g. we do not allow newline to be printed). The lvm.conf
comments contain the whole list that LVM2 accepts for time format
together with brief description (copied from strftime man page).

For example:
(defaults used - the format is the same as used before this patch)
$ lvs -o+time vg/lvol0 vg/lvol1
  LV    VG   Attr       LSize Time
  lvol0 vg   -wi-a----- 4.00m 2015-06-25 16:18:34 +0200
  lvol1 vg   -wi-a----- 4.00m 2015-06-29 09:17:11 +0200

(using 'time_format = "@%s"' in lvm.conf - number of seconds
since the Epoch)
$ lvs -o+time vg/lvol0 vg/lvol1
  LV    VG   Attr       LSize Time
  lvol0 vg   -wi-a----- 4.00m @1435241914
  lvol1 vg   -wi-a----- 4.00m @1435562231
2015-06-29 14:30:35 +02:00
Zdenek Kabelac
438a65dfdb display: drop allocation from display_lvname
Use of display_lvname() in plain log_debug() may accumulate memory in
command context mempool. Use instead small ringbuffer which allows to
store cuple (10 ATM) names so upto 10 full names can be used at one.

We are not keeping full VG/LV names as it may eventually consume larger
amount of RAM resouces if vgname is longer and lots of LVs are in use.

Note: if there would be ever needed for displaing more names at once,
the limit should be raised (e.g. log_debug() would need to print more
then 10 LVs on a single line).
2015-06-18 18:50:37 +02:00
Zdenek Kabelac
47b704462e display: fix return values
Return 1 on success in pvdisplay_short() and lvdisplay_full()
so commands like vgdisplay are not printinig stracktraces
on successful passes.

As the results of fail/success have been internally ignored for those
calls, it had no other visible side effect - command's return value was
still 0 (success).
2015-03-10 14:10:18 +01:00
Alasdair G Kergon
3562b5ab39 systemid: Init and merge lvm2 and lvm1 fields.
Use system_id field in preference to lvm1_system_id.
Initialise both for now.
2015-03-04 01:00:51 +00:00
Alasdair G Kergon
fcebf27a9f lvm-string: Fix HYPEN typo. 2015-02-23 17:09:35 +00:00
Zdenek Kabelac
9411c19b31 segments: introduce lvseg_name
Instead of segtype->ops->name()  introduce lvseg_name().

This also allows us to leave name() function 'empty' for default
return of segtype->name.

TODO: add functions for rest of ops->
2014-10-24 16:39:30 +02:00
Alasdair G Kergon
2360ce3551 cleanup: Use lv_is_ macros.
Use lv_is_* macros throughout the code base, introducing
lv_is_pvmove, lv_is_locked, lv_is_converting and lv_is_merging.

lv_is_mirror_type no longer includes pvmove.
2014-09-15 21:33:53 +01:00
Alasdair G Kergon
0b3d0e79f6 lvresize: Fix raid/mirror and %PE handling code.
Sort out the lvresize calculation code to handle size changes
specified as physical extents as well as logical extents
and to process mirror resizing and raid extensions correctly.

The 'approx alloc' option was masking the underlying problem.
2014-08-22 01:26:14 +01:00
Zdenek Kabelac
24df01f735 cleanup: avoid double assign
Skip setting a value to a variable which is never
used and overwritten/set afterwards.
2014-08-19 14:33:06 +02:00
Zdenek Kabelac
baf825331c prompt: display 'n' for EOF
When EOF is detect - it could be either 'Ctrl+C'
or empty stdin.

For Ctrl+C there is visual ^C sign.
For EOF print 'n' so decision is clear in debug print.
2014-07-11 12:47:41 +02:00
Alasdair G Kergon
64ce3a8066 report: Add lv_dm_path and lv_full_name fields. 2014-07-02 17:24:05 +01:00
Zdenek Kabelac
e21d0eb90e display: add display_lvname
Add simple function to print vg/lv name.
Useful i.e. in error messages.
2014-07-02 10:45:42 +02:00
Peter Rajnoha
cfed0d09e8 report: select: refactor: move percent handling code to libdm for reuse 2014-06-17 16:27:21 +02:00
Peter Rajnoha
5abdb52fdc report: select: refactor: move str_list to libdm
The list of strings is used quite frequently and we'd like to reuse
this simple structure for report selection support too. Make it part
of libdevmapper for general reuse throughout the code.

This also simplifies the LVM code a bit since we don't need to
include and manage lvm-types.h anymore (the string list was the
only structure defined there).
2014-06-17 16:27:20 +02:00
Zdenek Kabelac
11bedf1baf display: print skipped prompt
Since decisions in the silent mode may not be always obvious,
print skipped prompt with answer 'n'.

Also document  '-qq' behaviour (single -q only shuts
logging, while -qq sets silent mode).
2014-05-15 12:11:35 +02:00
Alasdair G Kergon
2eed136f0f signals: Move sigint handling out to lvm-signal. 2014-05-01 20:07:17 +01:00
Zdenek Kabelac
d8214cb154 cleanup: put all tests within switch
No reason to check for VALID in extra if.
2014-04-28 12:42:56 +02:00
Zdenek Kabelac
4c405a9b49 thin: move segment info display to correct code section
Relocate info from thin pool and thin volume segments
to proper code section for segments.
Add discards and thin count status info.

Info is shown with  'lvdisplay --maps' (like for other segments).
2014-04-28 12:41:25 +02:00
Zdenek Kabelac
71314a9905 thin: display info when -tpool is running
For percentage display we need -tpool - so check for layered
device presence here instead of plain pool device.
Also update 'info' - so when pool is 'available' we
display open count for -tpool device instead of mostly
irrelevant pool.
TODO: Maybe we should actually display this open info always?
(even when just -tpool is available, but pool is not)
2014-04-28 12:40:17 +02:00