linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block: remove blk-mq-sysfs dead code
@ 2021-07-13  8:18 Damien Le Moal
  2021-07-28 22:58 ` Damien Le Moal
  0 siblings, 1 reply; 3+ messages in thread
From: Damien Le Moal @ 2021-07-13  8:18 UTC (permalink / raw)
  To: linux-block, Jens Axboe

In block/blk-mq-sysfs.c, struct blk_mq_ctx_sysfs_entry is not used to
define any attribute since the "mq" sysfs directory contains only
sub-directories (no attribute files). As a result, blk_mq_sysfs_show(),
blk_mq_sysfs_store(), and struct sysfs_ops blk_mq_sysfs_ops are all
unused and unnecessary. Remove all this unused code.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 block/blk-mq-sysfs.c | 55 --------------------------------------------
 1 file changed, 55 deletions(-)

diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
index 7b52e7657b2d..253c857cba47 100644
--- a/block/blk-mq-sysfs.c
+++ b/block/blk-mq-sysfs.c
@@ -45,60 +45,12 @@ static void blk_mq_hw_sysfs_release(struct kobject *kobj)
 	kfree(hctx);
 }
 
-struct blk_mq_ctx_sysfs_entry {
-	struct attribute attr;
-	ssize_t (*show)(struct blk_mq_ctx *, char *);
-	ssize_t (*store)(struct blk_mq_ctx *, const char *, size_t);
-};
-
 struct blk_mq_hw_ctx_sysfs_entry {
 	struct attribute attr;
 	ssize_t (*show)(struct blk_mq_hw_ctx *, char *);
 	ssize_t (*store)(struct blk_mq_hw_ctx *, const char *, size_t);
 };
 
-static ssize_t blk_mq_sysfs_show(struct kobject *kobj, struct attribute *attr,
-				 char *page)
-{
-	struct blk_mq_ctx_sysfs_entry *entry;
-	struct blk_mq_ctx *ctx;
-	struct request_queue *q;
-	ssize_t res;
-
-	entry = container_of(attr, struct blk_mq_ctx_sysfs_entry, attr);
-	ctx = container_of(kobj, struct blk_mq_ctx, kobj);
-	q = ctx->queue;
-
-	if (!entry->show)
-		return -EIO;
-
-	mutex_lock(&q->sysfs_lock);
-	res = entry->show(ctx, page);
-	mutex_unlock(&q->sysfs_lock);
-	return res;
-}
-
-static ssize_t blk_mq_sysfs_store(struct kobject *kobj, struct attribute *attr,
-				  const char *page, size_t length)
-{
-	struct blk_mq_ctx_sysfs_entry *entry;
-	struct blk_mq_ctx *ctx;
-	struct request_queue *q;
-	ssize_t res;
-
-	entry = container_of(attr, struct blk_mq_ctx_sysfs_entry, attr);
-	ctx = container_of(kobj, struct blk_mq_ctx, kobj);
-	q = ctx->queue;
-
-	if (!entry->store)
-		return -EIO;
-
-	mutex_lock(&q->sysfs_lock);
-	res = entry->store(ctx, page, length);
-	mutex_unlock(&q->sysfs_lock);
-	return res;
-}
-
 static ssize_t blk_mq_hw_sysfs_show(struct kobject *kobj,
 				    struct attribute *attr, char *page)
 {
@@ -198,23 +150,16 @@ static struct attribute *default_hw_ctx_attrs[] = {
 };
 ATTRIBUTE_GROUPS(default_hw_ctx);
 
-static const struct sysfs_ops blk_mq_sysfs_ops = {
-	.show	= blk_mq_sysfs_show,
-	.store	= blk_mq_sysfs_store,
-};
-
 static const struct sysfs_ops blk_mq_hw_sysfs_ops = {
 	.show	= blk_mq_hw_sysfs_show,
 	.store	= blk_mq_hw_sysfs_store,
 };
 
 static struct kobj_type blk_mq_ktype = {
-	.sysfs_ops	= &blk_mq_sysfs_ops,
 	.release	= blk_mq_sysfs_release,
 };
 
 static struct kobj_type blk_mq_ctx_ktype = {
-	.sysfs_ops	= &blk_mq_sysfs_ops,
 	.release	= blk_mq_ctx_sysfs_release,
 };
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: remove blk-mq-sysfs dead code
  2021-07-13  8:18 [PATCH] block: remove blk-mq-sysfs dead code Damien Le Moal
@ 2021-07-28 22:58 ` Damien Le Moal
  2021-07-28 22:59   ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Damien Le Moal @ 2021-07-28 22:58 UTC (permalink / raw)
  To: linux-block, Jens Axboe

On 2021/07/13 17:18, Damien Le Moal wrote:
> In block/blk-mq-sysfs.c, struct blk_mq_ctx_sysfs_entry is not used to
> define any attribute since the "mq" sysfs directory contains only
> sub-directories (no attribute files). As a result, blk_mq_sysfs_show(),
> blk_mq_sysfs_store(), and struct sysfs_ops blk_mq_sysfs_ops are all
> unused and unnecessary. Remove all this unused code.

Jens,

any comment on this one ?

> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>  block/blk-mq-sysfs.c | 55 --------------------------------------------
>  1 file changed, 55 deletions(-)
> 
> diff --git a/block/blk-mq-sysfs.c b/block/blk-mq-sysfs.c
> index 7b52e7657b2d..253c857cba47 100644
> --- a/block/blk-mq-sysfs.c
> +++ b/block/blk-mq-sysfs.c
> @@ -45,60 +45,12 @@ static void blk_mq_hw_sysfs_release(struct kobject *kobj)
>  	kfree(hctx);
>  }
>  
> -struct blk_mq_ctx_sysfs_entry {
> -	struct attribute attr;
> -	ssize_t (*show)(struct blk_mq_ctx *, char *);
> -	ssize_t (*store)(struct blk_mq_ctx *, const char *, size_t);
> -};
> -
>  struct blk_mq_hw_ctx_sysfs_entry {
>  	struct attribute attr;
>  	ssize_t (*show)(struct blk_mq_hw_ctx *, char *);
>  	ssize_t (*store)(struct blk_mq_hw_ctx *, const char *, size_t);
>  };
>  
> -static ssize_t blk_mq_sysfs_show(struct kobject *kobj, struct attribute *attr,
> -				 char *page)
> -{
> -	struct blk_mq_ctx_sysfs_entry *entry;
> -	struct blk_mq_ctx *ctx;
> -	struct request_queue *q;
> -	ssize_t res;
> -
> -	entry = container_of(attr, struct blk_mq_ctx_sysfs_entry, attr);
> -	ctx = container_of(kobj, struct blk_mq_ctx, kobj);
> -	q = ctx->queue;
> -
> -	if (!entry->show)
> -		return -EIO;
> -
> -	mutex_lock(&q->sysfs_lock);
> -	res = entry->show(ctx, page);
> -	mutex_unlock(&q->sysfs_lock);
> -	return res;
> -}
> -
> -static ssize_t blk_mq_sysfs_store(struct kobject *kobj, struct attribute *attr,
> -				  const char *page, size_t length)
> -{
> -	struct blk_mq_ctx_sysfs_entry *entry;
> -	struct blk_mq_ctx *ctx;
> -	struct request_queue *q;
> -	ssize_t res;
> -
> -	entry = container_of(attr, struct blk_mq_ctx_sysfs_entry, attr);
> -	ctx = container_of(kobj, struct blk_mq_ctx, kobj);
> -	q = ctx->queue;
> -
> -	if (!entry->store)
> -		return -EIO;
> -
> -	mutex_lock(&q->sysfs_lock);
> -	res = entry->store(ctx, page, length);
> -	mutex_unlock(&q->sysfs_lock);
> -	return res;
> -}
> -
>  static ssize_t blk_mq_hw_sysfs_show(struct kobject *kobj,
>  				    struct attribute *attr, char *page)
>  {
> @@ -198,23 +150,16 @@ static struct attribute *default_hw_ctx_attrs[] = {
>  };
>  ATTRIBUTE_GROUPS(default_hw_ctx);
>  
> -static const struct sysfs_ops blk_mq_sysfs_ops = {
> -	.show	= blk_mq_sysfs_show,
> -	.store	= blk_mq_sysfs_store,
> -};
> -
>  static const struct sysfs_ops blk_mq_hw_sysfs_ops = {
>  	.show	= blk_mq_hw_sysfs_show,
>  	.store	= blk_mq_hw_sysfs_store,
>  };
>  
>  static struct kobj_type blk_mq_ktype = {
> -	.sysfs_ops	= &blk_mq_sysfs_ops,
>  	.release	= blk_mq_sysfs_release,
>  };
>  
>  static struct kobj_type blk_mq_ctx_ktype = {
> -	.sysfs_ops	= &blk_mq_sysfs_ops,
>  	.release	= blk_mq_ctx_sysfs_release,
>  };
>  
> 


-- 
Damien Le Moal
Western Digital Research

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: remove blk-mq-sysfs dead code
  2021-07-28 22:58 ` Damien Le Moal
@ 2021-07-28 22:59   ` Jens Axboe
  0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2021-07-28 22:59 UTC (permalink / raw)
  To: Damien Le Moal, linux-block

On 7/28/21 4:58 PM, Damien Le Moal wrote:
> On 2021/07/13 17:18, Damien Le Moal wrote:
>> In block/blk-mq-sysfs.c, struct blk_mq_ctx_sysfs_entry is not used to
>> define any attribute since the "mq" sysfs directory contains only
>> sub-directories (no attribute files). As a result, blk_mq_sysfs_show(),
>> blk_mq_sysfs_store(), and struct sysfs_ops blk_mq_sysfs_ops are all
>> unused and unnecessary. Remove all this unused code.
> 
> Jens,
> 
> any comment on this one ?

Shoot, I actually remember reading this one and thought I had applied it.
Guess I did not - now rectified, added for 5.15.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-07-28 23:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-13  8:18 [PATCH] block: remove blk-mq-sysfs dead code Damien Le Moal
2021-07-28 22:58 ` Damien Le Moal
2021-07-28 22:59   ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).