Chris Mason
2008-Feb-06 10:06 UTC
[Btrfs-devel] Re: [PATCH] btrfs: fixes for kobject changes in mainline
On Wednesday 06 February 2008, Greg KH wrote:> On Wed, Feb 06, 2008 at 09:01:30AM -0800, Greg KH wrote: > > Here's a patch against the unstable tree that gets the code to build > > against Linus's current tree (2.6.24-git12). This is needed as the > > kobject/kset api has changed there. > >Many thanks for these updates.> > I tried to make the smallest changes needed, and it builds and loads > > successfully, but I don't have a btrfs volume anywhere (yet) to try to > > see if things still work properly :) > > Ok, I created a file for the fs, ran mkfs.btrfs on it, mounted it > loopback through the loop block driver, and then tried to mount it. > > Lovely oops in btrfs_search_slot it can be seen at: > http://www.kerneloops.org/raw.php?rawid=3304&msgid> > Note, I'm running unstable for both the kernel module, and the userspace > tools... > > Was this something that I caused with the sysfs change? Or should I not > be testing this with a loopback filesystem?btrfs on top of loopback works fine here for btrfs-unstable. Given the oops, I'd guess someone is freeing the name field instead of strduping it. -chris
Greg KH
2008-Feb-13 08:19 UTC
[Btrfs-devel] [PATCH] btrfs: fixes for kobject changes in mainline
Here's a patch against the unstable tree that gets the code to build against Linus's current tree (2.6.24-git12). This is needed as the kobject/kset api has changed there. I tried to make the smallest changes needed, and it builds and loads successfully, but I don't have a btrfs volume anywhere (yet) to try to see if things still work properly :) Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> --- Note, I can remove a lot more sysfs-related code in here, to make it much simpler if you want me to. But that would make this file pretty messy if you need to keep backwards compatibility with old kernels. Also, the lifetime rules for your kobjects seem very suspect. Especially as you have a completion handler for your release functions. I can rework this if needed too. Time to go download the userspace tools to make sure I don't break anything really badly... diff -u btrfs-unstable-18f284b2de93.orig/sysfs.c btrfs-unstable-18f284b2de93/sysfs.c --- btrfs-unstable-18f284b2de93.orig/sysfs.c 2008-02-06 07:00:57.000000000 -0800 +++ btrfs-unstable-18f284b2de93/sysfs.c 2008-02-06 08:54:53.000000000 -0800 @@ -184,7 +184,8 @@ .release = btrfs_super_release, }; -static struct kset btrfs_kset; +/* /sys/fs/btrfs/ entry */ +static struct kset *btrfs_kset; int btrfs_sysfs_add_super(struct btrfs_fs_info *fs) { @@ -208,14 +209,9 @@ } name[len] = '\0'; - fs->super_kobj.kset = &btrfs_kset; - fs->super_kobj.ktype = &btrfs_super_ktype; - - error = kobject_set_name(&fs->super_kobj, "%s", name); - if (error) - goto fail; - - error = kobject_register(&fs->super_kobj); + fs->super_kobj.kset = btrfs_kset; + error = kobject_init_and_add(&fs->super_kobj, &btrfs_super_ktype, + NULL, "%s", name); if (error) goto fail; @@ -232,15 +228,9 @@ { int error; - root->root_kobj.ktype = &btrfs_root_ktype; - root->root_kobj.parent = &root->fs_info->super_kobj; - - error = kobject_set_name(&root->root_kobj, "%s", root->name); - if (error) { - goto fail; - } - - error = kobject_register(&root->root_kobj); + error = kobject_init_and_add(&root->root_kobj, &btrfs_root_ktype, + &root->fs_info->super_kobj, + "%s", root->name); if (error) goto fail; @@ -253,24 +243,25 @@ void btrfs_sysfs_del_root(struct btrfs_root *root) { - kobject_unregister(&root->root_kobj); + kobject_put(&root->root_kobj); wait_for_completion(&root->kobj_unregister); } void btrfs_sysfs_del_super(struct btrfs_fs_info *fs) { - kobject_unregister(&fs->super_kobj); + kobject_put(&fs->super_kobj); wait_for_completion(&fs->kobj_unregister); } int btrfs_init_sysfs() { - kobj_set_kset_s(&btrfs_kset, fs_subsys); - kobject_set_name(&btrfs_kset.kobj, "btrfs"); - return kset_register(&btrfs_kset); + btrfs_kset = kset_create_and_add("btrfs", NULL, fs_kobj); + if (!btrfs_kset) + return -ENOMEM; + return 0; } void btrfs_exit_sysfs() { - kset_unregister(&btrfs_kset); + kset_unregister(btrfs_kset); }
Greg KH
2008-Feb-13 08:19 UTC
[Btrfs-devel] Re: [PATCH] btrfs: fixes for kobject changes in mainline
On Wed, Feb 06, 2008 at 09:01:30AM -0800, Greg KH wrote:> Here's a patch against the unstable tree that gets the code to build > against Linus's current tree (2.6.24-git12). This is needed as the > kobject/kset api has changed there. > > I tried to make the smallest changes needed, and it builds and loads > successfully, but I don't have a btrfs volume anywhere (yet) to try to > see if things still work properly :)Ok, I created a file for the fs, ran mkfs.btrfs on it, mounted it loopback through the loop block driver, and then tried to mount it. Lovely oops in btrfs_search_slot it can be seen at: http://www.kerneloops.org/raw.php?rawid=3304&msgid Note, I'm running unstable for both the kernel module, and the userspace tools... Was this something that I caused with the sysfs change? Or should I not be testing this with a loopback filesystem? thanks, greg k-h