From: Christoph Hellwig <hch@lst.de>
To: Carlos Maiolino <cem@kernel.org>
Cc: linux-xfs@vger.kernel.org, "Darrick J. Wong" <djwong@kernel.org>
Subject: [PATCH 1/9] xfs: add a XLOG_CYCLE_DATA_SIZE constant
Date: Mon, 27 Oct 2025 08:05:48 +0100 [thread overview]
Message-ID: <20251027070610.729960-2-hch@lst.de> (raw)
In-Reply-To: <20251027070610.729960-1-hch@lst.de>
The XLOG_HEADER_CYCLE_SIZE / BBSIZE expression is used a lot
in the log code, give it a symbolic name.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
---
fs/xfs/libxfs/xfs_log_format.h | 5 +++--
fs/xfs/xfs_log.c | 18 +++++++++---------
fs/xfs/xfs_log_recover.c | 6 +++---
3 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index 6c50cb2ece19..91a841ea5bb3 100644
--- a/fs/xfs/libxfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
@@ -31,6 +31,7 @@ typedef uint32_t xlog_tid_t;
#define XLOG_BIG_RECORD_BSIZE (32*1024) /* 32k buffers */
#define XLOG_MAX_RECORD_BSIZE (256*1024)
#define XLOG_HEADER_CYCLE_SIZE (32*1024) /* cycle data in header */
+#define XLOG_CYCLE_DATA_SIZE (XLOG_HEADER_CYCLE_SIZE / BBSIZE)
#define XLOG_MIN_RECORD_BSHIFT 14 /* 16384 == 1 << 14 */
#define XLOG_BIG_RECORD_BSHIFT 15 /* 32k == 1 << 15 */
#define XLOG_MAX_RECORD_BSHIFT 18 /* 256k == 1 << 18 */
@@ -135,7 +136,7 @@ typedef struct xlog_rec_header {
__le32 h_crc; /* crc of log record : 4 */
__be32 h_prev_block; /* block number to previous LR : 4 */
__be32 h_num_logops; /* number of log operations in this LR : 4 */
- __be32 h_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE];
+ __be32 h_cycle_data[XLOG_CYCLE_DATA_SIZE];
/* fields added by the Linux port: */
__be32 h_fmt; /* format of log record : 4 */
@@ -172,7 +173,7 @@ typedef struct xlog_rec_header {
typedef struct xlog_rec_ext_header {
__be32 xh_cycle; /* write cycle of log : 4 */
- __be32 xh_cycle_data[XLOG_HEADER_CYCLE_SIZE / BBSIZE]; /* : 256 */
+ __be32 xh_cycle_data[XLOG_CYCLE_DATA_SIZE]; /* : 256 */
} xlog_rec_ext_header_t;
/*
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 603e85c1ab4c..e09e5f71ed8c 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1533,7 +1533,7 @@ xlog_pack_data(
dp = iclog->ic_datap;
for (i = 0; i < BTOBB(size); i++) {
- if (i >= (XLOG_HEADER_CYCLE_SIZE / BBSIZE))
+ if (i >= XLOG_CYCLE_DATA_SIZE)
break;
iclog->ic_header.h_cycle_data[i] = *(__be32 *)dp;
*(__be32 *)dp = cycle_lsn;
@@ -1544,8 +1544,8 @@ xlog_pack_data(
xlog_in_core_2_t *xhdr = iclog->ic_data;
for ( ; i < BTOBB(size); i++) {
- j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
- k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
+ j = i / XLOG_CYCLE_DATA_SIZE;
+ k = i % XLOG_CYCLE_DATA_SIZE;
xhdr[j].hic_xheader.xh_cycle_data[k] = *(__be32 *)dp;
*(__be32 *)dp = cycle_lsn;
dp += BBSIZE;
@@ -3368,9 +3368,9 @@ xlog_verify_iclog(
clientid = ophead->oh_clientid;
} else {
idx = BTOBBT((void *)&ophead->oh_clientid - iclog->ic_datap);
- if (idx >= (XLOG_HEADER_CYCLE_SIZE / BBSIZE)) {
- j = idx / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
- k = idx % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
+ if (idx >= XLOG_CYCLE_DATA_SIZE) {
+ j = idx / XLOG_CYCLE_DATA_SIZE;
+ k = idx % XLOG_CYCLE_DATA_SIZE;
clientid = xlog_get_client_id(
xhdr[j].hic_xheader.xh_cycle_data[k]);
} else {
@@ -3392,9 +3392,9 @@ xlog_verify_iclog(
op_len = be32_to_cpu(ophead->oh_len);
} else {
idx = BTOBBT((void *)&ophead->oh_len - iclog->ic_datap);
- if (idx >= (XLOG_HEADER_CYCLE_SIZE / BBSIZE)) {
- j = idx / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
- k = idx % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
+ if (idx >= XLOG_CYCLE_DATA_SIZE) {
+ j = idx / XLOG_CYCLE_DATA_SIZE;
+ k = idx % XLOG_CYCLE_DATA_SIZE;
op_len = be32_to_cpu(xhdr[j].hic_xheader.xh_cycle_data[k]);
} else {
op_len = be32_to_cpu(iclog->ic_header.h_cycle_data[idx]);
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 549d60959aee..bb2b3f976deb 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2866,7 +2866,7 @@ xlog_unpack_data(
int i, j, k;
for (i = 0; i < BTOBB(be32_to_cpu(rhead->h_len)) &&
- i < (XLOG_HEADER_CYCLE_SIZE / BBSIZE); i++) {
+ i < XLOG_CYCLE_DATA_SIZE; i++) {
*(__be32 *)dp = *(__be32 *)&rhead->h_cycle_data[i];
dp += BBSIZE;
}
@@ -2874,8 +2874,8 @@ xlog_unpack_data(
if (xfs_has_logv2(log->l_mp)) {
xlog_in_core_2_t *xhdr = (xlog_in_core_2_t *)rhead;
for ( ; i < BTOBB(be32_to_cpu(rhead->h_len)); i++) {
- j = i / (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
- k = i % (XLOG_HEADER_CYCLE_SIZE / BBSIZE);
+ j = i / XLOG_CYCLE_DATA_SIZE;
+ k = i % XLOG_CYCLE_DATA_SIZE;
*(__be32 *)dp = xhdr[j].hic_xheader.xh_cycle_data[k];
dp += BBSIZE;
}
--
2.47.3
next prev parent reply other threads:[~2025-10-27 7:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 7:05 kill xlog_in_core_2_t v3 Christoph Hellwig
2025-10-27 7:05 ` Christoph Hellwig [this message]
2025-10-31 13:24 ` [PATCH 1/9] xfs: add a XLOG_CYCLE_DATA_SIZE constant Carlos Maiolino
2025-10-27 7:05 ` [PATCH 2/9] xfs: add a on-disk log header cycle array accessor Christoph Hellwig
2025-10-31 13:38 ` Carlos Maiolino
2025-10-27 7:05 ` [PATCH 3/9] xfs: don't use xlog_in_core_2_t in struct xlog_in_core Christoph Hellwig
2025-10-31 13:42 ` Carlos Maiolino
2025-10-27 7:05 ` [PATCH 4/9] xfs: cleanup xlog_alloc_log a bit Christoph Hellwig
2025-10-31 13:49 ` Carlos Maiolino
2025-10-27 7:05 ` [PATCH 5/9] xfs: remove a very outdated comment from xlog_alloc_log Christoph Hellwig
2025-10-31 13:58 ` Carlos Maiolino
2025-10-27 7:05 ` [PATCH 6/9] xfs: remove xlog_in_core_2_t Christoph Hellwig
2025-10-31 14:12 ` Carlos Maiolino
2025-10-27 7:05 ` [PATCH 7/9] xfs: remove the xlog_rec_header_t typedef Christoph Hellwig
2025-10-31 14:13 ` Carlos Maiolino
2025-10-27 7:05 ` [PATCH 8/9] xfs: remove l_iclog_heads Christoph Hellwig
2025-10-31 14:15 ` Carlos Maiolino
2025-10-27 7:05 ` [PATCH 9/9] xfs: remove the xlog_in_core_t typedef Christoph Hellwig
2025-10-31 14:16 ` Carlos Maiolino
2025-11-12 10:33 ` kill xlog_in_core_2_t v3 Carlos Maiolino
-- strict thread matches above, loose matches on Subject: below --
2025-10-13 2:42 kill xlog_in_core_2_t v2 Christoph Hellwig
2025-10-13 2:42 ` [PATCH 1/9] xfs: add a XLOG_CYCLE_DATA_SIZE constant Christoph Hellwig
2025-10-14 21:16 ` Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251027070610.729960-2-hch@lst.de \
--to=hch@lst.de \
--cc=cem@kernel.org \
--cc=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).