summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-03-23 11:41:53 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2017-03-31 13:57:49 +0200
commit4fb92144c456172090ca2c23744b01b4a4fbe9c7 (patch)
tree13c04a81570f05a15aa2c94ce7270c7904d533c3
parent583acea6669550ffa7ffb465301ddb3529206afc (diff)
downloaddt-utils-4fb92144c456172090ca2c23744b01b4a4fbe9c7.tar.gz
state: bucket: Make output more informative
Print offset and number of the bucket along with the bucket specific messages to give a hint which bucket a message is for. Also it's pretty much expected that buckets sometimes have no data or need cleanup, so instead of complaining loudly, only write which bucket is used and which buckets are cleaned up. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--src/barebox-state/backend_storage.c25
-rw-r--r--src/barebox-state/state.h3
2 files changed, 18 insertions, 10 deletions
diff --git a/src/barebox-state/backend_storage.c b/src/barebox-state/backend_storage.c
index dbc403d..7c9ceaf 100644
--- a/src/barebox-state/backend_storage.c
+++ b/src/barebox-state/backend_storage.c
@@ -90,7 +90,11 @@ refresh:
ret = bucket->write(bucket, buf, len);
if (ret)
- dev_warn(storage->dev, "Failed to restore bucket\n");
+ dev_warn(storage->dev, "Failed to restore bucket %d@0x%08lx\n",
+ bucket->num, bucket->offset);
+ else
+ dev_info(storage->dev, "restored bucket %d@0x%08lx\n",
+ bucket->num, bucket->offset);
return ret;
}
@@ -123,13 +127,10 @@ int state_storage_read(struct state_backend_storage *storage,
*/
list_for_each_entry(bucket, &storage->buckets, bucket_list) {
ret = bucket->read(bucket, &bucket->buf, &bucket->len);
- if (ret == -EUCLEAN) {
+ if (ret == -EUCLEAN)
bucket->needs_refresh = 1;
- } else if (ret) {
- dev_warn(storage->dev, "Failed to read from state backend bucket, trying next, %d\n",
- ret);
+ else if (ret)
continue;
- }
/*
* Verify the buffer crcs. The buffer length is passed in the len argument,
@@ -138,10 +139,6 @@ int state_storage_read(struct state_backend_storage *storage,
ret = format->verify(format, magic, bucket->buf, &bucket->len);
if (!ret && !bucket_used)
bucket_used = bucket;
-
- if (ret)
- dev_warn(storage->dev, "Failed to verify read copy, trying next bucket, %d\n",
- ret);
}
if (!bucket_used) {
@@ -150,6 +147,8 @@ int state_storage_read(struct state_backend_storage *storage,
return -ENOENT;
}
+ dev_info(storage->dev, "Using bucket %d@0x%08lx\n", bucket_used->num, bucket_used->offset);
+
/*
* Restore/refresh all buckets except the one we currently use (in case
* it's the only usable bucket at the moment)
@@ -255,6 +254,9 @@ static int state_storage_mtd_buckets_init(struct state_backend_storage *storage,
continue;
}
+ bucket->offset = offset;
+ bucket->num = nr_copies;
+
list_add_tail(&bucket->bucket_list, &storage->buckets);
++nr_copies;
if (nr_copies >= desired_copies)
@@ -314,6 +316,9 @@ static int state_storage_file_buckets_init(struct state_backend_storage *storage
continue;
}
+ bucket->offset = offset;
+ bucket->num = nr_copies;
+
list_add_tail(&bucket->bucket_list, &storage->buckets);
++nr_copies;
}
diff --git a/src/barebox-state/state.h b/src/barebox-state/state.h
index 62544a2..f6ab200 100644
--- a/src/barebox-state/state.h
+++ b/src/barebox-state/state.h
@@ -26,6 +26,9 @@ struct state_backend_storage_bucket {
void ** buf, ssize_t * len_hint);
void (*free) (struct state_backend_storage_bucket * bucket);
+ int num;
+ off_t offset;
+
struct list_head bucket_list;
void *buf;