diff mbox series

[1/5] block: update error message for bio_check_ro()

Message ID 20190701215726.27601-2-chaitanya.kulkarni@wdc.com (mailing list archive)
State New, archived
Headers show
Series block: udpate debug messages with blk_op_str() | expand

Commit Message

Chaitanya Kulkarni July 1, 2019, 9:57 p.m. UTC
The existing code in the bio_check_ro() relies on the op_is_write().
op_is_write() checks for the last bit in the bio_op(). Now that we have
multiple REQ_OP_XXX with last bit set to 1 such as, (from blk_types.h):

	/* write sectors to the device */
	REQ_OP_WRITE		= 1,
	/* flush the volatile write cache */
	REQ_OP_DISCARD		= 3,
	/* securely erase sectors */
	REQ_OP_SECURE_ERASE	= 5,
	/* write the same sector many times */
	REQ_OP_WRITE_SAME	= 7,
	/* write the zero filled sector many times */
	REQ_OP_WRITE_ZEROES	= 9,

it is hard to understand which bio op failed in the bio_check_ro().

Modify the error message in bio_check_ro() to print correct REQ_OP_XXX
with the help of blk_op_str().

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

Comments

Minwoo Im July 3, 2019, 12:42 a.m. UTC | #1
On 19-07-01 14:57:22, Chaitanya Kulkarni wrote:
> The existing code in the bio_check_ro() relies on the op_is_write().
> op_is_write() checks for the last bit in the bio_op(). Now that we have
> multiple REQ_OP_XXX with last bit set to 1 such as, (from blk_types.h):
> 
> 	/* write sectors to the device */
> 	REQ_OP_WRITE		= 1,
> 	/* flush the volatile write cache */
> 	REQ_OP_DISCARD		= 3,
> 	/* securely erase sectors */
> 	REQ_OP_SECURE_ERASE	= 5,
> 	/* write the same sector many times */
> 	REQ_OP_WRITE_SAME	= 7,
> 	/* write the zero filled sector many times */
> 	REQ_OP_WRITE_ZEROES	= 9,
> 
> it is hard to understand which bio op failed in the bio_check_ro().
> 
> Modify the error message in bio_check_ro() to print correct REQ_OP_XXX
> with the help of blk_op_str().
> 
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>  block/blk-core.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blk-core.c b/block/blk-core.c
> index 5d1fc8e17dd1..47c8b9c48a57 100644
> --- a/block/blk-core.c
> +++ b/block/blk-core.c
> @@ -786,9 +786,9 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
>  			return false;
>  
>  		WARN_ONCE(1,
> -		       "generic_make_request: Trying to write "
> -			"to read-only block-device %s (partno %d)\n",
> -			bio_devname(bio, b), part->partno);
> +			"generic_make_request: Trying op %s on the "
> +			"read-only block-device %s (partno %d)\n",
> +			blk_op_str(op), bio_devname(bio, b), part->partno);

Maybe "s/Trying op %s on/Tyring op %s to" just like the previous one?
Not a native speaker, though ;)

I think it would be better to see the log which holds the exact request
operation type in a string.

Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
Chaitanya Kulkarni July 3, 2019, 2:24 a.m. UTC | #2
On 7/2/19 5:42 PM, Minwoo Im wrote:
> On 19-07-01 14:57:22, Chaitanya Kulkarni wrote:
>> The existing code in the bio_check_ro() relies on the op_is_write().
>> op_is_write() checks for the last bit in the bio_op(). Now that we have
>> multiple REQ_OP_XXX with last bit set to 1 such as, (from blk_types.h):
>>
>> 	/* write sectors to the device */
>> 	REQ_OP_WRITE		= 1,
>> 	/* flush the volatile write cache */
>> 	REQ_OP_DISCARD		= 3,
>> 	/* securely erase sectors */
>> 	REQ_OP_SECURE_ERASE	= 5,
>> 	/* write the same sector many times */
>> 	REQ_OP_WRITE_SAME	= 7,
>> 	/* write the zero filled sector many times */
>> 	REQ_OP_WRITE_ZEROES	= 9,
>>
>> it is hard to understand which bio op failed in the bio_check_ro().
>>
>> Modify the error message in bio_check_ro() to print correct REQ_OP_XXX
>> with the help of blk_op_str().
>>
>> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
>> ---
>>  block/blk-core.c | 6 +++---
>>  1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/block/blk-core.c b/block/blk-core.c
>> index 5d1fc8e17dd1..47c8b9c48a57 100644
>> --- a/block/blk-core.c
>> +++ b/block/blk-core.c
>> @@ -786,9 +786,9 @@ static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
>>  			return false;
>>  
>>  		WARN_ONCE(1,
>> -		       "generic_make_request: Trying to write "
>> -			"to read-only block-device %s (partno %d)\n",
>> -			bio_devname(bio, b), part->partno);
>> +			"generic_make_request: Trying op %s on the "
>> +			"read-only block-device %s (partno %d)\n",
>> +			blk_op_str(op), bio_devname(bio, b), part->partno);
> Maybe "s/Trying op %s on/Tyring op %s to" just like the previous one?
> Not a native speaker, though ;)

Yeah, can be done at the time of applying patch if Jens is okay with it.

Otherwise I'll send V2.

>
> I think it would be better to see the log which holds the exact request
> operation type in a string.
>
> Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
>
diff mbox series

Patch

diff --git a/block/blk-core.c b/block/blk-core.c
index 5d1fc8e17dd1..47c8b9c48a57 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -786,9 +786,9 @@  static inline bool bio_check_ro(struct bio *bio, struct hd_struct *part)
 			return false;
 
 		WARN_ONCE(1,
-		       "generic_make_request: Trying to write "
-			"to read-only block-device %s (partno %d)\n",
-			bio_devname(bio, b), part->partno);
+			"generic_make_request: Trying op %s on the "
+			"read-only block-device %s (partno %d)\n",
+			blk_op_str(op), bio_devname(bio, b), part->partno);
 		/* Older lvm-tools actually trigger this */
 		return false;
 	}