Skip to content

Commit 13dd7f8

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/teigland/dlm: dlm: choose better identifiers dlm: remove bkl dlm: fix address compare dlm: fix locking of lockspace list in dlm_scand dlm: detect available userspace daemon dlm: allow multiple lockspace creates
2 parents b0af205 + 27eccf4 commit 13dd7f8

File tree

9 files changed

+281
-100
lines changed

9 files changed

+281
-100
lines changed

fs/dlm/config.c

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
#include <linux/kernel.h>
1515
#include <linux/module.h>
1616
#include <linux/configfs.h>
17+
#include <linux/in.h>
18+
#include <linux/in6.h>
19+
#include <net/ipv6.h>
1720
#include <net/sock.h>
1821

1922
#include "config.h"
@@ -377,24 +380,24 @@ static struct config_item_type node_type = {
377380
.ct_owner = THIS_MODULE,
378381
};
379382

380-
static struct dlm_cluster *to_cluster(struct config_item *i)
383+
static struct dlm_cluster *config_item_to_cluster(struct config_item *i)
381384
{
382385
return i ? container_of(to_config_group(i), struct dlm_cluster, group) :
383386
NULL;
384387
}
385388

386-
static struct dlm_space *to_space(struct config_item *i)
389+
static struct dlm_space *config_item_to_space(struct config_item *i)
387390
{
388391
return i ? container_of(to_config_group(i), struct dlm_space, group) :
389392
NULL;
390393
}
391394

392-
static struct dlm_comm *to_comm(struct config_item *i)
395+
static struct dlm_comm *config_item_to_comm(struct config_item *i)
393396
{
394397
return i ? container_of(i, struct dlm_comm, item) : NULL;
395398
}
396399

397-
static struct dlm_node *to_node(struct config_item *i)
400+
static struct dlm_node *config_item_to_node(struct config_item *i)
398401
{
399402
return i ? container_of(i, struct dlm_node, item) : NULL;
400403
}
@@ -450,7 +453,7 @@ static struct config_group *make_cluster(struct config_group *g,
450453

451454
static void drop_cluster(struct config_group *g, struct config_item *i)
452455
{
453-
struct dlm_cluster *cl = to_cluster(i);
456+
struct dlm_cluster *cl = config_item_to_cluster(i);
454457
struct config_item *tmp;
455458
int j;
456459

@@ -468,7 +471,7 @@ static void drop_cluster(struct config_group *g, struct config_item *i)
468471

469472
static void release_cluster(struct config_item *i)
470473
{
471-
struct dlm_cluster *cl = to_cluster(i);
474+
struct dlm_cluster *cl = config_item_to_cluster(i);
472475
kfree(cl->group.default_groups);
473476
kfree(cl);
474477
}
@@ -507,7 +510,7 @@ static struct config_group *make_space(struct config_group *g, const char *name)
507510

508511
static void drop_space(struct config_group *g, struct config_item *i)
509512
{
510-
struct dlm_space *sp = to_space(i);
513+
struct dlm_space *sp = config_item_to_space(i);
511514
struct config_item *tmp;
512515
int j;
513516

@@ -524,7 +527,7 @@ static void drop_space(struct config_group *g, struct config_item *i)
524527

525528
static void release_space(struct config_item *i)
526529
{
527-
struct dlm_space *sp = to_space(i);
530+
struct dlm_space *sp = config_item_to_space(i);
528531
kfree(sp->group.default_groups);
529532
kfree(sp);
530533
}
@@ -546,7 +549,7 @@ static struct config_item *make_comm(struct config_group *g, const char *name)
546549

547550
static void drop_comm(struct config_group *g, struct config_item *i)
548551
{
549-
struct dlm_comm *cm = to_comm(i);
552+
struct dlm_comm *cm = config_item_to_comm(i);
550553
if (local_comm == cm)
551554
local_comm = NULL;
552555
dlm_lowcomms_close(cm->nodeid);
@@ -557,13 +560,13 @@ static void drop_comm(struct config_group *g, struct config_item *i)
557560

558561
static void release_comm(struct config_item *i)
559562
{
560-
struct dlm_comm *cm = to_comm(i);
563+
struct dlm_comm *cm = config_item_to_comm(i);
561564
kfree(cm);
562565
}
563566

564567
static struct config_item *make_node(struct config_group *g, const char *name)
565568
{
566-
struct dlm_space *sp = to_space(g->cg_item.ci_parent);
569+
struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent);
567570
struct dlm_node *nd;
568571

569572
nd = kzalloc(sizeof(struct dlm_node), GFP_KERNEL);
@@ -585,8 +588,8 @@ static struct config_item *make_node(struct config_group *g, const char *name)
585588

586589
static void drop_node(struct config_group *g, struct config_item *i)
587590
{
588-
struct dlm_space *sp = to_space(g->cg_item.ci_parent);
589-
struct dlm_node *nd = to_node(i);
591+
struct dlm_space *sp = config_item_to_space(g->cg_item.ci_parent);
592+
struct dlm_node *nd = config_item_to_node(i);
590593

591594
mutex_lock(&sp->members_lock);
592595
list_del(&nd->list);
@@ -598,7 +601,7 @@ static void drop_node(struct config_group *g, struct config_item *i)
598601

599602
static void release_node(struct config_item *i)
600603
{
601-
struct dlm_node *nd = to_node(i);
604+
struct dlm_node *nd = config_item_to_node(i);
602605
kfree(nd);
603606
}
604607

@@ -632,7 +635,7 @@ void dlm_config_exit(void)
632635
static ssize_t show_cluster(struct config_item *i, struct configfs_attribute *a,
633636
char *buf)
634637
{
635-
struct dlm_cluster *cl = to_cluster(i);
638+
struct dlm_cluster *cl = config_item_to_cluster(i);
636639
struct cluster_attribute *cla =
637640
container_of(a, struct cluster_attribute, attr);
638641
return cla->show ? cla->show(cl, buf) : 0;
@@ -642,7 +645,7 @@ static ssize_t store_cluster(struct config_item *i,
642645
struct configfs_attribute *a,
643646
const char *buf, size_t len)
644647
{
645-
struct dlm_cluster *cl = to_cluster(i);
648+
struct dlm_cluster *cl = config_item_to_cluster(i);
646649
struct cluster_attribute *cla =
647650
container_of(a, struct cluster_attribute, attr);
648651
return cla->store ? cla->store(cl, buf, len) : -EINVAL;
@@ -651,7 +654,7 @@ static ssize_t store_cluster(struct config_item *i,
651654
static ssize_t show_comm(struct config_item *i, struct configfs_attribute *a,
652655
char *buf)
653656
{
654-
struct dlm_comm *cm = to_comm(i);
657+
struct dlm_comm *cm = config_item_to_comm(i);
655658
struct comm_attribute *cma =
656659
container_of(a, struct comm_attribute, attr);
657660
return cma->show ? cma->show(cm, buf) : 0;
@@ -660,7 +663,7 @@ static ssize_t show_comm(struct config_item *i, struct configfs_attribute *a,
660663
static ssize_t store_comm(struct config_item *i, struct configfs_attribute *a,
661664
const char *buf, size_t len)
662665
{
663-
struct dlm_comm *cm = to_comm(i);
666+
struct dlm_comm *cm = config_item_to_comm(i);
664667
struct comm_attribute *cma =
665668
container_of(a, struct comm_attribute, attr);
666669
return cma->store ? cma->store(cm, buf, len) : -EINVAL;
@@ -714,7 +717,7 @@ static ssize_t comm_addr_write(struct dlm_comm *cm, const char *buf, size_t len)
714717
static ssize_t show_node(struct config_item *i, struct configfs_attribute *a,
715718
char *buf)
716719
{
717-
struct dlm_node *nd = to_node(i);
720+
struct dlm_node *nd = config_item_to_node(i);
718721
struct node_attribute *nda =
719722
container_of(a, struct node_attribute, attr);
720723
return nda->show ? nda->show(nd, buf) : 0;
@@ -723,7 +726,7 @@ static ssize_t show_node(struct config_item *i, struct configfs_attribute *a,
723726
static ssize_t store_node(struct config_item *i, struct configfs_attribute *a,
724727
const char *buf, size_t len)
725728
{
726-
struct dlm_node *nd = to_node(i);
729+
struct dlm_node *nd = config_item_to_node(i);
727730
struct node_attribute *nda =
728731
container_of(a, struct node_attribute, attr);
729732
return nda->store ? nda->store(nd, buf, len) : -EINVAL;
@@ -768,14 +771,41 @@ static struct dlm_space *get_space(char *name)
768771
i = config_group_find_item(space_list, name);
769772
mutex_unlock(&space_list->cg_subsys->su_mutex);
770773

771-
return to_space(i);
774+
return config_item_to_space(i);
772775
}
773776

774777
static void put_space(struct dlm_space *sp)
775778
{
776779
config_item_put(&sp->group.cg_item);
777780
}
778781

782+
static int addr_compare(struct sockaddr_storage *x, struct sockaddr_storage *y)
783+
{
784+
switch (x->ss_family) {
785+
case AF_INET: {
786+
struct sockaddr_in *sinx = (struct sockaddr_in *)x;
787+
struct sockaddr_in *siny = (struct sockaddr_in *)y;
788+
if (sinx->sin_addr.s_addr != siny->sin_addr.s_addr)
789+
return 0;
790+
if (sinx->sin_port != siny->sin_port)
791+
return 0;
792+
break;
793+
}
794+
case AF_INET6: {
795+
struct sockaddr_in6 *sinx = (struct sockaddr_in6 *)x;
796+
struct sockaddr_in6 *siny = (struct sockaddr_in6 *)y;
797+
if (!ipv6_addr_equal(&sinx->sin6_addr, &siny->sin6_addr))
798+
return 0;
799+
if (sinx->sin6_port != siny->sin6_port)
800+
return 0;
801+
break;
802+
}
803+
default:
804+
return 0;
805+
}
806+
return 1;
807+
}
808+
779809
static struct dlm_comm *get_comm(int nodeid, struct sockaddr_storage *addr)
780810
{
781811
struct config_item *i;
@@ -788,7 +818,7 @@ static struct dlm_comm *get_comm(int nodeid, struct sockaddr_storage *addr)
788818
mutex_lock(&clusters_root.subsys.su_mutex);
789819

790820
list_for_each_entry(i, &comm_list->cg_children, ci_entry) {
791-
cm = to_comm(i);
821+
cm = config_item_to_comm(i);
792822

793823
if (nodeid) {
794824
if (cm->nodeid != nodeid)
@@ -797,8 +827,7 @@ static struct dlm_comm *get_comm(int nodeid, struct sockaddr_storage *addr)
797827
config_item_get(i);
798828
break;
799829
} else {
800-
if (!cm->addr_count ||
801-
memcmp(cm->addr[0], addr, sizeof(*addr)))
830+
if (!cm->addr_count || !addr_compare(cm->addr[0], addr))
802831
continue;
803832
found = 1;
804833
config_item_get(i);

fs/dlm/dlm_internal.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
*******************************************************************************
33
**
44
** Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
5-
** Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
5+
** Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
66
**
77
** This copyrighted material is made available to anyone wishing to use,
88
** modify, copy, or redistribute it subject to the terms and conditions
@@ -441,8 +441,11 @@ struct dlm_ls {
441441
uint32_t ls_global_id; /* global unique lockspace ID */
442442
uint32_t ls_exflags;
443443
int ls_lvblen;
444-
int ls_count; /* reference count */
444+
int ls_count; /* refcount of processes in
445+
the dlm using this ls */
446+
int ls_create_count; /* create/release refcount */
445447
unsigned long ls_flags; /* LSFL_ */
448+
unsigned long ls_scan_time;
446449
struct kobject ls_kobj;
447450

448451
struct dlm_rsbtable *ls_rsbtbl;

0 commit comments

Comments
 (0)