aboutsummaryrefslogtreecommitdiffstats
path: root/fs/dlm/config.c
diff options
context:
space:
mode:
authorSatyam Sharma <ssatyam@cse.iitk.ac.in>2007-05-08 04:18:58 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2007-07-09 03:22:10 -0400
commit3168b0780d06ace875696f8a648d04d6089654e5 (patch)
treeb93814b13155cce67432e1ed11bee58c9a5d5a50 /fs/dlm/config.c
parentb524fe646c9a226a847e30ca1221dc22e952f16b (diff)
[DLM] fix a couple of races
Fix two races in fs/dlm/config.c: (1) Grab the configfs subsystem semaphore before calling config_group_find_obj() in get_space(). This solves a potential race between get_space() and concurrent mkdir(2) or rmdir(2). (2) Grab a reference on the found config_item _while_ holding the configfs subsystem semaphore in get_comm(), and not after it. This solves a potential race between get_comm() and concurrent rmdir(2). Signed-off-by: Satyam Sharma <ssatyam@cse.iitk.ac.in> Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/dlm/config.c')
-rw-r--r--fs/dlm/config.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/fs/dlm/config.c b/fs/dlm/config.c
index 822abdcd1434..5a3d390cc826 100644
--- a/fs/dlm/config.c
+++ b/fs/dlm/config.c
@@ -748,9 +748,16 @@ static ssize_t node_weight_write(struct node *nd, const char *buf, size_t len)
748 748
749static struct space *get_space(char *name) 749static struct space *get_space(char *name)
750{ 750{
751 struct config_item *i;
752
751 if (!space_list) 753 if (!space_list)
752 return NULL; 754 return NULL;
753 return to_space(config_group_find_obj(space_list, name)); 755
756 down(&space_list->cg_subsys->su_sem);
757 i = config_group_find_obj(space_list, name);
758 up(&space_list->cg_subsys->su_sem);
759
760 return to_space(i);
754} 761}
755 762
756static void put_space(struct space *sp) 763static void put_space(struct space *sp)
@@ -776,20 +783,20 @@ static struct comm *get_comm(int nodeid, struct sockaddr_storage *addr)
776 if (cm->nodeid != nodeid) 783 if (cm->nodeid != nodeid)
777 continue; 784 continue;
778 found = 1; 785 found = 1;
786 config_item_get(i);
779 break; 787 break;
780 } else { 788 } else {
781 if (!cm->addr_count || 789 if (!cm->addr_count ||
782 memcmp(cm->addr[0], addr, sizeof(*addr))) 790 memcmp(cm->addr[0], addr, sizeof(*addr)))
783 continue; 791 continue;
784 found = 1; 792 found = 1;
793 config_item_get(i);
785 break; 794 break;
786 } 795 }
787 } 796 }
788 up(&clusters_root.subsys.su_sem); 797 up(&clusters_root.subsys.su_sem);
789 798
790 if (found) 799 if (!found)
791 config_item_get(i);
792 else
793 cm = NULL; 800 cm = NULL;
794 return cm; 801 return cm;
795} 802}