Skip to contentSkip to conversation

state: make first boot with uninitialized legacy state less verbose

PATCH In review Ahmad Fatoum 3 participants 4 messages Nov 29, 2021 – Jan 3, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 state: make first boot with uninitialized legacy state less verbose

With non-legacy state, barebox checks a header for a specific magic signature. This can be all zero on an uninitialized state, so in that particular case, bump down the log message severity.

---
Applies on top of https://lore.barebox.org/barebox/[email protected]/

---
 common/state/backend_bucket_direct.c | 4 ++--
 common/state/backend_storage.c       | 7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)
common/state/backend_bucket_direct.c +2 -2
index 517aec60634b..117cdfb46c9e 100644
@@ -76,9 +76,9 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
 		if (meta.magic != ~0 && !!meta.magic)
 			bucket->wrong_magic = 1;
 		if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
-			dev_err(direct->dev, "No meta data header found\n");
 			dev_dbg(direct->dev, "Enable backward compatibility or increase stride size\n");
-			return -EINVAL;
+			return dev_err_state_init(direct->dev, meta.magic ? -EINVAL : -ENOMEDIUM,
+						  "No meta data header found\n");
 		}
 		read_len = direct->max_size;
 		if (lseek(direct->fd, direct->offset, SEEK_SET) !=
common/state/backend_storage.c +5 -2
index 72f8bcf521ad..c55d22e37f70 100644
@@ -156,10 +156,13 @@ int state_storage_read(struct state_backend_storage *storage,
 		totalbuckets++;
 
 		ret = bucket->read(bucket, &bucket->buf, &bucket->len);
-		if (ret == -EUCLEAN)
+		if (ret == -EUCLEAN) {
 			bucket->needs_refresh = 1;
-		else if (ret)
+		} else if (ret) {
+			if (ret == -ENOMEDIUM)
+				zerobuckets++;
 			continue;
+		}
 
 		/*
 		 * Verify the buffer crcs. The buffer length is passed in the len argument,
Signature · 7 lines
2.33.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw
Quoted 17 lines · Ahmad Fatoum

With non-legacy state, barebox checks a header for a specific magic signature. This can be all zero on an uninitialized state, so in that particular case, bump down the log message severity.

---
Applies on top of https://lore.barebox.org/barebox/[email protected]/

---
 common/state/backend_bucket_direct.c | 4 ++--
 common/state/backend_storage.c       | 7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)
common/state/backend_bucket_direct.c +0 -0
index 517aec60634b..117cdfb46c9e 100644

common/state/backend_bucket_direct.c static int state_backend_bucket_direct_read(struct state_backend_storage_bucket · line 81

Quoted 8 lines
common/state/backend_bucket_direct.c +2 -2
@@ -76,9 +76,9 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
 		if (meta.magic != ~0 && !!meta.magic)
 			bucket->wrong_magic = 1;
 		if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
-			dev_err(direct->dev, "No meta data header found\n");
 			dev_dbg(direct->dev, "Enable backward compatibility or increase stride size\n");
-			return -EINVAL;
+			return dev_err_state_init(direct->dev, meta.magic ? -EINVAL : -ENOMEDIUM,
+						  "No meta data header found\n");

What is dev_err_state_init()? I don't have that in my tree.

Quoted 8 lines
common/state/backend_bucket_direct.c +0 -0
 		}
 		read_len = direct->max_size;
 		if (lseek(direct->fd, direct->offset, SEEK_SET) !=
common/state/backend_storage.c +0 -0
index 72f8bcf521ad..c55d22e37f70 100644

common/state/backend_storage.c int state_storage_read(struct state_backend_storage *storage, · line 163

Quoted 10 lines
common/state/backend_storage.c +4 -2
@@ -156,10 +156,13 @@ int state_storage_read(struct state_backend_storage *storage,
 		totalbuckets++;
 
 		ret = bucket->read(bucket, &bucket->buf, &bucket->len);
-		if (ret == -EUCLEAN)
+		if (ret == -EUCLEAN) {
 			bucket->needs_refresh = 1;
-		else if (ret)
+		} else if (ret) {
+			if (ret == -ENOMEDIUM)
+				zerobuckets++;

This variable also does not exist. Does this patch depend on other patches?

Sascha

Signature · 9 lines
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 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Hello Sascha,

Quoted 8 lines · Sascha Hauer
Quoted 7 lines · Ahmad Fatoum

With non-legacy state, barebox checks a header for a specific magic signature. This can be all zero on an uninitialized state, so in that particular case, bump down the log message severity.

---
Applies on top of https://lore.barebox.org/barebox/[email protected]/

Yes, please see ^ first.

Quoted 31 lines
Quoted 10 lines
---
 common/state/backend_bucket_direct.c | 4 ++--
 common/state/backend_storage.c       | 7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)
common/state/backend_bucket_direct.c +0 -0
index 517aec60634b..117cdfb46c9e 100644

common/state/backend_bucket_direct.c static int state_backend_bucket_direct_read(struct state_backend_storage_bucket · line 81

Quoted 8 lines
common/state/backend_bucket_direct.c +2 -2
@@ -76,9 +76,9 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
 		if (meta.magic != ~0 && !!meta.magic)
 			bucket->wrong_magic = 1;
 		if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
-			dev_err(direct->dev, "No meta data header found\n");
 			dev_dbg(direct->dev, "Enable backward compatibility or increase stride size\n");
-			return -EINVAL;
+			return dev_err_state_init(direct->dev, meta.magic ? -EINVAL : -ENOMEDIUM,
+						  "No meta data header found\n");

What is dev_err_state_init()? I don't have that in my tree.

Quoted 10 lines
common/state/backend_bucket_direct.c +0 -0
 		}
 		read_len = direct->max_size;
 		if (lseek(direct->fd, direct->offset, SEEK_SET) !=
common/state/backend_storage.c +0 -0
index 72f8bcf521ad..c55d22e37f70 100644
@@ -156,10 +156,13 @@ int state_storage_read(struct state_backend_storage *storage,
 		totalbuckets++;
 
Quoted 11 lines

common/state/backend_storage.c int state_storage_read(struct state_backend_storage *storage, · line 163

Quoted 8 lines
common/state/backend_storage.c +4 -2
 		ret = bucket->read(bucket, &bucket->buf, &bucket->len);
-		if (ret == -EUCLEAN)
+		if (ret == -EUCLEAN) {
 			bucket->needs_refresh = 1;
-		else if (ret)
+		} else if (ret) {
+			if (ret == -ENOMEDIUM)
+				zerobuckets++;

This variable also does not exist. Does this patch depend on other patches?

It does. I

Quoted 3 lines

Sascha

Signature · 9 lines
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 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

Hello Sascha,

Quoted 8 lines · Ahmad Fatoum

Hello Sascha,

Quoted 5 lines · Sascha Hauer
Quoted 4 lines · Ahmad Fatoum

With non-legacy state, barebox checks a header for a specific magic signature. This can be all zero on an uninitialized state, so in that particular case, bump down the log message severity.

Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

---
Applies on top of https://lore.barebox.org/barebox/[email protected]/

Yes, please see ^ first.

Is this ok for next?

Cheers,
Ahmad

Quoted 51 lines
Quoted 32 lines
Quoted 11 lines
---
 common/state/backend_bucket_direct.c | 4 ++--
 common/state/backend_storage.c       | 7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)
common/state/backend_bucket_direct.c +0 -0
index 517aec60634b..117cdfb46c9e 100644

common/state/backend_bucket_direct.c static int state_backend_bucket_direct_read(struct state_backend_storage_bucket · line 81

Quoted 8 lines
common/state/backend_bucket_direct.c +2 -2
@@ -76,9 +76,9 @@ static int state_backend_bucket_direct_read(struct state_backend_storage_bucket
 		if (meta.magic != ~0 && !!meta.magic)
 			bucket->wrong_magic = 1;
 		if (!IS_ENABLED(CONFIG_STATE_BACKWARD_COMPATIBLE)) {
-			dev_err(direct->dev, "No meta data header found\n");
 			dev_dbg(direct->dev, "Enable backward compatibility or increase stride size\n");
-			return -EINVAL;
+			return dev_err_state_init(direct->dev, meta.magic ? -EINVAL : -ENOMEDIUM,
+						  "No meta data header found\n");

What is dev_err_state_init()? I don't have that in my tree.

Quoted 10 lines
common/state/backend_bucket_direct.c +0 -0
 		}
 		read_len = direct->max_size;
 		if (lseek(direct->fd, direct->offset, SEEK_SET) !=
common/state/backend_storage.c +0 -0
index 72f8bcf521ad..c55d22e37f70 100644
@@ -156,10 +156,13 @@ int state_storage_read(struct state_backend_storage *storage,
 		totalbuckets++;
 
Quoted 11 lines

common/state/backend_storage.c int state_storage_read(struct state_backend_storage *storage, · line 163

Quoted 8 lines
common/state/backend_storage.c +4 -2
 		ret = bucket->read(bucket, &bucket->buf, &bucket->len);
-		if (ret == -EUCLEAN)
+		if (ret == -EUCLEAN) {
 			bucket->needs_refresh = 1;
-		else if (ret)
+		} else if (ret) {
+			if (ret == -ENOMEDIUM)
+				zerobuckets++;

This variable also does not exist. Does this patch depend on other patches?

It does. I

Quoted 3 lines

Sascha

Signature · 9 lines
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 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox