xfs
[Top] [All Lists]

[PATCH 1/9] xfs: factor log item initialisation

To: xfs@xxxxxxxxxxx
Subject: [PATCH 1/9] xfs: factor log item initialisation
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Sat, 6 Mar 2010 12:51:16 +1100
In-reply-to: <1267840284-4652-1-git-send-email-david@xxxxxxxxxxxxx>
References: <1267840284-4652-1-git-send-email-david@xxxxxxxxxxxxx>
From: Dave Chinner <dchinner@xxxxxxxxxx>

Each log item type does manual initialisation of the log item.
Delayed logging introduceѕ new fields that need initialisation, so
factor all the open coded initialisation into a common function
first.

Signed-off-by: Dave Chinner <dchinner@xxxxxxxxxx>
---
 fs/xfs/quota/xfs_dquot_item.c |   12 ++++--------
 fs/xfs/xfs_buf_item.c         |    5 +----
 fs/xfs/xfs_extfree_item.c     |   10 ++--------
 fs/xfs/xfs_inode_item.c       |   12 ++----------
 fs/xfs/xfs_log.c              |   13 +++++++++++++
 fs/xfs/xfs_log.h              |    7 +++++++
 6 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/fs/xfs/quota/xfs_dquot_item.c b/fs/xfs/quota/xfs_dquot_item.c
index 4e4ee9a..639d965 100644
--- a/fs/xfs/quota/xfs_dquot_item.c
+++ b/fs/xfs/quota/xfs_dquot_item.c
@@ -357,9 +357,8 @@ xfs_qm_dquot_logitem_init(
        xfs_dq_logitem_t  *lp;
        lp = &dqp->q_logitem;
 
-       lp->qli_item.li_type = XFS_LI_DQUOT;
-       lp->qli_item.li_ops = &xfs_dquot_item_ops;
-       lp->qli_item.li_mountp = dqp->q_mount;
+       xfs_log_item_init(dqp->q_mount, &lp->qli_item, XFS_LI_DQUOT,
+                                       &xfs_dquot_item_ops);
        lp->qli_dquot = dqp;
        lp->qli_format.qlf_type = XFS_LI_DQUOT;
        lp->qli_format.qlf_id = be32_to_cpu(dqp->q_core.d_id);
@@ -586,11 +585,8 @@ xfs_qm_qoff_logitem_init(
 
        qf = (xfs_qoff_logitem_t*) kmem_zalloc(sizeof(xfs_qoff_logitem_t), 
KM_SLEEP);
 
-       qf->qql_item.li_type = XFS_LI_QUOTAOFF;
-       if (start)
-               qf->qql_item.li_ops = &xfs_qm_qoffend_logitem_ops;
-       else
-               qf->qql_item.li_ops = &xfs_qm_qoff_logitem_ops;
+       xfs_log_item_init(mp, &qf->qql_item, XFS_LI_QUOTAOFF, start ?
+                       &xfs_qm_qoffend_logitem_ops : &xfs_qm_qoff_logitem_ops);
        qf->qql_item.li_mountp = mp;
        qf->qql_format.qf_type = XFS_LI_QUOTAOFF;
        qf->qql_format.qf_flags = flags;
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index f3c49e6..aace237 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -733,10 +733,7 @@ xfs_buf_item_init(
 
        bip = (xfs_buf_log_item_t*)kmem_zone_zalloc(xfs_buf_item_zone,
                                                    KM_SLEEP);
-       bip->bli_item.li_type = XFS_LI_BUF;
-       bip->bli_item.li_ops = &xfs_buf_item_ops;
-       bip->bli_item.li_mountp = mp;
-       bip->bli_item.li_ailp = mp->m_ail;
+       xfs_log_item_init(mp, &bip->bli_item, XFS_LI_BUF, &xfs_buf_item_ops);
        bip->bli_buf = bp;
        xfs_buf_hold(bp);
        bip->bli_format.blf_type = XFS_LI_BUF;
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 6f35ed1..e461e93 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -259,10 +259,7 @@ xfs_efi_init(xfs_mount_t   *mp,
                                                             KM_SLEEP);
        }
 
-       efip->efi_item.li_type = XFS_LI_EFI;
-       efip->efi_item.li_ops = &xfs_efi_item_ops;
-       efip->efi_item.li_mountp = mp;
-       efip->efi_item.li_ailp = mp->m_ail;
+       xfs_log_item_init(mp, &efip->efi_item, XFS_LI_EFI, &xfs_efi_item_ops);
        efip->efi_format.efi_nextents = nextents;
        efip->efi_format.efi_id = (__psint_t)(void*)efip;
 
@@ -554,10 +551,7 @@ xfs_efd_init(xfs_mount_t   *mp,
                                                             KM_SLEEP);
        }
 
-       efdp->efd_item.li_type = XFS_LI_EFD;
-       efdp->efd_item.li_ops = &xfs_efd_item_ops;
-       efdp->efd_item.li_mountp = mp;
-       efdp->efd_item.li_ailp = mp->m_ail;
+       xfs_log_item_init(mp, &efdp->efd_item, XFS_LI_EFD, &xfs_efd_item_ops);
        efdp->efd_efip = efip;
        efdp->efd_format.efd_nextents = nextents;
        efdp->efd_format.efd_efi_id = efip->efi_format.efi_id;
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 7bfea85..32e4188 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -865,17 +865,9 @@ xfs_inode_item_init(
        ASSERT(ip->i_itemp == NULL);
        iip = ip->i_itemp = kmem_zone_zalloc(xfs_ili_zone, KM_SLEEP);
 
-       iip->ili_item.li_type = XFS_LI_INODE;
-       iip->ili_item.li_ops = &xfs_inode_item_ops;
-       iip->ili_item.li_mountp = mp;
-       iip->ili_item.li_ailp = mp->m_ail;
        iip->ili_inode = ip;
-
-       /*
-          We have zeroed memory. No need ...
-          iip->ili_extents_buf = NULL;
-        */
-
+       xfs_log_item_init(mp, &iip->ili_item, XFS_LI_INODE,
+                                               &xfs_inode_item_ops);
        iip->ili_format.ilf_type = XFS_LI_INODE;
        iip->ili_format.ilf_ino = ip->i_ino;
        iip->ili_format.ilf_blkno = ip->i_imap.im_blkno;
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index e8fba92..1f26a97 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -648,6 +648,19 @@ xfs_log_unmount(xfs_mount_t *mp)
        xlog_dealloc_log(mp->m_log);
 }
 
+void
+xfs_log_item_init(
+       struct xfs_mount        *mp,
+       struct xfs_log_item     *item,
+       int                     type,
+       struct xfs_item_ops     *ops)
+{
+       item->li_mountp = mp;
+       item->li_ailp = mp->m_ail;
+       item->li_type = type;
+       item->li_ops = ops;
+}
+
 /*
  * Write region vectors to log.  The write happens using the space reservation
  * of the ticket (tic).  It is not a requirement that all writes for a given
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index 97a24c7..f3a564d 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -126,6 +126,13 @@ typedef struct xfs_log_callback {
 struct xfs_mount;
 struct xlog_in_core;
 struct xlog_ticket;
+struct xfs_log_item;
+struct xfs_item_ops;
+
+void   xfs_log_item_init(struct xfs_mount      *mp,
+                       struct xfs_log_item     *item,
+                       int                     type,
+                       struct xfs_item_ops     *ops);
 
 xfs_lsn_t xfs_log_done(struct xfs_mount *mp,
                       struct xlog_ticket *ticket,
-- 
1.6.5

<Prev in Thread] Current Thread [Next in Thread>