Skip to contentSkip to conversation

Getting mapped device namw

DISCUSSION Gili B 5 participants 10 messages Jul 6, 2015 – Jul 8, 2015 Device mapper

lore
Share & tools
lore

Gili B

author
#0 lore raw

hi
when a user run :
dmsetup create [device name] ....
Can a device mapper target find out the device name that the user entered ? I need it for creating entries in proc for example.

Thanks
-gili

#1 lore raw
Quoted 4 lines · Gili B

hi
when a user run :
dmsetup create [device name] ....
Can a device mapper target find out the device name that the user entered ?

Apparently the name is being associated with a hash_cell object, which in turn is associated with struct mapped_device in dm_hash_insert (called from dev_create, which is invoked as part of the create IOCTL). So presumably if you get an instance of struct mapped_device and then invoke dm_get_mdptr(md). What you'd get is a pointer to struct hash_cell

Quoted 13 lines

I need it for creating entries in proc for example.

Thanks
-gili

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

author
#2 lore raw

Thanks
hash_cell is defined privately in dm_ioctl.c , so I cannot access it. also dm_get_mdptr ,is not extern so I can't access it neither.

Thanks
-gili

Quoted 36 lines

Date: Mon, 6 Jul 2015 12:32:33 +0300
From: [email protected]
To: [email protected]
Subject: Re: [dm-devel] Getting mapped device namw

Quoted 4 lines · Gili B

hi
when a user run :
dmsetup create [device name] ....
Can a device mapper target find out the device name that the user entered ?

Apparently the name is being associated with a hash_cell object, which in turn is associated with struct mapped_device in dm_hash_insert (called from dev_create, which is invoked as part of the create IOCTL). So presumably if you get an instance of struct mapped_device and then invoke dm_get_mdptr(md). What you'd get is a pointer to struct hash_cell

Quoted 8 lines

I need it for creating entries in proc for example.

Thanks
-gili

Quoted 5 lines

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#3 lore raw
Quoted 2 lines · Gili B

Thanks
hash_cell is defined privately in dm_ioctl.c , so I cannot access it.

The beauty of open source software is that you can always export it for you own needs :)

Quoted 1 line

also dm_get_mdptr ,is not extern so I can't access it neither.

The function is exposed via device_mapper.h so you can just include this header. Poke the code around you might come up with an even better idea. But generally you wouldn't want to use the name the user provided. Instead, use the name of the block device being created e.g. dm-1. This can be obtained from the dm_get_device function and using the dm_dev struct

Quoted 49 lines

Thanks
-gili

Quoted 32 lines

Date: Mon, 6 Jul 2015 12:32:33 +0300
From: [email protected]
To: [email protected]
Subject: Re: [dm-devel] Getting mapped device namw

Quoted 4 lines · Gili B

hi
when a user run :
dmsetup create [device name] ....
Can a device mapper target find out the device name that the user entered ?

Apparently the name is being associated with a hash_cell object, which in turn is associated with struct mapped_device in dm_hash_insert (called from dev_create, which is invoked as part of the create IOCTL). So presumably if you get an instance of struct mapped_device and then invoke dm_get_mdptr(md). What you'd get is a pointer to struct hash_cell

Quoted 8 lines

I need it for creating entries in proc for example.

Thanks
-gili

Quoted 5 lines

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Quoted 4 lines

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

author
#4 lore raw

Thanks
We are trying to create this module without modifying existing kernel code, so that it will be easy to install it in existing environements.
using a name like dm-1 is not user freindly , since the user needs to go and figure out this name before procceding.
I see that there's a method dm_copy_name_and_uuid , but its not extern.
I guess I'll just let the user set the name for now.

Thanks
-gili

Quoted 74 lines

Date: Mon, 6 Jul 2015 12:49:56 +0300
From: [email protected]
To: [email protected]
Subject: Re: [dm-devel] Getting mapped device namw

Quoted 2 lines · Gili B

Thanks
hash_cell is defined privately in dm_ioctl.c , so I cannot access it.

The beauty of open source software is that you can always export it for you own needs :)

Quoted 1 line

also dm_get_mdptr ,is not extern so I can't access it neither.

The function is exposed via device_mapper.h so you can just include this header. Poke the code around you might come up with an even better idea. But generally you wouldn't want to use the name the user provided. Instead, use the name of the block device being created e.g. dm-1. This can be obtained from the dm_get_device function and using the dm_dev struct

Quoted 44 lines

Thanks
-gili

Quoted 32 lines

Date: Mon, 6 Jul 2015 12:32:33 +0300
From: [email protected]
To: [email protected]
Subject: Re: [dm-devel] Getting mapped device namw

Quoted 4 lines · Gili B

hi
when a user run :
dmsetup create [device name] ....
Can a device mapper target find out the device name that the user entered ?

Apparently the name is being associated with a hash_cell object, which in turn is associated with struct mapped_device in dm_hash_insert (called from dev_create, which is invoked as part of the create IOCTL). So presumably if you get an instance of struct mapped_device and then invoke dm_get_mdptr(md). What you'd get is a pointer to struct hash_cell

Quoted 8 lines

I need it for creating entries in proc for example.

Thanks
-gili

Quoted 5 lines

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Quoted 4 lines

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

Quoted 5 lines

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#5 lore raw
In reply to Gili B

Dne 6.7.2015 v 11:20 Gili B napsal(a):

Quoted 5 lines

hi
when a user run :
dmsetup create [device name] ....
Can a device mapper target find out the device name that the user entered ? I need it for creating entries in proc for example.

It's probably worth to note here - the dm target should always care ONLY about major:minor - it should never care about the name of device. It looks like you are doing something weird in your target.

Regards

Zdeenk

author
#6 lore raw

Thanks
My module is creating target similar to pool and thin from dm_thin.c. if the user creates a pool named "Pool1", and now he wishes to watch statistics/inside info regarding this pool,
I wanted to create a proc entry
/proc/my module name/pools/Pool1

for that I need the pool name which now it seems to me that I cannot find out.

I can ask the user to add another parameter during the pool creation, but seems Like an overhead and I'll need to do some extra verefications etc.

Regards
-gili

Quoted 24 lines

To: [email protected]
From: [email protected]
Date: Mon, 6 Jul 2015 13:20:38 +0200
Subject: Re: [dm-devel] Getting mapped device namw

Dne 6.7.2015 v 11:20 Gili B napsal(a):

Quoted 5 lines

hi
when a user run :
dmsetup create [device name] ....
Can a device mapper target find out the device name that the user entered ? I need it for creating entries in proc for example.

It's probably worth to note here - the dm target should always care ONLY about major:minor - it should never care about the name of device.
It looks like you are doing something weird in your target.

Regards

Zdeenk

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

author
#8 lore raw

Thanks
I've looked at it and it loks like something that can assist us.
The general info mechanism we are working on requires more that just statistics though. Regarding the statistics :
When I run dmsetup (centos 6.5) on my device, it sais that my target doesnt support messages(ha because we didn't implement any yet ) , from the description in the link you've sent, it sounds like any dm target inherits this functionality.
Are there any methods I need to call, or do I need to re-implement this in my target?

Thanks
-gili

Quoted 22 lines

To: [email protected]
From: [email protected]
Date: Mon, 6 Jul 2015 14:19:42 +0200
Subject: Re: [dm-devel] Getting mapped device namw

Dne 6.7.2015 v 14:04 Gili B napsal(a):

Quoted 3 lines

Thanks
My module is creating target similar to pool and thin from dm_thin.c. if the user creates a pool named "Pool1", and now he wishes

Have you checked dm statistic support ?

https://www.kernel.org/doc/Documentation/device-mapper/statistics.txt

Zdenek

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#9 lore raw

Dne 7.7.2015 v 08:22 Gili B napsal(a):

Quoted 6 lines

Thanks
I've looked at it and it loks like something that can assist us. The general info mechanism we are working on requires more that just statistics though.
Regarding the statistics :
When I run dmsetup (centos 6.5) on my device, it sais that my target doesnt

Centos 6.5 is way too old for this feature.
It appears in 7.2.

Zdenek