Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm mpath: use more error codes

This patch allows path errors from the multipath ctr function to
propagate up to userspace as errno values from the ioctl() call.

This is in response to
https://www.redhat.com/archives/dm-devel/2008-May/msg00000.html
and
https://bugzilla.redhat.com/show_bug.cgi?id=444421

The patch only lets through the errors that it needs to in order to
get the path errors from parse_path().

Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Alasdair G Kergon <agk@redhat.com>

authored by

Benjamin Marzinski and committed by
Alasdair G Kergon
01460f35 3fa8749e

+12 -10
+12 -10
drivers/md/dm-mpath.c
··· 563 563 /* we need at least a path arg */ 564 564 if (as->argc < 1) { 565 565 ti->error = "no device given"; 566 - return NULL; 566 + return ERR_PTR(-EINVAL); 567 567 } 568 568 569 569 p = alloc_pgpath(); 570 570 if (!p) 571 - return NULL; 571 + return ERR_PTR(-ENOMEM); 572 572 573 573 r = dm_get_device(ti, shift(as), ti->begin, ti->len, 574 574 dm_table_get_mode(ti->table), &p->path.dev); ··· 596 596 597 597 bad: 598 598 free_pgpath(p); 599 - return NULL; 599 + return ERR_PTR(r); 600 600 } 601 601 602 602 static struct priority_group *parse_priority_group(struct arg_set *as, ··· 614 614 615 615 if (as->argc < 2) { 616 616 as->argc = 0; 617 - ti->error = "not enough priority group aruments"; 618 - return NULL; 617 + ti->error = "not enough priority group arguments"; 618 + return ERR_PTR(-EINVAL); 619 619 } 620 620 621 621 pg = alloc_priority_group(); 622 622 if (!pg) { 623 623 ti->error = "couldn't allocate priority group"; 624 - return NULL; 624 + return ERR_PTR(-ENOMEM); 625 625 } 626 626 pg->m = m; 627 627 ··· 654 654 path_args.argv = as->argv; 655 655 656 656 pgpath = parse_path(&path_args, &pg->ps, ti); 657 - if (!pgpath) 657 + if (IS_ERR(pgpath)) { 658 + r = PTR_ERR(pgpath); 658 659 goto bad; 660 + } 659 661 660 662 pgpath->pg = pg; 661 663 list_add_tail(&pgpath->list, &pg->pgpaths); ··· 668 666 669 667 bad: 670 668 free_priority_group(pg, ti); 671 - return NULL; 669 + return ERR_PTR(r); 672 670 } 673 671 674 672 static int parse_hw_handler(struct arg_set *as, struct multipath *m) ··· 787 785 struct priority_group *pg; 788 786 789 787 pg = parse_priority_group(&as, m); 790 - if (!pg) { 791 - r = -EINVAL; 788 + if (IS_ERR(pg)) { 789 + r = PTR_ERR(pg); 792 790 goto bad; 793 791 } 794 792