[PATCH v3 06/39] fs: super: introduce a get_super_cdev_thawed to get sb by cdev reference

Jan Kara jack at suse.cz
Tue Sep 15 14:24:57 PDT 2015


On Tue 15-09-15 17:02:01, Dongsheng Yang wrote:
> This patch refactors the original get_super_thawed to get a common
> helper function of __get_super_thawed. Then take the use of
> __get_super_thawed, we can implement get_super_cdev_thawed easily.
> 
> Signed-off-by: Dongsheng Yang <yangds.fnst at cn.fujitsu.com>

The patch looks good to me. You can add:

Reviewed-by: Jan Kara <jack at suse.com>

								Honza

> ---
>  fs/super.c         | 29 +++++++++++++++++++++++++----
>  include/linux/fs.h |  1 +
>  2 files changed, 26 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/super.c b/fs/super.c
> index 321d16b..df32393 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -629,18 +629,20 @@ struct super_block *get_super_cdev(struct cdev *cdev)
>  EXPORT_SYMBOL(get_super_cdev);
>  
>  /**
> - * get_super_thawed - get thawed superblock of a device
> - * @bdev: device to get the superblock for
> + * __get_super_thawed - get thawed superblock
> + * @func: function pointer to get superblock by key
> + * @key: key to find superblock
>   *
>   * Scans the superblock list and finds the superblock of the file system
>   * mounted on the device. The superblock is returned once it is thawed
>   * (or immediately if it was not frozen). %NULL is returned if no match
>   * is found.
>   */
> -struct super_block *get_super_thawed(struct block_device *bdev)
> +static struct super_block *__get_super_thawed(
> +		int (*compare)(struct super_block *, void *), void *key)
>  {
>  	while (1) {
> -		struct super_block *s = get_super(bdev);
> +		struct super_block *s = __get_super(compare, key);
>  		if (!s || s->s_writers.frozen == SB_UNFROZEN)
>  			return s;
>  		up_read(&s->s_umount);
> @@ -649,9 +651,28 @@ struct super_block *get_super_thawed(struct block_device *bdev)
>  		put_super(s);
>  	}
>  }
> +
> +/**
> + * get_super_thawed - get thawed superblock of a device
> + * @bdev: device to get the superblock for
> + */
> +struct super_block *get_super_thawed(struct block_device *bdev)
> +{
> +	return __get_super_thawed(bdev_compare, bdev);
> +}
>  EXPORT_SYMBOL(get_super_thawed);
>  
>  /**
> + * get_super_cdev_thawed - get thawed superblock of a char device
> + * @cdev: device to get the superblock for
> + */
> +struct super_block *get_super_cdev_thawed(struct cdev *cdev)
> +{
> +	return __get_super_thawed(cdev_compare, cdev);
> +}
> +EXPORT_SYMBOL(get_super_cdev_thawed);
> +
> +/**
>   * get_active_super - get an active reference to the superblock of a device
>   * @bdev: device to get the superblock for
>   *
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index df71cbb..2c1c122 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2798,6 +2798,7 @@ extern struct file_system_type *get_fs_type(const char *name);
>  extern struct super_block *get_super(struct block_device *);
>  extern struct super_block *get_super_cdev(struct cdev *);
>  extern struct super_block *get_super_thawed(struct block_device *);
> +extern struct super_block *get_super_cdev_thawed(struct cdev *);
>  extern struct super_block *get_active_super(struct block_device *bdev);
>  extern void drop_super(struct super_block *sb);
>  extern void iterate_supers(void (*)(struct super_block *, void *), void *);
> -- 
> 1.8.4.2
> 
-- 
Jan Kara <jack at suse.com>
SUSE Labs, CR



More information about the linux-mtd mailing list