[Top] [All Lists]

[PATCH v2] xfs: improve xfs_iext_destroy() by freeing extent indirection

To: "xfs@xxxxxxxxxxx" <xfs@xxxxxxxxxxx>
Subject: [PATCH v2] xfs: improve xfs_iext_destroy() by freeing extent indirection array directly
From: Jeff Liu <jeff.liu@xxxxxxxxxx>
Date: Tue, 24 Sep 2013 22:06:03 +0800
Delivered-to: xfs@xxxxxxxxxxx
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120410 Thunderbird/11.0.1
From: Jie Liu <jeff.liu@xxxxxxxxxx>

To free the incore file extents stores at an 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 inefficient for dealing with a file with thousands of incore
extent records stores at indirection arrays.

This patch improve this kind of things by freeing the extent records
from the indirection array directly so that we can get benefits for
reducing the overhead of alloc/free buffers which is depending on the
number of extents records.

Signed-off-by: Jie Liu <jeff.liu@xxxxxxxxxx>
- revise the commit message, no memory fragments at all.

 fs/xfs/xfs_inode_fork.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/xfs/xfs_inode_fork.c b/fs/xfs/xfs_inode_fork.c
index 02f1083..ba70f98 100644
--- a/fs/xfs/xfs_inode_fork.c
+++ b/fs/xfs/xfs_inode_fork.c
@@ -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_idx = 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) {

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