linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nvmet: fix data units read and written counters in SMART log
@ 2019-08-05  1:57 Tom Wu
       [not found] ` <CGME20190805015817epcas5p2617320fe4cae019ab373710395ca43ed@epcms2p2>
  2019-08-05 18:24 ` Sagi Grimberg
  0 siblings, 2 replies; 8+ messages in thread
From: Tom Wu @ 2019-08-05  1:57 UTC (permalink / raw)


In nvme spec 1.3 there is a definition for data write/read counters
from SMART log. (See section 5.14.1.2):
	This value is reported in thousands (i.e., a value of 1
	corresponds to 1000 units of 512 bytes read) and is rounded up.

However, in nvme target where value is reported with actual units,
but not thousands of units as the spec requires.

Signed-off-by: Tom Wu <tomwu at mellanox.com>
Reviewed-by: Israel Rukshin <israelr at mellanox.com>
Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
---
 drivers/nvme/target/admin-cmd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 9f72d51..acbadbe 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -85,6 +85,9 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
 	host_writes = part_stat_read(ns->bdev->bd_part, ios[WRITE]);
 	data_units_written = part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
 
+	data_units_read = DIV_ROUND_UP(data_units_read, 1000);
+	data_units_written = DIV_ROUND_UP(data_units_written, 1000);
+
 	put_unaligned_le64(host_reads, &slog->host_reads[0]);
 	put_unaligned_le64(data_units_read, &slog->data_units_read[0]);
 	put_unaligned_le64(host_writes, &slog->host_writes[0]);
@@ -120,6 +123,9 @@ static u16 nvmet_get_smart_log_all(struct nvmet_req *req,
 	}
 	rcu_read_unlock();
 
+	data_units_read = DIV_ROUND_UP(data_units_read, 1000);
+	data_units_written = DIV_ROUND_UP(data_units_written, 1000);
+
 	put_unaligned_le64(host_reads, &slog->host_reads[0]);
 	put_unaligned_le64(data_units_read, &slog->data_units_read[0]);
 	put_unaligned_le64(host_writes, &slog->host_writes[0]);
-- 
1.8.4.3

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

* [PATCH] nvmet: fix data units read and written counters in SMART log
       [not found] ` <CGME20190805015817epcas5p2617320fe4cae019ab373710395ca43ed@epcms2p2>
@ 2019-08-05  2:38   ` Minwoo Im
  0 siblings, 0 replies; 8+ messages in thread
From: Minwoo Im @ 2019-08-05  2:38 UTC (permalink / raw)


> -----Original Message-----
> From: Linux-nvme <linux-nvme-bounces at lists.infradead.org> On Behalf Of Tom Wu
> Sent: Monday, August 5, 2019 10:58 AM
> To: Linux-nvme <linux-nvme at lists.infradead.org>; keith.busch at intel.com;
> hch at lst.de; sagi at grimberg.me
> Cc: Shlomi Nimrodi <shlomin at mellanox.com>; Max Gurtovoy
> <maxg at mellanox.com>; Tom Wu <tomwu at mellanox.com>; Israel Rukshin
> <israelr at mellanox.com>
> Subject: [PATCH] nvmet: fix data units read and written counters in SMART log
> 
> In nvme spec 1.3 there is a definition for data write/read counters
> from SMART log. (See section 5.14.1.2):
> 	This value is reported in thousands (i.e., a value of 1
> 	corresponds to 1000 units of 512 bytes read) and is rounded up.
> 
> However, in nvme target where value is reported with actual units,
> but not thousands of units as the spec requires.
> 
> Signed-off-by: Tom Wu <tomwu at mellanox.com>
> Reviewed-by: Israel Rukshin <israelr at mellanox.com>
> Reviewed-by: Max Gurtovoy <maxg at mellanox.com>

Reviewed-by: Minwoo Im <minwoo.im at samsung.com>

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

* [PATCH] nvmet: fix data units read and written counters in SMART log
  2019-08-05  1:57 [PATCH] nvmet: fix data units read and written counters in SMART log Tom Wu
       [not found] ` <CGME20190805015817epcas5p2617320fe4cae019ab373710395ca43ed@epcms2p2>
@ 2019-08-05 18:24 ` Sagi Grimberg
  2019-08-06 10:49   ` Tom Wu
  1 sibling, 1 reply; 8+ messages in thread
From: Sagi Grimberg @ 2019-08-05 18:24 UTC (permalink / raw)



> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index 9f72d51..acbadbe 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -85,6 +85,9 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
>   	host_writes = part_stat_read(ns->bdev->bd_part, ios[WRITE]);
>   	data_units_written = part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
>   
> +	data_units_read = DIV_ROUND_UP(data_units_read, 1000);
> +	data_units_written = DIV_ROUND_UP(data_units_written, 1000);
> +

How about either modifying the actual retrieval or move the fixups right 
next to the initial setting...

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

* [PATCH] nvmet: fix data units read and written counters in SMART log
  2019-08-05 18:24 ` Sagi Grimberg
@ 2019-08-06 10:49   ` Tom Wu
  2019-08-07 20:54     ` Sagi Grimberg
  0 siblings, 1 reply; 8+ messages in thread
From: Tom Wu @ 2019-08-06 10:49 UTC (permalink / raw)


Hi, Sagi

when you say I can 'modifying the actual retrieval', you are try to 
suggest that I can do the changes as below, right?

--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -81,9 +81,11 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req 
*req,
 ??????????????? goto out;

 ??????? host_reads = part_stat_read(ns->bdev->bd_part, ios[READ]);
-?????? data_units_read = part_stat_read(ns->bdev->bd_part, sectors[READ]);
+?????? data_units_read = DIV_ROUND_UP(part_stat_read(ns->bdev->bd_part,
+?????????????? sectors[READ]), 1000);
 ??????? host_writes = part_stat_read(ns->bdev->bd_part, ios[WRITE]);
-?????? data_units_written = part_stat_read(ns->bdev->bd_part, 
sectors[WRITE]);
+?????? data_units_written = DIV_ROUND_UP(part_stat_read(ns->bdev->bd_part,
+?????????????? sectors[WRITE]), 1000);

 ??????? put_unaligned_le64(host_reads, &slog->host_reads[0]);
 ??????? put_unaligned_le64(data_units_read, &slog->data_units_read[0]);
@@ -112,10 +114,10 @@ static u16 nvmet_get_smart_log_all(struct 
nvmet_req *req,
 ??????????????????????? continue;
 ??????????????? host_reads += part_stat_read(ns->bdev->bd_part, ios[READ]);
 ??????????????? data_units_read +=
-?????????????????????? part_stat_read(ns->bdev->bd_part, sectors[READ]);
+ DIV_ROUND_UP(part_stat_read(ns->bdev->bd_part, sectors[READ]), 1000);
 ??????????????? host_writes += part_stat_read(ns->bdev->bd_part, 
ios[WRITE]);
 ??????????????? data_units_written +=
-?????????????????????? part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
+ DIV_ROUND_UP(part_stat_read(ns->bdev->bd_part, sectors[WRITE]), 1000);

 ??????? }

On 8/6/2019 2:24 AM, Sagi Grimberg wrote:
>
>> diff --git a/drivers/nvme/target/admin-cmd.c 
>> b/drivers/nvme/target/admin-cmd.c
>> index 9f72d51..acbadbe 100644
>> --- a/drivers/nvme/target/admin-cmd.c
>> +++ b/drivers/nvme/target/admin-cmd.c
>> @@ -85,6 +85,9 @@ static u16 nvmet_get_smart_log_nsid(struct 
>> nvmet_req *req,
>> ????? host_writes = part_stat_read(ns->bdev->bd_part, ios[WRITE]);
>> ????? data_units_written = part_stat_read(ns->bdev->bd_part, 
>> sectors[WRITE]);
>> ? +??? data_units_read = DIV_ROUND_UP(data_units_read, 1000);
>> +??? data_units_written = DIV_ROUND_UP(data_units_written, 1000);
>> +
>
> How about either modifying the actual retrieval or move the fixups 
> right next to the initial setting...

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

* [PATCH] nvmet: fix data units read and written counters in SMART log
  2019-08-06 10:49   ` Tom Wu
@ 2019-08-07 20:54     ` Sagi Grimberg
  0 siblings, 0 replies; 8+ messages in thread
From: Sagi Grimberg @ 2019-08-07 20:54 UTC (permalink / raw)



> Hi, Sagi
> 
> when you say I can 'modifying the actual retrieval', you are try to
> suggest that I can do the changes as below, right?

Yes.

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

* [PATCH] nvmet: fix data units read and written counters in SMART log
  2019-08-08  2:22 Tom Wu
  2019-08-08  3:47 ` Chaitanya Kulkarni
@ 2019-08-08 23:53 ` Sagi Grimberg
  1 sibling, 0 replies; 8+ messages in thread
From: Sagi Grimberg @ 2019-08-08 23:53 UTC (permalink / raw)


Thanks, pulled to nvme-5.4

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

* [PATCH] nvmet: fix data units read and written counters in SMART log
  2019-08-08  2:22 Tom Wu
@ 2019-08-08  3:47 ` Chaitanya Kulkarni
  2019-08-08 23:53 ` Sagi Grimberg
  1 sibling, 0 replies; 8+ messages in thread
From: Chaitanya Kulkarni @ 2019-08-08  3:47 UTC (permalink / raw)


Looks good to me.

Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
On 8/7/19 7:23 PM, Tom Wu wrote:
> In nvme spec 1.3 there is a definition for data write/read counters
> from SMART log, (See section 5.14.1.2):
> 	This value is reported in thousands (i.e., a value of 1
> 	corresponds to 1000 units of 512 bytes read) and is rounded up.
>
> However, in nvme target where value is reported with actual units,
> but not thousands of units as the spec requires.
>
> Signed-off-by: Tom Wu <tomwu at mellanox.com>
> Reviewed-by: Israel Rukshin <israelr at mellanox.com>
> Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
> ---
>  drivers/nvme/target/admin-cmd.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index 9f72d51..4099093 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -81,9 +81,11 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
>  		goto out;
>  
>  	host_reads = part_stat_read(ns->bdev->bd_part, ios[READ]);
> -	data_units_read = part_stat_read(ns->bdev->bd_part, sectors[READ]);
> +	data_units_read = DIV_ROUND_UP(part_stat_read(ns->bdev->bd_part,
> +		sectors[READ]), 1000);
>  	host_writes = part_stat_read(ns->bdev->bd_part, ios[WRITE]);
> -	data_units_written = part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
> +	data_units_written = DIV_ROUND_UP(part_stat_read(ns->bdev->bd_part,
> +		sectors[WRITE]), 1000);
>  
>  	put_unaligned_le64(host_reads, &slog->host_reads[0]);
>  	put_unaligned_le64(data_units_read, &slog->data_units_read[0]);
> @@ -111,11 +113,11 @@ static u16 nvmet_get_smart_log_all(struct nvmet_req *req,
>  		if (!ns->bdev)
>  			continue;
>  		host_reads += part_stat_read(ns->bdev->bd_part, ios[READ]);
> -		data_units_read +=
> -			part_stat_read(ns->bdev->bd_part, sectors[READ]);
> +		data_units_read += DIV_ROUND_UP(
> +			part_stat_read(ns->bdev->bd_part, sectors[READ]), 1000);
>  		host_writes += part_stat_read(ns->bdev->bd_part, ios[WRITE]);
> -		data_units_written +=
> -			part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
> +		data_units_written += DIV_ROUND_UP(
> +			part_stat_read(ns->bdev->bd_part, sectors[WRITE]), 1000);
>  
>  	}
>  	rcu_read_unlock();

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

* [PATCH] nvmet: fix data units read and written counters in SMART log
@ 2019-08-08  2:22 Tom Wu
  2019-08-08  3:47 ` Chaitanya Kulkarni
  2019-08-08 23:53 ` Sagi Grimberg
  0 siblings, 2 replies; 8+ messages in thread
From: Tom Wu @ 2019-08-08  2:22 UTC (permalink / raw)


In nvme spec 1.3 there is a definition for data write/read counters
from SMART log, (See section 5.14.1.2):
	This value is reported in thousands (i.e., a value of 1
	corresponds to 1000 units of 512 bytes read) and is rounded up.

However, in nvme target where value is reported with actual units,
but not thousands of units as the spec requires.

Signed-off-by: Tom Wu <tomwu at mellanox.com>
Reviewed-by: Israel Rukshin <israelr at mellanox.com>
Reviewed-by: Max Gurtovoy <maxg at mellanox.com>
---
 drivers/nvme/target/admin-cmd.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
index 9f72d51..4099093 100644
--- a/drivers/nvme/target/admin-cmd.c
+++ b/drivers/nvme/target/admin-cmd.c
@@ -81,9 +81,11 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
 		goto out;
 
 	host_reads = part_stat_read(ns->bdev->bd_part, ios[READ]);
-	data_units_read = part_stat_read(ns->bdev->bd_part, sectors[READ]);
+	data_units_read = DIV_ROUND_UP(part_stat_read(ns->bdev->bd_part,
+		sectors[READ]), 1000);
 	host_writes = part_stat_read(ns->bdev->bd_part, ios[WRITE]);
-	data_units_written = part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
+	data_units_written = DIV_ROUND_UP(part_stat_read(ns->bdev->bd_part,
+		sectors[WRITE]), 1000);
 
 	put_unaligned_le64(host_reads, &slog->host_reads[0]);
 	put_unaligned_le64(data_units_read, &slog->data_units_read[0]);
@@ -111,11 +113,11 @@ static u16 nvmet_get_smart_log_all(struct nvmet_req *req,
 		if (!ns->bdev)
 			continue;
 		host_reads += part_stat_read(ns->bdev->bd_part, ios[READ]);
-		data_units_read +=
-			part_stat_read(ns->bdev->bd_part, sectors[READ]);
+		data_units_read += DIV_ROUND_UP(
+			part_stat_read(ns->bdev->bd_part, sectors[READ]), 1000);
 		host_writes += part_stat_read(ns->bdev->bd_part, ios[WRITE]);
-		data_units_written +=
-			part_stat_read(ns->bdev->bd_part, sectors[WRITE]);
+		data_units_written += DIV_ROUND_UP(
+			part_stat_read(ns->bdev->bd_part, sectors[WRITE]), 1000);
 
 	}
 	rcu_read_unlock();
-- 
1.8.4.3

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

end of thread, other threads:[~2019-08-08 23:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05  1:57 [PATCH] nvmet: fix data units read and written counters in SMART log Tom Wu
     [not found] ` <CGME20190805015817epcas5p2617320fe4cae019ab373710395ca43ed@epcms2p2>
2019-08-05  2:38   ` Minwoo Im
2019-08-05 18:24 ` Sagi Grimberg
2019-08-06 10:49   ` Tom Wu
2019-08-07 20:54     ` Sagi Grimberg
2019-08-08  2:22 Tom Wu
2019-08-08  3:47 ` Chaitanya Kulkarni
2019-08-08 23:53 ` Sagi Grimberg

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).