Re: dm: wait until kobject is destroyed

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

 



On Thu, Jan 09 2014 at  8:53pm -0500,
Mikulas Patocka <mpatocka@xxxxxxxxxx> wrote:

> Hi
> 
> Here I'm sending the updated kobject patch.
> 
> Changes:
> 	The file was renamed to dm-builtin.c
> 	A comment with explanation of the race condition added.
> 
> Mikulas
> 
> 
> 
> From: Mikulas Patocka <mpatocka@xxxxxxxxxx>
> 
> There may be other parts of the kernel taking reference to the dm kobject.
> We must wait until they drop the references before deallocating the md
> structure.
> 
> Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx

This header could use some work considering the previous patch is
already staged in linux-dm.git's 'for-next' -- so this patch will build
on that.  Would be nice to see some commentary about introducing a
dm-builtin to avoid concerns about dm_kobject_release crash after dm-mod
is unloaded.  Also, touch on the role/need of struct dm_kobject_holder?

> Index: linux-3.13-rc7/drivers/md/dm-sysfs.c
> ===================================================================
> --- linux-3.13-rc7.orig/drivers/md/dm-sysfs.c	2014-01-09 20:50:18.000000000 +0100
> +++ linux-3.13-rc7/drivers/md/dm-sysfs.c	2014-01-09 20:50:38.000000000 +0100
> @@ -86,6 +86,7 @@ static const struct sysfs_ops dm_sysfs_o
>  static struct kobj_type dm_ktype = {
>  	.sysfs_ops	= &dm_sysfs_ops,
>  	.default_attrs	= dm_attrs,
> +	.release	= dm_kobject_release,
>  };
>  
>  /*
> @@ -104,5 +105,7 @@ int dm_sysfs_init(struct mapped_device *
>   */
>  void dm_sysfs_exit(struct mapped_device *md)
>  {
> -	kobject_put(dm_kobject(md));
> +	struct kobject *kobj = dm_kobject(md);
> +	kobject_put(kobj);
> +	wait_for_completion(dm_get_completion_from_kobject(kobj));
>  }
> Index: linux-3.13-rc7/drivers/md/dm.c
> ===================================================================
> --- linux-3.13-rc7.orig/drivers/md/dm.c	2014-01-09 20:50:18.000000000 +0100
> +++ linux-3.13-rc7/drivers/md/dm.c	2014-01-09 20:50:38.000000000 +0100
> @@ -200,8 +200,8 @@ struct mapped_device {
>  	/* forced geometry settings */
>  	struct hd_geometry geometry;
>  
> -	/* sysfs handle */
> -	struct kobject kobj;
> +	/* kobject and completion */
> +	struct dm_kobject_holder h;
>  
>  	/* zero-length flush that will be cloned and submitted to targets */
>  	struct bio flush_bio;

Could you rename 'h' to 'kobj_holder'?

Also, this patch needs to be rebased ontop of linux-dm.git's 'for-next'
branch.

Mike

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel




[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux