aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2008-07-20 20:17:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-20 20:17:52 -0400
commitf7df406dce01dfd30d7e0c570a928bcfeff03142 (patch)
tree6befad5177581f2f136b22117670f00019c7ea0f /fs/ocfs2
parent5e248ac9a5c465b356b936030d5a2e80887eb266 (diff)
parenta6795e9ebb420d87af43789174689af0d66d1d35 (diff)
Merge branch 'configfs-fixup-ptr-error' of git://oss.oracle.com/git/jlbec/linux-2.6
* 'configfs-fixup-ptr-error' of git://oss.oracle.com/git/jlbec/linux-2.6: configfs: Allow ->make_item() and ->make_group() to return detailed errors. Revert "configfs: Allow ->make_item() and ->make_group() to return detailed errors."
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/cluster/heartbeat.c19
-rw-r--r--fs/ocfs2/cluster/nodemanager.c49
2 files changed, 21 insertions, 47 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 443d108211ab..7dce1612553e 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1489,31 +1489,22 @@ static struct o2hb_heartbeat_group *to_o2hb_heartbeat_group(struct config_group
1489 : NULL; 1489 : NULL;
1490} 1490}
1491 1491
1492static int o2hb_heartbeat_group_make_item(struct config_group *group, 1492static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *group,
1493 const char *name, 1493 const char *name)
1494 struct config_item **new_item)
1495{ 1494{
1496 struct o2hb_region *reg = NULL; 1495 struct o2hb_region *reg = NULL;
1497 int ret = 0;
1498 1496
1499 reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); 1497 reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL);
1500 if (reg == NULL) { 1498 if (reg == NULL)
1501 ret = -ENOMEM; 1499 return ERR_PTR(-ENOMEM);
1502 goto out;
1503 }
1504 1500
1505 config_item_init_type_name(&reg->hr_item, name, &o2hb_region_type); 1501 config_item_init_type_name(&reg->hr_item, name, &o2hb_region_type);
1506 1502
1507 *new_item = &reg->hr_item;
1508
1509 spin_lock(&o2hb_live_lock); 1503 spin_lock(&o2hb_live_lock);
1510 list_add_tail(&reg->hr_all_item, &o2hb_all_regions); 1504 list_add_tail(&reg->hr_all_item, &o2hb_all_regions);
1511 spin_unlock(&o2hb_live_lock); 1505 spin_unlock(&o2hb_live_lock);
1512out:
1513 if (ret)
1514 kfree(reg);
1515 1506
1516 return ret; 1507 return &reg->hr_item;
1517} 1508}
1518 1509
1519static void o2hb_heartbeat_group_drop_item(struct config_group *group, 1510static void o2hb_heartbeat_group_drop_item(struct config_group *group,
diff --git a/fs/ocfs2/cluster/nodemanager.c b/fs/ocfs2/cluster/nodemanager.c
index b364b7052e46..816a3f61330c 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -644,35 +644,23 @@ out:
644 return ret; 644 return ret;
645} 645}
646 646
647static int o2nm_node_group_make_item(struct config_group *group, 647static struct config_item *o2nm_node_group_make_item(struct config_group *group,
648 const char *name, 648 const char *name)
649 struct config_item **new_item)
650{ 649{
651 struct o2nm_node *node = NULL; 650 struct o2nm_node *node = NULL;
652 int ret = 0;
653 651
654 if (strlen(name) > O2NM_MAX_NAME_LEN) { 652 if (strlen(name) > O2NM_MAX_NAME_LEN)
655 ret = -ENAMETOOLONG; 653 return ERR_PTR(-ENAMETOOLONG);
656 goto out;
657 }
658 654
659 node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL); 655 node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL);
660 if (node == NULL) { 656 if (node == NULL)
661 ret = -ENOMEM; 657 return ERR_PTR(-ENOMEM);
662 goto out;
663 }
664 658
665 strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ 659 strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */
666 config_item_init_type_name(&node->nd_item, name, &o2nm_node_type); 660 config_item_init_type_name(&node->nd_item, name, &o2nm_node_type);
667 spin_lock_init(&node->nd_lock); 661 spin_lock_init(&node->nd_lock);
668 662
669 *new_item = &node->nd_item; 663 return &node->nd_item;
670
671out:
672 if (ret)
673 kfree(node);
674
675 return ret;
676} 664}
677 665
678static void o2nm_node_group_drop_item(struct config_group *group, 666static void o2nm_node_group_drop_item(struct config_group *group,
@@ -756,31 +744,25 @@ static struct o2nm_cluster_group *to_o2nm_cluster_group(struct config_group *gro
756} 744}
757#endif 745#endif
758 746
759static int o2nm_cluster_group_make_group(struct config_group *group, 747static struct config_group *o2nm_cluster_group_make_group(struct config_group *group,
760 const char *name, 748 const char *name)
761 struct config_group **new_group)
762{ 749{
763 struct o2nm_cluster *cluster = NULL; 750 struct o2nm_cluster *cluster = NULL;
764 struct o2nm_node_group *ns = NULL; 751 struct o2nm_node_group *ns = NULL;
765 struct config_group *o2hb_group = NULL; 752 struct config_group *o2hb_group = NULL, *ret = NULL;
766 void *defs = NULL; 753 void *defs = NULL;
767 int ret = 0;
768 754
769 /* this runs under the parent dir's i_mutex; there can be only 755 /* this runs under the parent dir's i_mutex; there can be only
770 * one caller in here at a time */ 756 * one caller in here at a time */
771 if (o2nm_single_cluster) { 757 if (o2nm_single_cluster)
772 ret = -ENOSPC; 758 return ERR_PTR(-ENOSPC);
773 goto out;
774 }
775 759
776 cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); 760 cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL);
777 ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); 761 ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL);
778 defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); 762 defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL);
779 o2hb_group = o2hb_alloc_hb_set(); 763 o2hb_group = o2hb_alloc_hb_set();
780 if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL) { 764 if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL)
781 ret = -ENOMEM;
782 goto out; 765 goto out;
783 }
784 766
785 config_group_init_type_name(&cluster->cl_group, name, 767 config_group_init_type_name(&cluster->cl_group, name,
786 &o2nm_cluster_type); 768 &o2nm_cluster_type);
@@ -797,15 +779,16 @@ static int o2nm_cluster_group_make_group(struct config_group *group,
797 cluster->cl_idle_timeout_ms = O2NET_IDLE_TIMEOUT_MS_DEFAULT; 779 cluster->cl_idle_timeout_ms = O2NET_IDLE_TIMEOUT_MS_DEFAULT;
798 cluster->cl_keepalive_delay_ms = O2NET_KEEPALIVE_DELAY_MS_DEFAULT; 780 cluster->cl_keepalive_delay_ms = O2NET_KEEPALIVE_DELAY_MS_DEFAULT;
799 781
800 *new_group = &cluster->cl_group; 782 ret = &cluster->cl_group;
801 o2nm_single_cluster = cluster; 783 o2nm_single_cluster = cluster;
802 784
803out: 785out:
804 if (ret) { 786 if (ret == NULL) {
805 kfree(cluster); 787 kfree(cluster);
806 kfree(ns); 788 kfree(ns);
807 o2hb_free_hb_set(o2hb_group); 789 o2hb_free_hb_set(o2hb_group);
808 kfree(defs); 790 kfree(defs);
791 ret = ERR_PTR(-ENOMEM);
809 } 792 }
810 793
811 return ret; 794 return ret;