xfs: cleanup xlog_alloc_log a bit

Remove the separate head variable, move the ic_datap initialization
up a bit where the context is more obvious and remove the duplicate
memset right after a zeroing memory allocation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
Christoph Hellwig
2025-10-27 08:05:51 +01:00
committed by Carlos Maiolino
parent be665a4e27
commit 16c18021e1

View File

@@ -1367,7 +1367,6 @@ xlog_alloc_log(
int num_bblks)
{
struct xlog *log;
xlog_rec_header_t *head;
xlog_in_core_t **iclogp;
xlog_in_core_t *iclog, *prev_iclog=NULL;
int i;
@@ -1461,22 +1460,21 @@ xlog_alloc_log(
GFP_KERNEL | __GFP_RETRY_MAYFAIL);
if (!iclog->ic_header)
goto out_free_iclog;
head = iclog->ic_header;
memset(head, 0, sizeof(xlog_rec_header_t));
head->h_magicno = cpu_to_be32(XLOG_HEADER_MAGIC_NUM);
head->h_version = cpu_to_be32(
iclog->ic_header->h_magicno =
cpu_to_be32(XLOG_HEADER_MAGIC_NUM);
iclog->ic_header->h_version = cpu_to_be32(
xfs_has_logv2(log->l_mp) ? 2 : 1);
head->h_size = cpu_to_be32(log->l_iclog_size);
/* new fields */
head->h_fmt = cpu_to_be32(XLOG_FMT);
memcpy(&head->h_fs_uuid, &mp->m_sb.sb_uuid, sizeof(uuid_t));
iclog->ic_header->h_size = cpu_to_be32(log->l_iclog_size);
iclog->ic_header->h_fmt = cpu_to_be32(XLOG_FMT);
memcpy(&iclog->ic_header->h_fs_uuid, &mp->m_sb.sb_uuid,
sizeof(iclog->ic_header->h_fs_uuid));
iclog->ic_datap = (void *)iclog->ic_header + log->l_iclog_hsize;
iclog->ic_size = log->l_iclog_size - log->l_iclog_hsize;
iclog->ic_state = XLOG_STATE_ACTIVE;
iclog->ic_log = log;
atomic_set(&iclog->ic_refcnt, 0);
INIT_LIST_HEAD(&iclog->ic_callbacks);
iclog->ic_datap = (void *)iclog->ic_header + log->l_iclog_hsize;
init_waitqueue_head(&iclog->ic_force_wait);
init_waitqueue_head(&iclog->ic_write_wait);