[Btrfs-devel] [PATCH 2/2] block accounting+sysfs support for btrfs
chris.mason at oracle.com
Mon Aug 20 13:52:06 PDT 2007
On Fri, 17 Aug 2007 17:49:30 -0400
Josef Bacik <jbacik at redhat.com> wrote:
> This patch adds block accounting per root_item in btrfs, and adds a
> sysfs infrastructure to report it (as well as future things). The
> sysfs heirarchy is
> /sys/fs/btrfs/<sb->s_id>/<root_item name>/
Ok, this is almost perfect ;) I see one small problem, quoting from
the kobject docs (Documentation/kobject.txt
It is _imperative_ that you supply a destructor for dynamically
allocated kobjects to free them if you are using kobject reference
counts. The reference count controls the lifetime of the object.
If it goes to 0, then it is assumed that the object will
be freed and cannot be used.
This means that we have to free anything referenced by the kobject in
the destructor for the kobject. Looks like most of your sysfs bits
touch things from kmalloc (struct btrfs_root and struct btrfs_fs_info),
with the exception of the 3 fields that reference struct
What I would do in this case is just get rid of those sysfs methods.
You can get them via df, and we can deal with other problems later ;)
More information about the Btrfs-devel