* [patch review] reduce io impact for finding sanlock lv free lock offset
@ 2017-08-14 11:09 Zhang Huan
2017-08-14 11:59 ` Zdenek Kabelac
0 siblings, 1 reply; 2+ messages in thread
From: Zhang Huan @ 2017-08-14 11:09 UTC (permalink / raw)
To: lvm-devel
commit 19d8fbd0e142c0d35eb5bcc96671682afb548a23
Author: Huan Zhang <zhanghuan@chinac.com>
Date: Mon Aug 14 18:51:26 2017 +0800
reduce io impact for finding sanlock lv free lock offset
currently, lvcreate for sanlock find the free lock offset
from the beginning of the lvmlock every time.
after created thousands of lvs, it will issue thousands of read
ios for lvcreate to find free lock offset.
remeber the last free lock offset will greatly reduce the impact
Signed-off-by: Zhang Huan <zhanghuan@huayun.com>
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 01259c0..aefa98a 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -3304,7 +3304,6 @@ static int work_init_lv(struct action *act)
lm_type = ls->lm_type;
memcpy(vg_args, ls->vg_args, MAX_ARGS);
free_offset = ls->free_lock_offset;
- ls->free_lock_offset = 0;
}
pthread_mutex_unlock(&lockspaces_mutex);
diff --git a/daemons/lvmlockd/lvmlockd-sanlock.c b/daemons/lvmlockd/lvmlockd-sanlock.c
index aedd506..c6c7cc9 100644
--- a/daemons/lvmlockd/lvmlockd-sanlock.c
+++ b/daemons/lvmlockd/lvmlockd-sanlock.c
@@ -938,7 +938,9 @@ int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset)
struct lm_sanlock *lms = (struct lm_sanlock *)ls->lm_data;
struct sanlk_resourced rd;
uint64_t offset;
+ uint64_t start_offset;
int rv;
+ int round;
if (daemon_test) {
*free_offset = (1048576 * LV_LOCK_BEGIN) + (1048576 * (daemon_test_lv_count + 1));
@@ -951,9 +953,22 @@ int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset)
rd.rs.num_disks = 1;
strncpy(rd.rs.disks[0].path, lms->ss.host_id_disk.path, SANLK_PATH_LEN-1);
- offset = lms->align_size * LV_LOCK_BEGIN;
+ if (ls->free_lock_offset)
+ offset = ls->free_lock_offset;
+ else
+ offset = lms->align_size * LV_LOCK_BEGIN;
+
+ start_offset = offset;
while (1) {
+ if (offset >= start_offset && round) {
+ /* This indicates the all space are allocated. */
+ log_debug("S %s init_lv_san read back to start offset %llu",
+ ls->name, (unsigned long long)offset);
+ rv = -EMSGSIZE;
+ return rv;
+ }
+
rd.rs.disks[0].offset = offset;
memset(rd.rs.name, 0, SANLK_NAME_LEN);
@@ -963,7 +978,12 @@ int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset)
/* This indicates the end of the device is reached. */
log_debug("S %s find_free_lock_san read limit offset %llu",
ls->name, (unsigned long long)offset);
- return -EMSGSIZE;
+ round = 1;
+ offset = lms->align_size * LV_LOCK_BEGIN;
+ rd.rs.disks[0].offset = offset;
+ memset(rd.rs.name, 0, SANLK_NAME_LEN);
+
+ rv = sanlock_read_resource(&rd.rs, 0);
}
/*
Best Regards.
Zhang Huan
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [patch review] reduce io impact for finding sanlock lv free lock offset
2017-08-14 11:09 [patch review] reduce io impact for finding sanlock lv free lock offset Zhang Huan
@ 2017-08-14 11:59 ` Zdenek Kabelac
0 siblings, 0 replies; 2+ messages in thread
From: Zdenek Kabelac @ 2017-08-14 11:59 UTC (permalink / raw)
To: lvm-devel
Dne 14.8.2017 v 13:09 Zhang Huan napsal(a):
> commit 19d8fbd0e142c0d35eb5bcc96671682afb548a23
> Author: Huan Zhang <zhanghuan@chinac.com>
> Date: Mon Aug 14 18:51:26 2017 +0800
>
Hello Zhang
Can you please open upstream LVM2 BZ for this:
https://bugzilla.redhat.com/enter_bug.cgi?product=LVM%20and%20device-mapper
I expect the thing will not go so smoothly.
Regards
Zdenek
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-08-14 11:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-14 11:09 [patch review] reduce io impact for finding sanlock lv free lock offset Zhang Huan
2017-08-14 11:59 ` Zdenek Kabelac
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.