]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: set lv_bytes in xlog_write_one_vec
authorChristoph Hellwig <hch@lst.de>
Wed, 12 Nov 2025 12:14:18 +0000 (13:14 +0100)
committerCarlos Maiolino <cem@kernel.org>
Wed, 21 Jan 2026 11:57:16 +0000 (12:57 +0100)
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.

Note that even without this fix, the checkpoint commits would never
trigger a partial iclog write, as they have no payload beyond the
opheader.

The unmount record on the other hand could in theory trigger a an
overflow of the iclog, but given that is has never been seen in
the wild this has probably been masked by the small size of it
and the fact that the unmount process does multiple log forces
before writing the unmount record and we thus usually operate on
an empty or almost empty iclog.

Fixes: 110dc24ad2ae ("xfs: log vector rounding leaks log space")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_log.c

index c6fa258df844037651f93f153668012dcbc7b28b..4869eacfde241f34af13e7186ea5bc24f1211936 100644 (file)
@@ -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);
 }
 
 /*