Skip to content

Commit e3fe4e7

Browse files
gregkhchrismason-xx
authored andcommitted
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> Signed-off-by: Chris Mason <chris.mason@oracle.com>
1 parent 6e92f5e commit e3fe4e7

1 file changed

Lines changed: 15 additions & 24 deletions

File tree

‎fs/btrfs/sysfs.c‎

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ static struct kobj_type btrfs_super_ktype = {
184184
.release = btrfs_super_release,
185185
};
186186

187-
static struct kset btrfs_kset;
187+
/* /sys/fs/btrfs/ entry */
188+
static struct kset *btrfs_kset;
188189

189190
int btrfs_sysfs_add_super(struct btrfs_fs_info *fs)
190191
{
@@ -208,14 +209,9 @@ int btrfs_sysfs_add_super(struct btrfs_fs_info *fs)
208209
}
209210
name[len] = '\0';
210211

211-
fs->super_kobj.kset = &btrfs_kset;
212-
fs->super_kobj.ktype = &btrfs_super_ktype;
213-
214-
error = kobject_set_name(&fs->super_kobj, "%s", name);
215-
if (error)
216-
goto fail;
217-
218-
error = kobject_register(&fs->super_kobj);
212+
fs->super_kobj.kset = btrfs_kset;
213+
error = kobject_init_and_add(&fs->super_kobj, &btrfs_super_ktype,
214+
NULL, "%s", name);
219215
if (error)
220216
goto fail;
221217

@@ -232,15 +228,9 @@ int btrfs_sysfs_add_root(struct btrfs_root *root)
232228
{
233229
int error;
234230

235-
root->root_kobj.ktype = &btrfs_root_ktype;
236-
root->root_kobj.parent = &root->fs_info->super_kobj;
237-
238-
error = kobject_set_name(&root->root_kobj, "%s", root->name);
239-
if (error) {
240-
goto fail;
241-
}
242-
243-
error = kobject_register(&root->root_kobj);
231+
error = kobject_init_and_add(&root->root_kobj, &btrfs_root_ktype,
232+
&root->fs_info->super_kobj,
233+
"%s", root->name);
244234
if (error)
245235
goto fail;
246236

@@ -253,24 +243,25 @@ int btrfs_sysfs_add_root(struct btrfs_root *root)
253243

254244
void btrfs_sysfs_del_root(struct btrfs_root *root)
255245
{
256-
kobject_unregister(&root->root_kobj);
246+
kobject_put(&root->root_kobj);
257247
wait_for_completion(&root->kobj_unregister);
258248
}
259249

260250
void btrfs_sysfs_del_super(struct btrfs_fs_info *fs)
261251
{
262-
kobject_unregister(&fs->super_kobj);
252+
kobject_put(&fs->super_kobj);
263253
wait_for_completion(&fs->kobj_unregister);
264254
}
265255

266256
int btrfs_init_sysfs()
267257
{
268-
kobj_set_kset_s(&btrfs_kset, fs_subsys);
269-
kobject_set_name(&btrfs_kset.kobj, "btrfs");
270-
return kset_register(&btrfs_kset);
258+
btrfs_kset = kset_create_and_add("btrfs", NULL, fs_kobj);
259+
if (!btrfs_kset)
260+
return -ENOMEM;
261+
return 0;
271262
}
272263

273264
void btrfs_exit_sysfs()
274265
{
275-
kset_unregister(&btrfs_kset);
266+
kset_unregister(btrfs_kset);
276267
}

0 commit comments

Comments
 (0)