On Tue, 2005-08-09 at 18:31 -0400, Shailabh Nagar wrote:
> Move initialization (CKRM RCFS rewrite)
>  
> Move filesystem initialization code to inode.c and add some printk
> macros
> 
> Signed-off-by: Shailabh Nagar <[EMAIL PROTECTED]>
> 
>  fs/rcfs/inode.c      |   80
> ++++++++++++++++++++++++++++++++++++++++++++++++
>  fs/rcfs/super.c      |   84
> ---------------------------------------------------
>  include/linux/rcfs.h |   25 +++++++++------
>  3 files changed, 95 insertions(+), 94 deletions(-)
> 
> Index: linux-2.6.12/fs/rcfs/inode.c
> ===================================================================
> --- linux-2.6.12.orig/fs/rcfs/inode.c   2005-08-09 15:30:16.391408848
> -0400
> +++ linux-2.6.12/fs/rcfs/inode.c        2005-08-09 15:30:16.463397904
> -0400
> @@ -158,3 +158,83 @@ int rcfs_delete_internal(struct dentry *
>  struct inode_operations rcfs_file_inode_operations = {
>         .getattr = simple_getattr,
>  };
> +
> +/******************************
> + *
> + * Generic inode/dentry helpers
> + *
> + ******************************/
> +
> +static kmem_cache_t *rcfs_inode_cachep;
> +
> +static void rcfs_init_once(void *foo, kmem_cache_t * cachep, unsigned
> long flags)
> +{
> +       struct rcfs_inode_info *ri = (struct rcfs_inode_info *)foo;
> +
> +       if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
> +           SLAB_CTOR_CONSTRUCTOR)
> +               inode_init_once(&ri->vfs_inode);
> +}
> +
> +int rcfs_init_inodecache(void)
> +{
> +       rcfs_inode_cachep = kmem_cache_create("rcfs_inode_cache",
> +                                             sizeof(struct
> rcfs_inode_info),
> +                                             0,
> +                                             SLAB_HWCACHE_ALIGN |
> +                                             SLAB_RECLAIM_ACCOUNT,
> +                                             rcfs_init_once, NULL);
> +       if (rcfs_inode_cachep == NULL)
> +               return -ENOMEM;
> +       return 0;
> +}
> +
> +void rcfs_destroy_inodecache(void)
> +{
> +       if (kmem_cache_destroy(rcfs_inode_cachep))
> +               info("inode cache not freed\n");
> +}
> +
> +
> +static struct file_system_type rcfs_fs_type = {
> +       .owner =        THIS_MODULE,
> +       .name =         "rcfs",
> +       .get_sb =       rcfs_get_sb,
> +       .kill_sb =      rcfs_kill_sb,
> +};
> +
> +static int __init init_rcfs_fs(void)
> +{
> +       int ret;
> +
> +       ret = register_filesystem(&rcfs_fs_type);
> +       if (ret)
> +               goto out;
> +
> +       ret = rcfs_init_inodecache();
> +       if (ret)
> +               goto out_register;
> +
> +       /*
> +        * Due to tight coupling of this module with ckrm
> +        * do not allow this module to be removed.
> +        */
> +       try_module_get(THIS_MODULE);
> +       return ret;
> +
> +out_register:
> +       unregister_filesystem(&rcfs_fs_type);
> +out:
> +       return ret;
> +}
> +
> +static void __exit exit_rcfs_fs(void)
> +{
> +       rcfs_destroy_inodecache();
> +       unregister_filesystem(&rcfs_fs_type);
> +}
> +
> +module_init(init_rcfs_fs)
> +module_exit(exit_rcfs_fs)
> +
> +MODULE_LICENSE("GPL");
> Index: linux-2.6.12/fs/rcfs/super.c
> ===================================================================
> --- linux-2.6.12.orig/fs/rcfs/super.c   2005-08-09 15:30:16.391408848
> -0400
> +++ linux-2.6.12/fs/rcfs/super.c        2005-08-09 15:30:16.464397752
> -0400
> @@ -34,10 +34,6 @@
>  
>  static kmem_cache_t *rcfs_inode_cachep;
>  
> -inline struct rcfs_inode_info *rcfs_get_inode_info(struct inode
> *inode)
> -{
> -       return container_of(inode, struct rcfs_inode_info, vfs_inode);
> -}
>  
>  static struct inode *rcfs_alloc_inode(struct super_block *sb)
>  {
> @@ -58,37 +54,6 @@ static void rcfs_destroy_inode(struct in
>         kmem_cache_free(rcfs_inode_cachep, ri);
>  }
>  
> -static void
> -rcfs_init_once(void *foo, kmem_cache_t * cachep, unsigned long flags)
> -{
> -       struct rcfs_inode_info *ri = (struct rcfs_inode_info *)foo;
> -
> -       if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
> -           SLAB_CTOR_CONSTRUCTOR)
> -               inode_init_once(&ri->vfs_inode);
> -}
> -
> -int rcfs_init_inodecache(void)
> -{
> -       rcfs_inode_cachep = kmem_cache_create("rcfs_inode_cache",
> -                                             sizeof(struct
> rcfs_inode_info),
> -                                             0,
> -                                             SLAB_HWCACHE_ALIGN |
> -                                             SLAB_RECLAIM_ACCOUNT,
> -                                             rcfs_init_once, NULL);
> -       if (rcfs_inode_cachep == NULL)
> -               return -ENOMEM;
> -       return 0;
> -}
> -
> -void rcfs_destroy_inodecache(void)
> -{
> -       pr_debug("destroy inodecache was called\n");
> -       if (kmem_cache_destroy(rcfs_inode_cachep))
> -               printk(KERN_INFO
> -                      "rcfs_inode_cache: not all structures were
> freed\n");
> -}
> -
>  struct super_operations rcfs_super_ops = {
>         .alloc_inode = rcfs_alloc_inode,
>         .destroy_inode = rcfs_destroy_inode,
> @@ -240,52 +205,3 @@ void rcfs_kill_sb(struct super_block *sb
>         generic_shutdown_super(sb);
>  }
>  
> -static struct file_system_type rcfs_fs_type = {
> -       .name = "rcfs",
> -       .get_sb = rcfs_get_sb,
> -       .kill_sb = rcfs_kill_sb,
> -};
> -
> -struct rcfs_functions my_rcfs_fn = {
> -       .mkroot = rcfs_mkroot,
> -       .rmroot = rcfs_rmroot,
> -       .register_classtype = rcfs_register_classtype,
> -       .deregister_classtype = rcfs_deregister_classtype,
> -};
> -
> -extern struct rcfs_functions rcfs_fn;
> -
> -static int __init init_rcfs_fs(void)
> -{
> -       int ret;
> -
> -       ret = register_filesystem(&rcfs_fs_type);
> -       if (ret)
> -               goto init_register_err;
> -       ret = rcfs_init_inodecache();
> -       if (ret)
> -               goto init_cache_err;
> -       rcfs_fn = my_rcfs_fn;
> -       /*
> -        * Due to tight coupling of this module with ckrm
> -        * do not allow this module to be removed.
> -        */
> -       try_module_get(THIS_MODULE);
> -       return ret;
> -
> -init_cache_err:
> -       unregister_filesystem(&rcfs_fs_type);
> -init_register_err:
> -       return ret;
> -}
> -
> -static void __exit exit_rcfs_fs(void)
> -{
> -       rcfs_destroy_inodecache();
> -       unregister_filesystem(&rcfs_fs_type);
> -}
> -
> -module_init(init_rcfs_fs)
> -module_exit(exit_rcfs_fs)
> -
> -MODULE_LICENSE("GPL");
> Index: linux-2.6.12/include/linux/rcfs.h
> ===================================================================
> --- linux-2.6.12.orig/include/linux/rcfs.h      2005-08-09
> 15:30:16.391408848 -0400
> +++ linux-2.6.12/include/linux/rcfs.h   2005-08-09 15:30:16.465397600
> -0400
> @@ -57,7 +57,6 @@ struct rcfs_mfdesc {
>  
>  extern struct rcfs_mfdesc *genmfdesc[];
>  
> -struct rcfs_inode_info *rcfs_get_inode_info(struct inode *inode);
>  struct inode *rcfs_get_inode(struct super_block *, int, dev_t);
>  int rcfs_mknod(struct inode *, struct dentry *, int, dev_t);
>  struct dentry *rcfs_set_magf_byname(char *, void *);
> @@ -80,15 +79,6 @@ extern struct file_operations members_fi
>  extern struct file_operations reclassify_fileops;
>  extern struct file_operations rcfs_file_operations;
>  
> -/* Callbacks into rcfs from ckrm */
> -
> -struct rcfs_functions {
> -       int (*mkroot) (struct rcfs_magf *, int, struct dentry **);
> -       int (*rmroot) (struct dentry *);
> -       int (*register_classtype) (struct ckrm_classtype *);
> -       int (*deregister_classtype) (struct ckrm_classtype *);
> -};
> -
>  int rcfs_register_classtype(struct ckrm_classtype *);
>  int rcfs_deregister_classtype(struct ckrm_classtype *);
>  int rcfs_mkroot(struct rcfs_magf *, int, struct dentry **);
> @@ -98,4 +88,19 @@ int rcfs_rmroot(struct dentry *);
>  extern struct dentry *rcfs_rootde;
>  extern struct rbce_eng_callback rcfs_eng_callbacks;
>  
> +static inline struct rcfs_inode_info *rcfs_get_inode_info(struct
> inode *inode)
> +{
> +       return container_of(inode, struct rcfs_inode_info, vfs_inode);
> +}
> +
> +#ifdef RCFS_DEBUG
> +#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" ,
> __FUNCTION__ , ## arg)
> +#else
> +#define dbg(format, arg...) do {} while (0)
> +#endif
> +
> +#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" ,
> __FUNCTION__ , ## arg)
> +#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" ,
> __FUNCTION__ , ## arg)
> +#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" ,
> __FUNCTION__ , ## arg)
> +
>  #endif /* _LINUX_RCFS_H */

        These macros belong outside of CKRM. Furthermore, the names are so
generic that I suspect the C Preprocessor will use these macros in
inappropriate places. Hence, for errors, info, and warnings I think the
best solution is to just use printk directly. 

        For debugging printks I think a better name for the macro is required.
Perhaps rcfs_debug.

Cheers,
        -Matt



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
ckrm-tech mailing list
https://lists.sourceforge.net/lists/listinfo/ckrm-tech

Reply via email to