Re: [PATCH 14/14] bcache: add sysfs interface register_nvdimm_meta to register NVDIMM meta device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/15/21 7:49 AM, Coly Li wrote:
> This patch adds a sysfs interface register_nvdimm_meta to register
> NVDIMM meta device. The sysfs interface file only shows up when
> CONFIG_BCACHE_NVM_PAGES=y. Then a NVDIMM name space formatted by
> bcache-tools can be registered into bcache by e.g.,
>   echo /dev/pmem0 > /sys/fs/bcache/register_nvdimm_meta
> 
> Signed-off-by: Coly Li <colyli@xxxxxxx>
> Cc: Jianpeng Ma <jianpeng.ma@xxxxxxxxx>
> Cc: Qiaowei Ren <qiaowei.ren@xxxxxxxxx>
> ---
>  drivers/md/bcache/super.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 4d6666d03aa7..9d506d053548 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -2439,10 +2439,18 @@ static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
>  static ssize_t bch_pending_bdevs_cleanup(struct kobject *k,
>  					 struct kobj_attribute *attr,
>  					 const char *buffer, size_t size);
> +#if defined(CONFIG_BCACHE_NVM_PAGES)
> +static ssize_t register_nvdimm_meta(struct kobject *k,
> +				    struct kobj_attribute *attr,
> +				    const char *buffer, size_t size);
> +#endif
>  
>  kobj_attribute_write(register,		register_bcache);
>  kobj_attribute_write(register_quiet,	register_bcache);
>  kobj_attribute_write(pendings_cleanup,	bch_pending_bdevs_cleanup);
> +#if defined(CONFIG_BCACHE_NVM_PAGES)
> +kobj_attribute_write(register_nvdimm_meta, register_nvdimm_meta);
> +#endif
>  
>  static bool bch_is_open_backing(dev_t dev)
>  {
> @@ -2556,6 +2564,24 @@ static void register_device_async(struct async_reg_args *args)
>  	queue_delayed_work(system_wq, &args->reg_work, 10);
>  }
>  
> +#if defined(CONFIG_BCACHE_NVM_PAGES)
> +static ssize_t register_nvdimm_meta(struct kobject *k, struct kobj_attribute *attr,
> +				    const char *buffer, size_t size)
> +{
> +	ssize_t ret = size;
> +
> +	struct bch_nvm_namespace *ns = bch_register_namespace(buffer);
> +
> +	if (IS_ERR(ns)) {
> +		pr_err("register nvdimm namespace %s for meta device failed.\n",
> +			buffer);
> +		ret = -EINVAL;
> +	}
> +
> +	return ret;
> +}
> +#endif
> +
>  static ssize_t register_bcache(struct kobject *k, struct kobj_attribute *attr,
>  			       const char *buffer, size_t size)
>  {
> @@ -2898,6 +2924,9 @@ static int __init bcache_init(void)
>  	static const struct attribute *files[] = {
>  		&ksysfs_register.attr,
>  		&ksysfs_register_quiet.attr,
> +#if defined(CONFIG_BCACHE_NVM_PAGES)
> +		&ksysfs_register_nvdimm_meta.attr,
> +#endif
>  		&ksysfs_pendings_cleanup.attr,
>  		NULL
>  	};
> 
Reviewed-by: Hannes Reinecke <hare@xxxxxxx>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@xxxxxxx			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux