aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/cluster
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-07-17 18:21:29 -0400
committerJoel Becker <joel.becker@oracle.com>2008-07-17 18:21:29 -0400
commita6795e9ebb420d87af43789174689af0d66d1d35 (patch)
treefb2a86ad010015fdd311f3b7f6ef30f60c14b8f7 /fs/ocfs2/cluster
parentf89ab8619e5320cc9c2576f5f8dcbaf6c0ba3950 (diff)
configfs: Allow ->make_item() and ->make_group() to return detailed errors.
The configfs operations ->make_item() and ->make_group() currently return a new item/group. A return of NULL signifies an error. Because of this, -ENOMEM is the only return code bubbled up the stack. Multiple folks have requested the ability to return specific error codes when these operations fail. This patch adds that ability by changing the ->make_item/group() ops to return ERR_PTR() values. These errors are bubbled up appropriately. NULL returns are changed to -ENOMEM for compatibility. Also updated are the in-kernel users of configfs. This is a rework of reverted commit 11c3b79218390a139f2d474ee1e983a672d5839a. Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/cluster')
-rw-r--r--fs/ocfs2/cluster/heartbeat.c10
-rw-r--r--fs/ocfs2/cluster/nodemanager.c16
2 files changed, 7 insertions, 19 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index f02ccb34604d..7dce1612553e 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1493,24 +1493,18 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g
1493 const char *name) 1493 const char *name)
1494{ 1494{
1495 struct o2hb_region *reg = NULL; 1495 struct o2hb_region *reg = NULL;
1496 struct config_item *ret = NULL;
1497 1496
1498 reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); 1497 reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL);
1499 if (reg == NULL) 1498 if (reg == NULL)
1500 goto out; /* ENOMEM */ 1499 return ERR_PTR(-ENOMEM);
1501 1500
1502 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);
1503 1502
1504 ret = &reg->hr_item;
1505
1506 spin_lock(&o2hb_live_lock); 1503 spin_lock(&o2hb_live_lock);
1507 list_add_tail(&reg->hr_all_item, &o2hb_all_regions); 1504 list_add_tail(&reg->hr_all_item, &o2hb_all_regions);
1508 spin_unlock(&o2hb_live_lock); 1505 spin_unlock(&o2hb_live_lock);
1509out:
1510 if (ret == NULL)
1511 kfree(reg);
1512 1506
1513 return ret; 1507 return &reg->hr_item;
1514} 1508}
1515 1509
1516static 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 cfdb08b484ed..816a3f61330c 100644
--- a/fs/ocfs2/cluster/nodemanager.c
+++ b/fs/ocfs2/cluster/nodemanager.c
@@ -648,26 +648,19 @@ static struct config_item *o2nm_node_group_make_item(struct config_group *group,
648 const char *name) 648 const char *name)
649{ 649{
650 struct o2nm_node *node = NULL; 650 struct o2nm_node *node = NULL;
651 struct config_item *ret = NULL;
652 651
653 if (strlen(name) > O2NM_MAX_NAME_LEN) 652 if (strlen(name) > O2NM_MAX_NAME_LEN)
654 goto out; /* ENAMETOOLONG */ 653 return ERR_PTR(-ENAMETOOLONG);
655 654
656 node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL); 655 node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL);
657 if (node == NULL) 656 if (node == NULL)
658 goto out; /* ENOMEM */ 657 return ERR_PTR(-ENOMEM);
659 658
660 strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ 659 strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */
661 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);
662 spin_lock_init(&node->nd_lock); 661 spin_lock_init(&node->nd_lock);
663 662
664 ret = &node->nd_item; 663 return &node->nd_item;
665
666out:
667 if (ret == NULL)
668 kfree(node);
669
670 return ret;
671} 664}
672 665
673static void o2nm_node_group_drop_item(struct config_group *group, 666static void o2nm_node_group_drop_item(struct config_group *group,
@@ -762,7 +755,7 @@ static struct config_group *o2nm_cluster_group_make_group(struct config_group *g
762 /* 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
763 * one caller in here at a time */ 756 * one caller in here at a time */
764 if (o2nm_single_cluster) 757 if (o2nm_single_cluster)
765 goto out; /* ENOSPC */ 758 return ERR_PTR(-ENOSPC);
766 759
767 cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); 760 cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL);
768 ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); 761 ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL);
@@ -795,6 +788,7 @@ out:
795 kfree(ns); 788 kfree(ns);
796 o2hb_free_hb_set(o2hb_group); 789 o2hb_free_hb_set(o2hb_group);
797 kfree(defs); 790 kfree(defs);
791 ret = ERR_PTR(-ENOMEM);
798 } 792 }
799 793
800 return ret; 794 return ret;