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

159 Commits

Author SHA1 Message Date
Alasdair G Kergon
06abb2dd4c logging: classify log_debug messages
Place most log_debug() messages into a class.
2013-01-07 22:30:29 +00:00
Alasdair G Kergon
7f747a0d73 logging: add debug classes
Add log/debug_classes to lvm.conf to allow debug messages to be
classified and filtered at runtime.

The dm_errno field is only used by log_error(), so I've redefined it
for log_debug() messages to hold the message class.

By default, all existing messages appear, but we can add categories that
generate high volumes of data, such as logging all traffic to/from
lvmetad.
2013-01-07 22:25:19 +00:00
Zdenek Kabelac
13835d04ac cleanup: skip assignment
env is reassigned without the use, so drop this assign.
2012-12-15 14:57:40 +01:00
Peter Rajnoha
ed9751d9fa udev: add a warning message if DM_DISABLE_UDEV set and udev running
$ export DM_DISABLE_UDEV=1

$ dmsetup create test --table "0 1 zero"
Udev is running and DM_DISABLE_UDEV environment variable is set. Bypassing udev, device-mapper library will manage device nodes in device directory.

$ lvchange -ay vg/lvol0
  Udev is running and DM_DISABLE_UDEV environment variable is set. Bypassing udev, LVM will manage logical volume symlinks in device directory.
  Udev is running and DM_DISABLE_UDEV environment variable is set. Bypassing udev, LVM will obtain device list by scanning device directory.
  Udev is running and DM_DISABLE_UDEV environment variable is set. Bypassing udev, device-mapper library will manage device nodes in device directory.
2012-11-29 15:57:43 +01:00
Peter Rajnoha
b13d45d21d udev: _udev_disabled var visible also for !UDEV_SYNC_SUPPORT 2012-11-29 14:40:12 +01:00
Peter Rajnoha
4891a735d3 udev: recognize DM_DISABLE_UDEV environment variable
Setting this environment variable will cause a full fallback
to old direct node and symlink management in libdevmapper and lvm2.

It means:

 - disabling udev synchronization
   (--noudevsync in dmsetup and --noudevsync + activation/udev_sync=0
    lvm2 config)
 - disabling dm and any subsystem related udev rules
   (--noudevrules in dmsetup and activation/udev_rules=0 lvm2 config)
 - management of nodes/symlinks under /dev directly by libdevmapper/lvm2
   (--verifyudev in dmsetup and activation/verify_udev_operations=1
    lvm2 config)
 - not obtaining any device list from udev database
   (devices/obtain_device_list_from_udev=0 lvm2 config)

Note: we could set all of these before - there's no functional change!
However the DM_DISABLE_UDEV environment variable is a nice shortcut
to make it easier for libdevmapper users so that one can switch off all
of the udev management off at one go directly on the command line,
without a need to modify any source or add any extra switches.
2012-11-29 14:03:48 +01:00
Peter Rajnoha
a820a68619 udev_sync: cookie_set=1 on each dm_task_set_cookie call
cookie_set variable found in the struct dm_task should be always
set to 1 after dm_task_set_cookie_call, even if udev_sync is disabled
as the cookie itself carries synchronization informations *as well as*
extra flags to control other aspects of udev support.

For example, one could disable the synchronization itself, but still
direct the libdm code to disable library fallback via
DM_UDEV_DISABLE_LIBRARY_FALLBACK flag. These extra flags still need
to be carried out!

A concrete example:
  $ dmsetup create test --table "0 1 zero" --noudevsync

This disables synchronization with udev. As the --verifyudev option is
not used, we don't want to do any corrections. In other words, we
need DM_UDEV_DISABLE_LIBRARY_FALLBACK flag to be used. However,
with --noudevsync this was not the case - the flag was ignored!

This patch fixes the case when noudevsync is used but there are still
some extra flags passed within the cookie flag part. The synchronization
part of the cookie stays zero (which is ok as dm_udev_wait call on such a
cookie is simply a NOOP).
2012-10-23 13:23:35 +02:00
Peter Rajnoha
a621795a3c libdm: add mangling support for dm_task_set_uuid
Also, add a new field to struct dm_task called "mangled_uuid" that
will store mangled form of uuid if it differs from original uuid.
2012-10-10 17:16:13 +02:00
Peter Rajnoha
12f5c3f726 libdm: add dm_task_get_uuid_mangled/unmangled
Just like we already have existing mangling support for
device-mapper names, we need exactly the same for device-mapper
UUIDs as their character whitelist is wider than what udev supports.

In case udev is used to create entries in /dev based on UUIDs
and these UUIDs contain characters not supported by udev,
we'll end up with incorrect /dev content for such devices.
So we need to mangle them to a form that is supported by udev.

The mangling used for UUIDs follows the mangling used for names
(that is already supported and used throughout). That means,
setting the name mangling mode via dm_set_name_mangling_mode
affects mangling used for UUIDs in exactly the same manner.
It would be useless to add a new and separate
dm_set_uuid_mangling_mode fn, we'll reuse existing interface.
2012-10-10 16:59:47 +02:00
Peter Rajnoha
b0f48b9533 libdm: refactor internal mangling functions
(un)mangle_name -> (un)mangle_string
check_multiple_mangled_name_allowed -> check_multiple_mangled_string_allowed

Just for clarity as the same functions will be reused to (un)mangle dm UUIDs.
2012-10-10 16:59:11 +02:00
Zdenek Kabelac
ff86c6ed00 cleanup: keep MKNOD type cast clean
Setup major already a dev_t type before it gets shifted.
2012-08-23 14:37:21 +02:00
Alasdair Kergon
ea44a7d759 Adjust wording 2012-03-06 02:42:31 +00:00
Peter Rajnoha
ba428469e6 Check for multiple mangled names in auto mangling mode.
Auto mode can't deal with multiple mangled names. We can do that while working
in hex mode, but in auto mode, this would lead to device name ambiguity.
2012-03-05 12:48:12 +00:00
Peter Rajnoha
4961c3b4af Fix dm_task_get_name_unmangled to not unmangle already unmangled name.
In 'auto' and 'hex' mode, these names are already unmangled on ioctl return.
There's no point on trying to do that once again (actually it's a bug!).
2012-03-05 12:45:43 +00:00
Peter Rajnoha
921a46446d Check whether device names are properly mangled on ioctl return.
Be more strict when unmangling names on ioctl return - require the name to be
properly mangled in 'auto' and 'hex' mode. There really should not be any
blacklisted character since the names should be renamed already (by means of
renaming it directly or running 'dmsetup mangle' for automatic rename).
2012-03-05 12:43:03 +00:00
Peter Rajnoha
17f5531df0 Clean up internal mangling interface. 2012-03-05 12:40:34 +00:00
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
Peter Rajnoha
25b25bd1a2 Fix dm_task_set_name to properly resolve path to dm name.
Wrong variable was checked in _dm_task_set_name_from_path.
2012-02-28 08:36:51 +00:00
Peter Rajnoha
05bfdefdf8 Add DM_DEFAULT_NAME_MANGLING_MODE env. variable to override configured value.
Just in case of emergency when name mangling code causes any problems so
we can override the default value and switch off the mangling globally.
2012-02-15 12:23:15 +00:00
Peter Rajnoha
bd364a70b5 Add dm_task_get_name_mangled/unmangled to libdevmapper.
dm_task_get_name_mangled will always return mangled form of the name while
the dm_task_get_name_unmangled will always return unmangled form of the name
irrespective of the global setting (dm_set/get_name_mangling_mode).

This is handy in situations where we need to detect whether the name is already
mangled or not. Also display functions make use of it.
2012-02-15 11:39:38 +00:00
Peter Rajnoha
55761e14af Mangle device name on dm_task_set_name/newname call if necessary.
If dm_task_set_name/newname is called, the name provided will be
automatically translated to correct encoded form with the hex enconding
so any character not on udev whitelist will be mangled with \xNN
format where NN is hex value of the character used.

By default, the name mangling mode used is the one set during
configure with the '--with-default-name-mangling' option.
2012-02-15 11:27:01 +00:00
Zdenek Kabelac
c71b47b9e6 Fix missing temp_buf init for error path
In previous commit this was missing, also deallocate in reversed order.
2012-02-13 14:39:24 +00:00
Zdenek Kabelac
820aa36192 Do not write to -1 buffer address
In case of zero bytes would be read from sysfs, it would store '\0' on
temp_buf[-1] address.

Simplify some buffer length calculation and use strcpy if we've just
checked string fits in give buffer.

Replace jump label error: with bad: commonly used in libdm.
2012-02-13 10:49:28 +00:00
Zdenek Kabelac
b6e97cea2c Fix fd resource leak in error path
Use 'goto bad' to cleanup fd on error path.
2012-02-08 11:07:17 +00:00
Zdenek Kabelac
5dfd775384 Ensure strncpy() function always ends with '\0'
Since last character needs to be \0 for string,
pass buffer size smaller by 1 byte.
2012-02-08 11:05:04 +00:00
Zdenek Kabelac
0e6cacbbb6 Fix resource leak of file handle
Introduces when added dm_device_get_name.
Close file handle in all error paths.
2012-01-25 21:47:18 +00:00
Peter Rajnoha
26a3549fa0 Move dm_task_set_newname from libdm-iface.c to libdm-common.c 2012-01-17 14:36:58 +00:00
Peter Rajnoha
17c3e42b21 Add dm_device_get_name to get map name or block device name for given devno.
This is accomplished by reading associated sysfs information. For a dm device,
this is /sys/dev/block/major:minor/dm/name (supported in kernel version >= 2.6.29,
for older kernels, the behaviour is the same as for non-dm devices).

For a non-dm device, this is a readlink on /sys/dev/block/major:minor, e.g.
  /sys/dev/block/253:0 --> ../../devices/virtual/block/dm-0.
The last component of the path is a proper kernel name (block device name).

One can request to read only kernel names by setting the 'prefer_kernel_name'
argument if needed.
2012-01-11 12:34:44 +00:00
Alasdair Kergon
2e5ff5d11c Add dm_uuid_prefix/dm_set_uuid_prefix for non-lvm users to override hard-coded
LVM- prefix.

Try harder not to leave stray empty devices around (locally or remotely) when
reverting changes after failures while there are inactive tables.
2012-01-10 02:03:31 +00:00
Zdenek Kabelac
044abcf91b Use sysfs to set/get of read-ahead
If we know major:minor number of device (which is known after resume) we will
try to use  sysfs to set/get read ahead parameters of device.
This avoid potential problem of blocking commands like 'dmsetup info' awaiting
for device being usable for open/close - i.e. overfilled thin pool may block
such command.
2012-01-09 12:26:14 +00:00
Petr Rockai
845b1df617 Make a cleaner split between config tree and config file functionality. Move
the latter out of libdm.
2011-12-18 21:56:03 +00:00
Zdenek Kabelac
5392675f4c Check target type name for DM_MAX_TYPE_NAME length
Avoid creation of target type name when it's longer then
DM_MAX_TYPE_NAME (noticed by static analyzer where the
sp.target_type might be missing '\0' at the end.)

Before patch:

$> dmsetup create long
0 1000 looooooooooooooooooooooooooong
^D
device-mapper: reload ioctl failed: Invalid argument

After patch:

$> dmsetup create xxx
0 1000 looooooooooooooooooooooooooong
Target type name looooooooooooooooooooooooooong is too long.
Command failed
2011-11-18 19:34:02 +00:00
Peter Rajnoha
e8ee29e9c1 readlink does not append a null byte to the output string! 2011-09-24 11:47:53 +00:00
Peter Rajnoha
14254bd0be Add dm_device_has_holders fn to to check use of the device by another device.
Add dm_device_has_mounted_fs fn to check mounted filesystem on a device.

This requires sysfs directory to be correctly set via dm_set_sysfs_dir
(/sys by default). If sysfs dir is not used or it's set incorrectly,
dm_device_has_{holders,mounted_fs} will return 0!
2011-09-22 17:23:35 +00:00
Peter Rajnoha
07e237d6f4 Add dm_set_sysfs_dir to libdevmapper to set sysfs location.
Add dm_sysfs_dir to libdevmapper to retrieve sysfs location thas is set.
2011-09-22 17:17:07 +00:00
Alasdair Kergon
32b7009196 Log cookie values when incrementing/decrementing to give clues about races. 2011-07-08 15:34:47 +00:00
Alasdair Kergon
f92e31558b decode cookie flags in debug msgs 2011-07-05 16:17:14 +00:00
Alasdair Kergon
2243718fae Add framework for validation of ioctls. Doesn't do any checks yet.
dmsetup --checks
libdevmapper: dm_task_enable_checks()
lvm.conf: activation/checks=1
2011-07-01 14:09:19 +00:00
Alasdair Kergon
7b5e4dcf1f more fixes to readahead etc. 2011-06-28 09:24:13 +00:00
Alasdair Kergon
9032898eb1 Extend debug log messages to distinguish between the 3 states:
trust udev; verify udev; perform dev node operations directly.
2011-06-27 22:38:53 +00:00
Alasdair Kergon
0437bccc3c Move udev_only logic inside stacked node op code.
(We still need to treat add+readhead+del as a no-op.)
Rename udev_fallback to verify_udev_operations.
Rename --udevfallback to --verifyudev
2011-06-27 21:43:58 +00:00
Alasdair Kergon
1840aa0974 Maintain a count of the number of suspended devices in libdevmapper
and use this for the LVM critical section logic.  Also report an error if
code tries to load a table while any device is known to be in the
suspended state.
(If the variety of problems these changes are showing up can't be fixed
before the next release, the error messages can be reduced to debug
level.)
2011-06-13 03:32:45 +00:00
Peter Rajnoha
71b29ddcc4 Require libudev >= 143 when compiling with udev support.
Old versions of libudev < 143 were experimental and unstable. Require recent
and stable versions only (version 143 is old enough anyway).
2011-04-22 11:56:41 +00:00
Zdenek Kabelac
b8bdd780d8 Fix 2 signess warnings reported by gcc
Replace int with unsigned counter.
Replace snprintf with dm_snprintf.
2011-03-30 12:14:36 +00:00
Zdenek Kabelac
6460d5a405 Add attribute printf
gcc suggested to add these attributes to instrumentat
printf arguments. Adding it for internal functions as well.
2011-03-29 21:53:46 +00:00
Zdenek Kabelac
681858db90 Improve debug stack trace
dm_check_version reports log_error() - so use return_NULL.
2011-03-18 13:21:02 +00:00
Peter Rajnoha
eb36643cb7 Lower severity of selabel_lookup and matchpathcon failure to log_debug. 2011-03-03 13:05:40 +00:00
Zdenek Kabelac
63284817c7 Add missing return 2011-03-02 08:40:28 +00:00
Alasdair Kergon
d0e3d474d1 Fix dm_udev_wait calls in dmsetup to occur before readahead display not after.
Include an implicit dm_task_update_nodes() within dm_udev_wait().
2011-03-02 00:29:57 +00:00
Alasdair Kergon
6c7b95f281 pre-release 2011-02-04 22:07:43 +00:00