mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] state: backend_bucket_direct: add debug prints on read/write
@ 2023-07-28 13:31 Ahmad Fatoum
  2023-07-28 14:06 ` Johannes Zink
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2023-07-28 13:31 UTC (permalink / raw)
  To: barebox; +Cc: uol, Ahmad Fatoum

We already have debug prints for the circular backend to help see how
much data is read/written for each bucket. Add similar debugging info
for the direct backend as well. Example with stride size of 2048 and
44 bytes for the variable set:

  barebox@board:/ state -l
  state: Read state from 0 length 68
  state: Read state from 2048 length 68
  state: Read state from 4096 length 68

  barebox@board:/ state -s
  state: Written state to offset 0 length 68 data length 60
  state: Written state to offset 2048 length 68 data length 60
  state: Written state to offset 4096 length 68 data length 60

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/state/backend_bucket_direct.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
index f06e14277862..03c752d6fe41 100644
--- a/common/state/backend_bucket_direct.c
+++ b/common/state/backend_bucket_direct.c
@@ -52,7 +52,7 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
 	struct state_backend_storage_bucket_direct *direct =
 	    get_bucket_direct(bucket);
 	struct state_backend_storage_bucket_direct_meta meta;
-	uint32_t read_len;
+	uint32_t read_len, header_len = 0;
 	void *buf;
 	int ret;
 
@@ -72,6 +72,8 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
 			return -EINVAL;
 
 		}
+
+		header_len = sizeof(meta);
 	} else {
 		if (meta.magic != ~0 && !!meta.magic)
 			bucket->wrong_magic = 1;
@@ -87,12 +89,16 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
 				-errno);
 			return -errno;
 		}
+
 	}
 
 	buf = xmalloc(read_len);
 	if (!buf)
 		return -ENOMEM;
 
+	dev_dbg(direct->dev, "Read state from %lld length %d\n", (long long) direct->offset,
+		header_len + read_len);
+
 	ret = read_full(direct->fd, buf, read_len);
 	if (ret < 0) {
 		dev_err(direct->dev, "Failed to read from file, %d\n", ret);
@@ -112,6 +118,7 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
 {
 	struct state_backend_storage_bucket_direct *direct =
 	    get_bucket_direct(bucket);
+	size_t header_len = 0;
 	int ret;
 	struct state_backend_storage_bucket_direct_meta meta;
 
@@ -129,6 +136,8 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
 			dev_err(direct->dev, "Failed to write metadata to file, %d\n", ret);
 			return ret;
 		}
+
+		header_len = sizeof(meta);
 	} else {
 		if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
 			dev_dbg(direct->dev, "Too small stride size: must skip metadata! Increase stride size\n");
@@ -148,6 +157,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
 		return ret;
 	}
 
+	dev_dbg(direct->dev, "Written state to offset %lld length %zu data length %zu\n",
+		(long long)direct->offset, len + header_len, len);
+
 	return 0;
 }
 
-- 
2.39.2




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

* Re: [PATCH] state: backend_bucket_direct: add debug prints on read/write
  2023-07-28 13:31 [PATCH] state: backend_bucket_direct: add debug prints on read/write Ahmad Fatoum
@ 2023-07-28 14:06 ` Johannes Zink
  2023-07-28 14:08   ` Ahmad Fatoum
  2023-07-31 14:13 ` Sascha Hauer
  2023-07-31 14:14 ` Ahmad Fatoum
  2 siblings, 1 reply; 6+ messages in thread
From: Johannes Zink @ 2023-07-28 14:06 UTC (permalink / raw)
  To: Ahmad Fatoum, barebox; +Cc: uol

Hi Ahmad,

thanks for your patch.

On 7/28/23 15:31, Ahmad Fatoum wrote:
> We already have debug prints for the circular backend to help see how
> much data is read/written for each bucket. Add similar debugging info
> for the direct backend as well. Example with stride size of 2048 and
> 44 bytes for the variable set:
> 
>    barebox@board:/ state -l
>    state: Read state from 0 length 68
>    state: Read state from 2048 length 68
>    state: Read state from 4096 length 68
> 
>    barebox@board:/ state -s
>    state: Written state to offset 0 length 68 data length 60
>    state: Written state to offset 2048 length 68 data length 60
>    state: Written state to offset 4096 length 68 data length 60
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>   common/state/backend_bucket_direct.c | 14 +++++++++++++-
>   1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
> index f06e14277862..03c752d6fe41 100644
> --- a/common/state/backend_bucket_direct.c
> +++ b/common/state/backend_bucket_direct.c
> @@ -52,7 +52,7 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>   	struct state_backend_storage_bucket_direct *direct =
>   	    get_bucket_direct(bucket);
>   	struct state_backend_storage_bucket_direct_meta meta;
> -	uint32_t read_len;
> +	uint32_t read_len, header_len = 0;
>   	void *buf;
>   	int ret;
>   
> @@ -72,6 +72,8 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>   			return -EINVAL;
>   
>   		}
> +
> +		header_len = sizeof(meta);
>   	} else {
>   		if (meta.magic != ~0 && !!meta.magic)
>   			bucket->wrong_magic = 1;
> @@ -87,12 +89,16 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>   				-errno);
>   			return -errno;
>   		}
> +
>   	}
>   
>   	buf = xmalloc(read_len);
>   	if (!buf)
>   		return -ENOMEM;
>   
> +	dev_dbg(direct->dev, "Read state from %lld length %d\n", (long long) direct->offset,
> +		header_len + read_len);
> +

maybe this could use the same message format as for writing (i.e. total length 
and data length pointed out separately)?

Best regards
Johannes

>   	ret = read_full(direct->fd, buf, read_len);
>   	if (ret < 0) {
>   		dev_err(direct->dev, "Failed to read from file, %d\n", ret);
> @@ -112,6 +118,7 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>   {
>   	struct state_backend_storage_bucket_direct *direct =
>   	    get_bucket_direct(bucket);
> +	size_t header_len = 0;
>   	int ret;
>   	struct state_backend_storage_bucket_direct_meta meta;
>   
> @@ -129,6 +136,8 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>   			dev_err(direct->dev, "Failed to write metadata to file, %d\n", ret);
>   			return ret;
>   		}
> +
> +		header_len = sizeof(meta);
>   	} else {
>   		if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
>   			dev_dbg(direct->dev, "Too small stride size: must skip metadata! Increase stride size\n");
> @@ -148,6 +157,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>   		return ret;
>   	}
>   
> +	dev_dbg(direct->dev, "Written state to offset %lld length %zu data length %zu\n",
> +		(long long)direct->offset, len + header_len, len);
> +
>   	return 0;
>   }
>   

-- 
Pengutronix e.K.                | Johannes Zink                  |
Steuerwalder Str. 21            | https://www.pengutronix.de/    |
31137 Hildesheim, Germany       | Phone: +49-5121-206917-0       |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-5555    |




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

* Re: [PATCH] state: backend_bucket_direct: add debug prints on read/write
  2023-07-28 14:06 ` Johannes Zink
@ 2023-07-28 14:08   ` Ahmad Fatoum
  2023-07-28 14:11     ` Johannes Zink
  0 siblings, 1 reply; 6+ messages in thread
From: Ahmad Fatoum @ 2023-07-28 14:08 UTC (permalink / raw)
  To: Johannes Zink, barebox; +Cc: uol

On 28.07.23 16:06, Johannes Zink wrote:
> Hi Ahmad,
> 
> thanks for your patch.
> 
> On 7/28/23 15:31, Ahmad Fatoum wrote:
>> We already have debug prints for the circular backend to help see how
>> much data is read/written for each bucket. Add similar debugging info
>> for the direct backend as well. Example with stride size of 2048 and
>> 44 bytes for the variable set:
>>
>>    barebox@board:/ state -l
>>    state: Read state from 0 length 68
>>    state: Read state from 2048 length 68
>>    state: Read state from 4096 length 68
>>
>>    barebox@board:/ state -s
>>    state: Written state to offset 0 length 68 data length 60
>>    state: Written state to offset 2048 length 68 data length 60
>>    state: Written state to offset 4096 length 68 data length 60
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>>   common/state/backend_bucket_direct.c | 14 +++++++++++++-
>>   1 file changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
>> index f06e14277862..03c752d6fe41 100644
>> --- a/common/state/backend_bucket_direct.c
>> +++ b/common/state/backend_bucket_direct.c
>> @@ -52,7 +52,7 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>>       struct state_backend_storage_bucket_direct *direct =
>>           get_bucket_direct(bucket);
>>       struct state_backend_storage_bucket_direct_meta meta;
>> -    uint32_t read_len;
>> +    uint32_t read_len, header_len = 0;
>>       void *buf;
>>       int ret;
>>   @@ -72,6 +72,8 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>>               return -EINVAL;
>>             }
>> +
>> +        header_len = sizeof(meta);
>>       } else {
>>           if (meta.magic != ~0 && !!meta.magic)
>>               bucket->wrong_magic = 1;
>> @@ -87,12 +89,16 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>>                   -errno);
>>               return -errno;
>>           }
>> +
>>       }
>>         buf = xmalloc(read_len);
>>       if (!buf)
>>           return -ENOMEM;
>>   +    dev_dbg(direct->dev, "Read state from %lld length %d\n", (long long) direct->offset,
>> +        header_len + read_len);
>> +
> 
> maybe this could use the same message format as for writing (i.e. total length and data length pointed out separately)?

I chose it this way for symmetry with the circular backend.

> 
> Best regards
> Johannes
> 
>>       ret = read_full(direct->fd, buf, read_len);
>>       if (ret < 0) {
>>           dev_err(direct->dev, "Failed to read from file, %d\n", ret);
>> @@ -112,6 +118,7 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>>   {
>>       struct state_backend_storage_bucket_direct *direct =
>>           get_bucket_direct(bucket);
>> +    size_t header_len = 0;
>>       int ret;
>>       struct state_backend_storage_bucket_direct_meta meta;
>>   @@ -129,6 +136,8 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>>               dev_err(direct->dev, "Failed to write metadata to file, %d\n", ret);
>>               return ret;
>>           }
>> +
>> +        header_len = sizeof(meta);
>>       } else {
>>           if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
>>               dev_dbg(direct->dev, "Too small stride size: must skip metadata! Increase stride size\n");
>> @@ -148,6 +157,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>>           return ret;
>>       }
>>   +    dev_dbg(direct->dev, "Written state to offset %lld length %zu data length %zu\n",
>> +        (long long)direct->offset, len + header_len, len);
>> +
>>       return 0;
>>   }
>>   
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

* Re: [PATCH] state: backend_bucket_direct: add debug prints on read/write
  2023-07-28 14:08   ` Ahmad Fatoum
@ 2023-07-28 14:11     ` Johannes Zink
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Zink @ 2023-07-28 14:11 UTC (permalink / raw)
  To: Ahmad Fatoum, barebox; +Cc: uol

On 7/28/23 16:08, Ahmad Fatoum wrote:
> On 28.07.23 16:06, Johannes Zink wrote:
>> Hi Ahmad,
>>
>> thanks for your patch.
>>
>> On 7/28/23 15:31, Ahmad Fatoum wrote:
>>> We already have debug prints for the circular backend to help see how
>>> much data is read/written for each bucket. Add similar debugging info
>>> for the direct backend as well. Example with stride size of 2048 and
>>> 44 bytes for the variable set:
>>>
>>>     barebox@board:/ state -l
>>>     state: Read state from 0 length 68
>>>     state: Read state from 2048 length 68
>>>     state: Read state from 4096 length 68
>>>
>>>     barebox@board:/ state -s
>>>     state: Written state to offset 0 length 68 data length 60
>>>     state: Written state to offset 2048 length 68 data length 60
>>>     state: Written state to offset 4096 length 68 data length 60
>>>
>>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>>> ---
>>>    common/state/backend_bucket_direct.c | 14 +++++++++++++-
>>>    1 file changed, 13 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
>>> index f06e14277862..03c752d6fe41 100644
>>> --- a/common/state/backend_bucket_direct.c
>>> +++ b/common/state/backend_bucket_direct.c
>>> @@ -52,7 +52,7 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>>>        struct state_backend_storage_bucket_direct *direct =
>>>            get_bucket_direct(bucket);
>>>        struct state_backend_storage_bucket_direct_meta meta;
>>> -    uint32_t read_len;
>>> +    uint32_t read_len, header_len = 0;
>>>        void *buf;
>>>        int ret;
>>>    @@ -72,6 +72,8 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>>>                return -EINVAL;
>>>              }
>>> +
>>> +        header_len = sizeof(meta);
>>>        } else {
>>>            if (meta.magic != ~0 && !!meta.magic)
>>>                bucket->wrong_magic = 1;
>>> @@ -87,12 +89,16 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>>>                    -errno);
>>>                return -errno;
>>>            }
>>> +
>>>        }
>>>          buf = xmalloc(read_len);
>>>        if (!buf)
>>>            return -ENOMEM;
>>>    +    dev_dbg(direct->dev, "Read state from %lld length %d\n", (long long) direct->offset,
>>> +        header_len + read_len);
>>> +
>>
>> maybe this could use the same message format as for writing (i.e. total length and data length pointed out separately)?
> 
> I chose it this way for symmetry with the circular backend.

Fair point, add my

Reviewed-by: Johannes Zink <j.zink@pengutronix.de>

Best regards
Johannes

> 
>>
>> Best regards
>> Johannes
>>
>>>        ret = read_full(direct->fd, buf, read_len);
>>>        if (ret < 0) {
>>>            dev_err(direct->dev, "Failed to read from file, %d\n", ret);
>>> @@ -112,6 +118,7 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>>>    {
>>>        struct state_backend_storage_bucket_direct *direct =
>>>            get_bucket_direct(bucket);
>>> +    size_t header_len = 0;
>>>        int ret;
>>>        struct state_backend_storage_bucket_direct_meta meta;
>>>    @@ -129,6 +136,8 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>>>                dev_err(direct->dev, "Failed to write metadata to file, %d\n", ret);
>>>                return ret;
>>>            }
>>> +
>>> +        header_len = sizeof(meta);
>>>        } else {
>>>            if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
>>>                dev_dbg(direct->dev, "Too small stride size: must skip metadata! Increase stride size\n");
>>> @@ -148,6 +157,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>>>            return ret;
>>>        }
>>>    +    dev_dbg(direct->dev, "Written state to offset %lld length %zu data length %zu\n",
>>> +        (long long)direct->offset, len + header_len, len);
>>> +
>>>        return 0;
>>>    }
>>>    
>>
> 

-- 
Pengutronix e.K.                | Johannes Zink                  |
Steuerwalder Str. 21            | https://www.pengutronix.de/    |
31137 Hildesheim, Germany       | Phone: +49-5121-206917-0       |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-5555    |




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

* Re: [PATCH] state: backend_bucket_direct: add debug prints on read/write
  2023-07-28 13:31 [PATCH] state: backend_bucket_direct: add debug prints on read/write Ahmad Fatoum
  2023-07-28 14:06 ` Johannes Zink
@ 2023-07-31 14:13 ` Sascha Hauer
  2023-07-31 14:14 ` Ahmad Fatoum
  2 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2023-07-31 14:13 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox, uol

On Fri, Jul 28, 2023 at 03:31:58PM +0200, Ahmad Fatoum wrote:
> We already have debug prints for the circular backend to help see how
> much data is read/written for each bucket. Add similar debugging info
> for the direct backend as well. Example with stride size of 2048 and
> 44 bytes for the variable set:
> 
>   barebox@board:/ state -l
>   state: Read state from 0 length 68
>   state: Read state from 2048 length 68
>   state: Read state from 4096 length 68
> 
>   barebox@board:/ state -s
>   state: Written state to offset 0 length 68 data length 60
>   state: Written state to offset 2048 length 68 data length 60
>   state: Written state to offset 4096 length 68 data length 60
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  common/state/backend_bucket_direct.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
> index f06e14277862..03c752d6fe41 100644
> --- a/common/state/backend_bucket_direct.c
> +++ b/common/state/backend_bucket_direct.c
> @@ -52,7 +52,7 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>  	struct state_backend_storage_bucket_direct *direct =
>  	    get_bucket_direct(bucket);
>  	struct state_backend_storage_bucket_direct_meta meta;
> -	uint32_t read_len;
> +	uint32_t read_len, header_len = 0;
>  	void *buf;
>  	int ret;
>  
> @@ -72,6 +72,8 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>  			return -EINVAL;
>  
>  		}
> +
> +		header_len = sizeof(meta);
>  	} else {
>  		if (meta.magic != ~0 && !!meta.magic)
>  			bucket->wrong_magic = 1;
> @@ -87,12 +89,16 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>  				-errno);
>  			return -errno;
>  		}
> +
>  	}
>  
>  	buf = xmalloc(read_len);
>  	if (!buf)
>  		return -ENOMEM;
>  
> +	dev_dbg(direct->dev, "Read state from %lld length %d\n", (long long) direct->offset,
> +		header_len + read_len);
> +
>  	ret = read_full(direct->fd, buf, read_len);
>  	if (ret < 0) {
>  		dev_err(direct->dev, "Failed to read from file, %d\n", ret);
> @@ -112,6 +118,7 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>  {
>  	struct state_backend_storage_bucket_direct *direct =
>  	    get_bucket_direct(bucket);
> +	size_t header_len = 0;
>  	int ret;
>  	struct state_backend_storage_bucket_direct_meta meta;
>  
> @@ -129,6 +136,8 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>  			dev_err(direct->dev, "Failed to write metadata to file, %d\n", ret);
>  			return ret;
>  		}
> +
> +		header_len = sizeof(meta);
>  	} else {
>  		if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
>  			dev_dbg(direct->dev, "Too small stride size: must skip metadata! Increase stride size\n");
> @@ -148,6 +157,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>  		return ret;
>  	}
>  
> +	dev_dbg(direct->dev, "Written state to offset %lld length %zu data length %zu\n",
> +		(long long)direct->offset, len + header_len, len);
> +
>  	return 0;
>  }
>  
> -- 
> 2.39.2
> 
> 
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH] state: backend_bucket_direct: add debug prints on read/write
  2023-07-28 13:31 [PATCH] state: backend_bucket_direct: add debug prints on read/write Ahmad Fatoum
  2023-07-28 14:06 ` Johannes Zink
  2023-07-31 14:13 ` Sascha Hauer
@ 2023-07-31 14:14 ` Ahmad Fatoum
  2 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2023-07-31 14:14 UTC (permalink / raw)
  To: barebox; +Cc: uol

On 28.07.23 15:31, Ahmad Fatoum wrote:
> We already have debug prints for the circular backend to help see how
> much data is read/written for each bucket. Add similar debugging info
> for the direct backend as well. Example with stride size of 2048 and
> 44 bytes for the variable set:
> 
>   barebox@board:/ state -l
>   state: Read state from 0 length 68
>   state: Read state from 2048 length 68
>   state: Read state from 4096 length 68
> 
>   barebox@board:/ state -s
>   state: Written state to offset 0 length 68 data length 60
>   state: Written state to offset 2048 length 68 data length 60
>   state: Written state to offset 4096 length 68 data length 60
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  common/state/backend_bucket_direct.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/common/state/backend_bucket_direct.c b/common/state/backend_bucket_direct.c
> index f06e14277862..03c752d6fe41 100644
> --- a/common/state/backend_bucket_direct.c
> +++ b/common/state/backend_bucket_direct.c
> @@ -52,7 +52,7 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>  	struct state_backend_storage_bucket_direct *direct =
>  	    get_bucket_direct(bucket);
>  	struct state_backend_storage_bucket_direct_meta meta;
> -	uint32_t read_len;
> +	uint32_t read_len, header_len = 0;
>  	void *buf;
>  	int ret;
>  
> @@ -72,6 +72,8 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>  			return -EINVAL;
>  
>  		}
> +
> +		header_len = sizeof(meta);
>  	} else {
>  		if (meta.magic != ~0 && !!meta.magic)
>  			bucket->wrong_magic = 1;
> @@ -87,12 +89,16 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
>  				-errno);
>  			return -errno;
>  		}
> +

Oops. Stray new line.

>  	}
>  
>  	buf = xmalloc(read_len);
>  	if (!buf)
>  		return -ENOMEM;
>  
> +	dev_dbg(direct->dev, "Read state from %lld length %d\n", (long long) direct->offset,
> +		header_len + read_len);
> +
>  	ret = read_full(direct->fd, buf, read_len);
>  	if (ret < 0) {
>  		dev_err(direct->dev, "Failed to read from file, %d\n", ret);
> @@ -112,6 +118,7 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>  {
>  	struct state_backend_storage_bucket_direct *direct =
>  	    get_bucket_direct(bucket);
> +	size_t header_len = 0;
>  	int ret;
>  	struct state_backend_storage_bucket_direct_meta meta;
>  
> @@ -129,6 +136,8 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>  			dev_err(direct->dev, "Failed to write metadata to file, %d\n", ret);
>  			return ret;
>  		}
> +
> +		header_len = sizeof(meta);
>  	} else {
>  		if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
>  			dev_dbg(direct->dev, "Too small stride size: must skip metadata! Increase stride size\n");
> @@ -148,6 +157,9 @@ static int state_backend_bucket_direct_write(struct state_backend_storage_bucket
>  		return ret;
>  	}
>  
> +	dev_dbg(direct->dev, "Written state to offset %lld length %zu data length %zu\n",
> +		(long long)direct->offset, len + header_len, len);
> +
>  	return 0;
>  }
>  

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




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

end of thread, other threads:[~2023-07-31 14:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28 13:31 [PATCH] state: backend_bucket_direct: add debug prints on read/write Ahmad Fatoum
2023-07-28 14:06 ` Johannes Zink
2023-07-28 14:08   ` Ahmad Fatoum
2023-07-28 14:11     ` Johannes Zink
2023-07-31 14:13 ` Sascha Hauer
2023-07-31 14:14 ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox