diff mbox series

[1/2] block: improve print_req_error

Message ID 20190611200210.4819-2-chaitanya.kulkarni@wdc.com (mailing list archive)
State New, archived
Headers show
Series block: improve print_req_error() | expand

Commit Message

Chaitanya Kulkarni June 11, 2019, 8:02 p.m. UTC
From: Christoph Hellwig <hch@lst.de>

Print the calling function instead of print_req_error as a prefix, and
print the operation and op_flags separately instead of the whole field.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 block/blk-core.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Hannes Reinecke June 17, 2019, 8:42 a.m. UTC | #1
On 6/11/19 10:02 PM, Chaitanya Kulkarni wrote:
> From: Christoph Hellwig <hch@lst.de>
> 
> Print the calling function instead of print_req_error as a prefix, and
> print the operation and op_flags separately instead of the whole field.
> 
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>  block/blk-core.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index ee1b35fe8572..d1a227cfb72e 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -167,18 +167,20 @@ int blk_status_to_errno(blk_status_t status)
>  }
>  EXPORT_SYMBOL_GPL(blk_status_to_errno);
>  
> -static void print_req_error(struct request *req, blk_status_t status)
> +static void print_req_error(struct request *req, blk_status_t status,
> +		const char *caller)
>  {
>  	int idx = (__force int)status;
>  
>  	if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors)))
>  		return;
>  
> -	printk_ratelimited(KERN_ERR "%s: %s error, dev %s, sector %llu flags %x\n",
> -				__func__, blk_errors[idx].name,
> -				req->rq_disk ?  req->rq_disk->disk_name : "?",
> -				(unsigned long long)blk_rq_pos(req),
> -				req->cmd_flags);
> +	printk_ratelimited(KERN_ERR
> +		"%s: %s error, dev %s, sector %llu op 0x%x flags 0x%x\n",
> +		caller, blk_errors[idx].name,
> +		req->rq_disk ?  req->rq_disk->disk_name : "?",
> +		blk_rq_pos(req), req_op(req),
> +		req->cmd_flags & ~REQ_OP_MASK);
>  }
>  
>  static void req_bio_endio(struct request *rq, struct bio *bio,
> @@ -1360,7 +1362,7 @@ bool blk_update_request(struct request *req, blk_status_t error,
>  
>  	if (unlikely(error && !blk_rq_is_passthrough(req) &&
>  		     !(req->rq_flags & RQF_QUIET)))
> -		print_req_error(req, error);
> +		print_req_error(req, error, __func__);
>  
>  	blk_account_io_completion(req, nr_bytes);
>  
> 
I did ask this already, but didn't get an answer:
Why do we have the __func__ argument?
Can it print anything else than 'blk_update_request' ?
If so, can't it be dropped?

Cheers,

Hannes
Chaitanya Kulkarni June 17, 2019, 4:49 p.m. UTC | #2
On 06/17/2019 01:43 AM, Hannes Reinecke wrote:
> On 6/11/19 10:02 PM, Chaitanya Kulkarni wrote:
>> From: Christoph Hellwig <hch@lst.de>
>>
>> Print the calling function instead of print_req_error as a prefix, and
>> print the operation and op_flags separately instead of the whole field.
>>
>> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
>> ---
>>   block/blk-core.c | 16 +++++++++-------
>>   1 file changed, 9 insertions(+), 7 deletions(-)
>>
>> diff --git a/block/blk-core.c b/block/blk-core.c
>> index ee1b35fe8572..d1a227cfb72e 100644
>> --- a/block/blk-core.c
>> +++ b/block/blk-core.c
>> @@ -167,18 +167,20 @@ int blk_status_to_errno(blk_status_t status)
>>   }
>>   EXPORT_SYMBOL_GPL(blk_status_to_errno);
>>
>> -static void print_req_error(struct request *req, blk_status_t status)
>> +static void print_req_error(struct request *req, blk_status_t status,
>> +		const char *caller)
>>   {
>>   	int idx = (__force int)status;
>>
>>   	if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors)))
>>   		return;
>>
>> -	printk_ratelimited(KERN_ERR "%s: %s error, dev %s, sector %llu flags %x\n",
>> -				__func__, blk_errors[idx].name,
>> -				req->rq_disk ?  req->rq_disk->disk_name : "?",
>> -				(unsigned long long)blk_rq_pos(req),
>> -				req->cmd_flags);
>> +	printk_ratelimited(KERN_ERR
>> +		"%s: %s error, dev %s, sector %llu op 0x%x flags 0x%x\n",
>> +		caller, blk_errors[idx].name,
>> +		req->rq_disk ?  req->rq_disk->disk_name : "?",
>> +		blk_rq_pos(req), req_op(req),
>> +		req->cmd_flags & ~REQ_OP_MASK);
>>   }
>>
>>   static void req_bio_endio(struct request *rq, struct bio *bio,
>> @@ -1360,7 +1362,7 @@ bool blk_update_request(struct request *req, blk_status_t error,
>>
>>   	if (unlikely(error && !blk_rq_is_passthrough(req) &&
>>   		     !(req->rq_flags & RQF_QUIET)))
>> -		print_req_error(req, error);
>> +		print_req_error(req, error, __func__);
>>
>>   	blk_account_io_completion(req, nr_bytes);
>>
>>
> I did ask this already, but didn't get an answer:
> Why do we have the __func__ argument?
> Can it print anything else than 'blk_update_request' ?
> If so, can't it be dropped?
Thanks for looking into this. The caller argument I think is useful for 
future use if this function gets called from different places.

Are you okay with that ?

>
> Cheers,
>
> Hannes
>
Hannes Reinecke June 18, 2019, 11:09 a.m. UTC | #3
On 6/17/19 6:49 PM, Chaitanya Kulkarni wrote:
> On 06/17/2019 01:43 AM, Hannes Reinecke wrote:
>> On 6/11/19 10:02 PM, Chaitanya Kulkarni wrote:
>>> From: Christoph Hellwig <hch@lst.de>
>>>
>>> Print the calling function instead of print_req_error as a prefix, and
>>> print the operation and op_flags separately instead of the whole field.
>>>
>>> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
>>> ---
>>>   block/blk-core.c | 16 +++++++++-------
>>>   1 file changed, 9 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/block/blk-core.c b/block/blk-core.c
>>> index ee1b35fe8572..d1a227cfb72e 100644
>>> --- a/block/blk-core.c
>>> +++ b/block/blk-core.c
>>> @@ -167,18 +167,20 @@ int blk_status_to_errno(blk_status_t status)
>>>   }
>>>   EXPORT_SYMBOL_GPL(blk_status_to_errno);
>>>
>>> -static void print_req_error(struct request *req, blk_status_t status)
>>> +static void print_req_error(struct request *req, blk_status_t status,
>>> +		const char *caller)
>>>   {
>>>   	int idx = (__force int)status;
>>>
>>>   	if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors)))
>>>   		return;
>>>
>>> -	printk_ratelimited(KERN_ERR "%s: %s error, dev %s, sector %llu flags %x\n",
>>> -				__func__, blk_errors[idx].name,
>>> -				req->rq_disk ?  req->rq_disk->disk_name : "?",
>>> -				(unsigned long long)blk_rq_pos(req),
>>> -				req->cmd_flags);
>>> +	printk_ratelimited(KERN_ERR
>>> +		"%s: %s error, dev %s, sector %llu op 0x%x flags 0x%x\n",
>>> +		caller, blk_errors[idx].name,
>>> +		req->rq_disk ?  req->rq_disk->disk_name : "?",
>>> +		blk_rq_pos(req), req_op(req),
>>> +		req->cmd_flags & ~REQ_OP_MASK);
>>>   }
>>>
>>>   static void req_bio_endio(struct request *rq, struct bio *bio,
>>> @@ -1360,7 +1362,7 @@ bool blk_update_request(struct request *req, blk_status_t error,
>>>
>>>   	if (unlikely(error && !blk_rq_is_passthrough(req) &&
>>>   		     !(req->rq_flags & RQF_QUIET)))
>>> -		print_req_error(req, error);
>>> +		print_req_error(req, error, __func__);
>>>
>>>   	blk_account_io_completion(req, nr_bytes);
>>>
>>>
>> I did ask this already, but didn't get an answer:
>> Why do we have the __func__ argument?
>> Can it print anything else than 'blk_update_request' ?
>> If so, can't it be dropped?
> Thanks for looking into this. The caller argument I think is useful for 
> future use if this function gets called from different places.
> 
> Are you okay with that ?
> 
Yes, I am.

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

Cheers,

Hannes
diff mbox series

Patch

diff --git a/block/blk-core.c b/block/blk-core.c
index ee1b35fe8572..d1a227cfb72e 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -167,18 +167,20 @@  int blk_status_to_errno(blk_status_t status)
 }
 EXPORT_SYMBOL_GPL(blk_status_to_errno);
 
-static void print_req_error(struct request *req, blk_status_t status)
+static void print_req_error(struct request *req, blk_status_t status,
+		const char *caller)
 {
 	int idx = (__force int)status;
 
 	if (WARN_ON_ONCE(idx >= ARRAY_SIZE(blk_errors)))
 		return;
 
-	printk_ratelimited(KERN_ERR "%s: %s error, dev %s, sector %llu flags %x\n",
-				__func__, blk_errors[idx].name,
-				req->rq_disk ?  req->rq_disk->disk_name : "?",
-				(unsigned long long)blk_rq_pos(req),
-				req->cmd_flags);
+	printk_ratelimited(KERN_ERR
+		"%s: %s error, dev %s, sector %llu op 0x%x flags 0x%x\n",
+		caller, blk_errors[idx].name,
+		req->rq_disk ?  req->rq_disk->disk_name : "?",
+		blk_rq_pos(req), req_op(req),
+		req->cmd_flags & ~REQ_OP_MASK);
 }
 
 static void req_bio_endio(struct request *rq, struct bio *bio,
@@ -1360,7 +1362,7 @@  bool blk_update_request(struct request *req, blk_status_t error,
 
 	if (unlikely(error && !blk_rq_is_passthrough(req) &&
 		     !(req->rq_flags & RQF_QUIET)))
-		print_req_error(req, error);
+		print_req_error(req, error, __func__);
 
 	blk_account_io_completion(req, nr_bytes);