* Device names @ 2012-06-19 0:29 H. Peter Anvin 2012-06-19 23:51 ` Chris Mason 0 siblings, 1 reply; 7+ messages in thread From: H. Peter Anvin @ 2012-06-19 0:29 UTC (permalink / raw) To: linux-btrfs I just found out that all the device handling in btrfs is based on pathnames, but shorter pathnames (1024) that PATH_MAX (4096). This is confusing, and concerning for multiple reasons: 1. pathnames are namespace-specific; what is a pathname in one namespace might not be in another. 2. different truncation rules in the rest of the kernel. There seem to be no way one can do the equivalent of BTRFS_IOC_DEV_INFO but actually get a device number or other stable information for that device (that could be compared to a file descriptor for verification); is that an accurate observation? -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Device names 2012-06-19 0:29 Device names H. Peter Anvin @ 2012-06-19 23:51 ` Chris Mason 2012-06-20 0:00 ` H. Peter Anvin 0 siblings, 1 reply; 7+ messages in thread From: Chris Mason @ 2012-06-19 23:51 UTC (permalink / raw) To: H. Peter Anvin; +Cc: linux-btrfs@vger.kernel.org On Mon, Jun 18, 2012 at 06:29:59PM -0600, H. Peter Anvin wrote: > I just found out that all the device handling in btrfs is based on > pathnames, but shorter pathnames (1024) that PATH_MAX (4096). > > This is confusing, and concerning for multiple reasons: > > 1. pathnames are namespace-specific; what is a pathname in one namespace > might not be in another. > 2. different truncation rules in the rest of the kernel. > > There seem to be no way one can do the equivalent of BTRFS_IOC_DEV_INFO > but actually get a device number or other stable information for that > device (that could be compared to a file descriptor for verification); > is that an accurate observation? At mount time, we go through and verify the path names still belong to the filesystem you thought they belonged to. The bdev is locked during the verification, so it won't be able to go away or change. This is a long way of saying right we don't spit out device numbers. Even device numbers can change. We can easily add a uuid based listing, which I think is what you want. -chris ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Device names 2012-06-19 23:51 ` Chris Mason @ 2012-06-20 0:00 ` H. Peter Anvin 2012-06-20 13:37 ` Chris Mason 0 siblings, 1 reply; 7+ messages in thread From: H. Peter Anvin @ 2012-06-20 0:00 UTC (permalink / raw) To: Chris Mason, linux-btrfs@vger.kernel.org On 06/19/2012 04:51 PM, Chris Mason wrote: > > At mount time, we go through and verify the path names still belong to > the filesystem you thought they belonged to. The bdev is locked during > the verification, so it won't be able to go away or change. > > This is a long way of saying right we don't spit out device numbers. > Even device numbers can change. We can easily add a uuid based listing, > which I think is what you want. > No, I want to find the actual devices. I know I can get the UUID, but scanning all the block devices in the system looking for that UUID is a nonstarter. Device path names can change while the system is operating (and, worse, are dependent on namespace changes and chroot); device *numbers* cannot as long as the device is in use (e.g. mounted.) They can indeed change while not in use, of course. -hpa ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Device names 2012-06-20 0:00 ` H. Peter Anvin @ 2012-06-20 13:37 ` Chris Mason 2012-06-20 17:06 ` Goffredo Baroncelli 0 siblings, 1 reply; 7+ messages in thread From: Chris Mason @ 2012-06-20 13:37 UTC (permalink / raw) To: H. Peter Anvin; +Cc: linux-btrfs@vger.kernel.org On Tue, Jun 19, 2012 at 06:00:11PM -0600, H. Peter Anvin wrote: > On 06/19/2012 04:51 PM, Chris Mason wrote: > > > > At mount time, we go through and verify the path names still belong to > > the filesystem you thought they belonged to. The bdev is locked during > > the verification, so it won't be able to go away or change. > > > > This is a long way of saying right we don't spit out device numbers. > > Even device numbers can change. We can easily add a uuid based listing, > > which I think is what you want. > > > > No, I want to find the actual devices. I know I can get the UUID, but > scanning all the block devices in the system looking for that UUID is a > nonstarter. > > Device path names can change while the system is operating (and, worse, > are dependent on namespace changes and chroot); device *numbers* cannot > as long as the device is in use (e.g. mounted.) They can indeed change > while not in use, of course. Ok, my two choices for exporting this to you are a /sys/btrfs kind of directory (representing the mounted filesystems) or an ioctl. Which one is most usable for you? You want to map from /some_dir to a definitive list of devices you need to find in syslinux to later boot off that FS, right? -chris ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Device names 2012-06-20 13:37 ` Chris Mason @ 2012-06-20 17:06 ` Goffredo Baroncelli 0 siblings, 0 replies; 7+ messages in thread From: Goffredo Baroncelli @ 2012-06-20 17:06 UTC (permalink / raw) To: Chris Mason, H. Peter Anvin, linux-btrfs@vger.kernel.org On 06/20/2012 03:37 PM, Chris Mason wrote: > On Tue, Jun 19, 2012 at 06:00:11PM -0600, H. Peter Anvin wrote: >> On 06/19/2012 04:51 PM, Chris Mason wrote: >>> >>> At mount time, we go through and verify the path names still belong to >>> the filesystem you thought they belonged to. The bdev is locked during >>> the verification, so it won't be able to go away or change. >>> >>> This is a long way of saying right we don't spit out device numbers. >>> Even device numbers can change. We can easily add a uuid based listing, >>> which I think is what you want. >>> >> >> No, I want to find the actual devices. I know I can get the UUID, but >> scanning all the block devices in the system looking for that UUID is a >> nonstarter. >> >> Device path names can change while the system is operating (and, worse, >> are dependent on namespace changes and chroot); device *numbers* cannot >> as long as the device is in use (e.g. mounted.) They can indeed change >> while not in use, of course. > > Ok, my two choices for exporting this to you are a /sys/btrfs kind of > directory (representing the mounted filesystems) or an ioctl. Which one > is most usable for you? As short term solution, I suggest to update the BTRFS_IOC_DEV_INFO to export also the major:minor pair. This should be a minor change and also should be backward compatible (there is a lot of space in the struct btrfs_ioctl_dev_info_args ) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 14f8e1f..79fdd83 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2261,6 +2261,8 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, di_args->devid = dev->devid; di_args->bytes_used = dev->bytes_used; di_args->total_bytes = dev->total_bytes; + di_args->major = imajor(dev->bdev->bd_inode); + di_args->minor = iminor(dev->bdev->bd_inode); memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid)); if (dev->name) strncpy(di_args->path, dev->name, sizeof(di_args->path)); diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h index 086e6bd..7afa688 100644 --- a/fs/btrfs/ioctl.h +++ b/fs/btrfs/ioctl.h @@ -98,7 +98,9 @@ struct btrfs_ioctl_dev_info_args { __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */ __u64 bytes_used; /* out */ __u64 total_bytes; /* out */ - __u64 unused[379]; /* pad to 4k */ + __u64 major; /* out */ + __u64 minor; /* out */ + __u64 unused[377]; /* pad to 4k */ __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ }; As long term solution, exporting all this kind of information in /sys/btrfs/... could be a more robust solution, which could simplify the "backward compatible" problem. Only my 2¢... GB > > You want to map from /some_dir to a definitive list of devices you need > to find in syslinux to later boot off that FS, right? > > -chris > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > . > ^ permalink raw reply related [flat|nested] 7+ messages in thread
* device names @ 2003-10-19 18:30 James Courtier-Dutton 2003-10-20 9:08 ` Clemens Ladisch 0 siblings, 1 reply; 7+ messages in thread From: James Courtier-Dutton @ 2003-10-19 18:30 UTC (permalink / raw) To: alsa-devel I have 2 sound cards. To output to front speakers of card0 I can do: - front or front:0 For Card1 front:1 But for iec958 on Card1 if fails. What name should I use for Card1 for IEC958 spdif digital out? conf.c: parse_args() Parameter AES3 must be an integer. conf.c: snd_config_expand() Parse arguments error: Invalid argument. pcm.c: snd_pcm_open_noupdate() Unknown PCM iec958:AES0=0x6,AES1=0x82,AES2=0x0,AES3=0x2:1. audio_alsa_out: snd_pcm_open() of iec958:AES0=0x6,AES1=0x82,AES2=0x0,AES3=0x2:1 failed: Invalid argument audio_alsa_out: >>> check if another program don't already use PCM <<< Cheers James ------------------------------------------------------- This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo The Event For Linux Datacenter Solutions & Strategies in The Enterprise Linux in the Boardroom; in the Front Office; & in the Server Room http://www.enterpriselinuxforum.com ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: device names 2003-10-19 18:30 device names James Courtier-Dutton @ 2003-10-20 9:08 ` Clemens Ladisch 0 siblings, 0 replies; 7+ messages in thread From: Clemens Ladisch @ 2003-10-20 9:08 UTC (permalink / raw) To: James Courtier-Dutton; +Cc: alsa-devel James Courtier-Dutton wrote: > I have 2 sound cards. > To output to front speakers of card0 I can do: - > front > or > front:0 > > For Card1 > front:1 > > But for iec958 on Card1 if fails. > What name should I use for Card1 for IEC958 spdif digital out? > > conf.c: parse_args() Parameter AES3 must be an integer. > conf.c: snd_config_expand() Parse arguments error: Invalid argument. > pcm.c: snd_pcm_open_noupdate() Unknown PCM > iec958:AES0=0x6,AES1=0x82,AES2=0x0,AES3=0x2:1. > audio_alsa_out: snd_pcm_open() of > iec958:AES0=0x6,AES1=0x82,AES2=0x0,AES3=0x2:1 failed: Invalid argument The correct result would have been iec958:CARD=1,AES0=0x6,AES1=0x82,AES2=0x0,AES3=0x2 Try using this (or "iec958:CARD=1") as device name. HTH Clemens ------------------------------------------------------- This SF.net email sponsored by: Enterprise Linux Forum Conference & Expo The Event For Linux Datacenter Solutions & Strategies in The Enterprise Linux in the Boardroom; in the Front Office; & in the Server Room http://www.enterpriselinuxforum.com ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2012-06-20 17:06 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2012-06-19 0:29 Device names H. Peter Anvin 2012-06-19 23:51 ` Chris Mason 2012-06-20 0:00 ` H. Peter Anvin 2012-06-20 13:37 ` Chris Mason 2012-06-20 17:06 ` Goffredo Baroncelli -- strict thread matches above, loose matches on Subject: below -- 2003-10-19 18:30 device names James Courtier-Dutton 2003-10-20 9:08 ` Clemens Ladisch
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.