Skip to content

Commit e870cbe

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: use better names for size members in xfs_log_vec
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> Signed-off-by: Carlos Maiolino <cem@kernel.org>
1 parent 0177479 commit e870cbe

3 files changed

Lines changed: 25 additions & 24 deletions

File tree

fs/xfs/xfs_log.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ xlog_prepare_iovec(
109109
vec = &lv->lv_iovecp[0];
110110
}
111111

112-
len = lv->lv_buf_len + sizeof(struct xlog_op_header);
112+
len = lv->lv_buf_used + sizeof(struct xlog_op_header);
113113
if (!IS_ALIGNED(len, sizeof(uint64_t))) {
114-
lv->lv_buf_len = round_up(len, sizeof(uint64_t)) -
114+
lv->lv_buf_used = round_up(len, sizeof(uint64_t)) -
115115
sizeof(struct xlog_op_header);
116116
}
117117

118118
vec->i_type = type;
119-
vec->i_addr = lv->lv_buf + lv->lv_buf_len;
119+
vec->i_addr = lv->lv_buf + lv->lv_buf_used;
120120

121121
oph = vec->i_addr;
122122
oph->oh_clientid = XFS_TRANSACTION;
@@ -1931,9 +1931,9 @@ xlog_print_trans(
19311931
if (!lv)
19321932
continue;
19331933
xfs_warn(mp, " niovecs = %d", lv->lv_niovecs);
1934-
xfs_warn(mp, " size = %d", lv->lv_size);
1934+
xfs_warn(mp, " alloc_size = %d", lv->lv_alloc_size);
19351935
xfs_warn(mp, " bytes = %d", lv->lv_bytes);
1936-
xfs_warn(mp, " buf len = %d", lv->lv_buf_len);
1936+
xfs_warn(mp, " buf used= %d", lv->lv_buf_used);
19371937

19381938
/* dump each iovec for the log item */
19391939
vec = lv->lv_iovecp;

fs/xfs/xfs_log.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ struct xfs_log_vec {
1616
struct xfs_log_item *lv_item; /* owner */
1717
char *lv_buf; /* formatted buffer */
1818
int lv_bytes; /* accounted space in buffer */
19-
int lv_buf_len; /* aligned size of buffer */
20-
int lv_size; /* size of allocated lv */
19+
int lv_buf_used; /* buffer space used so far */
20+
int lv_alloc_size; /* size of allocated lv */
2121
};
2222

2323
#define XFS_LOG_VEC_ORDERED (-1)
@@ -64,12 +64,13 @@ xlog_finish_iovec(struct xfs_log_vec *lv, struct xfs_log_iovec *vec,
6464
oph->oh_len = cpu_to_be32(len);
6565

6666
len += sizeof(struct xlog_op_header);
67-
lv->lv_buf_len += len;
67+
lv->lv_buf_used += len;
6868
lv->lv_bytes += len;
6969
vec->i_len = len;
7070

7171
/* Catch buffer overruns */
72-
ASSERT((void *)lv->lv_buf + lv->lv_bytes <= (void *)lv + lv->lv_size);
72+
ASSERT((void *)lv->lv_buf + lv->lv_bytes <=
73+
(void *)lv + lv->lv_alloc_size);
7374
}
7475

7576
/*

fs/xfs/xfs_log_cil.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ xlog_cil_alloc_shadow_bufs(
275275
struct xfs_log_vec *lv;
276276
int niovecs = 0;
277277
int nbytes = 0;
278-
int buf_size;
278+
int alloc_size;
279279
bool ordered = false;
280280

281281
/* Skip items which aren't dirty in this transaction. */
@@ -316,14 +316,14 @@ xlog_cil_alloc_shadow_bufs(
316316
* that space to ensure we can align it appropriately and not
317317
* overrun the buffer.
318318
*/
319-
buf_size = nbytes + xlog_cil_iovec_space(niovecs);
319+
alloc_size = nbytes + xlog_cil_iovec_space(niovecs);
320320

321321
/*
322322
* if we have no shadow buffer, or it is too small, we need to
323323
* reallocate it.
324324
*/
325325
if (!lip->li_lv_shadow ||
326-
buf_size > lip->li_lv_shadow->lv_size) {
326+
alloc_size > lip->li_lv_shadow->lv_alloc_size) {
327327
/*
328328
* We free and allocate here as a realloc would copy
329329
* unnecessary data. We don't use kvzalloc() for the
@@ -332,25 +332,25 @@ xlog_cil_alloc_shadow_bufs(
332332
* storage.
333333
*/
334334
kvfree(lip->li_lv_shadow);
335-
lv = xlog_kvmalloc(buf_size);
335+
lv = xlog_kvmalloc(alloc_size);
336336

337337
memset(lv, 0, xlog_cil_iovec_space(niovecs));
338338

339339
INIT_LIST_HEAD(&lv->lv_list);
340340
lv->lv_item = lip;
341-
lv->lv_size = buf_size;
341+
lv->lv_alloc_size = alloc_size;
342342
if (ordered)
343-
lv->lv_buf_len = XFS_LOG_VEC_ORDERED;
343+
lv->lv_buf_used = XFS_LOG_VEC_ORDERED;
344344
else
345345
lv->lv_iovecp = (struct xfs_log_iovec *)&lv[1];
346346
lip->li_lv_shadow = lv;
347347
} else {
348348
/* same or smaller, optimise common overwrite case */
349349
lv = lip->li_lv_shadow;
350350
if (ordered)
351-
lv->lv_buf_len = XFS_LOG_VEC_ORDERED;
351+
lv->lv_buf_used = XFS_LOG_VEC_ORDERED;
352352
else
353-
lv->lv_buf_len = 0;
353+
lv->lv_buf_used = 0;
354354
lv->lv_bytes = 0;
355355
}
356356

@@ -375,7 +375,7 @@ xfs_cil_prepare_item(
375375
int *diff_len)
376376
{
377377
/* Account for the new LV being passed in */
378-
if (lv->lv_buf_len != XFS_LOG_VEC_ORDERED)
378+
if (lv->lv_buf_used != XFS_LOG_VEC_ORDERED)
379379
*diff_len += lv->lv_bytes;
380380

381381
/*
@@ -390,7 +390,7 @@ xfs_cil_prepare_item(
390390
lv->lv_item->li_ops->iop_pin(lv->lv_item);
391391
lv->lv_item->li_lv_shadow = NULL;
392392
} else if (lip->li_lv != lv) {
393-
ASSERT(lv->lv_buf_len != XFS_LOG_VEC_ORDERED);
393+
ASSERT(lv->lv_buf_used != XFS_LOG_VEC_ORDERED);
394394

395395
*diff_len -= lip->li_lv->lv_bytes;
396396
lv->lv_item->li_lv_shadow = lip->li_lv;
@@ -463,12 +463,12 @@ xlog_cil_insert_format_items(
463463
* The formatting size information is already attached to
464464
* the shadow lv on the log item.
465465
*/
466-
if (shadow->lv_buf_len == XFS_LOG_VEC_ORDERED) {
466+
if (shadow->lv_buf_used == XFS_LOG_VEC_ORDERED) {
467467
if (!lv) {
468468
lv = shadow;
469469
lv->lv_item = lip;
470470
}
471-
ASSERT(shadow->lv_size == lv->lv_size);
471+
ASSERT(shadow->lv_alloc_size == lv->lv_alloc_size);
472472
xfs_cil_prepare_item(log, lip, lv, diff_len);
473473
continue;
474474
}
@@ -478,7 +478,7 @@ xlog_cil_insert_format_items(
478478
continue;
479479

480480
/* compare to existing item size */
481-
if (lv && shadow->lv_size <= lv->lv_size) {
481+
if (lv && shadow->lv_alloc_size <= lv->lv_alloc_size) {
482482
/* same or smaller, optimise common overwrite case */
483483

484484
/*
@@ -491,7 +491,7 @@ xlog_cil_insert_format_items(
491491
lv->lv_niovecs = shadow->lv_niovecs;
492492

493493
/* reset the lv buffer information for new formatting */
494-
lv->lv_buf_len = 0;
494+
lv->lv_buf_used = 0;
495495
lv->lv_bytes = 0;
496496
lv->lv_buf = (char *)lv +
497497
xlog_cil_iovec_space(lv->lv_niovecs);
@@ -1238,7 +1238,7 @@ xlog_cil_build_lv_chain(
12381238
lv->lv_order_id = item->li_order_id;
12391239

12401240
/* we don't write ordered log vectors */
1241-
if (lv->lv_buf_len != XFS_LOG_VEC_ORDERED)
1241+
if (lv->lv_buf_used != XFS_LOG_VEC_ORDERED)
12421242
*num_bytes += lv->lv_bytes;
12431243
*num_iovecs += lv->lv_niovecs;
12441244
list_add_tail(&lv->lv_list, &ctx->lv_chain);

0 commit comments

Comments
 (0)