]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: use better names for size members in xfs_log_vec
authorChristoph Hellwig <hch@lst.de>
Thu, 22 May 2025 17:40:09 +0000 (19:40 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 23 May 2025 03:19:16 +0000 (05:19 +0200)
The lv_size member counts the size of the entire allocation, rename it
to lv_alloc_size to make that clear.

The lv_buf_size 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>
fs/xfs/xfs_log.c
fs/xfs/xfs_log.h
fs/xfs/xfs_log_cil.c

index 980aabc495128ea73c95356b4f7e817ed32d3f70..2625ddb62ba086a3d0f22a01701cae31436b0f1f 100644 (file)
@@ -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;
@@ -1951,9 +1951,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;
index 13455854365fa3ced1d50d91cf558ac7a540bd48..f239fce4f2606eac713d0063a15945cf47964c7b 100644 (file)
@@ -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);
 }
 
 /*
index 81b6780e0afcf970337a74ac398836ed3824c2cc..985f27a5b4badd21498c558c476ffc352173d6a4 100644 (file)
@@ -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);
@@ -1236,7 +1236,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);