Commit f89ab8619e5320cc9c2576f5f8dcbaf6c0ba3950
1 parent
5b664cb235
Exists in
master
and in
4 other branches
Revert "configfs: Allow ->make_item() and ->make_group() to return detailed errors."
This reverts commit 11c3b79218390a139f2d474ee1e983a672d5839a. The code will move to PTR_ERR(). Signed-off-by: Joel Becker <joel.becker@oracle.com>
Showing 8 changed files with 64 additions and 94 deletions Side-by-side Diff
Documentation/filesystems/configfs/configfs.txt
... | ... | @@ -233,12 +233,10 @@ |
233 | 233 | config_item_type. |
234 | 234 | |
235 | 235 | struct configfs_group_operations { |
236 | - int (*make_item)(struct config_group *group, | |
237 | - const char *name, | |
238 | - struct config_item **new_item); | |
239 | - int (*make_group)(struct config_group *group, | |
240 | - const char *name, | |
241 | - struct config_group **new_group); | |
236 | + struct config_item *(*make_item)(struct config_group *group, | |
237 | + const char *name); | |
238 | + struct config_group *(*make_group)(struct config_group *group, | |
239 | + const char *name); | |
242 | 240 | int (*commit_item)(struct config_item *item); |
243 | 241 | void (*disconnect_notify)(struct config_group *group, |
244 | 242 | struct config_item *item); |
Documentation/filesystems/configfs/configfs_example.c
... | ... | @@ -273,13 +273,13 @@ |
273 | 273 | return item ? container_of(to_config_group(item), struct simple_children, group) : NULL; |
274 | 274 | } |
275 | 275 | |
276 | -static int simple_children_make_item(struct config_group *group, const char *name, struct config_item **new_item) | |
276 | +static struct config_item *simple_children_make_item(struct config_group *group, const char *name) | |
277 | 277 | { |
278 | 278 | struct simple_child *simple_child; |
279 | 279 | |
280 | 280 | simple_child = kzalloc(sizeof(struct simple_child), GFP_KERNEL); |
281 | 281 | if (!simple_child) |
282 | - return -ENOMEM; | |
282 | + return NULL; | |
283 | 283 | |
284 | 284 | |
285 | 285 | config_item_init_type_name(&simple_child->item, name, |
... | ... | @@ -287,8 +287,7 @@ |
287 | 287 | |
288 | 288 | simple_child->storeme = 0; |
289 | 289 | |
290 | - *new_item = &simple_child->item; | |
291 | - return 0; | |
290 | + return &simple_child->item; | |
292 | 291 | } |
293 | 292 | |
294 | 293 | static struct configfs_attribute simple_children_attr_description = { |
295 | 294 | |
296 | 295 | |
... | ... | @@ -360,21 +359,20 @@ |
360 | 359 | * children of its own. |
361 | 360 | */ |
362 | 361 | |
363 | -static int group_children_make_group(struct config_group *group, const char *name, struct config_group **new_group) | |
362 | +static struct config_group *group_children_make_group(struct config_group *group, const char *name) | |
364 | 363 | { |
365 | 364 | struct simple_children *simple_children; |
366 | 365 | |
367 | 366 | simple_children = kzalloc(sizeof(struct simple_children), |
368 | 367 | GFP_KERNEL); |
369 | 368 | if (!simple_children) |
370 | - return -ENOMEM; | |
369 | + return NULL; | |
371 | 370 | |
372 | 371 | |
373 | 372 | config_group_init_type_name(&simple_children->group, name, |
374 | 373 | &simple_children_type); |
375 | 374 | |
376 | - *new_group = &simple_children->group; | |
377 | - return 0; | |
375 | + return &simple_children->group; | |
378 | 376 | } |
379 | 377 | |
380 | 378 | static struct configfs_attribute group_children_attr_description = { |
drivers/net/netconsole.c
... | ... | @@ -585,9 +585,8 @@ |
585 | 585 | * Group operations and type for netconsole_subsys. |
586 | 586 | */ |
587 | 587 | |
588 | -static int make_netconsole_target(struct config_group *group, | |
589 | - const char *name, | |
590 | - struct config_item **new_item) | |
588 | +static struct config_item *make_netconsole_target(struct config_group *group, | |
589 | + const char *name) | |
591 | 590 | { |
592 | 591 | unsigned long flags; |
593 | 592 | struct netconsole_target *nt; |
... | ... | @@ -599,7 +598,7 @@ |
599 | 598 | nt = kzalloc(sizeof(*nt), GFP_KERNEL); |
600 | 599 | if (!nt) { |
601 | 600 | printk(KERN_ERR "netconsole: failed to allocate memory\n"); |
602 | - return -ENOMEM; | |
601 | + return NULL; | |
603 | 602 | } |
604 | 603 | |
605 | 604 | nt->np.name = "netconsole"; |
... | ... | @@ -616,8 +615,7 @@ |
616 | 615 | list_add(&nt->list, &target_list); |
617 | 616 | spin_unlock_irqrestore(&target_list_lock, flags); |
618 | 617 | |
619 | - *new_item = &nt->item; | |
620 | - return 0; | |
618 | + return &nt->item; | |
621 | 619 | } |
622 | 620 | |
623 | 621 | static void drop_netconsole_target(struct config_group *group, |
fs/configfs/dir.c
... | ... | @@ -1073,24 +1073,25 @@ |
1073 | 1073 | group = NULL; |
1074 | 1074 | item = NULL; |
1075 | 1075 | if (type->ct_group_ops->make_group) { |
1076 | - ret = type->ct_group_ops->make_group(to_config_group(parent_item), name, &group); | |
1077 | - if (!ret) { | |
1076 | + group = type->ct_group_ops->make_group(to_config_group(parent_item), name); | |
1077 | + if (group) { | |
1078 | 1078 | link_group(to_config_group(parent_item), group); |
1079 | 1079 | item = &group->cg_item; |
1080 | 1080 | } |
1081 | 1081 | } else { |
1082 | - ret = type->ct_group_ops->make_item(to_config_group(parent_item), name, &item); | |
1083 | - if (!ret) | |
1082 | + item = type->ct_group_ops->make_item(to_config_group(parent_item), name); | |
1083 | + if (item) | |
1084 | 1084 | link_obj(parent_item, item); |
1085 | 1085 | } |
1086 | 1086 | mutex_unlock(&subsys->su_mutex); |
1087 | 1087 | |
1088 | 1088 | kfree(name); |
1089 | - if (ret) { | |
1089 | + if (!item) { | |
1090 | 1090 | /* |
1091 | - * If ret != 0, then link_obj() was never called. | |
1091 | + * If item == NULL, then link_obj() was never called. | |
1092 | 1092 | * There are no extra references to clean up. |
1093 | 1093 | */ |
1094 | + ret = -ENOMEM; | |
1094 | 1095 | goto out_put; |
1095 | 1096 | } |
1096 | 1097 |
fs/dlm/config.c
... | ... | @@ -41,20 +41,16 @@ |
41 | 41 | struct nodes; |
42 | 42 | struct node; |
43 | 43 | |
44 | -static int make_cluster(struct config_group *, const char *, | |
45 | - struct config_group **); | |
44 | +static struct config_group *make_cluster(struct config_group *, const char *); | |
46 | 45 | static void drop_cluster(struct config_group *, struct config_item *); |
47 | 46 | static void release_cluster(struct config_item *); |
48 | -static int make_space(struct config_group *, const char *, | |
49 | - struct config_group **); | |
47 | +static struct config_group *make_space(struct config_group *, const char *); | |
50 | 48 | static void drop_space(struct config_group *, struct config_item *); |
51 | 49 | static void release_space(struct config_item *); |
52 | -static int make_comm(struct config_group *, const char *, | |
53 | - struct config_item **); | |
50 | +static struct config_item *make_comm(struct config_group *, const char *); | |
54 | 51 | static void drop_comm(struct config_group *, struct config_item *); |
55 | 52 | static void release_comm(struct config_item *); |
56 | -static int make_node(struct config_group *, const char *, | |
57 | - struct config_item **); | |
53 | +static struct config_item *make_node(struct config_group *, const char *); | |
58 | 54 | static void drop_node(struct config_group *, struct config_item *); |
59 | 55 | static void release_node(struct config_item *); |
60 | 56 | |
... | ... | @@ -396,8 +392,8 @@ |
396 | 392 | return i ? container_of(i, struct node, item) : NULL; |
397 | 393 | } |
398 | 394 | |
399 | -static int make_cluster(struct config_group *g, const char *name, | |
400 | - struct config_group **new_g) | |
395 | +static struct config_group *make_cluster(struct config_group *g, | |
396 | + const char *name) | |
401 | 397 | { |
402 | 398 | struct cluster *cl = NULL; |
403 | 399 | struct spaces *sps = NULL; |
404 | 400 | |
... | ... | @@ -435,15 +431,14 @@ |
435 | 431 | |
436 | 432 | space_list = &sps->ss_group; |
437 | 433 | comm_list = &cms->cs_group; |
438 | - *new_g = &cl->group; | |
439 | - return 0; | |
434 | + return &cl->group; | |
440 | 435 | |
441 | 436 | fail: |
442 | 437 | kfree(cl); |
443 | 438 | kfree(gps); |
444 | 439 | kfree(sps); |
445 | 440 | kfree(cms); |
446 | - return -ENOMEM; | |
441 | + return NULL; | |
447 | 442 | } |
448 | 443 | |
449 | 444 | static void drop_cluster(struct config_group *g, struct config_item *i) |
... | ... | @@ -471,8 +466,7 @@ |
471 | 466 | kfree(cl); |
472 | 467 | } |
473 | 468 | |
474 | -static int make_space(struct config_group *g, const char *name, | |
475 | - struct config_group **new_g) | |
469 | +static struct config_group *make_space(struct config_group *g, const char *name) | |
476 | 470 | { |
477 | 471 | struct space *sp = NULL; |
478 | 472 | struct nodes *nds = NULL; |
479 | 473 | |
... | ... | @@ -495,14 +489,13 @@ |
495 | 489 | INIT_LIST_HEAD(&sp->members); |
496 | 490 | mutex_init(&sp->members_lock); |
497 | 491 | sp->members_count = 0; |
498 | - *new_g = &sp->group; | |
499 | - return 0; | |
492 | + return &sp->group; | |
500 | 493 | |
501 | 494 | fail: |
502 | 495 | kfree(sp); |
503 | 496 | kfree(gps); |
504 | 497 | kfree(nds); |
505 | - return -ENOMEM; | |
498 | + return NULL; | |
506 | 499 | } |
507 | 500 | |
508 | 501 | static void drop_space(struct config_group *g, struct config_item *i) |
509 | 502 | |
510 | 503 | |
... | ... | @@ -529,21 +522,19 @@ |
529 | 522 | kfree(sp); |
530 | 523 | } |
531 | 524 | |
532 | -static int make_comm(struct config_group *g, const char *name, | |
533 | - struct config_item **new_i) | |
525 | +static struct config_item *make_comm(struct config_group *g, const char *name) | |
534 | 526 | { |
535 | 527 | struct comm *cm; |
536 | 528 | |
537 | 529 | cm = kzalloc(sizeof(struct comm), GFP_KERNEL); |
538 | 530 | if (!cm) |
539 | - return -ENOMEM; | |
531 | + return NULL; | |
540 | 532 | |
541 | 533 | config_item_init_type_name(&cm->item, name, &comm_type); |
542 | 534 | cm->nodeid = -1; |
543 | 535 | cm->local = 0; |
544 | 536 | cm->addr_count = 0; |
545 | - *new_i = &cm->item; | |
546 | - return 0; | |
537 | + return &cm->item; | |
547 | 538 | } |
548 | 539 | |
549 | 540 | static void drop_comm(struct config_group *g, struct config_item *i) |
550 | 541 | |
... | ... | @@ -563,15 +554,14 @@ |
563 | 554 | kfree(cm); |
564 | 555 | } |
565 | 556 | |
566 | -static int make_node(struct config_group *g, const char *name, | |
567 | - struct config_item **new_i) | |
557 | +static struct config_item *make_node(struct config_group *g, const char *name) | |
568 | 558 | { |
569 | 559 | struct space *sp = to_space(g->cg_item.ci_parent); |
570 | 560 | struct node *nd; |
571 | 561 | |
572 | 562 | nd = kzalloc(sizeof(struct node), GFP_KERNEL); |
573 | 563 | if (!nd) |
574 | - return -ENOMEM; | |
564 | + return NULL; | |
575 | 565 | |
576 | 566 | config_item_init_type_name(&nd->item, name, &node_type); |
577 | 567 | nd->nodeid = -1; |
... | ... | @@ -583,8 +573,7 @@ |
583 | 573 | sp->members_count++; |
584 | 574 | mutex_unlock(&sp->members_lock); |
585 | 575 | |
586 | - *new_i = &nd->item; | |
587 | - return 0; | |
576 | + return &nd->item; | |
588 | 577 | } |
589 | 578 | |
590 | 579 | static void drop_node(struct config_group *g, struct config_item *i) |
fs/ocfs2/cluster/heartbeat.c
... | ... | @@ -1489,28 +1489,25 @@ |
1489 | 1489 | : NULL; |
1490 | 1490 | } |
1491 | 1491 | |
1492 | -static int o2hb_heartbeat_group_make_item(struct config_group *group, | |
1493 | - const char *name, | |
1494 | - struct config_item **new_item) | |
1492 | +static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *group, | |
1493 | + const char *name) | |
1495 | 1494 | { |
1496 | 1495 | struct o2hb_region *reg = NULL; |
1497 | - int ret = 0; | |
1496 | + struct config_item *ret = NULL; | |
1498 | 1497 | |
1499 | 1498 | reg = kzalloc(sizeof(struct o2hb_region), GFP_KERNEL); |
1500 | - if (reg == NULL) { | |
1501 | - ret = -ENOMEM; | |
1502 | - goto out; | |
1503 | - } | |
1499 | + if (reg == NULL) | |
1500 | + goto out; /* ENOMEM */ | |
1504 | 1501 | |
1505 | 1502 | config_item_init_type_name(®->hr_item, name, &o2hb_region_type); |
1506 | 1503 | |
1507 | - *new_item = ®->hr_item; | |
1504 | + ret = ®->hr_item; | |
1508 | 1505 | |
1509 | 1506 | spin_lock(&o2hb_live_lock); |
1510 | 1507 | list_add_tail(®->hr_all_item, &o2hb_all_regions); |
1511 | 1508 | spin_unlock(&o2hb_live_lock); |
1512 | 1509 | out: |
1513 | - if (ret) | |
1510 | + if (ret == NULL) | |
1514 | 1511 | kfree(reg); |
1515 | 1512 | |
1516 | 1513 | return ret; |
fs/ocfs2/cluster/nodemanager.c
... | ... | @@ -644,32 +644,27 @@ |
644 | 644 | return ret; |
645 | 645 | } |
646 | 646 | |
647 | -static int o2nm_node_group_make_item(struct config_group *group, | |
648 | - const char *name, | |
649 | - struct config_item **new_item) | |
647 | +static struct config_item *o2nm_node_group_make_item(struct config_group *group, | |
648 | + const char *name) | |
650 | 649 | { |
651 | 650 | struct o2nm_node *node = NULL; |
652 | - int ret = 0; | |
651 | + struct config_item *ret = NULL; | |
653 | 652 | |
654 | - if (strlen(name) > O2NM_MAX_NAME_LEN) { | |
655 | - ret = -ENAMETOOLONG; | |
656 | - goto out; | |
657 | - } | |
653 | + if (strlen(name) > O2NM_MAX_NAME_LEN) | |
654 | + goto out; /* ENAMETOOLONG */ | |
658 | 655 | |
659 | 656 | node = kzalloc(sizeof(struct o2nm_node), GFP_KERNEL); |
660 | - if (node == NULL) { | |
661 | - ret = -ENOMEM; | |
662 | - goto out; | |
663 | - } | |
657 | + if (node == NULL) | |
658 | + goto out; /* ENOMEM */ | |
664 | 659 | |
665 | 660 | strcpy(node->nd_name, name); /* use item.ci_namebuf instead? */ |
666 | 661 | config_item_init_type_name(&node->nd_item, name, &o2nm_node_type); |
667 | 662 | spin_lock_init(&node->nd_lock); |
668 | 663 | |
669 | - *new_item = &node->nd_item; | |
664 | + ret = &node->nd_item; | |
670 | 665 | |
671 | 666 | out: |
672 | - if (ret) | |
667 | + if (ret == NULL) | |
673 | 668 | kfree(node); |
674 | 669 | |
675 | 670 | return ret; |
676 | 671 | |
677 | 672 | |
678 | 673 | |
679 | 674 | |
680 | 675 | |
... | ... | @@ -756,31 +751,25 @@ |
756 | 751 | } |
757 | 752 | #endif |
758 | 753 | |
759 | -static int o2nm_cluster_group_make_group(struct config_group *group, | |
760 | - const char *name, | |
761 | - struct config_group **new_group) | |
754 | +static struct config_group *o2nm_cluster_group_make_group(struct config_group *group, | |
755 | + const char *name) | |
762 | 756 | { |
763 | 757 | struct o2nm_cluster *cluster = NULL; |
764 | 758 | struct o2nm_node_group *ns = NULL; |
765 | - struct config_group *o2hb_group = NULL; | |
759 | + struct config_group *o2hb_group = NULL, *ret = NULL; | |
766 | 760 | void *defs = NULL; |
767 | - int ret = 0; | |
768 | 761 | |
769 | 762 | /* this runs under the parent dir's i_mutex; there can be only |
770 | 763 | * one caller in here at a time */ |
771 | - if (o2nm_single_cluster) { | |
772 | - ret = -ENOSPC; | |
773 | - goto out; | |
774 | - } | |
764 | + if (o2nm_single_cluster) | |
765 | + goto out; /* ENOSPC */ | |
775 | 766 | |
776 | 767 | cluster = kzalloc(sizeof(struct o2nm_cluster), GFP_KERNEL); |
777 | 768 | ns = kzalloc(sizeof(struct o2nm_node_group), GFP_KERNEL); |
778 | 769 | defs = kcalloc(3, sizeof(struct config_group *), GFP_KERNEL); |
779 | 770 | o2hb_group = o2hb_alloc_hb_set(); |
780 | - if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL) { | |
781 | - ret = -ENOMEM; | |
771 | + if (cluster == NULL || ns == NULL || o2hb_group == NULL || defs == NULL) | |
782 | 772 | goto out; |
783 | - } | |
784 | 773 | |
785 | 774 | config_group_init_type_name(&cluster->cl_group, name, |
786 | 775 | &o2nm_cluster_type); |
787 | 776 | |
... | ... | @@ -797,11 +786,11 @@ |
797 | 786 | cluster->cl_idle_timeout_ms = O2NET_IDLE_TIMEOUT_MS_DEFAULT; |
798 | 787 | cluster->cl_keepalive_delay_ms = O2NET_KEEPALIVE_DELAY_MS_DEFAULT; |
799 | 788 | |
800 | - *new_group = &cluster->cl_group; | |
789 | + ret = &cluster->cl_group; | |
801 | 790 | o2nm_single_cluster = cluster; |
802 | 791 | |
803 | 792 | out: |
804 | - if (ret) { | |
793 | + if (ret == NULL) { | |
805 | 794 | kfree(cluster); |
806 | 795 | kfree(ns); |
807 | 796 | o2hb_free_hb_set(o2hb_group); |
include/linux/configfs.h
... | ... | @@ -165,8 +165,8 @@ |
165 | 165 | }; |
166 | 166 | |
167 | 167 | struct configfs_group_operations { |
168 | - int (*make_item)(struct config_group *group, const char *name, struct config_item **new_item); | |
169 | - int (*make_group)(struct config_group *group, const char *name, struct config_group **new_group); | |
168 | + struct config_item *(*make_item)(struct config_group *group, const char *name); | |
169 | + struct config_group *(*make_group)(struct config_group *group, const char *name); | |
170 | 170 | int (*commit_item)(struct config_item *item); |
171 | 171 | void (*disconnect_notify)(struct config_group *group, struct config_item *item); |
172 | 172 | void (*drop_item)(struct config_group *group, struct config_item *item); |