Author: mckusick
Date: Tue Jul  2 21:07:08 2013
New Revision: 252527
URL: http://svnweb.freebsd.org/changeset/base/252527

Log:
  Make better use of metadata area by avoiding using it for data blocks
  that no should no longer immediately follow their indirect blocks.
  
  MFC after:    2 weeks

Modified:
  head/sys/ufs/ffs/ffs_alloc.c
  head/sys/ufs/ffs/ffs_balloc.c

Modified: head/sys/ufs/ffs/ffs_alloc.c
==============================================================================
--- head/sys/ufs/ffs/ffs_alloc.c        Tue Jul  2 20:25:58 2013        
(r252526)
+++ head/sys/ufs/ffs/ffs_alloc.c        Tue Jul  2 21:07:08 2013        
(r252527)
@@ -1710,7 +1710,7 @@ ffs_alloccgblk(ip, bp, bpref, size)
        cgp = (struct cg *)bp->b_data;
        blksfree = cg_blksfree(cgp);
        if (bpref == 0) {
-               bpref = cgp->cg_rotor;
+               bpref = cgbase(fs, cgp->cg_cgx) + cgp->cg_rotor + fs->fs_frag;
        } else if ((cgbpref = dtog(fs, bpref)) != cgp->cg_cgx) {
                /* map bpref to correct zone in this cg */
                if (bpref < cgdata(fs, cgbpref))

Modified: head/sys/ufs/ffs/ffs_balloc.c
==============================================================================
--- head/sys/ufs/ffs/ffs_balloc.c       Tue Jul  2 20:25:58 2013        
(r252526)
+++ head/sys/ufs/ffs/ffs_balloc.c       Tue Jul  2 21:07:08 2013        
(r252527)
@@ -299,6 +299,10 @@ retry:
                        continue;
                }
                UFS_LOCK(ump);
+               /*
+                * If parent indirect has just been allocated, try to cluster
+                * immediately following it.
+                */
                if (pref == 0)
                        pref = ffs_blkpref_ufs1(ip, lbn, i - num - 1,
                            (ufs1_daddr_t *)0);
@@ -368,7 +372,14 @@ retry:
         */
        if (nb == 0) {
                UFS_LOCK(ump);
-               if (pref == 0)
+               /*
+                * If allocating metadata at the front of the cylinder
+                * group and parent indirect block has just been allocated,
+                * then cluster next to it if it is the first indirect in
+                * the file. Otherwise it has been allocated in the metadata
+                * area, so we want to find our own place out in the data area.
+                */
+               if (pref == 0 || (lbn > NDADDR && fs->fs_metaspace != 0))
                        pref = ffs_blkpref_ufs1(ip, lbn, indirs[i].in_off,
                            &bap[0]);
                error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize,
@@ -850,6 +861,10 @@ retry:
                        continue;
                }
                UFS_LOCK(ump);
+               /*
+                * If parent indirect has just been allocated, try to cluster
+                * immediately following it.
+                */
                if (pref == 0)
                        pref = ffs_blkpref_ufs2(ip, lbn, i - num - 1,
                            (ufs2_daddr_t *)0);
@@ -920,7 +935,14 @@ retry:
         */
        if (nb == 0) {
                UFS_LOCK(ump);
-               if (pref == 0)
+               /*
+                * If allocating metadata at the front of the cylinder
+                * group and parent indirect block has just been allocated,
+                * then cluster next to it if it is the first indirect in
+                * the file. Otherwise it has been allocated in the metadata
+                * area, so we want to find our own place out in the data area.
+                */
+               if (pref == 0 || (lbn > NDADDR && fs->fs_metaspace != 0))
                        pref = ffs_blkpref_ufs2(ip, lbn, indirs[i].in_off,
                            &bap[0]);
                error = ffs_alloc(ip, lbn, pref, (int)fs->fs_bsize,
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to