[XFS] consolidate extent item freeing
SGI-PV: 938062 SGI-Modid: xfs-linux:xfs-kern:194415a Signed-off-by: Christoph Hellwig <hch@sgi.com> Signed-off-by: Nathan Scott <nathans@sgi.com>
This commit is contained in:
committed by
Nathan Scott
parent
f898d6c09c
commit
7d795ca344
@@ -59,6 +59,18 @@ STATIC void xfs_efi_item_abort(xfs_efi_log_item_t *);
|
|||||||
STATIC void xfs_efd_item_abort(xfs_efd_log_item_t *);
|
STATIC void xfs_efd_item_abort(xfs_efd_log_item_t *);
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
xfs_efi_item_free(xfs_efi_log_item_t *efip)
|
||||||
|
{
|
||||||
|
int nexts = efip->efi_format.efi_nextents;
|
||||||
|
|
||||||
|
if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
|
||||||
|
kmem_free(efip, sizeof(xfs_efi_log_item_t) +
|
||||||
|
(nexts - 1) * sizeof(xfs_extent_t));
|
||||||
|
} else {
|
||||||
|
kmem_zone_free(xfs_efi_zone, efip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This returns the number of iovecs needed to log the given efi item.
|
* This returns the number of iovecs needed to log the given efi item.
|
||||||
@@ -120,8 +132,6 @@ xfs_efi_item_pin(xfs_efi_log_item_t *efip)
|
|||||||
STATIC void
|
STATIC void
|
||||||
xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
|
xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
|
||||||
{
|
{
|
||||||
int nexts;
|
|
||||||
int size;
|
|
||||||
xfs_mount_t *mp;
|
xfs_mount_t *mp;
|
||||||
SPLDECL(s);
|
SPLDECL(s);
|
||||||
|
|
||||||
@@ -132,21 +142,11 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
|
|||||||
* xfs_trans_delete_ail() drops the AIL lock.
|
* xfs_trans_delete_ail() drops the AIL lock.
|
||||||
*/
|
*/
|
||||||
xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
|
xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
|
||||||
|
xfs_efi_item_free(efip);
|
||||||
nexts = efip->efi_format.efi_nextents;
|
|
||||||
if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
|
|
||||||
size = sizeof(xfs_efi_log_item_t);
|
|
||||||
size += (nexts - 1) * sizeof(xfs_extent_t);
|
|
||||||
kmem_free(efip, size);
|
|
||||||
} else {
|
|
||||||
kmem_zone_free(xfs_efi_zone, efip);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
efip->efi_flags |= XFS_EFI_COMMITTED;
|
efip->efi_flags |= XFS_EFI_COMMITTED;
|
||||||
AIL_UNLOCK(mp, s);
|
AIL_UNLOCK(mp, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -159,8 +159,6 @@ xfs_efi_item_unpin(xfs_efi_log_item_t *efip, int stale)
|
|||||||
STATIC void
|
STATIC void
|
||||||
xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
|
xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
|
||||||
{
|
{
|
||||||
int nexts;
|
|
||||||
int size;
|
|
||||||
xfs_mount_t *mp;
|
xfs_mount_t *mp;
|
||||||
xfs_log_item_desc_t *lidp;
|
xfs_log_item_desc_t *lidp;
|
||||||
SPLDECL(s);
|
SPLDECL(s);
|
||||||
@@ -178,23 +176,11 @@ xfs_efi_item_unpin_remove(xfs_efi_log_item_t *efip, xfs_trans_t *tp)
|
|||||||
* xfs_trans_delete_ail() drops the AIL lock.
|
* xfs_trans_delete_ail() drops the AIL lock.
|
||||||
*/
|
*/
|
||||||
xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
|
xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
|
||||||
/*
|
xfs_efi_item_free(efip);
|
||||||
* now free the item itself
|
|
||||||
*/
|
|
||||||
nexts = efip->efi_format.efi_nextents;
|
|
||||||
if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
|
|
||||||
size = sizeof(xfs_efi_log_item_t);
|
|
||||||
size += (nexts - 1) * sizeof(xfs_extent_t);
|
|
||||||
kmem_free(efip, size);
|
|
||||||
} else {
|
|
||||||
kmem_zone_free(xfs_efi_zone, efip);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
efip->efi_flags |= XFS_EFI_COMMITTED;
|
efip->efi_flags |= XFS_EFI_COMMITTED;
|
||||||
AIL_UNLOCK(mp, s);
|
AIL_UNLOCK(mp, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -245,18 +231,7 @@ xfs_efi_item_committed(xfs_efi_log_item_t *efip, xfs_lsn_t lsn)
|
|||||||
STATIC void
|
STATIC void
|
||||||
xfs_efi_item_abort(xfs_efi_log_item_t *efip)
|
xfs_efi_item_abort(xfs_efi_log_item_t *efip)
|
||||||
{
|
{
|
||||||
int nexts;
|
xfs_efi_item_free(efip);
|
||||||
int size;
|
|
||||||
|
|
||||||
nexts = efip->efi_format.efi_nextents;
|
|
||||||
if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
|
|
||||||
size = sizeof(xfs_efi_log_item_t);
|
|
||||||
size += (nexts - 1) * sizeof(xfs_extent_t);
|
|
||||||
kmem_free(efip, size);
|
|
||||||
} else {
|
|
||||||
kmem_zone_free(xfs_efi_zone, efip);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -355,8 +330,6 @@ xfs_efi_release(xfs_efi_log_item_t *efip,
|
|||||||
{
|
{
|
||||||
xfs_mount_t *mp;
|
xfs_mount_t *mp;
|
||||||
int extents_left;
|
int extents_left;
|
||||||
uint size;
|
|
||||||
int nexts;
|
|
||||||
SPLDECL(s);
|
SPLDECL(s);
|
||||||
|
|
||||||
mp = efip->efi_item.li_mountp;
|
mp = efip->efi_item.li_mountp;
|
||||||
@@ -372,20 +345,10 @@ xfs_efi_release(xfs_efi_log_item_t *efip,
|
|||||||
* xfs_trans_delete_ail() drops the AIL lock.
|
* xfs_trans_delete_ail() drops the AIL lock.
|
||||||
*/
|
*/
|
||||||
xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
|
xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
|
||||||
|
xfs_efi_item_free(efip);
|
||||||
} else {
|
} else {
|
||||||
AIL_UNLOCK(mp, s);
|
AIL_UNLOCK(mp, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (extents_left == 0) {
|
|
||||||
nexts = efip->efi_format.efi_nextents;
|
|
||||||
if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
|
|
||||||
size = sizeof(xfs_efi_log_item_t);
|
|
||||||
size += (nexts - 1) * sizeof(xfs_extent_t);
|
|
||||||
kmem_free(efip, size);
|
|
||||||
} else {
|
|
||||||
kmem_zone_free(xfs_efi_zone, efip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -398,8 +361,6 @@ STATIC void
|
|||||||
xfs_efi_cancel(
|
xfs_efi_cancel(
|
||||||
xfs_efi_log_item_t *efip)
|
xfs_efi_log_item_t *efip)
|
||||||
{
|
{
|
||||||
int nexts;
|
|
||||||
int size;
|
|
||||||
xfs_mount_t *mp;
|
xfs_mount_t *mp;
|
||||||
SPLDECL(s);
|
SPLDECL(s);
|
||||||
|
|
||||||
@@ -410,26 +371,25 @@ xfs_efi_cancel(
|
|||||||
* xfs_trans_delete_ail() drops the AIL lock.
|
* xfs_trans_delete_ail() drops the AIL lock.
|
||||||
*/
|
*/
|
||||||
xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
|
xfs_trans_delete_ail(mp, (xfs_log_item_t *)efip, s);
|
||||||
|
xfs_efi_item_free(efip);
|
||||||
nexts = efip->efi_format.efi_nextents;
|
|
||||||
if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
|
|
||||||
size = sizeof(xfs_efi_log_item_t);
|
|
||||||
size += (nexts - 1) * sizeof(xfs_extent_t);
|
|
||||||
kmem_free(efip, size);
|
|
||||||
} else {
|
|
||||||
kmem_zone_free(xfs_efi_zone, efip);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
efip->efi_flags |= XFS_EFI_CANCELED;
|
efip->efi_flags |= XFS_EFI_CANCELED;
|
||||||
AIL_UNLOCK(mp, s);
|
AIL_UNLOCK(mp, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC void
|
||||||
|
xfs_efd_item_free(xfs_efd_log_item_t *efdp)
|
||||||
|
{
|
||||||
|
int nexts = efdp->efd_format.efd_nextents;
|
||||||
|
|
||||||
|
if (nexts > XFS_EFD_MAX_FAST_EXTENTS) {
|
||||||
|
kmem_free(efdp, sizeof(xfs_efd_log_item_t) +
|
||||||
|
(nexts - 1) * sizeof(xfs_extent_t));
|
||||||
|
} else {
|
||||||
|
kmem_zone_free(xfs_efd_zone, efdp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This returns the number of iovecs needed to log the given efd item.
|
* This returns the number of iovecs needed to log the given efd item.
|
||||||
@@ -533,9 +493,6 @@ xfs_efd_item_unlock(xfs_efd_log_item_t *efdp)
|
|||||||
STATIC xfs_lsn_t
|
STATIC xfs_lsn_t
|
||||||
xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
|
xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
|
||||||
{
|
{
|
||||||
uint size;
|
|
||||||
int nexts;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we got a log I/O error, it's always the case that the LR with the
|
* If we got a log I/O error, it's always the case that the LR with the
|
||||||
* EFI got unpinned and freed before the EFD got aborted.
|
* EFI got unpinned and freed before the EFD got aborted.
|
||||||
@@ -543,15 +500,7 @@ xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
|
|||||||
if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0)
|
if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0)
|
||||||
xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents);
|
xfs_efi_release(efdp->efd_efip, efdp->efd_format.efd_nextents);
|
||||||
|
|
||||||
nexts = efdp->efd_format.efd_nextents;
|
xfs_efd_item_free(efdp);
|
||||||
if (nexts > XFS_EFD_MAX_FAST_EXTENTS) {
|
|
||||||
size = sizeof(xfs_efd_log_item_t);
|
|
||||||
size += (nexts - 1) * sizeof(xfs_extent_t);
|
|
||||||
kmem_free(efdp, size);
|
|
||||||
} else {
|
|
||||||
kmem_zone_free(xfs_efd_zone, efdp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (xfs_lsn_t)-1;
|
return (xfs_lsn_t)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -565,9 +514,6 @@ xfs_efd_item_committed(xfs_efd_log_item_t *efdp, xfs_lsn_t lsn)
|
|||||||
STATIC void
|
STATIC void
|
||||||
xfs_efd_item_abort(xfs_efd_log_item_t *efdp)
|
xfs_efd_item_abort(xfs_efd_log_item_t *efdp)
|
||||||
{
|
{
|
||||||
int nexts;
|
|
||||||
int size;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we got a log I/O error, it's always the case that the LR with the
|
* If we got a log I/O error, it's always the case that the LR with the
|
||||||
* EFI got unpinned and freed before the EFD got aborted. So don't
|
* EFI got unpinned and freed before the EFD got aborted. So don't
|
||||||
@@ -576,15 +522,7 @@ xfs_efd_item_abort(xfs_efd_log_item_t *efdp)
|
|||||||
if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0)
|
if ((efdp->efd_item.li_flags & XFS_LI_ABORTED) == 0)
|
||||||
xfs_efi_cancel(efdp->efd_efip);
|
xfs_efi_cancel(efdp->efd_efip);
|
||||||
|
|
||||||
nexts = efdp->efd_format.efd_nextents;
|
xfs_efd_item_free(efdp);
|
||||||
if (nexts > XFS_EFD_MAX_FAST_EXTENTS) {
|
|
||||||
size = sizeof(xfs_efd_log_item_t);
|
|
||||||
size += (nexts - 1) * sizeof(xfs_extent_t);
|
|
||||||
kmem_free(efdp, size);
|
|
||||||
} else {
|
|
||||||
kmem_zone_free(xfs_efd_zone, efdp);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -118,6 +118,8 @@ xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint);
|
|||||||
xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
|
xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
|
||||||
uint);
|
uint);
|
||||||
|
|
||||||
|
void xfs_efi_item_free(xfs_efi_log_item_t *);
|
||||||
|
|
||||||
#endif /* __KERNEL__ */
|
#endif /* __KERNEL__ */
|
||||||
|
|
||||||
#endif /* __XFS_EXTFREE_ITEM_H__ */
|
#endif /* __XFS_EXTFREE_ITEM_H__ */
|
||||||
|
@@ -2747,7 +2747,6 @@ xlog_recover_do_efd_trans(
|
|||||||
xfs_efi_log_item_t *efip = NULL;
|
xfs_efi_log_item_t *efip = NULL;
|
||||||
xfs_log_item_t *lip;
|
xfs_log_item_t *lip;
|
||||||
int gen;
|
int gen;
|
||||||
int nexts;
|
|
||||||
__uint64_t efi_id;
|
__uint64_t efi_id;
|
||||||
SPLDECL(s);
|
SPLDECL(s);
|
||||||
|
|
||||||
@@ -2782,22 +2781,15 @@ xlog_recover_do_efd_trans(
|
|||||||
}
|
}
|
||||||
lip = xfs_trans_next_ail(mp, lip, &gen, NULL);
|
lip = xfs_trans_next_ail(mp, lip, &gen, NULL);
|
||||||
}
|
}
|
||||||
if (lip == NULL) {
|
|
||||||
AIL_UNLOCK(mp, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we found it, then free it up. If it wasn't there, it
|
* If we found it, then free it up. If it wasn't there, it
|
||||||
* must have been overwritten in the log. Oh well.
|
* must have been overwritten in the log. Oh well.
|
||||||
*/
|
*/
|
||||||
if (lip != NULL) {
|
if (lip != NULL) {
|
||||||
nexts = efip->efi_format.efi_nextents;
|
xfs_efi_item_free(efip);
|
||||||
if (nexts > XFS_EFI_MAX_FAST_EXTENTS) {
|
} else {
|
||||||
kmem_free(lip, sizeof(xfs_efi_log_item_t) +
|
AIL_UNLOCK(mp, s);
|
||||||
((nexts - 1) * sizeof(xfs_extent_t)));
|
|
||||||
} else {
|
|
||||||
kmem_zone_free(xfs_efi_zone, efip);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user