xfs: add a flag to release log items on commit
[linux-2.6-block.git] / fs / xfs / xfs_refcount_item.c
index fce38b56b962cf07ea5ce82b205db30dfe7dc2c8..5b03478c5d1f6c65586f30a137b8455acd677ba8 100644 (file)
@@ -94,15 +94,6 @@ xfs_cui_item_format(
                        xfs_cui_log_format_sizeof(cuip->cui_format.cui_nextents));
 }
 
-/*
- * Pinning has no meaning for an cui item, so just return.
- */
-STATIC void
-xfs_cui_item_pin(
-       struct xfs_log_item     *lip)
-{
-}
-
 /*
  * The unpin operation is the last place an CUI is manipulated in the log. It is
  * either inserted in the AIL or aborted in the event of a log I/O error. In
@@ -121,58 +112,16 @@ xfs_cui_item_unpin(
        xfs_cui_release(cuip);
 }
 
-/*
- * CUI items have no locking or pushing.  However, since CUIs are pulled from
- * the AIL when their corresponding CUDs are committed to disk, their situation
- * is very similar to being pinned.  Return XFS_ITEM_PINNED so that the caller
- * will eventually flush the log.  This should help in getting the CUI out of
- * the AIL.
- */
-STATIC uint
-xfs_cui_item_push(
-       struct xfs_log_item     *lip,
-       struct list_head        *buffer_list)
-{
-       return XFS_ITEM_PINNED;
-}
-
 /*
  * The CUI has been either committed or aborted if the transaction has been
  * cancelled. If the transaction was cancelled, an CUD isn't going to be
  * constructed and thus we free the CUI here directly.
  */
 STATIC void
-xfs_cui_item_unlock(
+xfs_cui_item_release(
        struct xfs_log_item     *lip)
 {
-       if (test_bit(XFS_LI_ABORTED, &lip->li_flags))
-               xfs_cui_release(CUI_ITEM(lip));
-}
-
-/*
- * The CUI is logged only once and cannot be moved in the log, so simply return
- * the lsn at which it's been logged.
- */
-STATIC xfs_lsn_t
-xfs_cui_item_committed(
-       struct xfs_log_item     *lip,
-       xfs_lsn_t               lsn)
-{
-       return lsn;
-}
-
-/*
- * The CUI dependency tracking op doesn't do squat.  It can't because
- * it doesn't know where the free extent is coming from.  The dependency
- * tracking has to be handled by the "enclosing" metadata object.  For
- * example, for inodes, the inode is locked throughout the extent freeing
- * so the dependency should be recorded there.
- */
-STATIC void
-xfs_cui_item_committing(
-       struct xfs_log_item     *lip,
-       xfs_lsn_t               lsn)
-{
+       xfs_cui_release(CUI_ITEM(lip));
 }
 
 /*
@@ -181,12 +130,8 @@ xfs_cui_item_committing(
 static const struct xfs_item_ops xfs_cui_item_ops = {
        .iop_size       = xfs_cui_item_size,
        .iop_format     = xfs_cui_item_format,
-       .iop_pin        = xfs_cui_item_pin,
        .iop_unpin      = xfs_cui_item_unpin,
-       .iop_unlock     = xfs_cui_item_unlock,
-       .iop_committed  = xfs_cui_item_committed,
-       .iop_push       = xfs_cui_item_push,
-       .iop_committing = xfs_cui_item_committing,
+       .iop_release    = xfs_cui_item_release,
 };
 
 /*
@@ -253,106 +198,29 @@ xfs_cud_item_format(
                        sizeof(struct xfs_cud_log_format));
 }
 
-/*
- * Pinning has no meaning for an cud item, so just return.
- */
-STATIC void
-xfs_cud_item_pin(
-       struct xfs_log_item     *lip)
-{
-}
-
-/*
- * Since pinning has no meaning for an cud item, unpinning does
- * not either.
- */
-STATIC void
-xfs_cud_item_unpin(
-       struct xfs_log_item     *lip,
-       int                     remove)
-{
-}
-
-/*
- * There isn't much you can do to push on an cud item.  It is simply stuck
- * waiting for the log to be flushed to disk.
- */
-STATIC uint
-xfs_cud_item_push(
-       struct xfs_log_item     *lip,
-       struct list_head        *buffer_list)
-{
-       return XFS_ITEM_PINNED;
-}
-
 /*
  * The CUD is either committed or aborted if the transaction is cancelled. If
  * the transaction is cancelled, drop our reference to the CUI and free the
  * CUD.
  */
 STATIC void
-xfs_cud_item_unlock(
+xfs_cud_item_release(
        struct xfs_log_item     *lip)
 {
        struct xfs_cud_log_item *cudp = CUD_ITEM(lip);
 
-       if (test_bit(XFS_LI_ABORTED, &lip->li_flags)) {
-               xfs_cui_release(cudp->cud_cuip);
-               kmem_zone_free(xfs_cud_zone, cudp);
-       }
-}
-
-/*
- * When the cud item is committed to disk, all we need to do is delete our
- * reference to our partner cui item and then free ourselves. Since we're
- * freeing ourselves we must return -1 to keep the transaction code from
- * further referencing this item.
- */
-STATIC xfs_lsn_t
-xfs_cud_item_committed(
-       struct xfs_log_item     *lip,
-       xfs_lsn_t               lsn)
-{
-       struct xfs_cud_log_item *cudp = CUD_ITEM(lip);
-
-       /*
-        * Drop the CUI reference regardless of whether the CUD has been
-        * aborted. Once the CUD transaction is constructed, it is the sole
-        * responsibility of the CUD to release the CUI (even if the CUI is
-        * aborted due to log I/O error).
-        */
        xfs_cui_release(cudp->cud_cuip);
        kmem_zone_free(xfs_cud_zone, cudp);
-
-       return (xfs_lsn_t)-1;
-}
-
-/*
- * The CUD dependency tracking op doesn't do squat.  It can't because
- * it doesn't know where the free extent is coming from.  The dependency
- * tracking has to be handled by the "enclosing" metadata object.  For
- * example, for inodes, the inode is locked throughout the extent freeing
- * so the dependency should be recorded there.
- */
-STATIC void
-xfs_cud_item_committing(
-       struct xfs_log_item     *lip,
-       xfs_lsn_t               lsn)
-{
 }
 
 /*
  * This is the ops vector shared by all cud log items.
  */
 static const struct xfs_item_ops xfs_cud_item_ops = {
+       .flags          = XFS_ITEM_RELEASE_WHEN_COMMITTED,
        .iop_size       = xfs_cud_item_size,
        .iop_format     = xfs_cud_item_format,
-       .iop_pin        = xfs_cud_item_pin,
-       .iop_unpin      = xfs_cud_item_unpin,
-       .iop_unlock     = xfs_cud_item_unlock,
-       .iop_committed  = xfs_cud_item_committed,
-       .iop_push       = xfs_cud_item_push,
-       .iop_committing = xfs_cud_item_committing,
+       .iop_release    = xfs_cud_item_release,
 };
 
 /*