diff options
author | Joel Becker <joel.becker@oracle.com> | 2008-07-17 18:21:29 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2008-07-17 18:21:29 -0400 |
commit | a6795e9ebb420d87af43789174689af0d66d1d35 (patch) | |
tree | fb2a86ad010015fdd311f3b7f6ef30f60c14b8f7 /fs/ocfs2/cluster/nodemanager.c | |
parent | f89ab8619e5320cc9c2576f5f8dcbaf6c0ba3950 (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/nodemanager.c')
-rw-r--r-- | fs/ocfs2/cluster/nodemanager.c | 16 |
1 files changed, 5 insertions, 11 deletions
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 | |||
666 | out: | ||
667 | if (ret == NULL) | ||
668 | kfree(node); | ||
669 | |||
670 | return ret; | ||
671 | } | 664 | } |
672 | 665 | ||
673 | static void o2nm_node_group_drop_item(struct config_group *group, | 666 | static 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; |