xfs
[Top] [All Lists]

Re: [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log)

To: Bill O'Donnell <billodo@xxxxxxxxxx>
Subject: Re: [PATCH 4/4] xfs: consolidate sysfs ops (dbg, stats, log)
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Wed, 9 Sep 2015 07:06:44 +1000
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1441734594-4175-5-git-send-email-billodo@xxxxxxxxxx>
References: <1441734594-4175-1-git-send-email-billodo@xxxxxxxxxx> <1441734594-4175-5-git-send-email-billodo@xxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Tue, Sep 08, 2015 at 12:49:54PM -0500, Bill O'Donnell wrote:
> As a part of the series to move xfs global stats from procfs to sysfs,
> this patch consolidates the sysfs ops functions and removes redundancy.
> 
> Signed-off-by: Bill O'Donnell <billodo@xxxxxxxxxx>
> ---
>  fs/xfs/xfs_stats.c |   2 +-
>  fs/xfs/xfs_sysfs.c | 144 
> +++++++++++++++++------------------------------------
>  2 files changed, 48 insertions(+), 98 deletions(-)
> 
> diff --git a/fs/xfs/xfs_stats.c b/fs/xfs/xfs_stats.c
> index 05d5227..dc6ca67 100644
> --- a/fs/xfs/xfs_stats.c
> +++ b/fs/xfs/xfs_stats.c
> @@ -92,7 +92,7 @@ int xfs_stats_format(char *buf)
>               0);
>  #endif
>  
> -return len;
> +     return len;
>  }
>  
>  void xfs_stats_clearall(void)
> diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
> index a094e20..6fd597b 100644
> --- a/fs/xfs/xfs_sysfs.c
> +++ b/fs/xfs/xfs_sysfs.c
> @@ -54,6 +54,50 @@ struct kobj_type xfs_mp_ktype = {
>       .release = xfs_sysfs_release,
>  };
>  
> +static inline struct xlog *
> +to_xlog(struct kobject *kobject)
> +{
> +     struct xfs_kobj *kobj = to_kobj(kobject);
> +
> +     return container_of(kobj, struct xlog, l_kobj);
> +}
> +
> +STATIC ssize_t
> +xfs_sysfs_object_show(
> +     struct kobject          *kobject,
> +     struct attribute        *attr,
> +     char                    *buf)
> +{
> +     struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
> +     struct kobj_type *ktype = get_ktype(kobject);
> +     void *data = NULL;
> +
> +     if (ktype == &xfs_log_ktype)
> +             data = to_xlog(kobject);

Move the to_xlog(kobject) to the relevant ->show/->store operations
and just pass the kobject to them. Otherwise we'll end up with a lot
of non-generic functionality in these functions.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>