diff mbox series

[RFC,v2,07/16] bcache: add comments for kobj release callback routine

Message ID 20190419160509.66298-8-colyli@suse.de (mailing list archive)
State New, archived
Headers show
Series bcache: fix journal no-space deadlock | expand

Commit Message

Coly Li April 19, 2019, 4:05 p.m. UTC
Bcache has several routines to release resources in implicit way, they
are called when the associated kobj released. This patch adds code
comments to notice when and which release callback will be called,
- When dc->disk.kobj released:
  void bch_cached_dev_release(struct kobject *kobj)
- When d->kobj released:
  void bch_flash_dev_release(struct kobject *kobj)
- When c->kobj released:
  void bch_cache_set_release(struct kobject *kobj)
- When ca->kobj released
  void bch_cache_release(struct kobject *kobj)

Signed-off-by: Coly Li <colyli@suse.de>
---
 drivers/md/bcache/super.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Chaitanya Kulkarni April 21, 2019, 5:52 p.m. UTC | #1
Looks good.

Reviewed-by:- Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

On 04/19/2019 11:24 AM, Coly Li wrote:
> Bcache has several routines to release resources in implicit way, they
> are called when the associated kobj released. This patch adds code
> comments to notice when and which release callback will be called,
> - When dc->disk.kobj released:
>    void bch_cached_dev_release(struct kobject *kobj)
> - When d->kobj released:
>    void bch_flash_dev_release(struct kobject *kobj)
> - When c->kobj released:
>    void bch_cache_set_release(struct kobject *kobj)
> - When ca->kobj released
>    void bch_cache_release(struct kobject *kobj)
>
> Signed-off-by: Coly Li <colyli@suse.de>
> ---
>   drivers/md/bcache/super.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 036bffad0bfe..400af446c372 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1174,6 +1174,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
>   	return 0;
>   }
>
> +/* when dc->disk.kobj released */
>   void bch_cached_dev_release(struct kobject *kobj)
>   {
>   	struct cached_dev *dc = container_of(kobj, struct cached_dev,
> @@ -1326,6 +1327,7 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,
>
>   /* Flash only volumes */
>
> +/* When d->kobj released */
>   void bch_flash_dev_release(struct kobject *kobj)
>   {
>   	struct bcache_device *d = container_of(kobj, struct bcache_device,
> @@ -1496,6 +1498,7 @@ bool bch_cache_set_error(struct cache_set *c, const char *fmt, ...)
>   	return true;
>   }
>
> +/* When c->kobj released */
>   void bch_cache_set_release(struct kobject *kobj)
>   {
>   	struct cache_set *c = container_of(kobj, struct cache_set, kobj);
> @@ -2023,6 +2026,7 @@ static const char *register_cache_set(struct cache *ca)
>
>   /* Cache device */
>
> +/* When ca->kobj released */
>   void bch_cache_release(struct kobject *kobj)
>   {
>   	struct cache *ca = container_of(kobj, struct cache, kobj);
>
Hannes Reinecke April 23, 2019, 7:03 a.m. UTC | #2
On 4/19/19 6:05 PM, Coly Li wrote:
> Bcache has several routines to release resources in implicit way, they
> are called when the associated kobj released. This patch adds code
> comments to notice when and which release callback will be called,
> - When dc->disk.kobj released:
>    void bch_cached_dev_release(struct kobject *kobj)
> - When d->kobj released:
>    void bch_flash_dev_release(struct kobject *kobj)
> - When c->kobj released:
>    void bch_cache_set_release(struct kobject *kobj)
> - When ca->kobj released
>    void bch_cache_release(struct kobject *kobj)
> 
> Signed-off-by: Coly Li <colyli@suse.de>
> ---
>   drivers/md/bcache/super.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 036bffad0bfe..400af446c372 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -1174,6 +1174,7 @@ int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
>   	return 0;
>   }
>   
> +/* when dc->disk.kobj released */
>   void bch_cached_dev_release(struct kobject *kobj)
>   {
>   	struct cached_dev *dc = container_of(kobj, struct cached_dev,
> @@ -1326,6 +1327,7 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,
>   
>   /* Flash only volumes */
>   
> +/* When d->kobj released */
>   void bch_flash_dev_release(struct kobject *kobj)
>   {
>   	struct bcache_device *d = container_of(kobj, struct bcache_device,
> @@ -1496,6 +1498,7 @@ bool bch_cache_set_error(struct cache_set *c, const char *fmt, ...)
>   	return true;
>   }
>   
> +/* When c->kobj released */
>   void bch_cache_set_release(struct kobject *kobj)
>   {
>   	struct cache_set *c = container_of(kobj, struct cache_set, kobj);
> @@ -2023,6 +2026,7 @@ static const char *register_cache_set(struct cache *ca)
>   
>   /* Cache device */
>   
> +/* When ca->kobj released */
>   void bch_cache_release(struct kobject *kobj)
>   {
>   	struct cache *ca = container_of(kobj, struct cache, kobj);
> 
This could be inferred from the 'container_of' statement for each relase 
function, but if you want ...

Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 036bffad0bfe..400af446c372 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1174,6 +1174,7 @@  int bch_cached_dev_attach(struct cached_dev *dc, struct cache_set *c,
 	return 0;
 }
 
+/* when dc->disk.kobj released */
 void bch_cached_dev_release(struct kobject *kobj)
 {
 	struct cached_dev *dc = container_of(kobj, struct cached_dev,
@@ -1326,6 +1327,7 @@  static void register_bdev(struct cache_sb *sb, struct page *sb_page,
 
 /* Flash only volumes */
 
+/* When d->kobj released */
 void bch_flash_dev_release(struct kobject *kobj)
 {
 	struct bcache_device *d = container_of(kobj, struct bcache_device,
@@ -1496,6 +1498,7 @@  bool bch_cache_set_error(struct cache_set *c, const char *fmt, ...)
 	return true;
 }
 
+/* When c->kobj released */
 void bch_cache_set_release(struct kobject *kobj)
 {
 	struct cache_set *c = container_of(kobj, struct cache_set, kobj);
@@ -2023,6 +2026,7 @@  static const char *register_cache_set(struct cache *ca)
 
 /* Cache device */
 
+/* When ca->kobj released */
 void bch_cache_release(struct kobject *kobj)
 {
 	struct cache *ca = container_of(kobj, struct cache, kobj);