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

125 Commits

Author SHA1 Message Date
Zdenek Kabelac
55fe07ad98 mm: fix leak in fail path
If the dm_realloc would fail, the already allocate _maps_buffer
memory would have been lost (overwritten with NULL).
Fix this by using temporary line buffer.

Also add a minor cleanup to set end of buffer to '\0',
only when we really know the file size fits the preallocated buffer.
2013-05-13 13:13:20 +02:00
Peter Rajnoha
386886f71c config: refer to config nodes using assigned IDs
For example, the old call and reference:

  find_config_tree_str(cmd, "devices/dir", DEFAULT_DEV_DIR)

...now becomes:

  find_config_tree_str(cmd, devices_dir_CFG)

So we're referring to the named configuration ID instead
of passing the configuration path and the default value
is taken from central config definition in config_settings.h
automatically.
2013-03-06 10:14:33 +01:00
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
Zdenek Kabelac
d5697b29ee mm: skip mlocking [vectors]
Somehow forgotten:
https://www.redhat.com/archives/linux-lvm/2012-June/msg00019.html
Need for arm architecture support.
2012-11-20 10:02:51 +01:00
Alasdair G Kergon
4dab0d3175 comments: misc updates
Miscellaneous clarifications to comments.
2012-08-07 18:34:30 +01:00
Zdenek Kabelac
2539769356 fix: limit preallocate stack size
If the user would set bigger reserved stack size then what
is allowed in resources (ulimit -s), then he would get coredump
So avoid coredump and ignore creation of such large stack size
(lvm should work properly, with just 64KB, so the option could
be eliminated).
2012-06-22 13:48:04 +02:00
Zdenek Kabelac
192fa11dab fix: use 64bit math for reserved memory
If the user specifies number in the range of [4G/1024, 4G>,
the used value would wrap around (32bit math).
So keep the math 64bit.

Note, using such large lvm.conf values is pointless with lvm2.
2012-06-22 13:32:19 +02:00
Zdenek Kabelac
cf518842b4 Log sys error for lseek 2012-03-01 21:19:20 +00:00
Zdenek Kabelac
489bf2fbdf Minor consistency update for debugging messages
Use mlock/munlock for debugging lines.
2012-02-01 10:48:22 +00:00
Zdenek Kabelac
b185993628 Fix compilation with disabled devmapper
During release preparation things has changed, so making sure
we are compilable with --disable-devmapper.
2012-01-25 13:12:59 +00:00
Alasdair Kergon
a7d2f7795a Make error message hit when preallocated memlock memory exceeded clearer. 2012-01-12 18:29:07 +00:00
Alasdair Kergon
594753751a Only use built-in stack size in clvmd - ignore lvm.conf. 2011-12-08 21:24:08 +00:00
Petr Rockai
e59e2f7c3c Move the core of the lib/config/config.c functionality into libdevmapper,
leaving behind the LVM-specific parts of the code (convenience wrappers that
handle `struct device` and `struct cmd_context`, basically). A number of
functions have been renamed (in addition to getting a dm_ prefix) -- namely,
all of the config interface now has a dm_config_ prefix.
2011-08-30 14:55:15 +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
Alasdair Kergon
29f2c5ada6 Disable critical section internal errors until this can be fixed properly
in libdevmapper.
2011-06-12 00:23:50 +00:00
Alasdair Kergon
df390f1799 Major pvmove fix to issue ioctls in the correct order when multiple LVs
are affected by the move.  (Currently it's possible for I/O to become
trapped between suspended devices amongst other problems.

The current fix was selected so as to minimise the testing surface.  I
hope eventually to replace it with a cleaner one that extends the
deptree code.

Some lvconvert scenarios still suffer from related problems.
2011-06-11 00:03:06 +00:00
Alasdair Kergon
2aa785c85f Report sector containing label in verbose message. 2011-06-01 19:26:38 +00:00
Alasdair Kergon
919ab56b6d pre-release clean-ups 2011-04-29 00:21:13 +00:00
Alasdair Kergon
9cda028a96 clean up critical section patch 2011-04-28 20:29:59 +00:00
Zdenek Kabelac
a1eba521e3 Fix some unmatching sign comparation gcc warnings
Simple replacement for unsigned type - usually in for() loops.
2011-04-08 14:40:18 +00:00
Zdenek Kabelac
a66bff47f1 Few more files filtered from memory locking
Code located in these files should not be used in critical section.
2011-03-30 13:06:13 +00:00
Zdenek Kabelac
01fb91c615 Valgrind updates
Avoid locking sum testing with valgrind compilation.

Make memory unaccessible in the valgrind for dm_pool_abadon_object.

Valgrind hinting should not be needed in _free_chunk for dm_free.
2011-03-30 12:43:32 +00:00
Zdenek Kabelac
2bd6583a34 Use lvm_getpagesize wrapper 2011-03-06 17:52:07 +00:00
Milan Broz
affd9c086d Fix hardcoded page size, fixing test fails with 8k page and new kernel. 2011-03-06 16:47:43 +00:00
Zdenek Kabelac
476ef1886f Memory unlock allows 1 page difference
As the kernel seems to be doing weird things during
mlock -> munlock -  allow 1 page locking difference without
warning - and log just debug message for a 1 page difference.

Allocation happens outside critical section probably during
log_warn printing.

Should make tests passing for now.
2011-02-18 14:51:04 +00:00
Zdenek Kabelac
b1bcff7424 Critical section
New strategy for memory locking to decrease the number of call to
to un/lock memory when processing critical lvm functions.

Introducing functions for critical section.

Inside the critical section - memory is always locked.
When leaving the critical section, the memory stays locked
until memlock_unlock() is called - this happens with
sync_local_dev_names() and sync_dev_names() function call.

memlock_reset() is needed to reset locking numbers after fork
(polldaemon).

The patch itself is mostly rename:

memlock_inc  -> critical_section_inc
memlock_dec  -> critical_section_dec
memlock      -> critical_section

Daemons (clmvd, dmevent) are using memlock_daemon_inc&dec
(mlockall()) thus they will never release or relock memory they've
already locked memory.

Macros sync_local_dev_names() and sync_dev_names() are functions.
It's better for debugging - and also we do not need to add memlock.h
to locking.h header (for memlock_unlock() prototyp).
2011-02-18 14:16:11 +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
aa4f87d6e3 Switch to char* arithmetic from void* 2010-10-25 13:00:35 +00:00
Zdenek Kabelac
d1ad03efce Speedup memory un/locking
Move the call of find_config_tree_node() from inner loop to outer
section of maps scanning.
2010-10-15 09:48:23 +00:00
Zdenek Kabelac
c631be7684 Maps fix
Read complete content of /proc/self/maps into one buffer without
realocation in the middle of reading and before doing any m/unlock
operation with these lines - as some of them gets change.
With previous implementation we've read some mappings twice ([stack])
2010-09-30 11:32:40 +00:00
Zdenek Kabelac
764eb41086 Fix format string from patch apply mistake 2010-07-08 14:47:46 +00:00
Zdenek Kabelac
37036b0215 Small update of memlock debug messages.
Gives slightly better alligned lines for reading.
2010-07-08 13:05:27 +00:00
Zdenek Kabelac
d301e5917f Preload libc locale messages.
Preload libc.mo file for localized lvm before taking memory lock - this way
we prevent disk access for some error paths in libdm, that prints localized
errno messages while they are still in memory locked state.
2010-06-24 08:29:30 +00:00
Zdenek Kabelac
ddf19eae0f Better debug message for Un/Locked memory size. 2010-04-01 14:53:47 +00:00
Zdenek Kabelac
39b6ac476d Set ret value to success initially. 2010-04-01 13:43:12 +00:00
Zdenek Kabelac
5de52e34f0 Count only readable size for memlock stats.
As we mlock() only readable pages, makes statistics only
for readable bytes.
2010-03-30 14:41:58 +00:00
Zdenek Kabelac
3f67b36b35 Update memlock
Code moves initilization of stats values to _memlock_maps().
For dmeventd we need to use mlockall() - so avoid reading config value
and go with _use_mlockall code path.

Patch assumes dmeventd uses C locales!
Patch needs the call or memlock_inc_daemon() before memlock_inc()
(which is our common use case).

Some minor code cleanup patch for _un/_lock_mem_if_needed().
2010-03-30 14:41:23 +00:00
Alasdair Kergon
415feb2f44 some missing debug messages 2010-03-09 12:31:51 +00:00
Zdenek Kabelac
d0c3da55a0 Update comments for selecting maps
Use dm_snprintf and check result whether we create correct /proc path name
2010-03-09 10:25:50 +00:00
Alasdair Kergon
f0f43bc093 Misc cleanups in the new mlock code, incl. improving some variable names
& messages; using more statics (for now) to avoid redundant
recalculation; validating config file just once on loading; keeping maps
file open.
2010-03-09 03:16:11 +00:00
Zdenek Kabelac
4e27a85a2b Use mlock() only on 'r' memory maps 2010-03-08 17:14:21 +00:00
Zdenek Kabelac
26ade5f27e Unconditionaly ignore also Virtual Dynamically-linked Shared Object
(VDSO on 32bit is VSyscall on 64bit)
It seems it could be locked on 64bit kernels running 32bit binaries,
but it makes troubles on real 32bit machines where mlock() returns
error when trying to lock such map area. (0xffffe000)
Behavior of mlockall() seems to be similar.
2010-03-08 15:55:52 +00:00
Zdenek Kabelac
c900819b4e Use '_' prefix for local static variable. 2010-03-05 15:14:03 +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
Petr Rockai
550cae2340 #define an INTERNAL_ERROR macro and use it throughout LVM. 2009-12-16 19:22:11 +00:00
Petr Rockai
4514bdcfa2 Fix another bug in memlock handling, this time the "global" dmeventd memlock
was preventing device scans in lvconvert --repair running from inside dmeventd.
2009-11-19 01:11:57 +00:00
Petr Rockai
39b1e58979 Issue an Internal error message whenever _memlock_count drops below 0. 2009-11-18 18:22:32 +00:00
Alasdair Kergon
0a5b690b70 fix setpriority int error 2008-05-28 23:12:45 +00:00
Alasdair Kergon
67cdbd7e4d Some whitespace tidy-ups. 2008-01-30 14:00:02 +00:00
Alasdair Kergon
be6845999b Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1. 2007-08-20 20:55:30 +00:00