Re: [PATCH] btrfs-progs: make btrfs dev scan multi path aware

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 21, 2013 at 07:56:44PM +0800, Anand Jain wrote:
>  We should avoid using non multi-path (mp) path for mp disks
>  As of now there is no good way (like api) to check that.
>  A workaround way is to check if the O_EXCL open is unsuccessful.
>  This is safe since otherwise the BTRFS_IOC_SCAN_DEV ioctl would
>  fail if the disk-path can not be opened with the flag O_EXCL set.

Agreed. Alternatively we could try to parse the /sys entries.

> --- a/cmds-device.c
> +++ b/cmds-device.c
> @@ -185,7 +185,7 @@ static const char * const cmd_scan_dev_usage[] = {
>  
>  static int cmd_scan_dev(int argc, char **argv)
>  {
> -	int	i, fd, e;
> +	int	i, fd, e, ret = 0;
>  	int	checklist = 1;
>  	int	devstart = 1;
>  
> @@ -197,6 +197,21 @@ static int cmd_scan_dev(int argc, char **argv)
>  		devstart += 1;
>  	}
>  
> +	fd = open("/dev/btrfs-control", O_RDWR);
> +	e = errno;
> +	if (fd < 0) {
> +		FILE *mfd = popen("lsmod | grep btrfs", "r");

Please transform this into C.

> +		char buf[16];
> +
> +		if (fread (buf, 1, sizeof (buf), mfd) > 0)
> +			fprintf(stderr, "ERROR: failed to open "\
> +				"/dev/btrfs-control - %s\n", strerror(e));
> +		else
> +			fprintf(stderr, "ERROR: btrfs kernel module "\
> +				"is not loaded\n");
> +		return 10;

We should not be using the old style of error codes in new code, other
paths in this functions return -1 .

> +	}


thanks,
david
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux