xfs: factor log item initialisation
authorDave Chinner <dchinner@redhat.com>
Mon, 22 Mar 2010 23:10:00 +0000 (10:10 +1100)
committerAlex Elder <aelder@sgi.com>
Wed, 19 May 2010 14:58:07 +0000 (09:58 -0500)
Each log item type does manual initialisation of the log item.
Delayed logging introduces new fields that need initialisation, so
factor all the open coded initialisation into a common function
first.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/quota/xfs_dquot_item.c
fs/xfs/xfs_buf_item.c
fs/xfs/xfs_extfree_item.c
fs/xfs/xfs_inode_item.c
fs/xfs/xfs_log.c
fs/xfs/xfs_log.h

index 4e4ee9a..639d965 100644 (file)
@@ -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;
index f3c49e6..aace237 100644 (file)
@@ -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;
index 6f35ed1..e461e93 100644 (file)
@@ -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;
index 7bfea85..32e4188 100644 (file)
@@ -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;
index 2be0191..8556c59 100644 (file)
@@ -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
index 97a24c7..f3a564d 100644 (file)
@@ -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,