* [Cluster-devel] [PATCH 0/3] dlm_controld: more plock fixes and cleanups
@ 2023-03-17 20:40 Alexander Aring
2023-03-17 20:41 ` [Cluster-devel] [PATCH 1/3] dlm_controld: initialize waiter->flags Alexander Aring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Alexander Aring @ 2023-03-17 20:40 UTC (permalink / raw)
To: cluster-devel.redhat.com
Hi,
more patches of fixes and cleanups found by Andreas Gruenbacher.
Changes by me:
Added more cases when waiter struct is allocated by malloc() and
flags is not zeroed.
Thanks.
Andreas Gruenbacher (3):
dlm_controld: initialize waiter->flags
dlm_controld: get rid of unnecessary memset
dlm_controld: remove unnecessary list_empty check
dlm_controld/plock.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 4+ messages in thread* [Cluster-devel] [PATCH 1/3] dlm_controld: initialize waiter->flags 2023-03-17 20:40 [Cluster-devel] [PATCH 0/3] dlm_controld: more plock fixes and cleanups Alexander Aring @ 2023-03-17 20:41 ` Alexander Aring 2023-03-17 20:41 ` [Cluster-devel] [PATCH 2/3] dlm_controld: get rid of unnecessary memset Alexander Aring 2023-03-17 20:41 ` [Cluster-devel] [PATCH 3/3] dlm_controld: remove unnecessary list_empty check Alexander Aring 2 siblings, 0 replies; 4+ messages in thread From: Alexander Aring @ 2023-03-17 20:41 UTC (permalink / raw) To: cluster-devel.redhat.com From: Andreas Gruenbacher <agruenba@redhat.com> In function add_waiter(), waiter->flags is left uninitialized. Fix that. In function add_lock(), the allocated lock is zeroed out and then all fields except po->flags are initialized. That's not wrong, but it seems easier to initialize po->flags instead, like add_waiter() does now. --- dlm_controld/plock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c index 24ad777a..f03f3abe 100644 --- a/dlm_controld/plock.c +++ b/dlm_controld/plock.c @@ -455,7 +455,6 @@ static int add_lock(struct resource *r, uint32_t nodeid, uint64_t owner, po = malloc(sizeof(struct posix_lock)); if (!po) return -ENOMEM; - memset(po, 0, sizeof(struct posix_lock)); po->start = start; po->end = end; @@ -463,6 +462,7 @@ static int add_lock(struct resource *r, uint32_t nodeid, uint64_t owner, po->owner = owner; po->pid = pid; po->ex = ex; + po->flags = 0; list_add_tail(&po->list, &r->locks); return 0; @@ -680,6 +680,7 @@ static int add_waiter(struct lockspace *ls, struct resource *r, if (!w) return -ENOMEM; memcpy(&w->info, in, sizeof(struct dlm_plock_info)); + w->flags = 0; list_add_tail(&w->list, &r->waiters); return 0; } @@ -1095,6 +1096,7 @@ static void save_pending_plock(struct lockspace *ls, struct resource *r, return; } memcpy(&w->info, in, sizeof(struct dlm_plock_info)); + w->flags = 0; list_add_tail(&w->list, &r->pending); } @@ -1967,6 +1969,7 @@ void receive_plocks_data(struct lockspace *ls, struct dlm_header *hd, int len) w->info.pid = le32_to_cpu(pp->pid); w->info.nodeid = le32_to_cpu(pp->nodeid); w->info.ex = pp->ex; + w->flags = 0; list_add_tail(&w->list, &r->waiters); } pp++; -- 2.31.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Cluster-devel] [PATCH 2/3] dlm_controld: get rid of unnecessary memset 2023-03-17 20:40 [Cluster-devel] [PATCH 0/3] dlm_controld: more plock fixes and cleanups Alexander Aring 2023-03-17 20:41 ` [Cluster-devel] [PATCH 1/3] dlm_controld: initialize waiter->flags Alexander Aring @ 2023-03-17 20:41 ` Alexander Aring 2023-03-17 20:41 ` [Cluster-devel] [PATCH 3/3] dlm_controld: remove unnecessary list_empty check Alexander Aring 2 siblings, 0 replies; 4+ messages in thread From: Alexander Aring @ 2023-03-17 20:41 UTC (permalink / raw) To: cluster-devel.redhat.com From: Andreas Gruenbacher <agruenba@redhat.com> In process_plocks(), we're reading in the entire info object, so there is no need to zero out the buffer first. --- dlm_controld/plock.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c index f03f3abe..85d6fdf2 100644 --- a/dlm_controld/plock.c +++ b/dlm_controld/plock.c @@ -1523,8 +1523,6 @@ void process_plocks(int ci) gettimeofday(&now, NULL); - memset(&info, 0, sizeof(info)); - rv = do_read(plock_device_fd, &info, sizeof(info)); if (rv < 0) { log_debug("process_plocks: read error %d fd %d\n", -- 2.31.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Cluster-devel] [PATCH 3/3] dlm_controld: remove unnecessary list_empty check 2023-03-17 20:40 [Cluster-devel] [PATCH 0/3] dlm_controld: more plock fixes and cleanups Alexander Aring 2023-03-17 20:41 ` [Cluster-devel] [PATCH 1/3] dlm_controld: initialize waiter->flags Alexander Aring 2023-03-17 20:41 ` [Cluster-devel] [PATCH 2/3] dlm_controld: get rid of unnecessary memset Alexander Aring @ 2023-03-17 20:41 ` Alexander Aring 2 siblings, 0 replies; 4+ messages in thread From: Alexander Aring @ 2023-03-17 20:41 UTC (permalink / raw) To: cluster-devel.redhat.com From: Andreas Gruenbacher <agruenba@redhat.com> All that do_waiters() does is iterate the the waiters list of a resource, so there is no need to check if the waiters list is empty before calling do_waiters(). --- dlm_controld/plock.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dlm_controld/plock.c b/dlm_controld/plock.c index 85d6fdf2..ad9b0f27 100644 --- a/dlm_controld/plock.c +++ b/dlm_controld/plock.c @@ -2055,8 +2055,7 @@ void purge_plocks(struct lockspace *ls, int nodeid, int unmount) send_pending_plocks(ls, r); } - if (!list_empty(&r->waiters)) - do_waiters(ls, r); + do_waiters(ls, r); if (!opt(plock_ownership_ind) && list_empty(&r->locks) && list_empty(&r->waiters)) { -- 2.31.1 ^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-03-17 20:41 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-03-17 20:40 [Cluster-devel] [PATCH 0/3] dlm_controld: more plock fixes and cleanups Alexander Aring 2023-03-17 20:41 ` [Cluster-devel] [PATCH 1/3] dlm_controld: initialize waiter->flags Alexander Aring 2023-03-17 20:41 ` [Cluster-devel] [PATCH 2/3] dlm_controld: get rid of unnecessary memset Alexander Aring 2023-03-17 20:41 ` [Cluster-devel] [PATCH 3/3] dlm_controld: remove unnecessary list_empty check Alexander Aring
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).