* misc log cleanups allocation
@ 2025-07-15 12:30 Christoph Hellwig
2025-07-15 12:30 ` [PATCH 01/18] xfs: don't pass the old lv to xfs_cil_prepare_item Christoph Hellwig
` (17 more replies)
0 siblings, 18 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Hi all,
this is the harmless part of the "cleanup log item formatting" that
does not change the log space accounting. I've reproduced the
issue Dave reported with that, which just got me further into the
rabit hole. So I'd appreciate reviews for just these mostly
cosmetic changes for now, and I'll return to the harder parts
some time later.
A git tree is also available here:
git://git.infradead.org/users/hch/xfs.git xfs-log-cleanups
Gitweb:
https://git.infradead.org/?p=users/hch/xfs.git;a=shortlog;h=refs/heads/xfs-log-cleanups
Diffstat:
libxfs/xfs_refcount.c | 4 -
scrub/common.c | 7 +
scrub/common.h | 2
scrub/dir_repair.c | 8 --
scrub/fscounters.c | 3
scrub/metapath.c | 4 -
scrub/nlinks.c | 8 --
scrub/nlinks_repair.c | 4 -
scrub/parent_repair.c | 12 ---
scrub/quotacheck.c | 4 -
scrub/repair.c | 16 ----
scrub/repair.h | 4 -
scrub/rmap_repair.c | 9 --
scrub/rtrmap_repair.c | 9 --
scrub/scrub.c | 5 -
xfs_attr_item.c | 5 -
xfs_discard.c | 12 ---
xfs_fsmap.c | 4 -
xfs_icache.c | 5 -
xfs_inode.c | 5 -
xfs_itable.c | 18 ----
xfs_iwalk.c | 11 --
xfs_log.c | 6 -
xfs_log_priv.h | 4 -
xfs_notify_failure.c | 5 -
xfs_qm.c | 10 --
xfs_rtalloc.c | 13 ---
xfs_trans.c | 196 +++++++++++++++++++++++---------------------------
xfs_trans.h | 3
xfs_zone_gc.c | 5 -
30 files changed, 147 insertions(+), 254 deletions(-)
^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 01/18] xfs: don't pass the old lv to xfs_cil_prepare_item
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 02/18] xfs: cleanup the ordered item logic in xlog_cil_insert_format_items Christoph Hellwig
` (16 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs, Carlos Maiolino
By the time xfs_cil_prepare_item is called, the old lv is still pointed
to by the log item. Take it from there instead of spreading the old lv
logic over xlog_cil_insert_format_items and xfs_cil_prepare_item.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
---
fs/xfs/xfs_log_cil.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index a80cb6b9969a..2c31c7c0ef97 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -370,8 +370,8 @@ xlog_cil_alloc_shadow_bufs(
STATIC void
xfs_cil_prepare_item(
struct xlog *log,
+ struct xfs_log_item *lip,
struct xfs_log_vec *lv,
- struct xfs_log_vec *old_lv,
int *diff_len)
{
/* Account for the new LV being passed in */
@@ -381,19 +381,19 @@ xfs_cil_prepare_item(
/*
* If there is no old LV, this is the first time we've seen the item in
* this CIL context and so we need to pin it. If we are replacing the
- * old_lv, then remove the space it accounts for and make it the shadow
+ * old lv, then remove the space it accounts for and make it the shadow
* buffer for later freeing. In both cases we are now switching to the
* shadow buffer, so update the pointer to it appropriately.
*/
- if (!old_lv) {
+ if (!lip->li_lv) {
if (lv->lv_item->li_ops->iop_pin)
lv->lv_item->li_ops->iop_pin(lv->lv_item);
lv->lv_item->li_lv_shadow = NULL;
- } else if (old_lv != lv) {
+ } else if (lip->li_lv != lv) {
ASSERT(lv->lv_buf_len != XFS_LOG_VEC_ORDERED);
- *diff_len -= old_lv->lv_bytes;
- lv->lv_item->li_lv_shadow = old_lv;
+ *diff_len -= lip->li_lv->lv_bytes;
+ lv->lv_item->li_lv_shadow = lip->li_lv;
}
/* attach new log vector to log item */
@@ -453,7 +453,6 @@ xlog_cil_insert_format_items(
list_for_each_entry(lip, &tp->t_items, li_trans) {
struct xfs_log_vec *lv;
- struct xfs_log_vec *old_lv = NULL;
struct xfs_log_vec *shadow;
bool ordered = false;
@@ -474,7 +473,6 @@ xlog_cil_insert_format_items(
continue;
/* compare to existing item size */
- old_lv = lip->li_lv;
if (lip->li_lv && shadow->lv_size <= lip->li_lv->lv_size) {
/* same or smaller, optimise common overwrite case */
lv = lip->li_lv;
@@ -510,7 +508,7 @@ xlog_cil_insert_format_items(
ASSERT(IS_ALIGNED((unsigned long)lv->lv_buf, sizeof(uint64_t)));
lip->li_ops->iop_format(lip, lv);
insert:
- xfs_cil_prepare_item(log, lv, old_lv, diff_len);
+ xfs_cil_prepare_item(log, lip, lv, diff_len);
}
}
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 02/18] xfs: cleanup the ordered item logic in xlog_cil_insert_format_items
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
2025-07-15 12:30 ` [PATCH 01/18] xfs: don't pass the old lv to xfs_cil_prepare_item Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 03/18] xfs: use better names for size members in xfs_log_vec Christoph Hellwig
` (15 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs, Carlos Maiolino
Split out handling of ordered items into a single branch in
xlog_cil_insert_format_items so that the rest of the code becomes more
clear.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
---
fs/xfs/xfs_log_cil.c | 31 +++++++++++++------------------
1 file changed, 13 insertions(+), 18 deletions(-)
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 2c31c7c0ef97..9200301e539b 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -452,9 +452,8 @@ xlog_cil_insert_format_items(
}
list_for_each_entry(lip, &tp->t_items, li_trans) {
- struct xfs_log_vec *lv;
- struct xfs_log_vec *shadow;
- bool ordered = false;
+ struct xfs_log_vec *lv = lip->li_lv;
+ struct xfs_log_vec *shadow = lip->li_lv_shadow;
/* Skip items which aren't dirty in this transaction. */
if (!test_bit(XFS_LI_DIRTY, &lip->li_flags))
@@ -464,21 +463,23 @@ xlog_cil_insert_format_items(
* The formatting size information is already attached to
* the shadow lv on the log item.
*/
- shadow = lip->li_lv_shadow;
- if (shadow->lv_buf_len == XFS_LOG_VEC_ORDERED)
- ordered = true;
+ if (shadow->lv_buf_len == XFS_LOG_VEC_ORDERED) {
+ if (!lv) {
+ lv = shadow;
+ lv->lv_item = lip;
+ }
+ ASSERT(shadow->lv_size == lv->lv_size);
+ xfs_cil_prepare_item(log, lip, lv, diff_len);
+ continue;
+ }
/* Skip items that do not have any vectors for writing */
- if (!shadow->lv_niovecs && !ordered)
+ if (!shadow->lv_niovecs)
continue;
/* compare to existing item size */
- if (lip->li_lv && shadow->lv_size <= lip->li_lv->lv_size) {
+ if (lv && shadow->lv_size <= lv->lv_size) {
/* same or smaller, optimise common overwrite case */
- lv = lip->li_lv;
-
- if (ordered)
- goto insert;
/*
* set the item up as though it is a new insertion so
@@ -498,16 +499,10 @@ xlog_cil_insert_format_items(
/* switch to shadow buffer! */
lv = shadow;
lv->lv_item = lip;
- if (ordered) {
- /* track as an ordered logvec */
- ASSERT(lip->li_lv == NULL);
- goto insert;
- }
}
ASSERT(IS_ALIGNED((unsigned long)lv->lv_buf, sizeof(uint64_t)));
lip->li_ops->iop_format(lip, lv);
-insert:
xfs_cil_prepare_item(log, lip, lv, diff_len);
}
}
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 03/18] xfs: use better names for size members in xfs_log_vec
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
2025-07-15 12:30 ` [PATCH 01/18] xfs: don't pass the old lv to xfs_cil_prepare_item Christoph Hellwig
2025-07-15 12:30 ` [PATCH 02/18] xfs: cleanup the ordered item logic in xlog_cil_insert_format_items Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 04/18] xfs: don't use a xfs_log_iovec for attr_item names and values Christoph Hellwig
` (14 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs, Carlos Maiolino
The lv_size member counts the size of the entire allocation, rename it to
lv_alloc_size to make that clear.
The lv_buf_len member tracks how much of lv_buf has been used up
to format the log item, rename it to lv_buf_used to make that more clear.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
---
fs/xfs/xfs_log.c | 10 +++++-----
fs/xfs/xfs_log.h | 9 +++++----
fs/xfs/xfs_log_cil.c | 30 +++++++++++++++---------------
3 files changed, 25 insertions(+), 24 deletions(-)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 793468b4d30d..3179923a68d4 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -109,14 +109,14 @@ xlog_prepare_iovec(
vec = &lv->lv_iovecp[0];
}
- len = lv->lv_buf_len + sizeof(struct xlog_op_header);
+ len = lv->lv_buf_used + sizeof(struct xlog_op_header);
if (!IS_ALIGNED(len, sizeof(uint64_t))) {
- lv->lv_buf_len = round_up(len, sizeof(uint64_t)) -
+ lv->lv_buf_used = round_up(len, sizeof(uint64_t)) -
sizeof(struct xlog_op_header);
}
vec->i_type = type;
- vec->i_addr = lv->lv_buf + lv->lv_buf_len;
+ vec->i_addr = lv->lv_buf + lv->lv_buf_used;
oph = vec->i_addr;
oph->oh_clientid = XFS_TRANSACTION;
@@ -1931,9 +1931,9 @@ xlog_print_trans(
if (!lv)
continue;
xfs_warn(mp, " niovecs = %d", lv->lv_niovecs);
- xfs_warn(mp, " size = %d", lv->lv_size);
+ xfs_warn(mp, " alloc_size = %d", lv->lv_alloc_size);
xfs_warn(mp, " bytes = %d", lv->lv_bytes);
- xfs_warn(mp, " buf len = %d", lv->lv_buf_len);
+ xfs_warn(mp, " buf used= %d", lv->lv_buf_used);
/* dump each iovec for the log item */
vec = lv->lv_iovecp;
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index 13455854365f..f239fce4f260 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -16,8 +16,8 @@ struct xfs_log_vec {
struct xfs_log_item *lv_item; /* owner */
char *lv_buf; /* formatted buffer */
int lv_bytes; /* accounted space in buffer */
- int lv_buf_len; /* aligned size of buffer */
- int lv_size; /* size of allocated lv */
+ int lv_buf_used; /* buffer space used so far */
+ int lv_alloc_size; /* size of allocated lv */
};
#define XFS_LOG_VEC_ORDERED (-1)
@@ -64,12 +64,13 @@ xlog_finish_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec *vec,
oph->oh_len = cpu_to_be32(len);
len += sizeof(struct xlog_op_header);
- lv->lv_buf_len += len;
+ lv->lv_buf_used += len;
lv->lv_bytes += len;
vec->i_len = len;
/* Catch buffer overruns */
- ASSERT((void *)lv->lv_buf + lv->lv_bytes <= (void *)lv + lv->lv_size);
+ ASSERT((void *)lv->lv_buf + lv->lv_bytes <=
+ (void *)lv + lv->lv_alloc_size);
}
/*
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 9200301e539b..f443757e93c2 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -275,7 +275,7 @@ xlog_cil_alloc_shadow_bufs(
struct xfs_log_vec *lv;
int niovecs = 0;
int nbytes = 0;
- int buf_size;
+ int alloc_size;
bool ordered = false;
/* Skip items which aren't dirty in this transaction. */
@@ -316,14 +316,14 @@ xlog_cil_alloc_shadow_bufs(
* that space to ensure we can align it appropriately and not
* overrun the buffer.
*/
- buf_size = nbytes + xlog_cil_iovec_space(niovecs);
+ alloc_size = nbytes + xlog_cil_iovec_space(niovecs);
/*
* if we have no shadow buffer, or it is too small, we need to
* reallocate it.
*/
if (!lip->li_lv_shadow ||
- buf_size > lip->li_lv_shadow->lv_size) {
+ alloc_size > lip->li_lv_shadow->lv_alloc_size) {
/*
* We free and allocate here as a realloc would copy
* unnecessary data. We don't use kvzalloc() for the
@@ -332,15 +332,15 @@ xlog_cil_alloc_shadow_bufs(
* storage.
*/
kvfree(lip->li_lv_shadow);
- lv = xlog_kvmalloc(buf_size);
+ lv = xlog_kvmalloc(alloc_size);
memset(lv, 0, xlog_cil_iovec_space(niovecs));
INIT_LIST_HEAD(&lv->lv_list);
lv->lv_item = lip;
- lv->lv_size = buf_size;
+ lv->lv_alloc_size = alloc_size;
if (ordered)
- lv->lv_buf_len = XFS_LOG_VEC_ORDERED;
+ lv->lv_buf_used = XFS_LOG_VEC_ORDERED;
else
lv->lv_iovecp = (struct xfs_log_iovec *)&lv[1];
lip->li_lv_shadow = lv;
@@ -348,9 +348,9 @@ xlog_cil_alloc_shadow_bufs(
/* same or smaller, optimise common overwrite case */
lv = lip->li_lv_shadow;
if (ordered)
- lv->lv_buf_len = XFS_LOG_VEC_ORDERED;
+ lv->lv_buf_used = XFS_LOG_VEC_ORDERED;
else
- lv->lv_buf_len = 0;
+ lv->lv_buf_used = 0;
lv->lv_bytes = 0;
}
@@ -375,7 +375,7 @@ xfs_cil_prepare_item(
int *diff_len)
{
/* Account for the new LV being passed in */
- if (lv->lv_buf_len != XFS_LOG_VEC_ORDERED)
+ if (lv->lv_buf_used != XFS_LOG_VEC_ORDERED)
*diff_len += lv->lv_bytes;
/*
@@ -390,7 +390,7 @@ xfs_cil_prepare_item(
lv->lv_item->li_ops->iop_pin(lv->lv_item);
lv->lv_item->li_lv_shadow = NULL;
} else if (lip->li_lv != lv) {
- ASSERT(lv->lv_buf_len != XFS_LOG_VEC_ORDERED);
+ ASSERT(lv->lv_buf_used != XFS_LOG_VEC_ORDERED);
*diff_len -= lip->li_lv->lv_bytes;
lv->lv_item->li_lv_shadow = lip->li_lv;
@@ -463,12 +463,12 @@ xlog_cil_insert_format_items(
* The formatting size information is already attached to
* the shadow lv on the log item.
*/
- if (shadow->lv_buf_len == XFS_LOG_VEC_ORDERED) {
+ if (shadow->lv_buf_used == XFS_LOG_VEC_ORDERED) {
if (!lv) {
lv = shadow;
lv->lv_item = lip;
}
- ASSERT(shadow->lv_size == lv->lv_size);
+ ASSERT(shadow->lv_alloc_size == lv->lv_alloc_size);
xfs_cil_prepare_item(log, lip, lv, diff_len);
continue;
}
@@ -478,7 +478,7 @@ xlog_cil_insert_format_items(
continue;
/* compare to existing item size */
- if (lv && shadow->lv_size <= lv->lv_size) {
+ if (lv && shadow->lv_alloc_size <= lv->lv_alloc_size) {
/* same or smaller, optimise common overwrite case */
/*
@@ -491,7 +491,7 @@ xlog_cil_insert_format_items(
lv->lv_niovecs = shadow->lv_niovecs;
/* reset the lv buffer information for new formatting */
- lv->lv_buf_len = 0;
+ lv->lv_buf_used = 0;
lv->lv_bytes = 0;
lv->lv_buf = (char *)lv +
xlog_cil_iovec_space(lv->lv_niovecs);
@@ -1238,7 +1238,7 @@ xlog_cil_build_lv_chain(
lv->lv_order_id = item->li_order_id;
/* we don't write ordered log vectors */
- if (lv->lv_buf_len != XFS_LOG_VEC_ORDERED)
+ if (lv->lv_buf_used != XFS_LOG_VEC_ORDERED)
*num_bytes += lv->lv_bytes;
*num_iovecs += lv->lv_niovecs;
list_add_tail(&lv->lv_list, &ctx->lv_chain);
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 04/18] xfs: don't use a xfs_log_iovec for attr_item names and values
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (2 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 03/18] xfs: use better names for size members in xfs_log_vec Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 05/18] xfs: don't use a xfs_log_iovec for ri_buf in log recovery Christoph Hellwig
` (13 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs, Carlos Maiolino
These buffers are not directly logged, just use a kvec and remove the
xlog_copy_from_iovec helper only used here.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
---
fs/xfs/xfs_attr_item.c | 111 +++++++++++++++++++++--------------------
fs/xfs/xfs_attr_item.h | 8 +--
fs/xfs/xfs_log.h | 7 ---
3 files changed, 60 insertions(+), 66 deletions(-)
diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
index f683b7a9323f..2b3dde2eec9c 100644
--- a/fs/xfs/xfs_attr_item.c
+++ b/fs/xfs/xfs_attr_item.c
@@ -91,41 +91,37 @@ xfs_attri_log_nameval_alloc(
name_len + new_name_len + value_len +
new_value_len);
- nv->name.i_addr = nv + 1;
- nv->name.i_len = name_len;
- nv->name.i_type = XLOG_REG_TYPE_ATTR_NAME;
- memcpy(nv->name.i_addr, name, name_len);
+ nv->name.iov_base = nv + 1;
+ nv->name.iov_len = name_len;
+ memcpy(nv->name.iov_base, name, name_len);
if (new_name_len) {
- nv->new_name.i_addr = nv->name.i_addr + name_len;
- nv->new_name.i_len = new_name_len;
- memcpy(nv->new_name.i_addr, new_name, new_name_len);
+ nv->new_name.iov_base = nv->name.iov_base + name_len;
+ nv->new_name.iov_len = new_name_len;
+ memcpy(nv->new_name.iov_base, new_name, new_name_len);
} else {
- nv->new_name.i_addr = NULL;
- nv->new_name.i_len = 0;
+ nv->new_name.iov_base = NULL;
+ nv->new_name.iov_len = 0;
}
- nv->new_name.i_type = XLOG_REG_TYPE_ATTR_NEWNAME;
if (value_len) {
- nv->value.i_addr = nv->name.i_addr + name_len + new_name_len;
- nv->value.i_len = value_len;
- memcpy(nv->value.i_addr, value, value_len);
+ nv->value.iov_base = nv->name.iov_base + name_len + new_name_len;
+ nv->value.iov_len = value_len;
+ memcpy(nv->value.iov_base, value, value_len);
} else {
- nv->value.i_addr = NULL;
- nv->value.i_len = 0;
+ nv->value.iov_base = NULL;
+ nv->value.iov_len = 0;
}
- nv->value.i_type = XLOG_REG_TYPE_ATTR_VALUE;
if (new_value_len) {
- nv->new_value.i_addr = nv->name.i_addr + name_len +
+ nv->new_value.iov_base = nv->name.iov_base + name_len +
new_name_len + value_len;
- nv->new_value.i_len = new_value_len;
- memcpy(nv->new_value.i_addr, new_value, new_value_len);
+ nv->new_value.iov_len = new_value_len;
+ memcpy(nv->new_value.iov_base, new_value, new_value_len);
} else {
- nv->new_value.i_addr = NULL;
- nv->new_value.i_len = 0;
+ nv->new_value.iov_base = NULL;
+ nv->new_value.iov_len = 0;
}
- nv->new_value.i_type = XLOG_REG_TYPE_ATTR_NEWVALUE;
refcount_set(&nv->refcount, 1);
return nv;
@@ -170,21 +166,21 @@ xfs_attri_item_size(
*nvecs += 2;
*nbytes += sizeof(struct xfs_attri_log_format) +
- xlog_calc_iovec_len(nv->name.i_len);
+ xlog_calc_iovec_len(nv->name.iov_len);
- if (nv->new_name.i_len) {
+ if (nv->new_name.iov_len) {
*nvecs += 1;
- *nbytes += xlog_calc_iovec_len(nv->new_name.i_len);
+ *nbytes += xlog_calc_iovec_len(nv->new_name.iov_len);
}
- if (nv->value.i_len) {
+ if (nv->value.iov_len) {
*nvecs += 1;
- *nbytes += xlog_calc_iovec_len(nv->value.i_len);
+ *nbytes += xlog_calc_iovec_len(nv->value.iov_len);
}
- if (nv->new_value.i_len) {
+ if (nv->new_value.iov_len) {
*nvecs += 1;
- *nbytes += xlog_calc_iovec_len(nv->new_value.i_len);
+ *nbytes += xlog_calc_iovec_len(nv->new_value.iov_len);
}
}
@@ -212,31 +208,36 @@ xfs_attri_item_format(
* the log recovery.
*/
- ASSERT(nv->name.i_len > 0);
+ ASSERT(nv->name.iov_len > 0);
attrip->attri_format.alfi_size++;
- if (nv->new_name.i_len > 0)
+ if (nv->new_name.iov_len > 0)
attrip->attri_format.alfi_size++;
- if (nv->value.i_len > 0)
+ if (nv->value.iov_len > 0)
attrip->attri_format.alfi_size++;
- if (nv->new_value.i_len > 0)
+ if (nv->new_value.iov_len > 0)
attrip->attri_format.alfi_size++;
xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRI_FORMAT,
&attrip->attri_format,
sizeof(struct xfs_attri_log_format));
- xlog_copy_from_iovec(lv, &vecp, &nv->name);
- if (nv->new_name.i_len > 0)
- xlog_copy_from_iovec(lv, &vecp, &nv->new_name);
+ xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NAME, nv->name.iov_base,
+ nv->name.iov_len);
- if (nv->value.i_len > 0)
- xlog_copy_from_iovec(lv, &vecp, &nv->value);
+ if (nv->new_name.iov_len > 0)
+ xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NEWNAME,
+ nv->new_name.iov_base, nv->new_name.iov_len);
- if (nv->new_value.i_len > 0)
- xlog_copy_from_iovec(lv, &vecp, &nv->new_value);
+ if (nv->value.iov_len > 0)
+ xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_VALUE,
+ nv->value.iov_base, nv->value.iov_len);
+
+ if (nv->new_value.iov_len > 0)
+ xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NEWVALUE,
+ nv->new_value.iov_base, nv->new_value.iov_len);
}
/*
@@ -383,22 +384,22 @@ xfs_attr_log_item(
attrp->alfi_ino = args->dp->i_ino;
ASSERT(!(attr->xattri_op_flags & ~XFS_ATTRI_OP_FLAGS_TYPE_MASK));
attrp->alfi_op_flags = attr->xattri_op_flags;
- attrp->alfi_value_len = nv->value.i_len;
+ attrp->alfi_value_len = nv->value.iov_len;
switch (xfs_attr_log_item_op(attrp)) {
case XFS_ATTRI_OP_FLAGS_PPTR_REPLACE:
- ASSERT(nv->value.i_len == nv->new_value.i_len);
+ ASSERT(nv->value.iov_len == nv->new_value.iov_len);
attrp->alfi_igen = VFS_I(args->dp)->i_generation;
- attrp->alfi_old_name_len = nv->name.i_len;
- attrp->alfi_new_name_len = nv->new_name.i_len;
+ attrp->alfi_old_name_len = nv->name.iov_len;
+ attrp->alfi_new_name_len = nv->new_name.iov_len;
break;
case XFS_ATTRI_OP_FLAGS_PPTR_REMOVE:
case XFS_ATTRI_OP_FLAGS_PPTR_SET:
attrp->alfi_igen = VFS_I(args->dp)->i_generation;
fallthrough;
default:
- attrp->alfi_name_len = nv->name.i_len;
+ attrp->alfi_name_len = nv->name.iov_len;
break;
}
@@ -690,14 +691,14 @@ xfs_attri_recover_work(
args->dp = ip;
args->geo = mp->m_attr_geo;
args->whichfork = XFS_ATTR_FORK;
- args->name = nv->name.i_addr;
- args->namelen = nv->name.i_len;
- args->new_name = nv->new_name.i_addr;
- args->new_namelen = nv->new_name.i_len;
- args->value = nv->value.i_addr;
- args->valuelen = nv->value.i_len;
- args->new_value = nv->new_value.i_addr;
- args->new_valuelen = nv->new_value.i_len;
+ args->name = nv->name.iov_base;
+ args->namelen = nv->name.iov_len;
+ args->new_name = nv->new_name.iov_base;
+ args->new_namelen = nv->new_name.iov_len;
+ args->value = nv->value.iov_base;
+ args->valuelen = nv->value.iov_len;
+ args->new_value = nv->new_value.iov_base;
+ args->new_valuelen = nv->new_value.iov_len;
args->attr_filter = attrp->alfi_attr_filter & XFS_ATTRI_FILTER_MASK;
args->op_flags = XFS_DA_OP_RECOVERY | XFS_DA_OP_OKNOENT |
XFS_DA_OP_LOGGED;
@@ -754,8 +755,8 @@ xfs_attr_recover_work(
*/
attrp = &attrip->attri_format;
if (!xfs_attri_validate(mp, attrp) ||
- !xfs_attr_namecheck(attrp->alfi_attr_filter, nv->name.i_addr,
- nv->name.i_len))
+ !xfs_attr_namecheck(attrp->alfi_attr_filter, nv->name.iov_base,
+ nv->name.iov_len))
return -EFSCORRUPTED;
attr = xfs_attri_recover_work(mp, dfp, attrp, &ip, nv);
diff --git a/fs/xfs/xfs_attr_item.h b/fs/xfs/xfs_attr_item.h
index e74128cbb722..d108a11b55ae 100644
--- a/fs/xfs/xfs_attr_item.h
+++ b/fs/xfs/xfs_attr_item.h
@@ -12,10 +12,10 @@ struct xfs_mount;
struct kmem_zone;
struct xfs_attri_log_nameval {
- struct xfs_log_iovec name;
- struct xfs_log_iovec new_name; /* PPTR_REPLACE only */
- struct xfs_log_iovec value;
- struct xfs_log_iovec new_value; /* PPTR_REPLACE only */
+ struct kvec name;
+ struct kvec new_name; /* PPTR_REPLACE only */
+ struct kvec value;
+ struct kvec new_value; /* PPTR_REPLACE only */
refcount_t refcount;
/* name and value follow the end of this struct */
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index f239fce4f260..af6daf4f6792 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -88,13 +88,6 @@ xlog_copy_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
return buf;
}
-static inline void *
-xlog_copy_from_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
- const struct xfs_log_iovec *src)
-{
- return xlog_copy_iovec(lv, vecp, src->i_type, src->i_addr, src->i_len);
-}
-
/*
* By comparing each component, we don't have to worry about extra
* endian issues in treating two 32 bit numbers as one 64 bit number
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 05/18] xfs: don't use a xfs_log_iovec for ri_buf in log recovery
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (3 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 04/18] xfs: don't use a xfs_log_iovec for attr_item names and values Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 06/18] xfs: add a xlog_write_one_vec helper Christoph Hellwig
` (12 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs, Carlos Maiolino
ri_buf just holds a pointer/len pair and is not a log iovec used for
writing to the log. Switch to use a kvec instead.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
---
fs/xfs/libxfs/xfs_log_recover.h | 4 +--
fs/xfs/xfs_attr_item.c | 32 +++++++++---------
fs/xfs/xfs_bmap_item.c | 18 +++++-----
fs/xfs/xfs_buf_item.c | 8 ++---
fs/xfs/xfs_buf_item.h | 2 +-
fs/xfs/xfs_buf_item_recover.c | 38 ++++++++++-----------
fs/xfs/xfs_dquot_item_recover.c | 20 +++++------
fs/xfs/xfs_exchmaps_item.c | 8 ++---
fs/xfs/xfs_extfree_item.c | 59 +++++++++++++++++----------------
fs/xfs/xfs_icreate_item.c | 2 +-
fs/xfs/xfs_inode_item.c | 6 ++--
fs/xfs/xfs_inode_item.h | 4 +--
fs/xfs/xfs_inode_item_recover.c | 26 +++++++--------
fs/xfs/xfs_log_recover.c | 16 ++++-----
fs/xfs/xfs_refcount_item.c | 34 +++++++++----------
fs/xfs/xfs_rmap_item.c | 34 +++++++++----------
fs/xfs/xfs_trans.h | 1 -
17 files changed, 157 insertions(+), 155 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_log_recover.h b/fs/xfs/libxfs/xfs_log_recover.h
index 66c7916fb5cd..95de23095030 100644
--- a/fs/xfs/libxfs/xfs_log_recover.h
+++ b/fs/xfs/libxfs/xfs_log_recover.h
@@ -104,7 +104,7 @@ struct xlog_recover_item {
struct list_head ri_list;
int ri_cnt; /* count of regions found */
int ri_total; /* total regions */
- struct xfs_log_iovec *ri_buf; /* ptr to regions buffer */
+ struct kvec *ri_buf; /* ptr to regions buffer */
const struct xlog_recover_item_ops *ri_ops;
};
@@ -117,7 +117,7 @@ struct xlog_recover {
struct list_head r_itemq; /* q for items */
};
-#define ITEM_TYPE(i) (*(unsigned short *)(i)->ri_buf[0].i_addr)
+#define ITEM_TYPE(i) (*(unsigned short *)(i)->ri_buf[0].iov_base)
#define XLOG_RECOVER_CRCPASS 0
#define XLOG_RECOVER_PASS1 1
diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
index 2b3dde2eec9c..bc970aa6832f 100644
--- a/fs/xfs/xfs_attr_item.c
+++ b/fs/xfs/xfs_attr_item.c
@@ -954,50 +954,50 @@ static inline void *
xfs_attri_validate_name_iovec(
struct xfs_mount *mp,
struct xfs_attri_log_format *attri_formatp,
- const struct xfs_log_iovec *iovec,
+ const struct kvec *iovec,
unsigned int name_len)
{
- if (iovec->i_len != xlog_calc_iovec_len(name_len)) {
+ if (iovec->iov_len != xlog_calc_iovec_len(name_len)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
attri_formatp, sizeof(*attri_formatp));
return NULL;
}
- if (!xfs_attr_namecheck(attri_formatp->alfi_attr_filter, iovec->i_addr,
+ if (!xfs_attr_namecheck(attri_formatp->alfi_attr_filter, iovec->iov_base,
name_len)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
attri_formatp, sizeof(*attri_formatp));
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- iovec->i_addr, iovec->i_len);
+ iovec->iov_base, iovec->iov_len);
return NULL;
}
- return iovec->i_addr;
+ return iovec->iov_base;
}
static inline void *
xfs_attri_validate_value_iovec(
struct xfs_mount *mp,
struct xfs_attri_log_format *attri_formatp,
- const struct xfs_log_iovec *iovec,
+ const struct kvec *iovec,
unsigned int value_len)
{
- if (iovec->i_len != xlog_calc_iovec_len(value_len)) {
+ if (iovec->iov_len != xlog_calc_iovec_len(value_len)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
attri_formatp, sizeof(*attri_formatp));
return NULL;
}
if ((attri_formatp->alfi_attr_filter & XFS_ATTR_PARENT) &&
- !xfs_parent_valuecheck(mp, iovec->i_addr, value_len)) {
+ !xfs_parent_valuecheck(mp, iovec->iov_base, value_len)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
attri_formatp, sizeof(*attri_formatp));
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- iovec->i_addr, iovec->i_len);
+ iovec->iov_base, iovec->iov_len);
return NULL;
}
- return iovec->i_addr;
+ return iovec->iov_base;
}
STATIC int
@@ -1024,13 +1024,13 @@ xlog_recover_attri_commit_pass2(
/* Validate xfs_attri_log_format before the large memory allocation */
len = sizeof(struct xfs_attri_log_format);
- if (item->ri_buf[i].i_len != len) {
+ if (item->ri_buf[i].iov_len != len) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
- attri_formatp = item->ri_buf[i].i_addr;
+ attri_formatp = item->ri_buf[i].iov_base;
if (!xfs_attri_validate(mp, attri_formatp)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
attri_formatp, len);
@@ -1219,10 +1219,10 @@ xlog_recover_attrd_commit_pass2(
{
struct xfs_attrd_log_format *attrd_formatp;
- attrd_formatp = item->ri_buf[0].i_addr;
- if (item->ri_buf[0].i_len != sizeof(struct xfs_attrd_log_format)) {
+ attrd_formatp = item->ri_buf[0].iov_base;
+ if (item->ri_buf[0].iov_len != sizeof(struct xfs_attrd_log_format)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index 646c515ee355..80f0c4bcc483 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -654,24 +654,24 @@ xlog_recover_bui_commit_pass2(
struct xfs_bui_log_format *bui_formatp;
size_t len;
- bui_formatp = item->ri_buf[0].i_addr;
+ bui_formatp = item->ri_buf[0].iov_base;
- if (item->ri_buf[0].i_len < xfs_bui_log_format_sizeof(0)) {
+ if (item->ri_buf[0].iov_len < xfs_bui_log_format_sizeof(0)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
if (bui_formatp->bui_nextents != XFS_BUI_MAX_FAST_EXTENTS) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
len = xfs_bui_log_format_sizeof(bui_formatp->bui_nextents);
- if (item->ri_buf[0].i_len != len) {
+ if (item->ri_buf[0].iov_len != len) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
@@ -705,10 +705,10 @@ xlog_recover_bud_commit_pass2(
{
struct xfs_bud_log_format *bud_formatp;
- bud_formatp = item->ri_buf[0].i_addr;
- if (item->ri_buf[0].i_len != sizeof(struct xfs_bud_log_format)) {
+ bud_formatp = item->ri_buf[0].iov_base;
+ if (item->ri_buf[0].iov_len != sizeof(struct xfs_bud_log_format)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 7fc54725c5f6..8d85b5eee444 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -90,16 +90,16 @@ xfs_buf_item_relse(
/* Is this log iovec plausibly large enough to contain the buffer log format? */
bool
xfs_buf_log_check_iovec(
- struct xfs_log_iovec *iovec)
+ struct kvec *iovec)
{
- struct xfs_buf_log_format *blfp = iovec->i_addr;
+ struct xfs_buf_log_format *blfp = iovec->iov_base;
char *bmp_end;
char *item_end;
- if (offsetof(struct xfs_buf_log_format, blf_data_map) > iovec->i_len)
+ if (offsetof(struct xfs_buf_log_format, blf_data_map) > iovec->iov_len)
return false;
- item_end = (char *)iovec->i_addr + iovec->i_len;
+ item_end = (char *)iovec->iov_base + iovec->iov_len;
bmp_end = (char *)&blfp->blf_data_map[blfp->blf_map_size];
return bmp_end <= item_end;
}
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index 416890b84f8c..3159325dd17b 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -61,7 +61,7 @@ static inline void xfs_buf_dquot_iodone(struct xfs_buf *bp)
}
#endif /* CONFIG_XFS_QUOTA */
void xfs_buf_iodone(struct xfs_buf *);
-bool xfs_buf_log_check_iovec(struct xfs_log_iovec *iovec);
+bool xfs_buf_log_check_iovec(struct kvec *iovec);
unsigned int xfs_buf_inval_log_space(unsigned int map_count,
unsigned int blocksize);
diff --git a/fs/xfs/xfs_buf_item_recover.c b/fs/xfs/xfs_buf_item_recover.c
index d4c5cef5bc43..5d58e2ae4972 100644
--- a/fs/xfs/xfs_buf_item_recover.c
+++ b/fs/xfs/xfs_buf_item_recover.c
@@ -159,7 +159,7 @@ STATIC enum xlog_recover_reorder
xlog_recover_buf_reorder(
struct xlog_recover_item *item)
{
- struct xfs_buf_log_format *buf_f = item->ri_buf[0].i_addr;
+ struct xfs_buf_log_format *buf_f = item->ri_buf[0].iov_base;
if (buf_f->blf_flags & XFS_BLF_CANCEL)
return XLOG_REORDER_CANCEL_LIST;
@@ -173,7 +173,7 @@ xlog_recover_buf_ra_pass2(
struct xlog *log,
struct xlog_recover_item *item)
{
- struct xfs_buf_log_format *buf_f = item->ri_buf[0].i_addr;
+ struct xfs_buf_log_format *buf_f = item->ri_buf[0].iov_base;
xlog_buf_readahead(log, buf_f->blf_blkno, buf_f->blf_len, NULL);
}
@@ -187,11 +187,11 @@ xlog_recover_buf_commit_pass1(
struct xlog *log,
struct xlog_recover_item *item)
{
- struct xfs_buf_log_format *bf = item->ri_buf[0].i_addr;
+ struct xfs_buf_log_format *bf = item->ri_buf[0].iov_base;
if (!xfs_buf_log_check_iovec(&item->ri_buf[0])) {
- xfs_err(log->l_mp, "bad buffer log item size (%d)",
- item->ri_buf[0].i_len);
+ xfs_err(log->l_mp, "bad buffer log item size (%zd)",
+ item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
@@ -487,8 +487,8 @@ xlog_recover_do_reg_buffer(
nbits = xfs_contig_bits(buf_f->blf_data_map,
buf_f->blf_map_size, bit);
ASSERT(nbits > 0);
- ASSERT(item->ri_buf[i].i_addr != NULL);
- ASSERT(item->ri_buf[i].i_len % XFS_BLF_CHUNK == 0);
+ ASSERT(item->ri_buf[i].iov_base != NULL);
+ ASSERT(item->ri_buf[i].iov_len % XFS_BLF_CHUNK == 0);
ASSERT(BBTOB(bp->b_length) >=
((uint)bit << XFS_BLF_SHIFT) + (nbits << XFS_BLF_SHIFT));
@@ -500,8 +500,8 @@ xlog_recover_do_reg_buffer(
* the log. Hence we need to trim nbits back to the length of
* the current region being copied out of the log.
*/
- if (item->ri_buf[i].i_len < (nbits << XFS_BLF_SHIFT))
- nbits = item->ri_buf[i].i_len >> XFS_BLF_SHIFT;
+ if (item->ri_buf[i].iov_len < (nbits << XFS_BLF_SHIFT))
+ nbits = item->ri_buf[i].iov_len >> XFS_BLF_SHIFT;
/*
* Do a sanity check if this is a dquot buffer. Just checking
@@ -511,18 +511,18 @@ xlog_recover_do_reg_buffer(
fa = NULL;
if (buf_f->blf_flags &
(XFS_BLF_UDQUOT_BUF|XFS_BLF_PDQUOT_BUF|XFS_BLF_GDQUOT_BUF)) {
- if (item->ri_buf[i].i_addr == NULL) {
+ if (item->ri_buf[i].iov_base == NULL) {
xfs_alert(mp,
"XFS: NULL dquot in %s.", __func__);
goto next;
}
- if (item->ri_buf[i].i_len < size_disk_dquot) {
+ if (item->ri_buf[i].iov_len < size_disk_dquot) {
xfs_alert(mp,
- "XFS: dquot too small (%d) in %s.",
- item->ri_buf[i].i_len, __func__);
+ "XFS: dquot too small (%zd) in %s.",
+ item->ri_buf[i].iov_len, __func__);
goto next;
}
- fa = xfs_dquot_verify(mp, item->ri_buf[i].i_addr, -1);
+ fa = xfs_dquot_verify(mp, item->ri_buf[i].iov_base, -1);
if (fa) {
xfs_alert(mp,
"dquot corrupt at %pS trying to replay into block 0x%llx",
@@ -533,7 +533,7 @@ xlog_recover_do_reg_buffer(
memcpy(xfs_buf_offset(bp,
(uint)bit << XFS_BLF_SHIFT), /* dest */
- item->ri_buf[i].i_addr, /* source */
+ item->ri_buf[i].iov_base, /* source */
nbits<<XFS_BLF_SHIFT); /* length */
next:
i++;
@@ -669,8 +669,8 @@ xlog_recover_do_inode_buffer(
if (next_unlinked_offset < reg_buf_offset)
continue;
- ASSERT(item->ri_buf[item_index].i_addr != NULL);
- ASSERT((item->ri_buf[item_index].i_len % XFS_BLF_CHUNK) == 0);
+ ASSERT(item->ri_buf[item_index].iov_base != NULL);
+ ASSERT((item->ri_buf[item_index].iov_len % XFS_BLF_CHUNK) == 0);
ASSERT((reg_buf_offset + reg_buf_bytes) <= BBTOB(bp->b_length));
/*
@@ -678,7 +678,7 @@ xlog_recover_do_inode_buffer(
* current di_next_unlinked field. Extract its value
* and copy it to the buffer copy.
*/
- logged_nextp = item->ri_buf[item_index].i_addr +
+ logged_nextp = item->ri_buf[item_index].iov_base +
next_unlinked_offset - reg_buf_offset;
if (XFS_IS_CORRUPT(mp, *logged_nextp == 0)) {
xfs_alert(mp,
@@ -1002,7 +1002,7 @@ xlog_recover_buf_commit_pass2(
struct xlog_recover_item *item,
xfs_lsn_t current_lsn)
{
- struct xfs_buf_log_format *buf_f = item->ri_buf[0].i_addr;
+ struct xfs_buf_log_format *buf_f = item->ri_buf[0].iov_base;
struct xfs_mount *mp = log->l_mp;
struct xfs_buf *bp;
int error;
diff --git a/fs/xfs/xfs_dquot_item_recover.c b/fs/xfs/xfs_dquot_item_recover.c
index 2c2720ce6923..89bc9bcaf51e 100644
--- a/fs/xfs/xfs_dquot_item_recover.c
+++ b/fs/xfs/xfs_dquot_item_recover.c
@@ -34,10 +34,10 @@ xlog_recover_dquot_ra_pass2(
if (mp->m_qflags == 0)
return;
- recddq = item->ri_buf[1].i_addr;
+ recddq = item->ri_buf[1].iov_base;
if (recddq == NULL)
return;
- if (item->ri_buf[1].i_len < sizeof(struct xfs_disk_dquot))
+ if (item->ri_buf[1].iov_len < sizeof(struct xfs_disk_dquot))
return;
type = recddq->d_type & XFS_DQTYPE_REC_MASK;
@@ -45,7 +45,7 @@ xlog_recover_dquot_ra_pass2(
if (log->l_quotaoffs_flag & type)
return;
- dq_f = item->ri_buf[0].i_addr;
+ dq_f = item->ri_buf[0].iov_base;
ASSERT(dq_f);
ASSERT(dq_f->qlf_len == 1);
@@ -79,14 +79,14 @@ xlog_recover_dquot_commit_pass2(
if (mp->m_qflags == 0)
return 0;
- recddq = item->ri_buf[1].i_addr;
+ recddq = item->ri_buf[1].iov_base;
if (recddq == NULL) {
xfs_alert(log->l_mp, "NULL dquot in %s.", __func__);
return -EFSCORRUPTED;
}
- if (item->ri_buf[1].i_len < sizeof(struct xfs_disk_dquot)) {
- xfs_alert(log->l_mp, "dquot too small (%d) in %s.",
- item->ri_buf[1].i_len, __func__);
+ if (item->ri_buf[1].iov_len < sizeof(struct xfs_disk_dquot)) {
+ xfs_alert(log->l_mp, "dquot too small (%zd) in %s.",
+ item->ri_buf[1].iov_len, __func__);
return -EFSCORRUPTED;
}
@@ -108,7 +108,7 @@ xlog_recover_dquot_commit_pass2(
* The other possibility, of course, is that the quota subsystem was
* removed since the last mount - ENOSYS.
*/
- dq_f = item->ri_buf[0].i_addr;
+ dq_f = item->ri_buf[0].iov_base;
ASSERT(dq_f);
fa = xfs_dquot_verify(mp, recddq, dq_f->qlf_id);
if (fa) {
@@ -147,7 +147,7 @@ xlog_recover_dquot_commit_pass2(
}
}
- memcpy(ddq, recddq, item->ri_buf[1].i_len);
+ memcpy(ddq, recddq, item->ri_buf[1].iov_len);
if (xfs_has_crc(mp)) {
xfs_update_cksum((char *)dqb, sizeof(struct xfs_dqblk),
XFS_DQUOT_CRC_OFF);
@@ -192,7 +192,7 @@ xlog_recover_quotaoff_commit_pass1(
struct xlog *log,
struct xlog_recover_item *item)
{
- struct xfs_qoff_logformat *qoff_f = item->ri_buf[0].i_addr;
+ struct xfs_qoff_logformat *qoff_f = item->ri_buf[0].iov_base;
ASSERT(qoff_f);
/*
diff --git a/fs/xfs/xfs_exchmaps_item.c b/fs/xfs/xfs_exchmaps_item.c
index 264a121c5e16..229cbe0adf17 100644
--- a/fs/xfs/xfs_exchmaps_item.c
+++ b/fs/xfs/xfs_exchmaps_item.c
@@ -558,12 +558,12 @@ xlog_recover_xmi_commit_pass2(
size_t len;
len = sizeof(struct xfs_xmi_log_format);
- if (item->ri_buf[0].i_len != len) {
+ if (item->ri_buf[0].iov_len != len) {
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
return -EFSCORRUPTED;
}
- xmi_formatp = item->ri_buf[0].i_addr;
+ xmi_formatp = item->ri_buf[0].iov_base;
if (xmi_formatp->__pad != 0) {
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
return -EFSCORRUPTED;
@@ -598,8 +598,8 @@ xlog_recover_xmd_commit_pass2(
{
struct xfs_xmd_log_format *xmd_formatp;
- xmd_formatp = item->ri_buf[0].i_addr;
- if (item->ri_buf[0].i_len != sizeof(struct xfs_xmd_log_format)) {
+ xmd_formatp = item->ri_buf[0].iov_base;
+ if (item->ri_buf[0].iov_len != sizeof(struct xfs_xmd_log_format)) {
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, log->l_mp);
return -EFSCORRUPTED;
}
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index d574f5f639fa..47ee598a9827 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -182,15 +182,18 @@ xfs_efi_init(
* It will handle the conversion of formats if necessary.
*/
STATIC int
-xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt)
+xfs_efi_copy_format(
+ struct kvec *buf,
+ struct xfs_efi_log_format *dst_efi_fmt)
{
- xfs_efi_log_format_t *src_efi_fmt = buf->i_addr;
- uint i;
- uint len = xfs_efi_log_format_sizeof(src_efi_fmt->efi_nextents);
- uint len32 = xfs_efi_log_format32_sizeof(src_efi_fmt->efi_nextents);
- uint len64 = xfs_efi_log_format64_sizeof(src_efi_fmt->efi_nextents);
+ struct xfs_efi_log_format *src_efi_fmt = buf->iov_base;
+ uint len, len32, len64, i;
- if (buf->i_len == len) {
+ len = xfs_efi_log_format_sizeof(src_efi_fmt->efi_nextents);
+ len32 = xfs_efi_log_format32_sizeof(src_efi_fmt->efi_nextents);
+ len64 = xfs_efi_log_format64_sizeof(src_efi_fmt->efi_nextents);
+
+ if (buf->iov_len == len) {
memcpy(dst_efi_fmt, src_efi_fmt,
offsetof(struct xfs_efi_log_format, efi_extents));
for (i = 0; i < src_efi_fmt->efi_nextents; i++)
@@ -198,8 +201,8 @@ xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt)
&src_efi_fmt->efi_extents[i],
sizeof(struct xfs_extent));
return 0;
- } else if (buf->i_len == len32) {
- xfs_efi_log_format_32_t *src_efi_fmt_32 = buf->i_addr;
+ } else if (buf->iov_len == len32) {
+ xfs_efi_log_format_32_t *src_efi_fmt_32 = buf->iov_base;
dst_efi_fmt->efi_type = src_efi_fmt_32->efi_type;
dst_efi_fmt->efi_size = src_efi_fmt_32->efi_size;
@@ -212,8 +215,8 @@ xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt)
src_efi_fmt_32->efi_extents[i].ext_len;
}
return 0;
- } else if (buf->i_len == len64) {
- xfs_efi_log_format_64_t *src_efi_fmt_64 = buf->i_addr;
+ } else if (buf->iov_len == len64) {
+ xfs_efi_log_format_64_t *src_efi_fmt_64 = buf->iov_base;
dst_efi_fmt->efi_type = src_efi_fmt_64->efi_type;
dst_efi_fmt->efi_size = src_efi_fmt_64->efi_size;
@@ -227,8 +230,8 @@ xfs_efi_copy_format(xfs_log_iovec_t *buf, xfs_efi_log_format_t *dst_efi_fmt)
}
return 0;
}
- XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, NULL, buf->i_addr,
- buf->i_len);
+ XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, NULL, buf->iov_base,
+ buf->iov_len);
return -EFSCORRUPTED;
}
@@ -865,11 +868,11 @@ xlog_recover_efi_commit_pass2(
struct xfs_efi_log_format *efi_formatp;
int error;
- efi_formatp = item->ri_buf[0].i_addr;
+ efi_formatp = item->ri_buf[0].iov_base;
- if (item->ri_buf[0].i_len < xfs_efi_log_format_sizeof(0)) {
+ if (item->ri_buf[0].iov_len < xfs_efi_log_format_sizeof(0)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
@@ -904,11 +907,11 @@ xlog_recover_rtefi_commit_pass2(
struct xfs_efi_log_format *efi_formatp;
int error;
- efi_formatp = item->ri_buf[0].i_addr;
+ efi_formatp = item->ri_buf[0].iov_base;
- if (item->ri_buf[0].i_len < xfs_efi_log_format_sizeof(0)) {
+ if (item->ri_buf[0].iov_len < xfs_efi_log_format_sizeof(0)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
@@ -933,7 +936,7 @@ xlog_recover_rtefi_commit_pass2(
xfs_lsn_t lsn)
{
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
#endif
@@ -958,9 +961,9 @@ xlog_recover_efd_commit_pass2(
xfs_lsn_t lsn)
{
struct xfs_efd_log_format *efd_formatp;
- int buflen = item->ri_buf[0].i_len;
+ int buflen = item->ri_buf[0].iov_len;
- efd_formatp = item->ri_buf[0].i_addr;
+ efd_formatp = item->ri_buf[0].iov_base;
if (buflen < sizeof(struct xfs_efd_log_format)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
@@ -968,9 +971,9 @@ xlog_recover_efd_commit_pass2(
return -EFSCORRUPTED;
}
- if (item->ri_buf[0].i_len != xfs_efd_log_format32_sizeof(
+ if (item->ri_buf[0].iov_len != xfs_efd_log_format32_sizeof(
efd_formatp->efd_nextents) &&
- item->ri_buf[0].i_len != xfs_efd_log_format64_sizeof(
+ item->ri_buf[0].iov_len != xfs_efd_log_format64_sizeof(
efd_formatp->efd_nextents)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
efd_formatp, buflen);
@@ -995,9 +998,9 @@ xlog_recover_rtefd_commit_pass2(
xfs_lsn_t lsn)
{
struct xfs_efd_log_format *efd_formatp;
- int buflen = item->ri_buf[0].i_len;
+ int buflen = item->ri_buf[0].iov_len;
- efd_formatp = item->ri_buf[0].i_addr;
+ efd_formatp = item->ri_buf[0].iov_base;
if (buflen < sizeof(struct xfs_efd_log_format)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
@@ -1005,9 +1008,9 @@ xlog_recover_rtefd_commit_pass2(
return -EFSCORRUPTED;
}
- if (item->ri_buf[0].i_len != xfs_efd_log_format32_sizeof(
+ if (item->ri_buf[0].iov_len != xfs_efd_log_format32_sizeof(
efd_formatp->efd_nextents) &&
- item->ri_buf[0].i_len != xfs_efd_log_format64_sizeof(
+ item->ri_buf[0].iov_len != xfs_efd_log_format64_sizeof(
efd_formatp->efd_nextents)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
efd_formatp, buflen);
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index 4345db501714..f83ec2bd0583 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -158,7 +158,7 @@ xlog_recover_icreate_commit_pass2(
int nbufs;
int i;
- icl = (struct xfs_icreate_log *)item->ri_buf[0].i_addr;
+ icl = (struct xfs_icreate_log *)item->ri_buf[0].iov_base;
if (icl->icl_type != XFS_LI_ICREATE) {
xfs_warn(log->l_mp, "xlog_recover_do_icreate_trans: bad type");
return -EINVAL;
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 285e27ff89e2..829675700fcd 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -1182,12 +1182,12 @@ xfs_iflush_shutdown_abort(
*/
int
xfs_inode_item_format_convert(
- struct xfs_log_iovec *buf,
+ struct kvec *buf,
struct xfs_inode_log_format *in_f)
{
- struct xfs_inode_log_format_32 *in_f32 = buf->i_addr;
+ struct xfs_inode_log_format_32 *in_f32 = buf->iov_base;
- if (buf->i_len != sizeof(*in_f32)) {
+ if (buf->iov_len != sizeof(*in_f32)) {
XFS_ERROR_REPORT(__func__, XFS_ERRLEVEL_LOW, NULL);
return -EFSCORRUPTED;
}
diff --git a/fs/xfs/xfs_inode_item.h b/fs/xfs/xfs_inode_item.h
index 377e06007804..ba92ce11a011 100644
--- a/fs/xfs/xfs_inode_item.h
+++ b/fs/xfs/xfs_inode_item.h
@@ -46,8 +46,8 @@ extern void xfs_inode_item_init(struct xfs_inode *, struct xfs_mount *);
extern void xfs_inode_item_destroy(struct xfs_inode *);
extern void xfs_iflush_abort(struct xfs_inode *);
extern void xfs_iflush_shutdown_abort(struct xfs_inode *);
-extern int xfs_inode_item_format_convert(xfs_log_iovec_t *,
- struct xfs_inode_log_format *);
+int xfs_inode_item_format_convert(struct kvec *buf,
+ struct xfs_inode_log_format *in_f);
extern struct kmem_cache *xfs_ili_cache;
diff --git a/fs/xfs/xfs_inode_item_recover.c b/fs/xfs/xfs_inode_item_recover.c
index 7205fd14f6b3..9d1999d41be1 100644
--- a/fs/xfs/xfs_inode_item_recover.c
+++ b/fs/xfs/xfs_inode_item_recover.c
@@ -30,13 +30,13 @@ xlog_recover_inode_ra_pass2(
struct xlog *log,
struct xlog_recover_item *item)
{
- if (item->ri_buf[0].i_len == sizeof(struct xfs_inode_log_format)) {
- struct xfs_inode_log_format *ilfp = item->ri_buf[0].i_addr;
+ if (item->ri_buf[0].iov_len == sizeof(struct xfs_inode_log_format)) {
+ struct xfs_inode_log_format *ilfp = item->ri_buf[0].iov_base;
xlog_buf_readahead(log, ilfp->ilf_blkno, ilfp->ilf_len,
&xfs_inode_buf_ra_ops);
} else {
- struct xfs_inode_log_format_32 *ilfp = item->ri_buf[0].i_addr;
+ struct xfs_inode_log_format_32 *ilfp = item->ri_buf[0].iov_base;
xlog_buf_readahead(log, ilfp->ilf_blkno, ilfp->ilf_len,
&xfs_inode_buf_ra_ops);
@@ -326,8 +326,8 @@ xlog_recover_inode_commit_pass2(
int need_free = 0;
xfs_failaddr_t fa;
- if (item->ri_buf[0].i_len == sizeof(struct xfs_inode_log_format)) {
- in_f = item->ri_buf[0].i_addr;
+ if (item->ri_buf[0].iov_len == sizeof(struct xfs_inode_log_format)) {
+ in_f = item->ri_buf[0].iov_base;
} else {
in_f = kmalloc(sizeof(struct xfs_inode_log_format),
GFP_KERNEL | __GFP_NOFAIL);
@@ -366,7 +366,7 @@ xlog_recover_inode_commit_pass2(
error = -EFSCORRUPTED;
goto out_release;
}
- ldip = item->ri_buf[1].i_addr;
+ ldip = item->ri_buf[1].iov_base;
if (XFS_IS_CORRUPT(mp, ldip->di_magic != XFS_DINODE_MAGIC)) {
xfs_alert(mp,
"%s: Bad inode log record, rec ptr "PTR_FMT", ino %lld",
@@ -472,12 +472,12 @@ xlog_recover_inode_commit_pass2(
goto out_release;
}
isize = xfs_log_dinode_size(mp);
- if (unlikely(item->ri_buf[1].i_len > isize)) {
+ if (unlikely(item->ri_buf[1].iov_len > isize)) {
XFS_CORRUPTION_ERROR("Bad log dinode size", XFS_ERRLEVEL_LOW,
mp, ldip, sizeof(*ldip));
xfs_alert(mp,
- "Bad inode 0x%llx log dinode size 0x%x",
- in_f->ilf_ino, item->ri_buf[1].i_len);
+ "Bad inode 0x%llx log dinode size 0x%zx",
+ in_f->ilf_ino, item->ri_buf[1].iov_len);
error = -EFSCORRUPTED;
goto out_release;
}
@@ -500,8 +500,8 @@ xlog_recover_inode_commit_pass2(
if (in_f->ilf_size == 2)
goto out_owner_change;
- len = item->ri_buf[2].i_len;
- src = item->ri_buf[2].i_addr;
+ len = item->ri_buf[2].iov_len;
+ src = item->ri_buf[2].iov_base;
ASSERT(in_f->ilf_size <= 4);
ASSERT((in_f->ilf_size == 3) || (fields & XFS_ILOG_AFORK));
ASSERT(!(fields & XFS_ILOG_DFORK) ||
@@ -538,8 +538,8 @@ xlog_recover_inode_commit_pass2(
} else {
attr_index = 2;
}
- len = item->ri_buf[attr_index].i_len;
- src = item->ri_buf[attr_index].i_addr;
+ len = item->ri_buf[attr_index].iov_len;
+ src = item->ri_buf[attr_index].iov_base;
ASSERT(len == xlog_calc_iovec_len(in_f->ilf_asize));
switch (in_f->ilf_fields & XFS_ILOG_AFORK) {
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 2f76531842f8..e6ed9e09c027 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2131,15 +2131,15 @@ xlog_recover_add_to_cont_trans(
item = list_entry(trans->r_itemq.prev, struct xlog_recover_item,
ri_list);
- old_ptr = item->ri_buf[item->ri_cnt-1].i_addr;
- old_len = item->ri_buf[item->ri_cnt-1].i_len;
+ old_ptr = item->ri_buf[item->ri_cnt-1].iov_base;
+ old_len = item->ri_buf[item->ri_cnt-1].iov_len;
ptr = kvrealloc(old_ptr, len + old_len, GFP_KERNEL);
if (!ptr)
return -ENOMEM;
memcpy(&ptr[old_len], dp, len);
- item->ri_buf[item->ri_cnt-1].i_len += len;
- item->ri_buf[item->ri_cnt-1].i_addr = ptr;
+ item->ri_buf[item->ri_cnt-1].iov_len += len;
+ item->ri_buf[item->ri_cnt-1].iov_base = ptr;
trace_xfs_log_recover_item_add_cont(log, trans, item, 0);
return 0;
}
@@ -2223,7 +2223,7 @@ xlog_recover_add_to_trans(
}
item->ri_total = in_f->ilf_size;
- item->ri_buf = kzalloc(item->ri_total * sizeof(xfs_log_iovec_t),
+ item->ri_buf = kcalloc(item->ri_total, sizeof(*item->ri_buf),
GFP_KERNEL | __GFP_NOFAIL);
}
@@ -2237,8 +2237,8 @@ xlog_recover_add_to_trans(
}
/* Description region is ri_buf[0] */
- item->ri_buf[item->ri_cnt].i_addr = ptr;
- item->ri_buf[item->ri_cnt].i_len = len;
+ item->ri_buf[item->ri_cnt].iov_base = ptr;
+ item->ri_buf[item->ri_cnt].iov_len = len;
item->ri_cnt++;
trace_xfs_log_recover_item_add(log, trans, item, 0);
return 0;
@@ -2262,7 +2262,7 @@ xlog_recover_free_trans(
/* Free the regions in the item. */
list_del(&item->ri_list);
for (i = 0; i < item->ri_cnt; i++)
- kvfree(item->ri_buf[i].i_addr);
+ kvfree(item->ri_buf[i].iov_base);
/* Free the item itself */
kfree(item->ri_buf);
kfree(item);
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index 076501123d89..3728234699a2 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -717,18 +717,18 @@ xlog_recover_cui_commit_pass2(
struct xfs_cui_log_format *cui_formatp;
size_t len;
- cui_formatp = item->ri_buf[0].i_addr;
+ cui_formatp = item->ri_buf[0].iov_base;
- if (item->ri_buf[0].i_len < xfs_cui_log_format_sizeof(0)) {
+ if (item->ri_buf[0].iov_len < xfs_cui_log_format_sizeof(0)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
len = xfs_cui_log_format_sizeof(cui_formatp->cui_nextents);
- if (item->ri_buf[0].i_len != len) {
+ if (item->ri_buf[0].iov_len != len) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
@@ -759,18 +759,18 @@ xlog_recover_rtcui_commit_pass2(
struct xfs_cui_log_format *cui_formatp;
size_t len;
- cui_formatp = item->ri_buf[0].i_addr;
+ cui_formatp = item->ri_buf[0].iov_base;
- if (item->ri_buf[0].i_len < xfs_cui_log_format_sizeof(0)) {
+ if (item->ri_buf[0].iov_len < xfs_cui_log_format_sizeof(0)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
len = xfs_cui_log_format_sizeof(cui_formatp->cui_nextents);
- if (item->ri_buf[0].i_len != len) {
+ if (item->ri_buf[0].iov_len != len) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
@@ -791,7 +791,7 @@ xlog_recover_rtcui_commit_pass2(
xfs_lsn_t lsn)
{
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
#endif
@@ -817,10 +817,10 @@ xlog_recover_cud_commit_pass2(
{
struct xfs_cud_log_format *cud_formatp;
- cud_formatp = item->ri_buf[0].i_addr;
- if (item->ri_buf[0].i_len != sizeof(struct xfs_cud_log_format)) {
+ cud_formatp = item->ri_buf[0].iov_base;
+ if (item->ri_buf[0].iov_len != sizeof(struct xfs_cud_log_format)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
@@ -843,10 +843,10 @@ xlog_recover_rtcud_commit_pass2(
{
struct xfs_cud_log_format *cud_formatp;
- cud_formatp = item->ri_buf[0].i_addr;
- if (item->ri_buf[0].i_len != sizeof(struct xfs_cud_log_format)) {
+ cud_formatp = item->ri_buf[0].iov_base;
+ if (item->ri_buf[0].iov_len != sizeof(struct xfs_cud_log_format)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index c99700318ec2..15f0903f6fd4 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -746,18 +746,18 @@ xlog_recover_rui_commit_pass2(
struct xfs_rui_log_format *rui_formatp;
size_t len;
- rui_formatp = item->ri_buf[0].i_addr;
+ rui_formatp = item->ri_buf[0].iov_base;
- if (item->ri_buf[0].i_len < xfs_rui_log_format_sizeof(0)) {
+ if (item->ri_buf[0].iov_len < xfs_rui_log_format_sizeof(0)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
len = xfs_rui_log_format_sizeof(rui_formatp->rui_nextents);
- if (item->ri_buf[0].i_len != len) {
+ if (item->ri_buf[0].iov_len != len) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
@@ -788,18 +788,18 @@ xlog_recover_rtrui_commit_pass2(
struct xfs_rui_log_format *rui_formatp;
size_t len;
- rui_formatp = item->ri_buf[0].i_addr;
+ rui_formatp = item->ri_buf[0].iov_base;
- if (item->ri_buf[0].i_len < xfs_rui_log_format_sizeof(0)) {
+ if (item->ri_buf[0].iov_len < xfs_rui_log_format_sizeof(0)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
len = xfs_rui_log_format_sizeof(rui_formatp->rui_nextents);
- if (item->ri_buf[0].i_len != len) {
+ if (item->ri_buf[0].iov_len != len) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
@@ -820,7 +820,7 @@ xlog_recover_rtrui_commit_pass2(
xfs_lsn_t lsn)
{
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
- item->ri_buf[0].i_addr, item->ri_buf[0].i_len);
+ item->ri_buf[0].iov_base, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
#endif
@@ -846,10 +846,10 @@ xlog_recover_rud_commit_pass2(
{
struct xfs_rud_log_format *rud_formatp;
- rud_formatp = item->ri_buf[0].i_addr;
- if (item->ri_buf[0].i_len != sizeof(struct xfs_rud_log_format)) {
+ rud_formatp = item->ri_buf[0].iov_base;
+ if (item->ri_buf[0].iov_len != sizeof(struct xfs_rud_log_format)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
- rud_formatp, item->ri_buf[0].i_len);
+ rud_formatp, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
@@ -872,10 +872,10 @@ xlog_recover_rtrud_commit_pass2(
{
struct xfs_rud_log_format *rud_formatp;
- rud_formatp = item->ri_buf[0].i_addr;
- if (item->ri_buf[0].i_len != sizeof(struct xfs_rud_log_format)) {
+ rud_formatp = item->ri_buf[0].iov_base;
+ if (item->ri_buf[0].iov_len != sizeof(struct xfs_rud_log_format)) {
XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, log->l_mp,
- rud_formatp, item->ri_buf[0].i_len);
+ rud_formatp, item->ri_buf[0].iov_len);
return -EFSCORRUPTED;
}
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index 2b366851e9a4..fa1724b4690e 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -15,7 +15,6 @@ struct xfs_efd_log_item;
struct xfs_efi_log_item;
struct xfs_inode;
struct xfs_item_ops;
-struct xfs_log_iovec;
struct xfs_mount;
struct xfs_trans;
struct xfs_trans_res;
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 06/18] xfs: add a xlog_write_one_vec helper
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (4 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 05/18] xfs: don't use a xfs_log_iovec for ri_buf in log recovery Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 07/18] xfs: set lv_bytes in xlog_write_one_vec Christoph Hellwig
` (11 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Add a wrapper for xlog_write for the two callers who need to build a
log_vec and add it to a single-entry chain instead of duplicating the
code.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_log.c | 35 +++++++++++++++++++++--------------
fs/xfs/xfs_log_cil.c | 11 +----------
fs/xfs/xfs_log_priv.h | 2 ++
3 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 3179923a68d4..96807140df73 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -848,6 +848,26 @@ xlog_wait_on_iclog(
return 0;
}
+int
+xlog_write_one_vec(
+ struct xlog *log,
+ struct xfs_cil_ctx *ctx,
+ struct xfs_log_iovec *reg,
+ struct xlog_ticket *ticket)
+{
+ struct xfs_log_vec lv = {
+ .lv_niovecs = 1,
+ .lv_iovecp = reg,
+ };
+ LIST_HEAD (lv_chain);
+
+ /* account for space used by record data */
+ ticket->t_curr_res -= reg->i_len;
+
+ list_add(&lv.lv_list, &lv_chain);
+ return xlog_write(log, ctx, &lv_chain, ticket, reg->i_len);
+}
+
/*
* Write out an unmount record using the ticket provided. We have to account for
* the data space used in the unmount ticket as this write is not done from a
@@ -876,21 +896,8 @@ xlog_write_unmount_record(
.i_len = sizeof(unmount_rec),
.i_type = XLOG_REG_TYPE_UNMOUNT,
};
- struct xfs_log_vec vec = {
- .lv_niovecs = 1,
- .lv_iovecp = ®,
- };
- LIST_HEAD(lv_chain);
- list_add(&vec.lv_list, &lv_chain);
-
- BUILD_BUG_ON((sizeof(struct xlog_op_header) +
- sizeof(struct xfs_unmount_log_format)) !=
- sizeof(unmount_rec));
-
- /* account for space used by record data */
- ticket->t_curr_res -= sizeof(unmount_rec);
- return xlog_write(log, NULL, &lv_chain, ticket, reg.i_len);
+ return xlog_write_one_vec(log, NULL, ®, ticket);
}
/*
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index f443757e93c2..1ac2cd9a5a36 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -1098,13 +1098,7 @@ xlog_cil_write_commit_record(
.i_len = sizeof(struct xlog_op_header),
.i_type = XLOG_REG_TYPE_COMMIT,
};
- struct xfs_log_vec vec = {
- .lv_niovecs = 1,
- .lv_iovecp = ®,
- };
int error;
- LIST_HEAD(lv_chain);
- list_add(&vec.lv_list, &lv_chain);
if (xlog_is_shutdown(log))
return -EIO;
@@ -1112,10 +1106,7 @@ xlog_cil_write_commit_record(
error = xlog_cil_order_write(ctx->cil, ctx->sequence, _COMMIT_RECORD);
if (error)
return error;
-
- /* account for space used by record data */
- ctx->ticket->t_curr_res -= reg.i_len;
- error = xlog_write(log, ctx, &lv_chain, ctx->ticket, reg.i_len);
+ error = xlog_write_one_vec(log, ctx, ®, ctx->ticket);
if (error)
xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR);
return error;
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index 39a102cc1b43..463daf51da15 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -511,6 +511,8 @@ void xlog_print_trans(struct xfs_trans *);
int xlog_write(struct xlog *log, struct xfs_cil_ctx *ctx,
struct list_head *lv_chain, struct xlog_ticket *tic,
uint32_t len);
+int xlog_write_one_vec(struct xlog *log, struct xfs_cil_ctx *ctx,
+ struct xfs_log_iovec *reg, struct xlog_ticket *ticket);
void xfs_log_ticket_ungrant(struct xlog *log, struct xlog_ticket *ticket);
void xfs_log_ticket_regrant(struct xlog *log, struct xlog_ticket *ticket);
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 07/18] xfs: set lv_bytes in xlog_write_one_vec
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (5 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 06/18] xfs: add a xlog_write_one_vec helper Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 08/18] xfs: improve the ->iop_format interface Christoph Hellwig
` (10 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
lv_bytes is mostly just use by the CIL code, but has crept into the
low-level log writing code to decide on a full or partial iclog
write. Ensure it is valid even for the special log writes that don't
go through the CIL by initializing it in xlog_write_one_vec.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_log.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 96807140df73..2e2e1202e5bd 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -858,14 +858,15 @@ xlog_write_one_vec(
struct xfs_log_vec lv = {
.lv_niovecs = 1,
.lv_iovecp = reg,
+ .lv_bytes = reg->i_len,
};
LIST_HEAD (lv_chain);
/* account for space used by record data */
- ticket->t_curr_res -= reg->i_len;
+ ticket->t_curr_res -= lv.lv_bytes;
list_add(&lv.lv_list, &lv_chain);
- return xlog_write(log, ctx, &lv_chain, ticket, reg->i_len);
+ return xlog_write(log, ctx, &lv_chain, ticket, lv.lv_bytes);
}
/*
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 08/18] xfs: improve the ->iop_format interface
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (6 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 07/18] xfs: set lv_bytes in xlog_write_one_vec Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 09/18] xfs: move struct xfs_log_iovec to xfs_log_priv.h Christoph Hellwig
` (9 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Export a higher level interface to format log items. The xlog_format_buf
structure is hidden inside xfs_log_cil.c and only accessed using two
helpers (and a wrapper build on top), hiding details of log iovecs from
the log items. This also allows simply using an index into lv_iovecp
instead of keeping a cursor vec.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_attr_item.c | 27 +++++-----
fs/xfs/xfs_bmap_item.c | 10 ++--
fs/xfs/xfs_buf_item.c | 19 +++----
fs/xfs/xfs_dquot_item.c | 9 ++--
fs/xfs/xfs_exchmaps_item.c | 11 ++--
fs/xfs/xfs_extfree_item.c | 10 ++--
fs/xfs/xfs_icreate_item.c | 6 +--
fs/xfs/xfs_inode_item.c | 49 +++++++++---------
fs/xfs/xfs_log.c | 56 ---------------------
fs/xfs/xfs_log.h | 53 ++++----------------
fs/xfs/xfs_log_cil.c | 100 ++++++++++++++++++++++++++++++++++++-
fs/xfs/xfs_refcount_item.c | 10 ++--
fs/xfs/xfs_rmap_item.c | 10 ++--
fs/xfs/xfs_trans.h | 4 +-
14 files changed, 180 insertions(+), 194 deletions(-)
diff --git a/fs/xfs/xfs_attr_item.c b/fs/xfs/xfs_attr_item.c
index bc970aa6832f..932c9dbb9ab6 100644
--- a/fs/xfs/xfs_attr_item.c
+++ b/fs/xfs/xfs_attr_item.c
@@ -192,10 +192,9 @@ xfs_attri_item_size(
STATIC void
xfs_attri_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_attri_log_item *attrip = ATTRI_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
struct xfs_attri_log_nameval *nv = attrip->attri_nameval;
attrip->attri_format.alfi_type = XFS_LI_ATTRI;
@@ -220,24 +219,23 @@ xfs_attri_item_format(
if (nv->new_value.iov_len > 0)
attrip->attri_format.alfi_size++;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRI_FORMAT,
- &attrip->attri_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_ATTRI_FORMAT, &attrip->attri_format,
sizeof(struct xfs_attri_log_format));
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NAME, nv->name.iov_base,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_ATTR_NAME, nv->name.iov_base,
nv->name.iov_len);
if (nv->new_name.iov_len > 0)
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NEWNAME,
- nv->new_name.iov_base, nv->new_name.iov_len);
+ xlog_format_copy(lfb, XLOG_REG_TYPE_ATTR_NEWNAME,
+ nv->new_name.iov_base, nv->new_name.iov_len);
if (nv->value.iov_len > 0)
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_VALUE,
- nv->value.iov_base, nv->value.iov_len);
+ xlog_format_copy(lfb, XLOG_REG_TYPE_ATTR_VALUE,
+ nv->value.iov_base, nv->value.iov_len);
if (nv->new_value.iov_len > 0)
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTR_NEWVALUE,
- nv->new_value.iov_base, nv->new_value.iov_len);
+ xlog_format_copy(lfb, XLOG_REG_TYPE_ATTR_NEWVALUE,
+ nv->new_value.iov_base, nv->new_value.iov_len);
}
/*
@@ -322,16 +320,15 @@ xfs_attrd_item_size(
*/
STATIC void
xfs_attrd_item_format(
- struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xfs_log_item *lip,
+ struct xlog_format_buf *lfb)
{
struct xfs_attrd_log_item *attrdp = ATTRD_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
attrdp->attrd_format.alfd_type = XFS_LI_ATTRD;
attrdp->attrd_format.alfd_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ATTRD_FORMAT,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_ATTRD_FORMAT,
&attrdp->attrd_format,
sizeof(struct xfs_attrd_log_format));
}
diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index 80f0c4bcc483..f38ed63fe86b 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -92,10 +92,9 @@ unsigned int xfs_bui_log_space(unsigned int nr)
STATIC void
xfs_bui_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_bui_log_item *buip = BUI_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
ASSERT(atomic_read(&buip->bui_next_extent) ==
buip->bui_format.bui_nextents);
@@ -103,7 +102,7 @@ xfs_bui_item_format(
buip->bui_format.bui_type = XFS_LI_BUI;
buip->bui_format.bui_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_BUI_FORMAT, &buip->bui_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_BUI_FORMAT, &buip->bui_format,
xfs_bui_log_format_sizeof(buip->bui_format.bui_nextents));
}
@@ -188,15 +187,14 @@ unsigned int xfs_bud_log_space(void)
STATIC void
xfs_bud_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_bud_log_item *budp = BUD_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
budp->bud_format.bud_type = XFS_LI_BUD;
budp->bud_format.bud_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_BUD_FORMAT, &budp->bud_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_BUD_FORMAT, &budp->bud_format,
sizeof(struct xfs_bud_log_format));
}
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index 8d85b5eee444..c998983ade64 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -263,24 +263,21 @@ xfs_buf_item_size(
static inline void
xfs_buf_item_copy_iovec(
- struct xfs_log_vec *lv,
- struct xfs_log_iovec **vecp,
+ struct xlog_format_buf *lfb,
struct xfs_buf *bp,
uint offset,
int first_bit,
uint nbits)
{
offset += first_bit * XFS_BLF_CHUNK;
- xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_BCHUNK,
- xfs_buf_offset(bp, offset),
+ xlog_format_copy(lfb, XLOG_REG_TYPE_BCHUNK, xfs_buf_offset(bp, offset),
nbits * XFS_BLF_CHUNK);
}
static void
xfs_buf_item_format_segment(
struct xfs_buf_log_item *bip,
- struct xfs_log_vec *lv,
- struct xfs_log_iovec **vecp,
+ struct xlog_format_buf *lfb,
uint offset,
struct xfs_buf_log_format *blfp)
{
@@ -308,7 +305,7 @@ xfs_buf_item_format_segment(
return;
}
- blfp = xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_BFORMAT, blfp, base_size);
+ blfp = xlog_format_copy(lfb, XLOG_REG_TYPE_BFORMAT, blfp, base_size);
blfp->blf_size = 1;
if (bip->bli_flags & XFS_BLI_STALE) {
@@ -331,8 +328,7 @@ xfs_buf_item_format_segment(
nbits = xfs_contig_bits(blfp->blf_data_map,
blfp->blf_map_size, first_bit);
ASSERT(nbits > 0);
- xfs_buf_item_copy_iovec(lv, vecp, bp, offset,
- first_bit, nbits);
+ xfs_buf_item_copy_iovec(lfb, bp, offset, first_bit, nbits);
blfp->blf_size++;
/*
@@ -357,11 +353,10 @@ xfs_buf_item_format_segment(
STATIC void
xfs_buf_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_buf_log_item *bip = BUF_ITEM(lip);
struct xfs_buf *bp = bip->bli_buf;
- struct xfs_log_iovec *vecp = NULL;
uint offset = 0;
int i;
@@ -398,7 +393,7 @@ xfs_buf_item_format(
}
for (i = 0; i < bip->bli_format_count; i++) {
- xfs_buf_item_format_segment(bip, lv, &vecp, offset,
+ xfs_buf_item_format_segment(bip, lfb, offset,
&bip->bli_formats[i]);
offset += BBTOB(bp->b_maps[i].bm_len);
}
diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index 271b195ebb93..9c2fcfbdf7dc 100644
--- a/fs/xfs/xfs_dquot_item.c
+++ b/fs/xfs/xfs_dquot_item.c
@@ -44,25 +44,24 @@ xfs_qm_dquot_logitem_size(
STATIC void
xfs_qm_dquot_logitem_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_disk_dquot ddq;
struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
struct xfs_dq_logformat *qlf;
- qlf = xlog_prepare_iovec(lv, &vecp, XLOG_REG_TYPE_QFORMAT);
+ qlf = xlog_format_start(lfb, XLOG_REG_TYPE_QFORMAT);
qlf->qlf_type = XFS_LI_DQUOT;
qlf->qlf_size = 2;
qlf->qlf_id = qlip->qli_dquot->q_id;
qlf->qlf_blkno = qlip->qli_dquot->q_blkno;
qlf->qlf_len = 1;
qlf->qlf_boffset = qlip->qli_dquot->q_bufoffset;
- xlog_finish_iovec(lv, vecp, sizeof(struct xfs_dq_logformat));
+ xlog_format_commit(lfb, sizeof(struct xfs_dq_logformat));
xfs_dquot_to_disk(&ddq, qlip->qli_dquot);
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_DQUOT, &ddq,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_DQUOT, &ddq,
sizeof(struct xfs_disk_dquot));
}
diff --git a/fs/xfs/xfs_exchmaps_item.c b/fs/xfs/xfs_exchmaps_item.c
index 229cbe0adf17..10d6fbeff651 100644
--- a/fs/xfs/xfs_exchmaps_item.c
+++ b/fs/xfs/xfs_exchmaps_item.c
@@ -83,16 +83,14 @@ xfs_xmi_item_size(
STATIC void
xfs_xmi_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_xmi_log_item *xmi_lip = XMI_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
xmi_lip->xmi_format.xmi_type = XFS_LI_XMI;
xmi_lip->xmi_format.xmi_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_XMI_FORMAT,
- &xmi_lip->xmi_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_XMI_FORMAT, &xmi_lip->xmi_format,
sizeof(struct xfs_xmi_log_format));
}
@@ -166,15 +164,14 @@ xfs_xmd_item_size(
STATIC void
xfs_xmd_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_xmd_log_item *xmd_lip = XMD_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
xmd_lip->xmd_format.xmd_type = XFS_LI_XMD;
xmd_lip->xmd_format.xmd_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_XMD_FORMAT, &xmd_lip->xmd_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_XMD_FORMAT, &xmd_lip->xmd_format,
sizeof(struct xfs_xmd_log_format));
}
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 47ee598a9827..750557641604 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -98,10 +98,9 @@ unsigned int xfs_efi_log_space(unsigned int nr)
STATIC void
xfs_efi_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_efi_log_item *efip = EFI_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
ASSERT(atomic_read(&efip->efi_next_extent) ==
efip->efi_format.efi_nextents);
@@ -110,7 +109,7 @@ xfs_efi_item_format(
efip->efi_format.efi_type = lip->li_type;
efip->efi_format.efi_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_EFI_FORMAT, &efip->efi_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_EFI_FORMAT, &efip->efi_format,
xfs_efi_log_format_sizeof(efip->efi_format.efi_nextents));
}
@@ -277,10 +276,9 @@ unsigned int xfs_efd_log_space(unsigned int nr)
STATIC void
xfs_efd_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_efd_log_item *efdp = EFD_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
ASSERT(efdp->efd_next_extent == efdp->efd_format.efd_nextents);
ASSERT(lip->li_type == XFS_LI_EFD || lip->li_type == XFS_LI_EFD_RT);
@@ -288,7 +286,7 @@ xfs_efd_item_format(
efdp->efd_format.efd_type = lip->li_type;
efdp->efd_format.efd_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_EFD_FORMAT, &efdp->efd_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_EFD_FORMAT, &efdp->efd_format,
xfs_efd_log_format_sizeof(efdp->efd_format.efd_nextents));
}
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index f83ec2bd0583..004dd22393dc 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -49,13 +49,11 @@ xfs_icreate_item_size(
STATIC void
xfs_icreate_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_icreate_item *icp = ICR_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_ICREATE,
- &icp->ic_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_ICREATE, &icp->ic_format,
sizeof(struct xfs_icreate_log));
}
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 829675700fcd..5558befd9741 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -346,8 +346,7 @@ STATIC void
xfs_inode_item_format_data_fork(
struct xfs_inode_log_item *iip,
struct xfs_inode_log_format *ilf,
- struct xfs_log_vec *lv,
- struct xfs_log_iovec **vecp)
+ struct xlog_format_buf *lfb)
{
struct xfs_inode *ip = iip->ili_inode;
size_t data_bytes;
@@ -364,9 +363,9 @@ xfs_inode_item_format_data_fork(
ASSERT(xfs_iext_count(&ip->i_df) > 0);
- p = xlog_prepare_iovec(lv, vecp, XLOG_REG_TYPE_IEXT);
+ p = xlog_format_start(lfb, XLOG_REG_TYPE_IEXT);
data_bytes = xfs_iextents_copy(ip, p, XFS_DATA_FORK);
- xlog_finish_iovec(lv, *vecp, data_bytes);
+ xlog_format_commit(lfb, data_bytes);
ASSERT(data_bytes <= ip->i_df.if_bytes);
@@ -384,7 +383,7 @@ xfs_inode_item_format_data_fork(
if ((iip->ili_fields & XFS_ILOG_DBROOT) &&
ip->i_df.if_broot_bytes > 0) {
ASSERT(ip->i_df.if_broot != NULL);
- xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_IBROOT,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_IBROOT,
ip->i_df.if_broot,
ip->i_df.if_broot_bytes);
ilf->ilf_dsize = ip->i_df.if_broot_bytes;
@@ -402,8 +401,9 @@ xfs_inode_item_format_data_fork(
ip->i_df.if_bytes > 0) {
ASSERT(ip->i_df.if_data != NULL);
ASSERT(ip->i_disk_size > 0);
- xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_ILOCAL,
- ip->i_df.if_data, ip->i_df.if_bytes);
+ xlog_format_copy(lfb, XLOG_REG_TYPE_ILOCAL,
+ ip->i_df.if_data,
+ ip->i_df.if_bytes);
ilf->ilf_dsize = (unsigned)ip->i_df.if_bytes;
ilf->ilf_size++;
} else {
@@ -426,8 +426,7 @@ STATIC void
xfs_inode_item_format_attr_fork(
struct xfs_inode_log_item *iip,
struct xfs_inode_log_format *ilf,
- struct xfs_log_vec *lv,
- struct xfs_log_iovec **vecp)
+ struct xlog_format_buf *lfb)
{
struct xfs_inode *ip = iip->ili_inode;
size_t data_bytes;
@@ -445,9 +444,9 @@ xfs_inode_item_format_attr_fork(
ASSERT(xfs_iext_count(&ip->i_af) ==
ip->i_af.if_nextents);
- p = xlog_prepare_iovec(lv, vecp, XLOG_REG_TYPE_IATTR_EXT);
+ p = xlog_format_start(lfb, XLOG_REG_TYPE_IATTR_EXT);
data_bytes = xfs_iextents_copy(ip, p, XFS_ATTR_FORK);
- xlog_finish_iovec(lv, *vecp, data_bytes);
+ xlog_format_commit(lfb, data_bytes);
ilf->ilf_asize = data_bytes;
ilf->ilf_size++;
@@ -463,7 +462,7 @@ xfs_inode_item_format_attr_fork(
ip->i_af.if_broot_bytes > 0) {
ASSERT(ip->i_af.if_broot != NULL);
- xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_IATTR_BROOT,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_IATTR_BROOT,
ip->i_af.if_broot,
ip->i_af.if_broot_bytes);
ilf->ilf_asize = ip->i_af.if_broot_bytes;
@@ -479,8 +478,9 @@ xfs_inode_item_format_attr_fork(
if ((iip->ili_fields & XFS_ILOG_ADATA) &&
ip->i_af.if_bytes > 0) {
ASSERT(ip->i_af.if_data != NULL);
- xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_IATTR_LOCAL,
- ip->i_af.if_data, ip->i_af.if_bytes);
+ xlog_format_copy(lfb, XLOG_REG_TYPE_IATTR_LOCAL,
+ ip->i_af.if_data,
+ ip->i_af.if_bytes);
ilf->ilf_asize = (unsigned)ip->i_af.if_bytes;
ilf->ilf_size++;
} else {
@@ -629,14 +629,13 @@ xfs_inode_to_log_dinode(
static void
xfs_inode_item_format_core(
struct xfs_inode *ip,
- struct xfs_log_vec *lv,
- struct xfs_log_iovec **vecp)
+ struct xlog_format_buf *lfb)
{
struct xfs_log_dinode *dic;
- dic = xlog_prepare_iovec(lv, vecp, XLOG_REG_TYPE_ICORE);
+ dic = xlog_format_start(lfb, XLOG_REG_TYPE_ICORE);
xfs_inode_to_log_dinode(ip, dic, ip->i_itemp->ili_item.li_lsn);
- xlog_finish_iovec(lv, *vecp, xfs_log_dinode_size(ip->i_mount));
+ xlog_format_commit(lfb, xfs_log_dinode_size(ip->i_mount));
}
/*
@@ -654,14 +653,13 @@ xfs_inode_item_format_core(
STATIC void
xfs_inode_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_inode_log_item *iip = INODE_ITEM(lip);
struct xfs_inode *ip = iip->ili_inode;
- struct xfs_log_iovec *vecp = NULL;
struct xfs_inode_log_format *ilf;
- ilf = xlog_prepare_iovec(lv, &vecp, XLOG_REG_TYPE_IFORMAT);
+ ilf = xlog_format_start(lfb, XLOG_REG_TYPE_IFORMAT);
ilf->ilf_type = XFS_LI_INODE;
ilf->ilf_ino = ip->i_ino;
ilf->ilf_blkno = ip->i_imap.im_blkno;
@@ -678,13 +676,12 @@ xfs_inode_item_format(
ilf->ilf_asize = 0;
ilf->ilf_pad = 0;
memset(&ilf->ilf_u, 0, sizeof(ilf->ilf_u));
+ xlog_format_commit(lfb, sizeof(*ilf));
- xlog_finish_iovec(lv, vecp, sizeof(*ilf));
-
- xfs_inode_item_format_core(ip, lv, &vecp);
- xfs_inode_item_format_data_fork(iip, ilf, lv, &vecp);
+ xfs_inode_item_format_core(ip, lfb);
+ xfs_inode_item_format_data_fork(iip, ilf, lfb);
if (xfs_inode_has_attr_fork(ip)) {
- xfs_inode_item_format_attr_fork(iip, ilf, lv, &vecp);
+ xfs_inode_item_format_attr_fork(iip, ilf, lfb);
} else {
iip->ili_fields &=
~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT);
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 2e2e1202e5bd..621d22328622 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -74,62 +74,6 @@ xlog_iclogs_empty(
static int
xfs_log_cover(struct xfs_mount *);
-/*
- * We need to make sure the buffer pointer returned is naturally aligned for the
- * biggest basic data type we put into it. We have already accounted for this
- * padding when sizing the buffer.
- *
- * However, this padding does not get written into the log, and hence we have to
- * track the space used by the log vectors separately to prevent log space hangs
- * due to inaccurate accounting (i.e. a leak) of the used log space through the
- * CIL context ticket.
- *
- * We also add space for the xlog_op_header that describes this region in the
- * log. This prepends the data region we return to the caller to copy their data
- * into, so do all the static initialisation of the ophdr now. Because the ophdr
- * is not 8 byte aligned, we have to be careful to ensure that we align the
- * start of the buffer such that the region we return to the call is 8 byte
- * aligned and packed against the tail of the ophdr.
- */
-void *
-xlog_prepare_iovec(
- struct xfs_log_vec *lv,
- struct xfs_log_iovec **vecp,
- uint type)
-{
- struct xfs_log_iovec *vec = *vecp;
- struct xlog_op_header *oph;
- uint32_t len;
- void *buf;
-
- if (vec) {
- ASSERT(vec - lv->lv_iovecp < lv->lv_niovecs);
- vec++;
- } else {
- vec = &lv->lv_iovecp[0];
- }
-
- len = lv->lv_buf_used + sizeof(struct xlog_op_header);
- if (!IS_ALIGNED(len, sizeof(uint64_t))) {
- lv->lv_buf_used = round_up(len, sizeof(uint64_t)) -
- sizeof(struct xlog_op_header);
- }
-
- vec->i_type = type;
- vec->i_addr = lv->lv_buf + lv->lv_buf_used;
-
- oph = vec->i_addr;
- oph->oh_clientid = XFS_TRANSACTION;
- oph->oh_res2 = 0;
- oph->oh_flags = 0;
-
- buf = vec->i_addr + sizeof(struct xlog_op_header);
- ASSERT(IS_ALIGNED((unsigned long)buf, sizeof(uint64_t)));
-
- *vecp = vec;
- return buf;
-}
-
static inline void
xlog_grant_sub_space(
struct xlog_grant_head *head,
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index af6daf4f6792..110f02690f85 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -6,6 +6,7 @@
#ifndef __XFS_LOG_H__
#define __XFS_LOG_H__
+struct xlog_format_buf;
struct xfs_cil_ctx;
struct xfs_log_vec {
@@ -33,58 +34,24 @@ xlog_calc_iovec_len(int len)
return roundup(len, sizeof(uint32_t));
}
-void *xlog_prepare_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
- uint type);
-
-static inline void
-xlog_finish_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec *vec,
- int data_len)
-{
- struct xlog_op_header *oph = vec->i_addr;
- int len;
-
- /*
- * Always round up the length to the correct alignment so callers don't
- * need to know anything about this log vec layout requirement. This
- * means we have to zero the area the data to be written does not cover.
- * This is complicated by fact the payload region is offset into the
- * logvec region by the opheader that tracks the payload.
- */
- len = xlog_calc_iovec_len(data_len);
- if (len - data_len != 0) {
- char *buf = vec->i_addr + sizeof(struct xlog_op_header);
-
- memset(buf + data_len, 0, len - data_len);
- }
-
- /*
- * The opheader tracks aligned payload length, whilst the logvec tracks
- * the overall region length.
- */
- oph->oh_len = cpu_to_be32(len);
-
- len += sizeof(struct xlog_op_header);
- lv->lv_buf_used += len;
- lv->lv_bytes += len;
- vec->i_len = len;
-
- /* Catch buffer overruns */
- ASSERT((void *)lv->lv_buf + lv->lv_bytes <=
- (void *)lv + lv->lv_alloc_size);
-}
+void *xlog_format_start(struct xlog_format_buf *lfb, uint16_t type);
+void xlog_format_commit(struct xlog_format_buf *lfb, unsigned int data_len);
/*
* Copy the amount of data requested by the caller into a new log iovec.
*/
static inline void *
-xlog_copy_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec **vecp,
- uint type, void *data, int len)
+xlog_format_copy(
+ struct xlog_format_buf *lfb,
+ uint16_t type,
+ void *data,
+ unsigned int len)
{
void *buf;
- buf = xlog_prepare_iovec(lv, vecp, type);
+ buf = xlog_format_start(lfb, type);
memcpy(buf, data, len);
- xlog_finish_iovec(lv, *vecp, len);
+ xlog_format_commit(lfb, len);
return buf;
}
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c
index 1ac2cd9a5a36..3be2e6b097a8 100644
--- a/fs/xfs/xfs_log_cil.c
+++ b/fs/xfs/xfs_log_cil.c
@@ -409,6 +409,102 @@ xfs_cil_prepare_item(
lv->lv_item->li_seq = log->l_cilp->xc_ctx->sequence;
}
+struct xlog_format_buf {
+ struct xfs_log_vec *lv;
+ unsigned int idx;
+};
+
+/*
+ * We need to make sure the buffer pointer returned is naturally aligned for the
+ * biggest basic data type we put into it. We have already accounted for this
+ * padding when sizing the buffer.
+ *
+ * However, this padding does not get written into the log, and hence we have to
+ * track the space used by the log vectors separately to prevent log space hangs
+ * due to inaccurate accounting (i.e. a leak) of the used log space through the
+ * CIL context ticket.
+ *
+ * We also add space for the xlog_op_header that describes this region in the
+ * log. This prepends the data region we return to the caller to copy their data
+ * into, so do all the static initialisation of the ophdr now. Because the ophdr
+ * is not 8 byte aligned, we have to be careful to ensure that we align the
+ * start of the buffer such that the region we return to the call is 8 byte
+ * aligned and packed against the tail of the ophdr.
+ */
+void *
+xlog_format_start(
+ struct xlog_format_buf *lfb,
+ uint16_t type)
+{
+ struct xfs_log_vec *lv = lfb->lv;
+ struct xfs_log_iovec *vec = &lv->lv_iovecp[lfb->idx];
+ struct xlog_op_header *oph;
+ uint32_t len;
+ void *buf;
+
+ ASSERT(lfb->idx < lv->lv_niovecs);
+
+ len = lv->lv_buf_used + sizeof(struct xlog_op_header);
+ if (!IS_ALIGNED(len, sizeof(uint64_t))) {
+ lv->lv_buf_used = round_up(len, sizeof(uint64_t)) -
+ sizeof(struct xlog_op_header);
+ }
+
+ vec->i_type = type;
+ vec->i_addr = lv->lv_buf + lv->lv_buf_used;
+
+ oph = vec->i_addr;
+ oph->oh_clientid = XFS_TRANSACTION;
+ oph->oh_res2 = 0;
+ oph->oh_flags = 0;
+
+ buf = vec->i_addr + sizeof(struct xlog_op_header);
+ ASSERT(IS_ALIGNED((unsigned long)buf, sizeof(uint64_t)));
+ return buf;
+}
+
+void
+xlog_format_commit(
+ struct xlog_format_buf *lfb,
+ unsigned int data_len)
+{
+ struct xfs_log_vec *lv = lfb->lv;
+ struct xfs_log_iovec *vec = &lv->lv_iovecp[lfb->idx];
+ struct xlog_op_header *oph = vec->i_addr;
+ int len;
+
+ /*
+ * Always round up the length to the correct alignment so callers don't
+ * need to know anything about this log vec layout requirement. This
+ * means we have to zero the area the data to be written does not cover.
+ * This is complicated by fact the payload region is offset into the
+ * logvec region by the opheader that tracks the payload.
+ */
+ len = xlog_calc_iovec_len(data_len);
+ if (len - data_len != 0) {
+ char *buf = vec->i_addr + sizeof(struct xlog_op_header);
+
+ memset(buf + data_len, 0, len - data_len);
+ }
+
+ /*
+ * The opheader tracks aligned payload length, whilst the logvec tracks
+ * the overall region length.
+ */
+ oph->oh_len = cpu_to_be32(len);
+
+ len += sizeof(struct xlog_op_header);
+ lv->lv_buf_used += len;
+ lv->lv_bytes += len;
+ vec->i_len = len;
+
+ /* Catch buffer overruns */
+ ASSERT((void *)lv->lv_buf + lv->lv_bytes <=
+ (void *)lv + lv->lv_alloc_size);
+
+ lfb->idx++;
+}
+
/*
* Format log item into a flat buffers
*
@@ -454,6 +550,7 @@ xlog_cil_insert_format_items(
list_for_each_entry(lip, &tp->t_items, li_trans) {
struct xfs_log_vec *lv = lip->li_lv;
struct xfs_log_vec *shadow = lip->li_lv_shadow;
+ struct xlog_format_buf lfb = { };
/* Skip items which aren't dirty in this transaction. */
if (!test_bit(XFS_LI_DIRTY, &lip->li_flags))
@@ -501,8 +598,9 @@ xlog_cil_insert_format_items(
lv->lv_item = lip;
}
+ lfb.lv = lv;
ASSERT(IS_ALIGNED((unsigned long)lv->lv_buf, sizeof(uint64_t)));
- lip->li_ops->iop_format(lip, lv);
+ lip->li_ops->iop_format(lip, &lfb);
xfs_cil_prepare_item(log, lip, lv, diff_len);
}
}
diff --git a/fs/xfs/xfs_refcount_item.c b/fs/xfs/xfs_refcount_item.c
index 3728234699a2..a41f5b577e22 100644
--- a/fs/xfs/xfs_refcount_item.c
+++ b/fs/xfs/xfs_refcount_item.c
@@ -93,10 +93,9 @@ unsigned int xfs_cui_log_space(unsigned int nr)
STATIC void
xfs_cui_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_cui_log_item *cuip = CUI_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
ASSERT(atomic_read(&cuip->cui_next_extent) ==
cuip->cui_format.cui_nextents);
@@ -105,7 +104,7 @@ xfs_cui_item_format(
cuip->cui_format.cui_type = lip->li_type;
cuip->cui_format.cui_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_CUI_FORMAT, &cuip->cui_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_CUI_FORMAT, &cuip->cui_format,
xfs_cui_log_format_sizeof(cuip->cui_format.cui_nextents));
}
@@ -199,17 +198,16 @@ unsigned int xfs_cud_log_space(void)
STATIC void
xfs_cud_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_cud_log_item *cudp = CUD_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
ASSERT(lip->li_type == XFS_LI_CUD || lip->li_type == XFS_LI_CUD_RT);
cudp->cud_format.cud_type = lip->li_type;
cudp->cud_format.cud_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_CUD_FORMAT, &cudp->cud_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_CUD_FORMAT, &cudp->cud_format,
sizeof(struct xfs_cud_log_format));
}
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c
index 15f0903f6fd4..8bf04b101156 100644
--- a/fs/xfs/xfs_rmap_item.c
+++ b/fs/xfs/xfs_rmap_item.c
@@ -92,10 +92,9 @@ unsigned int xfs_rui_log_space(unsigned int nr)
STATIC void
xfs_rui_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_rui_log_item *ruip = RUI_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
ASSERT(atomic_read(&ruip->rui_next_extent) ==
ruip->rui_format.rui_nextents);
@@ -105,7 +104,7 @@ xfs_rui_item_format(
ruip->rui_format.rui_type = lip->li_type;
ruip->rui_format.rui_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_RUI_FORMAT, &ruip->rui_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_RUI_FORMAT, &ruip->rui_format,
xfs_rui_log_format_sizeof(ruip->rui_format.rui_nextents));
}
@@ -200,17 +199,16 @@ unsigned int xfs_rud_log_space(void)
STATIC void
xfs_rud_item_format(
struct xfs_log_item *lip,
- struct xfs_log_vec *lv)
+ struct xlog_format_buf *lfb)
{
struct xfs_rud_log_item *rudp = RUD_ITEM(lip);
- struct xfs_log_iovec *vecp = NULL;
ASSERT(lip->li_type == XFS_LI_RUD || lip->li_type == XFS_LI_RUD_RT);
rudp->rud_format.rud_type = lip->li_type;
rudp->rud_format.rud_size = 1;
- xlog_copy_iovec(lv, &vecp, XLOG_REG_TYPE_RUD_FORMAT, &rudp->rud_format,
+ xlog_format_copy(lfb, XLOG_REG_TYPE_RUD_FORMAT, &rudp->rud_format,
sizeof(struct xfs_rud_log_format));
}
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index fa1724b4690e..20ed112850d3 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -9,6 +9,7 @@
/* kernel only transaction subsystem defines */
struct xlog;
+struct xlog_format_buf;
struct xfs_buf;
struct xfs_buftarg;
struct xfs_efd_log_item;
@@ -70,7 +71,8 @@ struct xfs_log_item {
struct xfs_item_ops {
unsigned flags;
void (*iop_size)(struct xfs_log_item *, int *, int *);
- void (*iop_format)(struct xfs_log_item *, struct xfs_log_vec *);
+ void (*iop_format)(struct xfs_log_item *lip,
+ struct xlog_format_buf *lfb);
void (*iop_pin)(struct xfs_log_item *);
void (*iop_unpin)(struct xfs_log_item *, int remove);
uint64_t (*iop_sort)(struct xfs_log_item *lip);
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 09/18] xfs: move struct xfs_log_iovec to xfs_log_priv.h
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (7 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 08/18] xfs: improve the ->iop_format interface Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 10/18] xfs: move struct xfs_log_vec " Christoph Hellwig
` (8 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
This structure is now only used by the core logging and CIL code.
Also remove the unused typedef.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_log_format.h | 8 --------
fs/xfs/xfs_log_priv.h | 6 ++++++
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index 0d637c276db0..4f12664d1005 100644
--- a/fs/xfs/libxfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
@@ -194,14 +194,6 @@ typedef union xlog_in_core2 {
char hic_sector[XLOG_HEADER_SIZE];
} xlog_in_core_2_t;
-/* not an on-disk structure, but needed by log recovery in userspace */
-typedef struct xfs_log_iovec {
- void *i_addr; /* beginning address of region */
- int i_len; /* length in bytes of region */
- uint i_type; /* type of region */
-} xfs_log_iovec_t;
-
-
/*
* Transaction Header definitions.
*
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index 463daf51da15..fd6968ce7bd0 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -13,6 +13,12 @@ struct xlog;
struct xlog_ticket;
struct xfs_mount;
+struct xfs_log_iovec {
+ void *i_addr; /* beginning address of region */
+ int i_len; /* length in bytes of region */
+ uint i_type; /* type of region */
+};
+
/*
* get client id from packed copy.
*
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 10/18] xfs: move struct xfs_log_vec to xfs_log_priv.h
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (8 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 09/18] xfs: move struct xfs_log_iovec to xfs_log_priv.h Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 11/18] xfs: remove the xlog_op_header_t typedef Christoph Hellwig
` (7 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
The log_vec is a private type for the log/CIL code and should not be
exposed to anything else.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_log.h | 12 ------------
fs/xfs/xfs_log_priv.h | 12 ++++++++++++
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index 110f02690f85..780155839df4 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -9,18 +9,6 @@
struct xlog_format_buf;
struct xfs_cil_ctx;
-struct xfs_log_vec {
- struct list_head lv_list; /* CIL lv chain ptrs */
- uint32_t lv_order_id; /* chain ordering info */
- int lv_niovecs; /* number of iovecs in lv */
- struct xfs_log_iovec *lv_iovecp; /* iovec array */
- struct xfs_log_item *lv_item; /* owner */
- char *lv_buf; /* formatted buffer */
- int lv_bytes; /* accounted space in buffer */
- int lv_buf_used; /* buffer space used so far */
- int lv_alloc_size; /* size of allocated lv */
-};
-
#define XFS_LOG_VEC_ORDERED (-1)
/*
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index fd6968ce7bd0..7c298fba26e7 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -19,6 +19,18 @@ struct xfs_log_iovec {
uint i_type; /* type of region */
};
+struct xfs_log_vec {
+ struct list_head lv_list; /* CIL lv chain ptrs */
+ uint32_t lv_order_id; /* chain ordering info */
+ int lv_niovecs; /* number of iovecs in lv */
+ struct xfs_log_iovec *lv_iovecp; /* iovec array */
+ struct xfs_log_item *lv_item; /* owner */
+ char *lv_buf; /* formatted buffer */
+ int lv_bytes; /* accounted space in buffer */
+ int lv_buf_used; /* buffer space used so far */
+ int lv_alloc_size; /* size of allocated lv */
+};
+
/*
* get client id from packed copy.
*
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 11/18] xfs: remove the xlog_op_header_t typedef
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (9 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 10/18] xfs: move struct xfs_log_vec " Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 12/18] xfs: remove the xfs_trans_header_t typedef Christoph Hellwig
` (6 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Almost no users of the typedef left, kill it and switch the remaining
users to use the underlying struct.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_log_format.h | 5 ++---
fs/xfs/xfs_log.c | 17 +++++++++--------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index 4f12664d1005..6cdcc6eef539 100644
--- a/fs/xfs/libxfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
@@ -141,14 +141,13 @@ struct xfs_unmount_log_format {
#define XLOG_END_TRANS 0x10 /* End a continued transaction */
#define XLOG_UNMOUNT_TRANS 0x20 /* Unmount a filesystem transaction */
-
-typedef struct xlog_op_header {
+struct xlog_op_header {
__be32 oh_tid; /* transaction id of operation : 4 b */
__be32 oh_len; /* bytes in data region : 4 b */
__u8 oh_clientid; /* who sent me this : 1 b */
__u8 oh_flags; /* : 1 b */
__u16 oh_res2; /* 32 bit align : 2 b */
-} xlog_op_header_t;
+};
/* valid values for h_fmt */
#define XLOG_FMT_UNKNOWN 0
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 621d22328622..aa7a4c7ae49b 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -2608,10 +2608,11 @@ xlog_state_get_iclog_space(
* until you know exactly how many bytes get copied. Therefore, wait
* until later to update ic_offset.
*
- * xlog_write() algorithm assumes that at least 2 xlog_op_header_t's
+ * xlog_write() algorithm assumes that at least 2 xlog_op_header's
* can fit into remaining data section.
*/
- if (iclog->ic_size - iclog->ic_offset < 2*sizeof(xlog_op_header_t)) {
+ if (iclog->ic_size - iclog->ic_offset <
+ 2 * sizeof(struct xlog_op_header)) {
int error = 0;
xlog_state_switch_iclogs(log, iclog, iclog->ic_size);
@@ -3105,11 +3106,11 @@ xlog_calc_unit_res(
*/
/* for trans header */
- unit_bytes += sizeof(xlog_op_header_t);
+ unit_bytes += sizeof(struct xlog_op_header);
unit_bytes += sizeof(xfs_trans_header_t);
/* for start-rec */
- unit_bytes += sizeof(xlog_op_header_t);
+ unit_bytes += sizeof(struct xlog_op_header);
/*
* for LR headers - the space for data in an iclog is the size minus
@@ -3132,12 +3133,12 @@ xlog_calc_unit_res(
num_headers = howmany(unit_bytes, iclog_space);
/* for split-recs - ophdrs added when data split over LRs */
- unit_bytes += sizeof(xlog_op_header_t) * num_headers;
+ unit_bytes += sizeof(struct xlog_op_header) * num_headers;
/* add extra header reservations if we overrun */
while (!num_headers ||
howmany(unit_bytes, iclog_space) > num_headers) {
- unit_bytes += sizeof(xlog_op_header_t);
+ unit_bytes += sizeof(struct xlog_op_header);
num_headers++;
}
unit_bytes += log->l_iclog_hsize * num_headers;
@@ -3274,7 +3275,7 @@ xlog_verify_iclog(
struct xlog_in_core *iclog,
int count)
{
- xlog_op_header_t *ophead;
+ struct xlog_op_header *ophead;
xlog_in_core_t *icptr;
xlog_in_core_2_t *xhdr;
void *base_ptr, *ptr, *p;
@@ -3352,7 +3353,7 @@ xlog_verify_iclog(
op_len = be32_to_cpu(iclog->ic_header.h_cycle_data[idx]);
}
}
- ptr += sizeof(xlog_op_header_t) + op_len;
+ ptr += sizeof(struct xlog_op_header) + op_len;
}
}
#endif
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 12/18] xfs: remove the xfs_trans_header_t typedef
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (10 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 11/18] xfs: remove the xlog_op_header_t typedef Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 13/18] xfs: move the XLOG_REG_ constants out of xfs_log_format.h Christoph Hellwig
` (5 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Almost no users of the typedef left, kill it and switch the remaining
users to use the underlying struct.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_log_format.h | 4 ++--
fs/xfs/libxfs/xfs_log_recover.h | 2 +-
fs/xfs/xfs_log.c | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index 6cdcc6eef539..e5e6f8c0408f 100644
--- a/fs/xfs/libxfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
@@ -204,12 +204,12 @@ typedef union xlog_in_core2 {
* Do not change the below structure without redoing the code in
* xlog_recover_add_to_trans() and xlog_recover_add_to_cont_trans().
*/
-typedef struct xfs_trans_header {
+struct xfs_trans_header {
uint th_magic; /* magic number */
uint th_type; /* transaction type */
int32_t th_tid; /* transaction id (unused) */
uint th_num_items; /* num items logged by trans */
-} xfs_trans_header_t;
+};
#define XFS_TRANS_HEADER_MAGIC 0x5452414e /* TRAN */
diff --git a/fs/xfs/libxfs/xfs_log_recover.h b/fs/xfs/libxfs/xfs_log_recover.h
index 95de23095030..9e712e62369c 100644
--- a/fs/xfs/libxfs/xfs_log_recover.h
+++ b/fs/xfs/libxfs/xfs_log_recover.h
@@ -111,7 +111,7 @@ struct xlog_recover_item {
struct xlog_recover {
struct hlist_node r_list;
xlog_tid_t r_log_tid; /* log's transaction id */
- xfs_trans_header_t r_theader; /* trans header for partial */
+ struct xfs_trans_header r_theader; /* trans header for partial */
int r_state; /* not needed */
xfs_lsn_t r_lsn; /* xact lsn */
struct list_head r_itemq; /* q for items */
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index aa7a4c7ae49b..15fc7cac6da3 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -3107,7 +3107,7 @@ xlog_calc_unit_res(
/* for trans header */
unit_bytes += sizeof(struct xlog_op_header);
- unit_bytes += sizeof(xfs_trans_header_t);
+ unit_bytes += sizeof(struct xfs_trans_header);
/* for start-rec */
unit_bytes += sizeof(struct xlog_op_header);
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 13/18] xfs: move the XLOG_REG_ constants out of xfs_log_format.h
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (11 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 12/18] xfs: remove the xfs_trans_header_t typedef Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 14/18] xfs: regularize iclog space accounting in xlog_write_partial Christoph Hellwig
` (4 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
These are purely in-memory values and not used at all in xfsprogs.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_log_format.h | 37 ----------------------------------
fs/xfs/xfs_log.h | 37 ++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h
index e5e6f8c0408f..da99ab4aea6c 100644
--- a/fs/xfs/libxfs/xfs_log_format.h
+++ b/fs/xfs/libxfs/xfs_log_format.h
@@ -86,43 +86,6 @@ struct xfs_unmount_log_format {
uint32_t pad2; /* may as well make it 64 bits */
};
-/* Region types for iovec's i_type */
-#define XLOG_REG_TYPE_BFORMAT 1
-#define XLOG_REG_TYPE_BCHUNK 2
-#define XLOG_REG_TYPE_EFI_FORMAT 3
-#define XLOG_REG_TYPE_EFD_FORMAT 4
-#define XLOG_REG_TYPE_IFORMAT 5
-#define XLOG_REG_TYPE_ICORE 6
-#define XLOG_REG_TYPE_IEXT 7
-#define XLOG_REG_TYPE_IBROOT 8
-#define XLOG_REG_TYPE_ILOCAL 9
-#define XLOG_REG_TYPE_IATTR_EXT 10
-#define XLOG_REG_TYPE_IATTR_BROOT 11
-#define XLOG_REG_TYPE_IATTR_LOCAL 12
-#define XLOG_REG_TYPE_QFORMAT 13
-#define XLOG_REG_TYPE_DQUOT 14
-#define XLOG_REG_TYPE_QUOTAOFF 15
-#define XLOG_REG_TYPE_LRHEADER 16
-#define XLOG_REG_TYPE_UNMOUNT 17
-#define XLOG_REG_TYPE_COMMIT 18
-#define XLOG_REG_TYPE_TRANSHDR 19
-#define XLOG_REG_TYPE_ICREATE 20
-#define XLOG_REG_TYPE_RUI_FORMAT 21
-#define XLOG_REG_TYPE_RUD_FORMAT 22
-#define XLOG_REG_TYPE_CUI_FORMAT 23
-#define XLOG_REG_TYPE_CUD_FORMAT 24
-#define XLOG_REG_TYPE_BUI_FORMAT 25
-#define XLOG_REG_TYPE_BUD_FORMAT 26
-#define XLOG_REG_TYPE_ATTRI_FORMAT 27
-#define XLOG_REG_TYPE_ATTRD_FORMAT 28
-#define XLOG_REG_TYPE_ATTR_NAME 29
-#define XLOG_REG_TYPE_ATTR_VALUE 30
-#define XLOG_REG_TYPE_XMI_FORMAT 31
-#define XLOG_REG_TYPE_XMD_FORMAT 32
-#define XLOG_REG_TYPE_ATTR_NEWNAME 33
-#define XLOG_REG_TYPE_ATTR_NEWVALUE 34
-#define XLOG_REG_TYPE_MAX 34
-
/*
* Flags to log operation header
*
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index 780155839df4..0f23812b0b31 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -9,6 +9,43 @@
struct xlog_format_buf;
struct xfs_cil_ctx;
+/* Region types for iovec's i_type */
+#define XLOG_REG_TYPE_BFORMAT 1
+#define XLOG_REG_TYPE_BCHUNK 2
+#define XLOG_REG_TYPE_EFI_FORMAT 3
+#define XLOG_REG_TYPE_EFD_FORMAT 4
+#define XLOG_REG_TYPE_IFORMAT 5
+#define XLOG_REG_TYPE_ICORE 6
+#define XLOG_REG_TYPE_IEXT 7
+#define XLOG_REG_TYPE_IBROOT 8
+#define XLOG_REG_TYPE_ILOCAL 9
+#define XLOG_REG_TYPE_IATTR_EXT 10
+#define XLOG_REG_TYPE_IATTR_BROOT 11
+#define XLOG_REG_TYPE_IATTR_LOCAL 12
+#define XLOG_REG_TYPE_QFORMAT 13
+#define XLOG_REG_TYPE_DQUOT 14
+#define XLOG_REG_TYPE_QUOTAOFF 15
+#define XLOG_REG_TYPE_LRHEADER 16
+#define XLOG_REG_TYPE_UNMOUNT 17
+#define XLOG_REG_TYPE_COMMIT 18
+#define XLOG_REG_TYPE_TRANSHDR 19
+#define XLOG_REG_TYPE_ICREATE 20
+#define XLOG_REG_TYPE_RUI_FORMAT 21
+#define XLOG_REG_TYPE_RUD_FORMAT 22
+#define XLOG_REG_TYPE_CUI_FORMAT 23
+#define XLOG_REG_TYPE_CUD_FORMAT 24
+#define XLOG_REG_TYPE_BUI_FORMAT 25
+#define XLOG_REG_TYPE_BUD_FORMAT 26
+#define XLOG_REG_TYPE_ATTRI_FORMAT 27
+#define XLOG_REG_TYPE_ATTRD_FORMAT 28
+#define XLOG_REG_TYPE_ATTR_NAME 29
+#define XLOG_REG_TYPE_ATTR_VALUE 30
+#define XLOG_REG_TYPE_XMI_FORMAT 31
+#define XLOG_REG_TYPE_XMD_FORMAT 32
+#define XLOG_REG_TYPE_ATTR_NEWNAME 33
+#define XLOG_REG_TYPE_ATTR_NEWVALUE 34
+#define XLOG_REG_TYPE_MAX 34
+
#define XFS_LOG_VEC_ORDERED (-1)
/*
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 14/18] xfs: regularize iclog space accounting in xlog_write_partial
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (12 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 13/18] xfs: move the XLOG_REG_ constants out of xfs_log_format.h Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 15/18] xfs: improve the calling convention for the xlog_write helpers Christoph Hellwig
` (3 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
When xlog_write_partial splits a log region over multiple iclogs, it
has to include the continuation ophder in the length requested for the
new iclog. Currently is simply adds that to the request, which makes
the accounting of the used space below look slightly different from the
other users of iclog space that decrement it. To prepare for more code
sharing, adding the ophdr size to the len variable before the call to
xlog_write_get_more_iclog_space and then decrement it later.
This changes the contents of len when xlog_write_get_more_iclog_space
returns an error, but as nothing looks at len in that case the
difference doesn't matter.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_log.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 15fc7cac6da3..19f5521405bf 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -2079,10 +2079,10 @@ xlog_write_partial(
* consumes hasn't been accounted to the lv we are
* writing.
*/
+ *len += sizeof(struct xlog_op_header);
error = xlog_write_get_more_iclog_space(ticket,
- &iclog, log_offset,
- *len + sizeof(struct xlog_op_header),
- record_cnt, data_cnt);
+ &iclog, log_offset, *len, record_cnt,
+ data_cnt);
if (error)
return error;
@@ -2095,6 +2095,7 @@ xlog_write_partial(
ticket->t_curr_res -= sizeof(struct xlog_op_header);
*log_offset += sizeof(struct xlog_op_header);
*data_cnt += sizeof(struct xlog_op_header);
+ *len -= sizeof(struct xlog_op_header);
/*
* If rlen fits in the iclog, then end the region
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 15/18] xfs: improve the calling convention for the xlog_write helpers
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (13 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 14/18] xfs: regularize iclog space accounting in xlog_write_partial Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 16/18] xfs: add a xlog_write_space_left helper Christoph Hellwig
` (2 subsequent siblings)
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
The xlog_write chain passes around the same seven variables that are
often passed by reference. Add a xlog_write_data structure to contain
them to improve code generation and readability.
This change reduces the generated code size by almost 200 bytes for my
x86_64 build:
$ size fs/xfs/xfs_log.o*
text data bss dec hex filename
26330 1292 8 27630 6bee fs/xfs/xfs_log.o
26158 1292 8 27458 6b42 fs/xfs/xfs_log.o.old
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_log.c | 193 ++++++++++++++++++++---------------------------
1 file changed, 80 insertions(+), 113 deletions(-)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 19f5521405bf..8a91f1b4d927 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -22,6 +22,15 @@
#include "xfs_health.h"
#include "xfs_zone_alloc.h"
+struct xlog_write_data {
+ struct xlog_ticket *ticket;
+ struct xlog_in_core *iclog;
+ uint32_t bytes_left;
+ uint32_t record_cnt;
+ uint32_t data_cnt;
+ int log_offset;
+};
+
struct kmem_cache *xfs_log_ticket_cache;
/* Local miscellaneous function prototypes */
@@ -43,10 +52,7 @@ STATIC void xlog_state_do_callback(
STATIC int
xlog_state_get_iclog_space(
struct xlog *log,
- int len,
- struct xlog_in_core **iclog,
- struct xlog_ticket *ticket,
- int *logoffsetp);
+ struct xlog_write_data *data);
STATIC void
xlog_sync(
struct xlog *log,
@@ -1905,23 +1911,19 @@ xlog_print_trans(
static inline void
xlog_write_iovec(
- struct xlog_in_core *iclog,
- uint32_t *log_offset,
- void *data,
- uint32_t write_len,
- int *bytes_left,
- uint32_t *record_cnt,
- uint32_t *data_cnt)
+ struct xlog_write_data *data,
+ void *buf,
+ uint32_t buf_len)
{
- ASSERT(*log_offset < iclog->ic_log->l_iclog_size);
- ASSERT(*log_offset % sizeof(int32_t) == 0);
- ASSERT(write_len % sizeof(int32_t) == 0);
+ ASSERT(data->log_offset < data->iclog->ic_log->l_iclog_size);
+ ASSERT(data->log_offset % sizeof(int32_t) == 0);
+ ASSERT(buf_len % sizeof(int32_t) == 0);
- memcpy(iclog->ic_datap + *log_offset, data, write_len);
- *log_offset += write_len;
- *bytes_left -= write_len;
- (*record_cnt)++;
- *data_cnt += write_len;
+ memcpy(data->iclog->ic_datap + data->log_offset, buf, buf_len);
+ data->log_offset += buf_len;
+ data->bytes_left -= buf_len;
+ data->record_cnt++;
+ data->data_cnt += buf_len;
}
/*
@@ -1931,17 +1933,12 @@ xlog_write_iovec(
static void
xlog_write_full(
struct xfs_log_vec *lv,
- struct xlog_ticket *ticket,
- struct xlog_in_core *iclog,
- uint32_t *log_offset,
- uint32_t *len,
- uint32_t *record_cnt,
- uint32_t *data_cnt)
+ struct xlog_write_data *data)
{
int index;
- ASSERT(*log_offset + *len <= iclog->ic_size ||
- iclog->ic_state == XLOG_STATE_WANT_SYNC);
+ ASSERT(data->log_offset + data->bytes_left <= data->iclog->ic_size ||
+ data->iclog->ic_state == XLOG_STATE_WANT_SYNC);
/*
* Ordered log vectors have no regions to write so this
@@ -1951,40 +1948,32 @@ xlog_write_full(
struct xfs_log_iovec *reg = &lv->lv_iovecp[index];
struct xlog_op_header *ophdr = reg->i_addr;
- ophdr->oh_tid = cpu_to_be32(ticket->t_tid);
- xlog_write_iovec(iclog, log_offset, reg->i_addr,
- reg->i_len, len, record_cnt, data_cnt);
+ ophdr->oh_tid = cpu_to_be32(data->ticket->t_tid);
+ xlog_write_iovec(data, reg->i_addr, reg->i_len);
}
}
static int
xlog_write_get_more_iclog_space(
- struct xlog_ticket *ticket,
- struct xlog_in_core **iclogp,
- uint32_t *log_offset,
- uint32_t len,
- uint32_t *record_cnt,
- uint32_t *data_cnt)
+ struct xlog_write_data *data)
{
- struct xlog_in_core *iclog = *iclogp;
- struct xlog *log = iclog->ic_log;
+ struct xlog *log = data->iclog->ic_log;
int error;
spin_lock(&log->l_icloglock);
- ASSERT(iclog->ic_state == XLOG_STATE_WANT_SYNC);
- xlog_state_finish_copy(log, iclog, *record_cnt, *data_cnt);
- error = xlog_state_release_iclog(log, iclog, ticket);
+ ASSERT(data->iclog->ic_state == XLOG_STATE_WANT_SYNC);
+ xlog_state_finish_copy(log, data->iclog, data->record_cnt,
+ data->data_cnt);
+ error = xlog_state_release_iclog(log, data->iclog, data->ticket);
spin_unlock(&log->l_icloglock);
if (error)
return error;
- error = xlog_state_get_iclog_space(log, len, &iclog, ticket,
- log_offset);
+ error = xlog_state_get_iclog_space(log, data);
if (error)
return error;
- *record_cnt = 0;
- *data_cnt = 0;
- *iclogp = iclog;
+ data->record_cnt = 0;
+ data->data_cnt = 0;
return 0;
}
@@ -1997,14 +1986,8 @@ xlog_write_get_more_iclog_space(
static int
xlog_write_partial(
struct xfs_log_vec *lv,
- struct xlog_ticket *ticket,
- struct xlog_in_core **iclogp,
- uint32_t *log_offset,
- uint32_t *len,
- uint32_t *record_cnt,
- uint32_t *data_cnt)
+ struct xlog_write_data *data)
{
- struct xlog_in_core *iclog = *iclogp;
struct xlog_op_header *ophdr;
int index = 0;
uint32_t rlen;
@@ -2026,25 +2009,23 @@ xlog_write_partial(
* Hence if there isn't space for region data after the
* opheader, then we need to start afresh with a new iclog.
*/
- if (iclog->ic_size - *log_offset <=
+ if (data->iclog->ic_size - data->log_offset <=
sizeof(struct xlog_op_header)) {
- error = xlog_write_get_more_iclog_space(ticket,
- &iclog, log_offset, *len, record_cnt,
- data_cnt);
+ error = xlog_write_get_more_iclog_space(data);
if (error)
return error;
}
ophdr = reg->i_addr;
- rlen = min_t(uint32_t, reg->i_len, iclog->ic_size - *log_offset);
+ rlen = min_t(uint32_t, reg->i_len,
+ data->iclog->ic_size - data->log_offset);
- ophdr->oh_tid = cpu_to_be32(ticket->t_tid);
+ ophdr->oh_tid = cpu_to_be32(data->ticket->t_tid);
ophdr->oh_len = cpu_to_be32(rlen - sizeof(struct xlog_op_header));
if (rlen != reg->i_len)
ophdr->oh_flags |= XLOG_CONTINUE_TRANS;
- xlog_write_iovec(iclog, log_offset, reg->i_addr,
- rlen, len, record_cnt, data_cnt);
+ xlog_write_iovec(data, reg->i_addr, rlen);
/* If we wrote the whole region, move to the next. */
if (rlen == reg->i_len)
@@ -2079,23 +2060,22 @@ xlog_write_partial(
* consumes hasn't been accounted to the lv we are
* writing.
*/
- *len += sizeof(struct xlog_op_header);
- error = xlog_write_get_more_iclog_space(ticket,
- &iclog, log_offset, *len, record_cnt,
- data_cnt);
+ data->bytes_left += sizeof(struct xlog_op_header);
+ error = xlog_write_get_more_iclog_space(data);
if (error)
return error;
- ophdr = iclog->ic_datap + *log_offset;
- ophdr->oh_tid = cpu_to_be32(ticket->t_tid);
+ ophdr = data->iclog->ic_datap + data->log_offset;
+ ophdr->oh_tid = cpu_to_be32(data->ticket->t_tid);
ophdr->oh_clientid = XFS_TRANSACTION;
ophdr->oh_res2 = 0;
ophdr->oh_flags = XLOG_WAS_CONT_TRANS;
- ticket->t_curr_res -= sizeof(struct xlog_op_header);
- *log_offset += sizeof(struct xlog_op_header);
- *data_cnt += sizeof(struct xlog_op_header);
- *len -= sizeof(struct xlog_op_header);
+ data->ticket->t_curr_res -=
+ sizeof(struct xlog_op_header);
+ data->log_offset += sizeof(struct xlog_op_header);
+ data->data_cnt += sizeof(struct xlog_op_header);
+ data->bytes_left -= sizeof(struct xlog_op_header);
/*
* If rlen fits in the iclog, then end the region
@@ -2103,26 +2083,19 @@ xlog_write_partial(
*/
reg_offset += rlen;
rlen = reg->i_len - reg_offset;
- if (rlen <= iclog->ic_size - *log_offset)
+ if (rlen <= data->iclog->ic_size - data->log_offset)
ophdr->oh_flags |= XLOG_END_TRANS;
else
ophdr->oh_flags |= XLOG_CONTINUE_TRANS;
- rlen = min_t(uint32_t, rlen, iclog->ic_size - *log_offset);
+ rlen = min_t(uint32_t, rlen,
+ data->iclog->ic_size - data->log_offset);
ophdr->oh_len = cpu_to_be32(rlen);
- xlog_write_iovec(iclog, log_offset,
- reg->i_addr + reg_offset,
- rlen, len, record_cnt, data_cnt);
-
+ xlog_write_iovec(data, reg->i_addr + reg_offset, rlen);
} while (ophdr->oh_flags & XLOG_CONTINUE_TRANS);
}
- /*
- * No more iovecs remain in this logvec so return the next log vec to
- * the caller so it can go back to fast path copying.
- */
- *iclogp = iclog;
return 0;
}
@@ -2175,12 +2148,12 @@ xlog_write(
uint32_t len)
{
- struct xlog_in_core *iclog = NULL;
struct xfs_log_vec *lv;
- uint32_t record_cnt = 0;
- uint32_t data_cnt = 0;
- int error = 0;
- int log_offset;
+ struct xlog_write_data data = {
+ .ticket = ticket,
+ .bytes_left = len,
+ };
+ int error;
if (ticket->t_curr_res < 0) {
xfs_alert_tag(log->l_mp, XFS_PTAG_LOGRES,
@@ -2189,12 +2162,11 @@ xlog_write(
xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR);
}
- error = xlog_state_get_iclog_space(log, len, &iclog, ticket,
- &log_offset);
+ error = xlog_state_get_iclog_space(log, &data);
if (error)
return error;
- ASSERT(log_offset <= iclog->ic_size - 1);
+ ASSERT(data.log_offset <= data.iclog->ic_size - 1);
/*
* If we have a context pointer, pass it the first iclog we are
@@ -2202,7 +2174,7 @@ xlog_write(
* ordering.
*/
if (ctx)
- xlog_cil_set_ctx_write_state(ctx, iclog);
+ xlog_cil_set_ctx_write_state(ctx, data.iclog);
list_for_each_entry(lv, lv_chain, lv_list) {
/*
@@ -2210,10 +2182,8 @@ xlog_write(
* the partial copy loop which can handle this case.
*/
if (lv->lv_niovecs &&
- lv->lv_bytes > iclog->ic_size - log_offset) {
- error = xlog_write_partial(lv, ticket, &iclog,
- &log_offset, &len, &record_cnt,
- &data_cnt);
+ lv->lv_bytes > data.iclog->ic_size - data.log_offset) {
+ error = xlog_write_partial(lv, &data);
if (error) {
/*
* We have no iclog to release, so just return
@@ -2222,11 +2192,10 @@ xlog_write(
return error;
}
} else {
- xlog_write_full(lv, ticket, iclog, &log_offset,
- &len, &record_cnt, &data_cnt);
+ xlog_write_full(lv, &data);
}
}
- ASSERT(len == 0);
+ ASSERT(data.bytes_left == 0);
/*
* We've already been guaranteed that the last writes will fit inside
@@ -2235,8 +2204,8 @@ xlog_write(
* iclog with the number of bytes written here.
*/
spin_lock(&log->l_icloglock);
- xlog_state_finish_copy(log, iclog, record_cnt, 0);
- error = xlog_state_release_iclog(log, iclog, ticket);
+ xlog_state_finish_copy(log, data.iclog, data.record_cnt, 0);
+ error = xlog_state_release_iclog(log, data.iclog, ticket);
spin_unlock(&log->l_icloglock);
return error;
@@ -2558,14 +2527,11 @@ xlog_state_done_syncing(
STATIC int
xlog_state_get_iclog_space(
struct xlog *log,
- int len,
- struct xlog_in_core **iclogp,
- struct xlog_ticket *ticket,
- int *logoffsetp)
+ struct xlog_write_data *data)
{
- int log_offset;
- xlog_rec_header_t *head;
- xlog_in_core_t *iclog;
+ int log_offset;
+ struct xlog_rec_header *head;
+ struct xlog_in_core *iclog;
restart:
spin_lock(&log->l_icloglock);
@@ -2596,7 +2562,7 @@ xlog_state_get_iclog_space(
* must be written.
*/
if (log_offset == 0) {
- ticket->t_curr_res -= log->l_iclog_hsize;
+ data->ticket->t_curr_res -= log->l_iclog_hsize;
head->h_cycle = cpu_to_be32(log->l_curr_cycle);
head->h_lsn = cpu_to_be64(
xlog_assign_lsn(log->l_curr_cycle, log->l_curr_block));
@@ -2626,7 +2592,8 @@ xlog_state_get_iclog_space(
* reference to the iclog.
*/
if (!atomic_add_unless(&iclog->ic_refcnt, -1, 1))
- error = xlog_state_release_iclog(log, iclog, ticket);
+ error = xlog_state_release_iclog(log, iclog,
+ data->ticket);
spin_unlock(&log->l_icloglock);
if (error)
return error;
@@ -2639,16 +2606,16 @@ xlog_state_get_iclog_space(
* iclogs (to mark it taken), this particular iclog will release/sync
* to disk in xlog_write().
*/
- if (len <= iclog->ic_size - iclog->ic_offset)
- iclog->ic_offset += len;
+ if (data->bytes_left <= iclog->ic_size - iclog->ic_offset)
+ iclog->ic_offset += data->bytes_left;
else
xlog_state_switch_iclogs(log, iclog, iclog->ic_size);
- *iclogp = iclog;
+ data->iclog = iclog;
ASSERT(iclog->ic_offset <= iclog->ic_size);
spin_unlock(&log->l_icloglock);
- *logoffsetp = log_offset;
+ data->log_offset = log_offset;
return 0;
}
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 16/18] xfs: add a xlog_write_space_left helper
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (14 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 15/18] xfs: improve the calling convention for the xlog_write helpers Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 17/18] xfs: improve the iclog space assert in xlog_write_iovec Christoph Hellwig
2025-07-15 12:30 ` [PATCH 18/18] xfs: factor out a xlog_write_space_advance helper Christoph Hellwig
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Various places check how much space is left in the current iclog,
add a helper for that.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_log.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 8a91f1b4d927..062eefac1a36 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1909,13 +1909,18 @@ xlog_print_trans(
}
}
+static inline uint32_t xlog_write_space_left(struct xlog_write_data *data)
+{
+ return data->iclog->ic_size - data->log_offset;
+}
+
static inline void
xlog_write_iovec(
struct xlog_write_data *data,
void *buf,
uint32_t buf_len)
{
- ASSERT(data->log_offset < data->iclog->ic_log->l_iclog_size);
+ ASSERT(xlog_write_space_left(data) > 0);
ASSERT(data->log_offset % sizeof(int32_t) == 0);
ASSERT(buf_len % sizeof(int32_t) == 0);
@@ -1937,7 +1942,7 @@ xlog_write_full(
{
int index;
- ASSERT(data->log_offset + data->bytes_left <= data->iclog->ic_size ||
+ ASSERT(data->bytes_left <= xlog_write_space_left(data) ||
data->iclog->ic_state == XLOG_STATE_WANT_SYNC);
/*
@@ -2009,7 +2014,7 @@ xlog_write_partial(
* Hence if there isn't space for region data after the
* opheader, then we need to start afresh with a new iclog.
*/
- if (data->iclog->ic_size - data->log_offset <=
+ if (xlog_write_space_left(data) <=
sizeof(struct xlog_op_header)) {
error = xlog_write_get_more_iclog_space(data);
if (error)
@@ -2017,8 +2022,7 @@ xlog_write_partial(
}
ophdr = reg->i_addr;
- rlen = min_t(uint32_t, reg->i_len,
- data->iclog->ic_size - data->log_offset);
+ rlen = min_t(uint32_t, reg->i_len, xlog_write_space_left(data));
ophdr->oh_tid = cpu_to_be32(data->ticket->t_tid);
ophdr->oh_len = cpu_to_be32(rlen - sizeof(struct xlog_op_header));
@@ -2083,13 +2087,13 @@ xlog_write_partial(
*/
reg_offset += rlen;
rlen = reg->i_len - reg_offset;
- if (rlen <= data->iclog->ic_size - data->log_offset)
+ if (rlen <= xlog_write_space_left(data))
ophdr->oh_flags |= XLOG_END_TRANS;
else
ophdr->oh_flags |= XLOG_CONTINUE_TRANS;
rlen = min_t(uint32_t, rlen,
- data->iclog->ic_size - data->log_offset);
+ xlog_write_space_left(data));
ophdr->oh_len = cpu_to_be32(rlen);
xlog_write_iovec(data, reg->i_addr + reg_offset, rlen);
@@ -2166,7 +2170,7 @@ xlog_write(
if (error)
return error;
- ASSERT(data.log_offset <= data.iclog->ic_size - 1);
+ ASSERT(xlog_write_space_left(&data) > 0);
/*
* If we have a context pointer, pass it the first iclog we are
@@ -2182,7 +2186,7 @@ xlog_write(
* the partial copy loop which can handle this case.
*/
if (lv->lv_niovecs &&
- lv->lv_bytes > data.iclog->ic_size - data.log_offset) {
+ lv->lv_bytes > xlog_write_space_left(&data)) {
error = xlog_write_partial(lv, &data);
if (error) {
/*
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 17/18] xfs: improve the iclog space assert in xlog_write_iovec
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (15 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 16/18] xfs: add a xlog_write_space_left helper Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
2025-07-15 12:30 ` [PATCH 18/18] xfs: factor out a xlog_write_space_advance helper Christoph Hellwig
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
We need enough space for the length we copy into the iclog, not just
some space, so tighten up the check a bit.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_log.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 062eefac1a36..48fc17cad60a 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1920,7 +1920,7 @@ xlog_write_iovec(
void *buf,
uint32_t buf_len)
{
- ASSERT(xlog_write_space_left(data) > 0);
+ ASSERT(xlog_write_space_left(data) >= buf_len);
ASSERT(data->log_offset % sizeof(int32_t) == 0);
ASSERT(buf_len % sizeof(int32_t) == 0);
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 18/18] xfs: factor out a xlog_write_space_advance helper
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
` (16 preceding siblings ...)
2025-07-15 12:30 ` [PATCH 17/18] xfs: improve the iclog space assert in xlog_write_iovec Christoph Hellwig
@ 2025-07-15 12:30 ` Christoph Hellwig
17 siblings, 0 replies; 19+ messages in thread
From: Christoph Hellwig @ 2025-07-15 12:30 UTC (permalink / raw)
To: Carlos Maiolino; +Cc: linux-xfs
Add a new xlog_write_space_advance that returns the current place in the
iclog that data is written to, and advances the various counters by the
amount taken from xlog_write_iovec, and also use it xlog_write_partial,
which open codes the counter adjustments, but misses the asserts.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_log.c | 32 ++++++++++++++++++++------------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 48fc17cad60a..802329d2e360 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -1914,21 +1914,31 @@ static inline uint32_t xlog_write_space_left(struct xlog_write_data *data)
return data->iclog->ic_size - data->log_offset;
}
+static void *
+xlog_write_space_advance(
+ struct xlog_write_data *data,
+ unsigned int len)
+{
+ void *p = data->iclog->ic_datap + data->log_offset;
+
+ ASSERT(xlog_write_space_left(data) >= len);
+ ASSERT(data->log_offset % sizeof(int32_t) == 0);
+ ASSERT(len % sizeof(int32_t) == 0);
+
+ data->data_cnt += len;
+ data->log_offset += len;
+ data->bytes_left -= len;
+ return p;
+}
+
static inline void
xlog_write_iovec(
struct xlog_write_data *data,
void *buf,
uint32_t buf_len)
{
- ASSERT(xlog_write_space_left(data) >= buf_len);
- ASSERT(data->log_offset % sizeof(int32_t) == 0);
- ASSERT(buf_len % sizeof(int32_t) == 0);
-
- memcpy(data->iclog->ic_datap + data->log_offset, buf, buf_len);
- data->log_offset += buf_len;
- data->bytes_left -= buf_len;
+ memcpy(xlog_write_space_advance(data, buf_len), buf, buf_len);
data->record_cnt++;
- data->data_cnt += buf_len;
}
/*
@@ -2069,7 +2079,8 @@ xlog_write_partial(
if (error)
return error;
- ophdr = data->iclog->ic_datap + data->log_offset;
+ ophdr = xlog_write_space_advance(data,
+ sizeof(struct xlog_op_header));
ophdr->oh_tid = cpu_to_be32(data->ticket->t_tid);
ophdr->oh_clientid = XFS_TRANSACTION;
ophdr->oh_res2 = 0;
@@ -2077,9 +2088,6 @@ xlog_write_partial(
data->ticket->t_curr_res -=
sizeof(struct xlog_op_header);
- data->log_offset += sizeof(struct xlog_op_header);
- data->data_cnt += sizeof(struct xlog_op_header);
- data->bytes_left -= sizeof(struct xlog_op_header);
/*
* If rlen fits in the iclog, then end the region
--
2.47.2
^ permalink raw reply related [flat|nested] 19+ messages in thread
end of thread, other threads:[~2025-07-15 12:32 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-15 12:30 misc log cleanups allocation Christoph Hellwig
2025-07-15 12:30 ` [PATCH 01/18] xfs: don't pass the old lv to xfs_cil_prepare_item Christoph Hellwig
2025-07-15 12:30 ` [PATCH 02/18] xfs: cleanup the ordered item logic in xlog_cil_insert_format_items Christoph Hellwig
2025-07-15 12:30 ` [PATCH 03/18] xfs: use better names for size members in xfs_log_vec Christoph Hellwig
2025-07-15 12:30 ` [PATCH 04/18] xfs: don't use a xfs_log_iovec for attr_item names and values Christoph Hellwig
2025-07-15 12:30 ` [PATCH 05/18] xfs: don't use a xfs_log_iovec for ri_buf in log recovery Christoph Hellwig
2025-07-15 12:30 ` [PATCH 06/18] xfs: add a xlog_write_one_vec helper Christoph Hellwig
2025-07-15 12:30 ` [PATCH 07/18] xfs: set lv_bytes in xlog_write_one_vec Christoph Hellwig
2025-07-15 12:30 ` [PATCH 08/18] xfs: improve the ->iop_format interface Christoph Hellwig
2025-07-15 12:30 ` [PATCH 09/18] xfs: move struct xfs_log_iovec to xfs_log_priv.h Christoph Hellwig
2025-07-15 12:30 ` [PATCH 10/18] xfs: move struct xfs_log_vec " Christoph Hellwig
2025-07-15 12:30 ` [PATCH 11/18] xfs: remove the xlog_op_header_t typedef Christoph Hellwig
2025-07-15 12:30 ` [PATCH 12/18] xfs: remove the xfs_trans_header_t typedef Christoph Hellwig
2025-07-15 12:30 ` [PATCH 13/18] xfs: move the XLOG_REG_ constants out of xfs_log_format.h Christoph Hellwig
2025-07-15 12:30 ` [PATCH 14/18] xfs: regularize iclog space accounting in xlog_write_partial Christoph Hellwig
2025-07-15 12:30 ` [PATCH 15/18] xfs: improve the calling convention for the xlog_write helpers Christoph Hellwig
2025-07-15 12:30 ` [PATCH 16/18] xfs: add a xlog_write_space_left helper Christoph Hellwig
2025-07-15 12:30 ` [PATCH 17/18] xfs: improve the iclog space assert in xlog_write_iovec Christoph Hellwig
2025-07-15 12:30 ` [PATCH 18/18] xfs: factor out a xlog_write_space_advance helper Christoph Hellwig
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).