On Fri, May 16, 2014 at 02:12:45PM -0400, Brian Foster wrote:
> Initialize/destroy a kset on module init/fini for XFS. The XFS attribute
> directory is represented as /sys/fs/xfs. Create a subdirectory per-mount
> based on the system device name.
>
> Also add some basic macros to aid in the addition of sysfs attributes.
> This code is modeled after the equivalent mechanism for ext4.
>
> Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx>
> ---
> fs/xfs/xfs_mount.c | 79
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> fs/xfs/xfs_mount.h | 2 ++
> fs/xfs/xfs_super.c | 12 ++++++++-
> 3 files changed, 92 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
> index 944f3d9..9ed9dd0 100644
> --- a/fs/xfs/xfs_mount.c
> +++ b/fs/xfs/xfs_mount.c
> @@ -60,6 +60,9 @@ static DEFINE_MUTEX(xfs_uuid_table_mutex);
> static int xfs_uuid_table_size;
> static uuid_t *xfs_uuid_table;
>
> +extern struct kset *xfs_kset;
> +static struct kobj_type xfs_ktype;
> +
> /*
> * See if the UUID is unique among mounted XFS filesystems.
> * Mount fails if UUID is nil or a FS with the same UUID is already mounted.
> @@ -955,6 +958,13 @@ xfs_mountfs(
> "Unable to allocate reserve blocks. Continuing without reserve pool.");
> }
>
> + mp->m_kobject.kset = xfs_kset;
> + init_completion(&mp->m_kobject_complete);
> + error = kobject_init_and_add(&mp->m_kobject, &xfs_ktype, NULL,
> + "%s", mp->m_fsname);
> + if (error)
> + goto out_rtunmount;
> +
I think this should be wrapped in a helper, same for the destruction
code. It shoul dalso be called earlier rather than later, because we
are going to want to add children to this object (e.g. per-ag sysfs
attribute directories), and we probably want to isolate information
from different subsystems to different subdirectories under this.
e.g;
/sysfs/fs/xfs/vda/....
/vdb/log/...
/trans/...
/ag/0/sb/....
/agf/....
/agi/....
/agfl/....
/1/sb/...
...
/n/agfl/....
/quota/....
Dumping everything in the root directory is probably not a good
idea, and hence we shoul dbe creating the heirarchy as we initialise
subsystems during mount, and freeing them as we tear them down from
unmount...
Cheers,
Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx
|