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

exofs: Add option to mount by osdname

If /dev/osd* devices are shuffled because more devices
where added, and/or login order has changed. It is hard to
mount the FS you want.

Add an option to mount by osdname. osdname is any osd-device's
osdname as specified to the mkfs.exofs command when formatting
the osd-devices.
The new mount format is:
OPT="osdname=$UUID0,pid=$PID,_netdev"
mount -t exofs -o $OPT $DEV_OSD0 $MOUNTDIR

if "osdname=" is specified in options above $DEV_OSD0 is
ignored and can be empty.

Also while at it: Removed some old unused Opt_* enums.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>

+36 -5
+9 -1
Documentation/filesystems/exofs.txt
··· 104 104 exofs specific options: Options are separated by commas (,) 105 105 pid=<integer> - The partition number to mount/create as 106 106 container of the filesystem. 107 - This option is mandatory. 107 + This option is mandatory. integer can be 108 + Hex by pre-pending an 0x to the number. 109 + osdname=<id> - Mount by a device's osdname. 110 + osdname is usually a 36 character uuid of the 111 + form "d2683732-c906-4ee1-9dbd-c10c27bb40df". 112 + It is one of the device's uuid specified in the 113 + mkfs.exofs format command. 114 + If this option is specified then the /dev/osdX 115 + above can be empty and is ignored. 108 116 to=<integer> - Timeout in ticks for a single command. 109 117 default is (60 * HZ) [for debugging only] 110 118
+27 -4
fs/exofs/super.c
··· 48 48 * struct to hold what we get from mount options 49 49 */ 50 50 struct exofs_mountopt { 51 + bool is_osdname; 51 52 const char *dev_name; 52 53 uint64_t pid; 53 54 int timeout; ··· 57 56 /* 58 57 * exofs-specific mount-time options. 59 58 */ 60 - enum { Opt_pid, Opt_to, Opt_mkfs, Opt_format, Opt_err }; 59 + enum { Opt_name, Opt_pid, Opt_to, Opt_err }; 61 60 62 61 /* 63 62 * Our mount-time options. These should ideally be 64-bit unsigned, but the ··· 65 64 * sufficient for most applications now. 66 65 */ 67 66 static match_table_t tokens = { 67 + {Opt_name, "osdname=%s"}, 68 68 {Opt_pid, "pid=%u"}, 69 69 {Opt_to, "to=%u"}, 70 70 {Opt_err, NULL} ··· 96 94 97 95 token = match_token(p, tokens, args); 98 96 switch (token) { 97 + case Opt_name: 98 + opts->dev_name = match_strdup(&args[0]); 99 + if (unlikely(!opts->dev_name)) { 100 + EXOFS_ERR("Error allocating dev_name"); 101 + return -ENOMEM; 102 + } 103 + opts->is_osdname = true; 104 + break; 99 105 case Opt_pid: 100 106 if (0 == match_strlcpy(str, &args[0], sizeof(str))) 101 107 return -EINVAL; ··· 585 575 goto free_bdi; 586 576 587 577 /* use mount options to fill superblock */ 588 - od = osduld_path_lookup(opts->dev_name); 578 + if (opts->is_osdname) { 579 + struct osd_dev_info odi = {.systemid_len = 0}; 580 + 581 + odi.osdname_len = strlen(opts->dev_name); 582 + odi.osdname = (u8 *)opts->dev_name; 583 + od = osduld_info_lookup(&odi); 584 + } else { 585 + od = osduld_path_lookup(opts->dev_name); 586 + } 589 587 if (IS_ERR(od)) { 590 - ret = PTR_ERR(od); 588 + ret = -EINVAL; 591 589 goto free_sbi; 592 590 } 593 591 ··· 688 670 689 671 _exofs_print_device("Mounting", opts->dev_name, sbi->layout.s_ods[0], 690 672 sbi->layout.s_pid); 673 + if (opts->is_osdname) 674 + kfree(opts->dev_name); 691 675 return 0; 692 676 693 677 free_sbi: ··· 698 678 EXOFS_ERR("Unable to mount exofs on %s pid=0x%llx err=%d\n", 699 679 opts->dev_name, sbi->layout.s_pid, ret); 700 680 exofs_free_sbi(sbi); 681 + if (opts->is_osdname) 682 + kfree(opts->dev_name); 701 683 return ret; 702 684 } 703 685 ··· 717 695 if (ret) 718 696 return ERR_PTR(ret); 719 697 720 - opts.dev_name = dev_name; 698 + if (!opts.dev_name) 699 + opts.dev_name = dev_name; 721 700 return mount_nodev(type, flags, &opts, exofs_fill_super); 722 701 } 723 702