From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Tue, 27 Feb 2024 15:26:16 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1reyPQ-00AlCG-1b for lore@lore.pengutronix.de; Tue, 27 Feb 2024 15:26:16 +0100 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1reyPP-00046t-Aq; Tue, 27 Feb 2024 15:26:15 +0100 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1reyPM-00040F-OK for oss-tools@pengutronix.de; Tue, 27 Feb 2024 15:26:12 +0100 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1reyPM-003Dbl-9a for oss-tools@pengutronix.de; Tue, 27 Feb 2024 15:26:12 +0100 Received: from mfe by dude02.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1reyPM-00AA2J-0l for oss-tools@pengutronix.de; Tue, 27 Feb 2024 15:26:12 +0100 From: Marco Felsch To: oss-tools@pengutronix.de Date: Tue, 27 Feb 2024 15:26:11 +0100 Message-Id: <20240227142611.2421711-7-m.felsch@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240227142611.2421711-1-m.felsch@pengutronix.de> References: <20240227142611.2421711-1-m.felsch@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [OSS-Tools] [PATCH dt-utils 6/6] state: backend_bucket_direct: add debug prints on read/write X-BeenThere: oss-tools@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: Pengutronix Public Open-Source-Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "OSS-Tools" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: oss-tools-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false This ports barebox commit: | commit 2cc9777631ac22e2f8831727a7463000ba83c80e | Author: Ahmad Fatoum | Date: Fri Jul 28 15:31:58 2023 +0200 | | state: backend_bucket_direct: add debug prints on read/write | | 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 | Reviewed-by: Johannes Zink | Link: https://lore.barebox.org/20230728133158.3828436-1-a.fatoum@pengutronix.de | Signed-off-by: Sascha Hauer Signed-off-by: Marco Felsch --- src/barebox-state/backend_bucket_direct.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/barebox-state/backend_bucket_direct.c b/src/barebox-state/backend_bucket_direct.c index bf060ebed4c0..3e756e21dd41 100644 --- a/src/barebox-state/backend_bucket_direct.c +++ b/src/barebox-state/backend_bucket_direct.c @@ -53,7 +53,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; @@ -73,6 +73,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; @@ -88,12 +90,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); @@ -113,6 +119,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; @@ -130,6 +137,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"); @@ -149,6 +158,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