diff options
author | Zdenek Kabelac <zkabelac@redhat.com> | 2010-03-05 14:48:33 +0000 |
---|---|---|
committer | Zdenek Kabelac <zkabelac@redhat.com> | 2010-03-05 14:48:33 +0000 |
commit | 18b82048e457d6ff426d9dd828475d4dd02b8204 (patch) | |
tree | 3c265f7b4471c8a45cfd10d4b8765a77de45eb96 /lib/locking | |
parent | db724a449b8a6325e81d04e835f7e24a35f9e78b (diff) | |
download | lvm2-18b82048e457d6ff426d9dd828475d4dd02b8204.tar.gz lvm2-18b82048e457d6ff426d9dd828475d4dd02b8204.tar.xz lvm2-18b82048e457d6ff426d9dd828475d4dd02b8204.zip |
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.
Diffstat (limited to 'lib/locking')
-rw-r--r-- | lib/locking/locking.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/locking/locking.c b/lib/locking/locking.c index a636f7c7..76dbda53 100644 --- a/lib/locking/locking.c +++ b/lib/locking/locking.c @@ -161,22 +161,22 @@ static void _unblock_signals(void) _signals_blocked = 0; } -static void _lock_memory(lv_operation_t lv_op) +static void _lock_memory(struct cmd_context *cmd, lv_operation_t lv_op) { if (!(_locking.flags & LCK_PRE_MEMLOCK)) return; if (lv_op == LV_SUSPEND) - memlock_inc(); + memlock_inc(cmd); } -static void _unlock_memory(lv_operation_t lv_op) +static void _unlock_memory(struct cmd_context *cmd, lv_operation_t lv_op) { if (!(_locking.flags & LCK_PRE_MEMLOCK)) return; if (lv_op == LV_RESUME) - memlock_dec(); + memlock_dec(cmd); } void reset_locking(void) @@ -363,7 +363,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource, int ret = 0; _block_signals(flags); - _lock_memory(lv_op); + _lock_memory(cmd, lv_op); assert(resource); @@ -390,7 +390,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource, _update_vg_lock_count(resource, flags); } - _unlock_memory(lv_op); + _unlock_memory(cmd, lv_op); _unblock_signals(); return ret; |