All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs: clean up btrfs_dev_stat_inc() usage
@ 2017-10-20  9:50 Anand Jain
  2017-10-20 11:48 ` Nikolay Borisov
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Anand Jain @ 2017-10-20  9:50 UTC (permalink / raw)
  To: linux-btrfs

btrfs_end_bio() is using btrfs_dev_stat_inc() and then
btrfs_dev_stat_print_on_error() separately instead
use btrfs_dev_stat_inc_and_print() directly.

No need to worry about print lines one for read/write
and another if the source of IO request is flush, since
as mentioned in this patch
 [patch] btrfs: REQ_PREFLUSH does not use btrfs_end_bio() completion callback
there isn't any IO which is doing that.

This consolidation is a preparatory patch to add device
critical error handling in btrfs_dev_stat_inc_and_print()
and can be renamed as needed.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index efaf85dd91b0..d1d8aa226bff 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6004,15 +6004,14 @@ static void btrfs_end_bio(struct bio *bio)
 			dev = bbio->stripes[stripe_index].dev;
 			if (dev->bdev) {
 				if (bio_op(bio) == REQ_OP_WRITE)
-					btrfs_dev_stat_inc(dev,
+					btrfs_dev_stat_inc_and_print(dev,
 						BTRFS_DEV_STAT_WRITE_ERRS);
 				else
-					btrfs_dev_stat_inc(dev,
+					btrfs_dev_stat_inc_and_print(dev,
 						BTRFS_DEV_STAT_READ_ERRS);
 				if (bio->bi_opf & REQ_PREFLUSH)
-					btrfs_dev_stat_inc(dev,
+					btrfs_dev_stat_inc_and_print(dev,
 						BTRFS_DEV_STAT_FLUSH_ERRS);
-				btrfs_dev_stat_print_on_error(dev);
 			}
 		}
 	}
-- 
2.13.1


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

* Re: [PATCH] btrfs: clean up btrfs_dev_stat_inc() usage
  2017-10-20  9:50 [PATCH] btrfs: clean up btrfs_dev_stat_inc() usage Anand Jain
@ 2017-10-20 11:48 ` Nikolay Borisov
  2017-10-20 15:27 ` David Sterba
  2017-10-20 17:45 ` [PATCH v2] " Anand Jain
  2 siblings, 0 replies; 6+ messages in thread
From: Nikolay Borisov @ 2017-10-20 11:48 UTC (permalink / raw)
  To: Anand Jain, linux-btrfs



On 20.10.2017 12:50, Anand Jain wrote:
> btrfs_end_bio() is using btrfs_dev_stat_inc() and then
> btrfs_dev_stat_print_on_error() separately instead
> use btrfs_dev_stat_inc_and_print() directly.
> 
> No need to worry about print lines one for read/write
> and another if the source of IO request is flush, since
> as mentioned in this patch
>  [patch] btrfs: REQ_PREFLUSH does not use btrfs_end_bio() completion callback
> there isn't any IO which is doing that.
> 
> This consolidation is a preparatory patch to add device
> critical error handling in btrfs_dev_stat_inc_and_print()
> and can be renamed as needed.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>


Reviewed-by: Nikolay Borisov <nborisov@suse.com>

> ---
>  fs/btrfs/volumes.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index efaf85dd91b0..d1d8aa226bff 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -6004,15 +6004,14 @@ static void btrfs_end_bio(struct bio *bio)
>  			dev = bbio->stripes[stripe_index].dev;
>  			if (dev->bdev) {
>  				if (bio_op(bio) == REQ_OP_WRITE)
> -					btrfs_dev_stat_inc(dev,
> +					btrfs_dev_stat_inc_and_print(dev,
>  						BTRFS_DEV_STAT_WRITE_ERRS);
>  				else
> -					btrfs_dev_stat_inc(dev,
> +					btrfs_dev_stat_inc_and_print(dev,
>  						BTRFS_DEV_STAT_READ_ERRS);
>  				if (bio->bi_opf & REQ_PREFLUSH)
> -					btrfs_dev_stat_inc(dev,
> +					btrfs_dev_stat_inc_and_print(dev,
>  						BTRFS_DEV_STAT_FLUSH_ERRS);
> -				btrfs_dev_stat_print_on_error(dev);
>  			}
>  		}
>  	}
> 

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

* Re: [PATCH] btrfs: clean up btrfs_dev_stat_inc() usage
  2017-10-20  9:50 [PATCH] btrfs: clean up btrfs_dev_stat_inc() usage Anand Jain
  2017-10-20 11:48 ` Nikolay Borisov
@ 2017-10-20 15:27 ` David Sterba
  2017-10-20 17:34   ` Anand Jain
  2017-10-20 17:45 ` [PATCH v2] " Anand Jain
  2 siblings, 1 reply; 6+ messages in thread
From: David Sterba @ 2017-10-20 15:27 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs

On Fri, Oct 20, 2017 at 05:50:59PM +0800, Anand Jain wrote:
> btrfs_end_bio() is using btrfs_dev_stat_inc() and then
> btrfs_dev_stat_print_on_error() separately instead
> use btrfs_dev_stat_inc_and_print() directly.
> 
> No need to worry about print lines one for read/write
> and another if the source of IO request is flush, since
> as mentioned in this patch
>  [patch] btrfs: REQ_PREFLUSH does not use btrfs_end_bio() completion callback

I don't see such patch merged, I've only found
https://patchwork.kernel.org/patch/9619949/
so the remark in the changelog is insufficient to understand what you're
referring to.

This patch itself looks good but the changelog should be improved.

> there isn't any IO which is doing that.
> 
> This consolidation is a preparatory patch to add device
> critical error handling in btrfs_dev_stat_inc_and_print()
> and can be renamed as needed.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  fs/btrfs/volumes.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
> index efaf85dd91b0..d1d8aa226bff 100644
> --- a/fs/btrfs/volumes.c
> +++ b/fs/btrfs/volumes.c
> @@ -6004,15 +6004,14 @@ static void btrfs_end_bio(struct bio *bio)
>  			dev = bbio->stripes[stripe_index].dev;
>  			if (dev->bdev) {
>  				if (bio_op(bio) == REQ_OP_WRITE)
> -					btrfs_dev_stat_inc(dev,
> +					btrfs_dev_stat_inc_and_print(dev,
>  						BTRFS_DEV_STAT_WRITE_ERRS);
>  				else
> -					btrfs_dev_stat_inc(dev,
> +					btrfs_dev_stat_inc_and_print(dev,
>  						BTRFS_DEV_STAT_READ_ERRS);
>  				if (bio->bi_opf & REQ_PREFLUSH)
> -					btrfs_dev_stat_inc(dev,
> +					btrfs_dev_stat_inc_and_print(dev,
>  						BTRFS_DEV_STAT_FLUSH_ERRS);
> -				btrfs_dev_stat_print_on_error(dev);
>  			}
>  		}
>  	}
> -- 
> 2.13.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH] btrfs: clean up btrfs_dev_stat_inc() usage
  2017-10-20 15:27 ` David Sterba
@ 2017-10-20 17:34   ` Anand Jain
  0 siblings, 0 replies; 6+ messages in thread
From: Anand Jain @ 2017-10-20 17:34 UTC (permalink / raw)
  To: dsterba, linux-btrfs



On 10/20/2017 11:27 PM, David Sterba wrote:
> On Fri, Oct 20, 2017 at 05:50:59PM +0800, Anand Jain wrote:
>> btrfs_end_bio() is using btrfs_dev_stat_inc() and then
>> btrfs_dev_stat_print_on_error() separately instead
>> use btrfs_dev_stat_inc_and_print() directly.
>>
>> No need to worry about print lines one for read/write
>> and another if the source of IO request is flush, since
>> as mentioned in this patch
>>   [patch] btrfs: REQ_PREFLUSH does not use btrfs_end_bio() completion callback
> 
> I don't see such patch merged, I've only found
> https://patchwork.kernel.org/patch/9619949/
> so the remark in the changelog is insufficient to understand what you're
> referring to.
> 
> This patch itself looks good but the changelog should be improved.

  Sure will update.

Thanks, Anand


>> there isn't any IO which is doing that.
>>
>> This consolidation is a preparatory patch to add device
>> critical error handling in btrfs_dev_stat_inc_and_print()
>> and can be renamed as needed.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   fs/btrfs/volumes.c | 7 +++----
>>   1 file changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
>> index efaf85dd91b0..d1d8aa226bff 100644
>> --- a/fs/btrfs/volumes.c
>> +++ b/fs/btrfs/volumes.c
>> @@ -6004,15 +6004,14 @@ static void btrfs_end_bio(struct bio *bio)
>>   			dev = bbio->stripes[stripe_index].dev;
>>   			if (dev->bdev) {
>>   				if (bio_op(bio) == REQ_OP_WRITE)
>> -					btrfs_dev_stat_inc(dev,
>> +					btrfs_dev_stat_inc_and_print(dev,
>>   						BTRFS_DEV_STAT_WRITE_ERRS);
>>   				else
>> -					btrfs_dev_stat_inc(dev,
>> +					btrfs_dev_stat_inc_and_print(dev,
>>   						BTRFS_DEV_STAT_READ_ERRS);
>>   				if (bio->bi_opf & REQ_PREFLUSH)

  With reference to the un-merged patch I meant to say it never
  reaches this part since the

>> -					btrfs_dev_stat_inc(dev,
>> +					btrfs_dev_stat_inc_and_print(dev,
>>   						BTRFS_DEV_STAT_FLUSH_ERRS);



>> -				btrfs_dev_stat_print_on_error(dev);
>>   			}
>>   		}
>>   	}
>> -- 
>> 2.13.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH v2] btrfs: clean up btrfs_dev_stat_inc() usage
  2017-10-20  9:50 [PATCH] btrfs: clean up btrfs_dev_stat_inc() usage Anand Jain
  2017-10-20 11:48 ` Nikolay Borisov
  2017-10-20 15:27 ` David Sterba
@ 2017-10-20 17:45 ` Anand Jain
  2017-10-30 12:51   ` David Sterba
  2 siblings, 1 reply; 6+ messages in thread
From: Anand Jain @ 2017-10-20 17:45 UTC (permalink / raw)
  To: linux-btrfs

btrfs_end_bio() is using btrfs_dev_stat_inc() and then
btrfs_dev_stat_print_on_error() separately instead use
btrfs_dev_stat_inc_and_print() directly.

As of now there isn't any bio in btrfs which is - a non-empty write and
also the REQ_PREFLUSH flag is set. So in actual the condition
   if (bio->bi_opf & REQ_PREFLUSH)
is never true in btrfs_end_bio(), and so there won't be any redundant error
log by using btrfs_dev_stat_inc_and_print() separately one for write and
another for flush.

This consolidation will help to add the device critical error handles in the
function btrfs_dev_stat_inc_and_print() and which can be renamed as needed.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index efaf85dd91b0..d1d8aa226bff 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -6004,15 +6004,14 @@ static void btrfs_end_bio(struct bio *bio)
 			dev = bbio->stripes[stripe_index].dev;
 			if (dev->bdev) {
 				if (bio_op(bio) == REQ_OP_WRITE)
-					btrfs_dev_stat_inc(dev,
+					btrfs_dev_stat_inc_and_print(dev,
 						BTRFS_DEV_STAT_WRITE_ERRS);
 				else
-					btrfs_dev_stat_inc(dev,
+					btrfs_dev_stat_inc_and_print(dev,
 						BTRFS_DEV_STAT_READ_ERRS);
 				if (bio->bi_opf & REQ_PREFLUSH)
-					btrfs_dev_stat_inc(dev,
+					btrfs_dev_stat_inc_and_print(dev,
 						BTRFS_DEV_STAT_FLUSH_ERRS);
-				btrfs_dev_stat_print_on_error(dev);
 			}
 		}
 	}
-- 
2.13.1


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

* Re: [PATCH v2] btrfs: clean up btrfs_dev_stat_inc() usage
  2017-10-20 17:45 ` [PATCH v2] " Anand Jain
@ 2017-10-30 12:51   ` David Sterba
  0 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2017-10-30 12:51 UTC (permalink / raw)
  To: Anand Jain; +Cc: linux-btrfs

On Sat, Oct 21, 2017 at 01:45:33AM +0800, Anand Jain wrote:
> btrfs_end_bio() is using btrfs_dev_stat_inc() and then
> btrfs_dev_stat_print_on_error() separately instead use
> btrfs_dev_stat_inc_and_print() directly.
> 
> As of now there isn't any bio in btrfs which is - a non-empty write and
> also the REQ_PREFLUSH flag is set. So in actual the condition
>    if (bio->bi_opf & REQ_PREFLUSH)
> is never true in btrfs_end_bio(), and so there won't be any redundant error
> log by using btrfs_dev_stat_inc_and_print() separately one for write and
> another for flush.
> 
> This consolidation will help to add the device critical error handles in the
> function btrfs_dev_stat_inc_and_print() and which can be renamed as needed.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Reviewed-by: David Sterba <dsterba@suse.com>

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

end of thread, other threads:[~2017-10-30 12:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-20  9:50 [PATCH] btrfs: clean up btrfs_dev_stat_inc() usage Anand Jain
2017-10-20 11:48 ` Nikolay Borisov
2017-10-20 15:27 ` David Sterba
2017-10-20 17:34   ` Anand Jain
2017-10-20 17:45 ` [PATCH v2] " Anand Jain
2017-10-30 12:51   ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.