Skip to contentSkip to conversation

xfs: improve xfs_iext_destroy() by freeing extent indirection array directly

PATCH In review Jeff Liu 1 participant 2 messages Sep 20, 2013 XFS filesystem

lore
Share & tools
lore

Jeff Liu

author
#0 lore raw

PATCH 1/1 xfs: improve xfs_iext_destroy() by freeing extent indirection array directly

From: Jie Liu <[email protected]>

To free the incore file extents stores at the indirection array, we call the common routine xfs_iext_irec_remove() to remove a record from the array one at a time in reverse order, which will resize an extent indirection array repeatedly according to the array size.

This is not often the case to make a file with thousands extent records stores at an indirection array, but above operation is inefficient and could result in memory fragments.

This patch refine xfs_iext_destroy() by freeing the extent records from the indirection array directly in this case.

---
 fs/xfs/xfs_inode_fork.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/xfs/xfs_inode_fork.c +5 -2
index 02f1083..ba70f98 100644
@@ -1525,9 +1525,12 @@ xfs_iext_destroy(
 		int	nlists;
 
 		nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
-		for (erp_idx = nlists - 1; erp_idx >= 0 ; erp_idx--) {
-			xfs_iext_irec_remove(ifp, erp_idx);
+		for (erp_idex = 0; erp_idx < nlists; erp_idx++) {
+			xfs_ext_irec_t	*erp = &ifp->if_u1.if_ext_irec[erp_idx];
+			if (erp->er_extbuf)
+				kmem_free(erp->er_extbuf);
 		}
+		kmem_free(ifp->if_u1.if_ext_irec);
 		ifp->if_flags &= ~XFS_IFEXTIREC;
 	} else if (ifp->if_real_bytes) {
 		kmem_free(ifp->if_u1.if_extents);
Signature · 6 lines
1.7.9.5

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#1 lore raw
Quoted 24 lines · Jeff Liu

From: Jie Liu <[email protected]>

To free the incore file extents stores at the indirection array, we call the common routine xfs_iext_irec_remove() to remove a record from the array one at a time in reverse order, which will resize an extent indirection array repeatedly according to the array size.

This is not often the case to make a file with thousands extent records stores at an indirection array, but above operation is inefficient and could result in memory fragments.

This patch refine xfs_iext_destroy() by freeing the extent records from the indirection array directly in this case.

---
 fs/xfs/xfs_inode_fork.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
fs/xfs/xfs_inode_fork.c +0 -0
index 02f1083..ba70f98 100644

fs/xfs/xfs_inode_fork.c xfs_iext_destroy( · line 1528

Quoted 6 lines
fs/xfs/xfs_inode_fork.c +1 -2
@@ -1525,9 +1525,12 @@ xfs_iext_destroy(
 		int	nlists;
 
 		nlists = ifp->if_real_bytes / XFS_IEXT_BUFSZ;
-		for (erp_idx = nlists - 1; erp_idx >= 0 ; erp_idx--) {
-			xfs_iext_irec_remove(ifp, erp_idx);
+		for (erp_idex = 0; erp_idx < nlists; erp_idx++) {

Sorry, here is a typo, s/erp_idex/erp_idx/, will resend it.

fs/xfs/xfs_inode_fork.c xfs_iext_destroy( · line 1536

Quoted 8 lines
fs/xfs/xfs_inode_fork.c +4 -0
+			xfs_ext_irec_t	*erp = &ifp->if_u1.if_ext_irec[erp_idx];
+			if (erp->er_extbuf)
+				kmem_free(erp->er_extbuf);
 		}
+		kmem_free(ifp->if_u1.if_ext_irec);
 		ifp->if_flags &= ~XFS_IFEXTIREC;
 	} else if (ifp->if_real_bytes) {
 		kmem_free(ifp->if_u1.if_extents);

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs