xfs
[Top] [All Lists]

[PATCH] xfs_fsr: avoid unnessary copying

To: linux-xfs@xxxxxxxxxxx
Subject: [PATCH] xfs_fsr: avoid unnessary copying
From: utz lehmann <xfs@xxxxxxxxxx>
Date: Sun, 2 Mar 2003 23:28:30 +0100
Sender: linux-xfs-bounce@xxxxxxxxxxx
User-agent: Mutt/1.2.5.1i
Hi

This patch moves the check for improved extent count directly after the
preallocation of the extents. So it can avoid copying of the extent data in
the case that no improvement is made. The patch is against current CVS.

On my testsystem with 3 files which cant improved the elapsed time went down
from 3min to 6s and saved about 3GB disk io.


utz


--- xfs_fsr.c.orig      Sat Mar  1 13:53:36 2003
+++ xfs_fsr.c   Sun Mar  2 23:02:25 2003
@@ -967,7 +967,8 @@
 {
        int             tfd;
        int             srval;
-       int             nextents, extent, cur_nextents, new_nextents;
+       int             nextents, extent, cur_nextents;
+       int             new_nextents = 0;
        unsigned        blksz_dio;
        unsigned        dio_min;
        struct dioattr  dio;
@@ -1111,6 +1112,15 @@
                                return -1;
                        }
                }
+               /* Check if the extent count improved */
+               new_nextents = getnextents(tfd);
+               if (cur_nextents <= new_nextents) {
+                       if (vflag)
+                               fsrprintf(_("No improvement made: %s\n"), 
fname);
+                       close(tfd);
+                       free(fbuf);
+                       return 1; /* no change/no error */
+               }
                for (cnt = outmap[extent].bmv_length; cnt > 0;
                     cnt -= ct, pos += ct) {
                        if (nfrags && --nfrags) {
@@ -1195,15 +1205,6 @@
        sx.sx_offset   = 0;
        sx.sx_length   = statp->bs_size;
 
-       /* Check if the extent count improved */
-       new_nextents = getnextents(tfd);
-       if (cur_nextents <= new_nextents) {
-               if (vflag)
-                       fsrprintf(_("No improvement made: %s\n"), fname);
-               close(tfd);
-               return 1; /* no change/no error */
-       }
-
        /* switch to the owner's id, to keep quota in line */
         if (fchown(tfd, statp->bs_uid, statp->bs_gid) < 0) {
                 if (vflag)




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