[PATCH 18/42] state: bucket: Make output more informative

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 common/state/backend_storage.c | 25 +++++++++++++++----------
 common/state/state.h           |  3 +++
 2 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/common/state/backend_storage.c b/common/state/backend_storage.c
index 218c67f2d7..4e0548af85 100644
--- a/common/state/backend_storage.c
+++ b/common/state/backend_storage.c
@@ -89,7 +89,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;
 }
@@ -122,13 +126,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,
@@ -137,10 +138,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) {
@@ -149,6 +146,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)
@@ -254,6 +253,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)
@@ -313,6 +315,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/common/state/state.h b/common/state/state.h
index 62544a207c..f6ab2009cc 100644
--- a/common/state/state.h
+++ b/common/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;
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux