[zfs-code] Accessing ZFS User Property from Code
How do I access the value of a user property from within my version of the kernel code? For example, I am using a user property named ?myscope:myprop?. I can set the user property via the command line as follows: zfs set myscope:myprop=2 mypool/myfs I can retrieve the user property from the command line as follows: zfs get myscope:myprop mypool/myfs But? how do I access the user property from within my version of the kernel code? I have looked at the zfs_get_prop(?), and zfs_get_prop_name(?) routines, but these seem to apply to properties which are not user properties. Any help you can give would be appreciated. Duff -- This messages posted from opensolaris.org
[zfs-code] Accessing ZFS User Property from Code
You want zfs_get_user_props(), which will return an nvlist of all user properties. With the caveat that it's an unstable interface, of course ;-) - Eric On Wed, Oct 03, 2007 at 01:46:04PM -0700, J Duff wrote: > How do I access the value of a user property from within my version of the > kernel code? > > For example, I am using a user property named ?myscope:myprop?. I can set the > user property via the command line as follows: > > zfs set myscope:myprop=2 mypool/myfs > > I can retrieve the user property from the command line as follows: > > zfs get myscope:myprop mypool/myfs > > But? how do I access the user property from within my version of the kernel > code? I have looked at the zfs_get_prop(?), and zfs_get_prop_name(?) > routines, but these seem to apply to properties which are not user properties. > > Any help you can give would be appreciated. > > Duff > -- > This messages posted from opensolaris.org > ___ > zfs-code mailing list > zfs-code at opensolaris.org > http://mail.opensolaris.org/mailman/listinfo/zfs-code -- Eric Schrock, Solaris Kernel Development http://blogs.sun.com/eschrock
[zfs-code] Accessing ZFS User Property from Code
I just got back to implementing this. I am willing to work with the unstable interface. What is bothering me is that zfs_get_user_props takes a zfs_handle_t* as an input arg. Since I am working within the kernel, I have only a spa_t* to work with, and I can't figure out how to get a zfs_handle_t* from the spa_t*. How do I get a proper zfs_handle_t*? (The only examples of zfs_get_user_prop calls I can find are in the cmd sub-tree, and they have a different starting context.) Thanks for any help you can give. Duff -- This messages posted from opensolaris.org
[zfs-code] Accessing ZFS User Property from Code
On Mon, Oct 08, 2007 at 03:35:49PM -0700, J Duff wrote: > I just got back to implementing this. I am willing to work with the unstable > interface. > > What is bothering me is that zfs_get_user_props takes a zfs_handle_t* > as an input arg. Since I am working within the kernel, I have only a > spa_t* to work with, and I can't figure out how to get a zfs_handle_t* > from the spa_t*. > > How do I get a proper zfs_handle_t*? Wow, I didn't know you were in the kernel. Yeah, things are a little different there ;-) You can use dsl_prop_get() to get a property for a particular dataset. - Eric -- Eric Schrock, Solaris Kernel Development http://blogs.sun.com/eschrock
[zfs-code] Accessing ZFS User Property from Code
J Duff wrote: > I just got back to implementing this. I am willing to work with the unstable > interface. > > What is bothering me is that zfs_get_user_props takes a zfs_handle_t* as an > input arg. Since I am working within the kernel, I have only a spa_t* to work > with, and I can't figure out how to get a zfs_handle_t* from the spa_t*. > > How do I get a proper zfs_handle_t*? Are you "in" the zfs module or some other module ? If you are "in" the zfs module I would seriously question why you are looking at a user property rather than adding a new "system" property. What data is held in your property and what part of the system uses it ? -- Darren J Moffat
[zfs-code] Accessing ZFS User Property from Code
I'm playing around with using ZFS on a laptop, and I want to add a property that identifies the pool as a laptop pool. My first thought was to add my own zpool property. However, I ran into problems because of an apparent mismatch between the zfs_prop_t enum in usr/src/uts/common/sys/fs/zfs.h and the zfs_prop_table in usr/src/common/zfs/zfs_prop.c. See the forum thread http://www.opensolaris.org/jive/thread.jspa?threadID=39359 for more details. A response in the above thread encouraged me to wait for PSARC 2007/342 "Enhanced ZFS Pool Properties" which looks like it will be in snv_75, and 6582456 "property code is overdue for some spring cleaning" which is already in snv_71. In the meantime, it was suggested I try using a zfs filesystem user property. This would be easier for me since I wouldn?t have to write as much code. I started down this path, but I had trouble figuring out how to access user properties from within the kernel. (This does sound inappropriate (the kernel using user properties!) now that I think about it.) However, it will allow me to continue with my experiment until snv_75 comes out. Certainly, true ZFS kernel changes shouldn?t be accessing user properties. If you have any advice on this, please let me know. So? continuing on with perhaps an interim solution, I am experimenting with the dsl_prop_get and more specifically the dsl_prop_get_integer call. I?m confused by the first argument of the method, i.e., ddname. Is this the name of my top level file system which happens to also be the name of my pool? If so, can I just use spa->spa_name for the ddname argument? Duff -- This messages posted from opensolaris.org