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

4161 Commits

Author SHA1 Message Date
Zdenek Kabelac
9f2961f259 cache: check for internal error
Don't try to duplicate NULL on internal error path.
2014-11-20 16:35:46 +01:00
Zdenek Kabelac
d7985ebead thin: fix error path
Print pool name and not the origin name.
2014-11-19 18:58:30 +01:00
Zdenek Kabelac
53d2db31c6 cleanup: drop unused var 2014-11-18 16:50:49 +01:00
Zdenek Kabelac
01760967b4 locking: rename LCK_CONVERT
All 'MODE' bits are using _MODE suffix so rename to LCK_CONVERT_MODE
(part of rhbz 735445).
No functional change.
2014-11-18 16:50:49 +01:00
Petr Rockai
cf37c04347 memlock: Make malloc reserve more robust against glibc tricks. 2014-11-18 03:17:27 +01:00
Zdenek Kabelac
38200c2000 cleanup: add '.' to log messages 2014-11-14 18:12:35 +01:00
Zdenek Kabelac
f36080a05d vg_read: correct warning
Use log_warn when we are effectively not creating an error -
we 'allowed' inconsistent read for a reason - so it's just warning
level we process inconsistent VG - it's upto caller later to decide
error level of command return value and in case of error it needs
to use log_error then.
2014-11-14 18:12:35 +01:00
Zdenek Kabelac
06e3f1757e vg_read: use new error flag
Failed recovery provides different (NULL) VG then FAILED_INCONSISTENT.
Mark it with different failure bit - since FAILED_INCONSISTENT is
supposed to contain something 'usable' (thought inconsistent).
2014-11-14 18:09:27 +01:00
Zdenek Kabelac
88e944b5a3 cleanup: remove unused headers 2014-11-13 17:49:42 +01:00
Zdenek Kabelac
428b9fcd87 cleanup: validate pointers
Mostly on almost impossible to happen paths - but stay safe.
2014-11-13 17:49:42 +01:00
Zdenek Kabelac
6308a8b06d cache: wrong feature in seg is internal error 2014-11-13 17:44:31 +01:00
Peter Rajnoha
83308fdff9 cleanup: cleanup internal interface to acquire segment status
- Add separate lv_status fn (if we're interested only in seg status,
   but not lv info at the same time as it is with existing
   lv_info_with_seg_status fn). So we 3 fns:

     - lv_info (existing one, runs only info ioctl, fills in struct lvinfo only)

     - lv_status (new one, runs status ioctl, fills in struct lv_seg_status only)

     - lv_info_with_seg_status (existing one, runs status ioctl, fills
       in struct lvinfo as well as lv_seg_status)

 - Add more comments in the code explaining the difference between lv_info,
   lv_status and lv_info_with_seg_status and their return values.

 - Move decision whether lv_info_with_seg_status needs to call only
   status ioctl (in case the segment for which we require status is from
   the LV for which we require info) or separate status and info ioctl
   (in case the segment for which we require status is from different
    LV that the one for which we require info) into
   lv_info_with_seg_status fn so caller doesn't need to bother about
   this at all.

 - Cleanup internal interface for this seg status so it's more readable.
2014-11-13 14:28:51 +01:00
Zdenek Kabelac
c3e2990359 cleanu: drop duplicate const 2014-11-13 13:15:58 +01:00
Zdenek Kabelac
8cb79dad0b pool: fix removal of pool metadata spare
Since we support device stack of pools over pool
(thin-pool with cache data volume) the existing code
is no longer able to detect orphan _pmspare.

So instead do a _pmspare check after volume removal,
and remove spare afterwards.
2014-11-13 13:09:07 +01:00
Zdenek Kabelac
fba86dd42b cache: improve pending_delete
We need to stop guessing deleted names - so rather collect
deleted  UUID into a string list - and then remove them properly
in _clean_tree. Restore origin _clean_tree behaviour them for
currently unconverted removal of snapshots.

Pending delete feature now properly tracks whole subtree of cache
(so i.e. data or metadata as raid volumes).
It properly replaces all related volumes with 'errors' in suspend
preload, then resume them as error and remove collected UUIDs
from root - since they are not longer part of any volume deps.
2014-11-13 11:54:41 +01:00
Peter Rajnoha
359dc6fa76 coverity: commit ba2302346 - report log_sys_error properly
log_sys_error uses errno, hence we need to report the first
failure before reporting another failure that uses errno as well.
2014-11-12 15:16:54 +01:00
Peter Rajnoha
c03d8473ea coverity: fix possible dereference of NULL pointer
This would be in case the pool segment was not found.

LVM2.2.02.112/lib/metadata/pool_manip.c:238:36: warning: Access to field 'segtype' results in a dereference of a null pointer (loaded from variable 'pool_seg')
2014-11-12 10:17:17 +01:00
Peter Rajnoha
ce8730b508 coverity: fix possible integer overflow
LVM2.2.02.112/lib/metadata/cache_manip.c:73: overflow_before_widen: Potentially overflowing expression "*pool_metadata_extents *vg->extent_size" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned).
LVM2.2.02.112/lib/activate/dev_manager.c:217: overflow_before_widen: Potentially overflowing expression "seg_status->seg->len * extent_size" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned).
LVM2.2.02.112/lib/activate/dev_manager.c:217: overflow_before_widen: Potentially overflowing expression "seg_status->seg->le * extent_size" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type "uint64_t" (64 bits, unsigned).
2014-11-12 10:03:27 +01:00
Peter Rajnoha
60cc666c94 coverity: fix compiler warning
LVM2.2.02.112/lib/activate/dev_manager.c:196:5: warning: 'dmtask' may be used uninitialized in this function [-Wmaybe-uninitialized]

In _info_run fn:

switch (type) {
	case INFO:
		...
	case STATUS:
		...
	case MKNODES:
		...
}

The "type" is enum and currently only those three types are supported,
but if we added a new type in the future, this would end up with a bug
(if we forgot to add the new "case" in that "switch"). So let's make
sure proper internal error is printed:

	default:
		log_error(INTERNAL_ERROR "_info_run: unhandled info type");
                return 0;
2014-11-12 09:55:12 +01:00
Zdenek Kabelac
57c618b0ed cache: fix clean_tree
Fix 8121074fda - the patch
incorrectly removed also other top-level nodes.

It needs to deactivate purely subnodes of _corig.
2014-11-12 09:40:27 +01:00
Peter Rajnoha
ba23023464 coverity: fix resource leaks
LVM2.2.02.112/tools/toollib.c:1991: leaked_storage: Variable "iter" going out of scope leaks the storage it points to.
LVM2.2.02.112/lib/filters/filter-usable.c:89: leaked_storage: Variable "f" going out of scope leaks the storage it points to.
LVM2.2.02.112/lib/activate/dev_manager.c:1874: leaked_handle: Handle variable "fd" going out of scope leaks the handle.
2014-11-12 09:19:14 +01:00
Alasdair G Kergon
9a5910bdf9 pre-release 2014-11-11 14:13:00 +00:00
Peter Rajnoha
9704515c1e dev_manager: only support status for cache segment at the moment
When getting status for LV segment types, we need to be sure
that proper segment is selected for the status ioctl.

When reporting fields that require status ioctl,
the "_choose_lv_segment_for_status_report" fn in tools/reporter.c
must be completed properly to choose the proper segment for all
the LV types (at the moment, it just takes the first LV segment
by default).

This works fine with cache LVs surely. The other segment types
need more auditing. We use this status ioctl only for cache status
fields at the moment only, so restrict it to the cache only.

Once the _choose_lv_segment_for_status_report is completed
properly, release the restriction in _get_segment_status_from_target_params.
2014-11-11 15:02:21 +01:00
Zdenek Kabelac
8121074fda cache: pending_delete fixes 2014-11-11 13:32:41 +01:00
Zdenek Kabelac
9a6e3683a2 cache: never create new table entry for deleted cache 2014-11-11 13:32:41 +01:00
Zdenek Kabelac
42a3305ec7 cache: no status for pending deleted cache 2014-11-11 13:32:41 +01:00
Peter Rajnoha
2dde6c6531 report: add cache device status fields
New reporting fields related to cache device status:
  - cache_total_blocks
  - cache_used_blocks
  - cache_dirty_blocks
  - cache_read_hits
  - cache_read_misses
  - cache_write_hits
  - cache_write_misses
2014-11-11 13:07:30 +01:00
Peter Rajnoha
a2c1024f6a dev_manager: enhance dev_manager_info to acquire LV segment status if requested, add lv_info_with_seg_status fn 2014-11-11 13:04:02 +01:00
Peter Rajnoha
7f90ad84c1 report: add new LVSSTATUS and SEGSSTATUS report type
Similar to LVSINFO type which gathers LV + its DM_DEVICE_INFO, the
new LVSSTATUS/SEGSSTATUS report type will gather LV/segment + its
DM_DEVICE_STATUS.

Since we can report status only for certain segment, in case
of LVSSTATUS we need to choose which segment related to the LV
should be processed that represents the "LV status". In case of
SEGSSTATUS type it's clear - the status is reported for the
segment just processed.
2014-11-11 08:53:28 +01:00
Peter Rajnoha
d7e5f03888 refactor: rename struct lv_with_info used in reporting code to lv_with_info_and_seg_status
The former struct lv_with_info is renamed to lv_with_info_and_seg_status as it can
hold more than just "info", there's lv's segment status now in addition:

	struct lv_with_info_and_seg_status {
		struct logical_volume *lv;
		struct lvinfo *info;
		struct lv_seg_status *seg_status;
	}

Where struct lv_seg_status is:

	struct lv_seg_status {
		struct dm_pool *mem;
		struct lv_segment lv_seg;
		lv_seg_status_type_t type;
		void *status; /* struct dm_status_* */
	}

Where lv_seg points to lv's segment that is being reported or
processed in general.

New struct lv_seg_status keeps the information about segment status -
the status retrieved via DM_DEVICE_STATUS ioctl. This information will
be used for reporting dm device target status for the LV segment
specified.

So this patch introduces third level of LV information that is
kept for reuse while reporting fields within one reporting line,
causing only one DM_DEVICE_STATUS ioctl call per LV segment line
reported (otherwise we'd need to call the DM_DEVICE_STATUS for each
segment status field in one LV segment/reporting line which is not
efficient).

This is following exactly the same principle as already introduced
by commit ecb2be5d16.

So currently we have three levels of information that can be used
to report an LV/LV segment:

    - LV metadata itself (struct logical_volume *lv)

    - LV's DM_DEVICE_INFO ioctl result (struct lvinfo *info)

    - LV's segment DM_DEVICE_STATUS ioctl result (this status must be
      bound to a segment, not the whole LV as the whole LV may be
      composed of several segments of course)
      (this is the new struct lv_seg_status *seg_status)
2014-11-11 08:53:28 +01:00
Zdenek Kabelac
20b22cd023 libdm: still better API
Do not use 'any' policy name as a value in config tree - so we stick
with 'policy_settings' and extra 'policy_name' for libdm params.

Update lvm2 API as well.

Example of supported metadata:

 policy = "mq"
 policy_settings {
      migration_threshold = 2048
      sequential_threshold = 512
      random_threshold = 4
      read_promote_adjustment = 10
 }
2014-11-11 00:54:03 +01:00
Zdenek Kabelac
ca509c9746 dev_manager: workaround to allow top-level _tmeta, _tdata 2014-11-11 00:53:37 +01:00
Zdenek Kabelac
a7fc108298 mirror: layer remove doesn't work properly with mirrors 2014-11-10 22:32:43 +01:00
Zdenek Kabelac
02f49caa35 debug: log tree type is created
Print tree type and use internal_error for unknown type.
2014-11-10 22:05:49 +01:00
Zdenek Kabelac
e5d3f81285 cleanup: indents comments backtraces 2014-11-10 22:05:49 +01:00
Zdenek Kabelac
1e97d2dd28 cleanup: use chunk_size directly 2014-11-10 22:05:49 +01:00
Zdenek Kabelac
f5e265a07f cache: use LV_PENDING_DELETE 2014-11-10 22:05:49 +01:00
Zdenek Kabelac
f6932bfcf9 cache: _corig has UUID suffix
Use -real suffix for cache origin device.
2014-11-10 22:05:49 +01:00
Zdenek Kabelac
6effcb16fc cache: option 2014-11-10 22:05:49 +01:00
Zdenek Kabelac
c5c2665a21 man: _corig is reserved 2014-11-10 22:05:49 +01:00
Zdenek Kabelac
3e230a8ad8 cache: new API for libdm 2014-11-10 22:05:49 +01:00
Zdenek Kabelac
824019531c libdm: tunning cache API
Support new PASSTHROUGH 'feature' flag.

Add dm_config_node to pass in policy args.

Really use origin_uuid instead of using extra call
to pass seg_areas.

Switch to 64bit feature flag bit set so there is
enough space in future for new bits...
2014-11-10 22:05:48 +01:00
Zdenek Kabelac
3dbcd2a1c9 cleanup: cache API get/set 2014-11-10 22:05:48 +01:00
Zdenek Kabelac
2e0c926d56 cleanup: API get/set fixes 2014-11-10 22:05:48 +01:00
Zdenek Kabelac
8d7340b7a1 report: for cache LV report chunksize
Cache LV reports chunksize via cache-pool.
2014-11-10 22:05:48 +01:00
Zdenek Kabelac
6a41286c01 snapshot: virtual save commit
More efficient spare volume creation. Save 1 extra commit
and properly activate this volume according to our cluster
activation rules (using lv_active_change() for this).
2014-11-10 22:05:48 +01:00
Zdenek Kabelac
ff30783a4f lv_manip: remove_layer_from_lv restore lv name
Since we 'layer' for cache origin which and we support dropping
cache layer - we need to restore origin name in case
the origin LV is more complex target  - i.e. raid.

Drop _corig from name

Cleanup and rename parent -> parent_lv.
2014-11-10 22:05:48 +01:00
Zdenek Kabelac
979d12eb4a lvremove: few more validation before archive
Before we finally call archive, we still can do a few more validation
without modifying VG. So delay archive() call few lines.
2014-11-10 22:05:48 +01:00
Zdenek Kabelac
e2c4a3ef67 segtype: add SEG_ONLY_EXCLUSIVE flag
Mark segtypes which do require exclusive activation in cluster.r
2014-11-10 22:05:48 +01:00
Zdenek Kabelac
0dc73f7dbd dmeventd: time scaling for status retry
In normal case it's too slow to wait 1 second for default.
So rather start with short time and increase sleep between status
retesting.
2014-11-10 22:05:48 +01:00