Print this page
4045 zfs write throttle & i/o scheduler performance work
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Christopher Siden <christopher.siden@delphix.com>


   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 




  26 #include <sys/zfs_context.h>
  27 #include <sys/dnode.h>
  28 #include <sys/dmu_objset.h>
  29 #include <sys/dmu_zfetch.h>
  30 #include <sys/dmu.h>
  31 #include <sys/dbuf.h>
  32 #include <sys/kstat.h>
  33 
  34 /*
  35  * I'm against tune-ables, but these should probably exist as tweakable globals
  36  * until we can get this working the way we want it to.
  37  */
  38 
  39 int zfs_prefetch_disable = 0;
  40 
  41 /* max # of streams per zfetch */
  42 uint32_t        zfetch_max_streams = 8;
  43 /* min time before stream reclaim */
  44 uint32_t        zfetch_min_sec_reap = 2;
  45 /* max number of blocks to fetch at a time */


 270 
 271         list_create(&zf->zf_stream, sizeof (zstream_t),
 272             offsetof(zstream_t, zst_node));
 273 
 274         rw_init(&zf->zf_rwlock, NULL, RW_DEFAULT, NULL);
 275 }
 276 
 277 /*
 278  * This function computes the actual size, in blocks, that can be prefetched,
 279  * and fetches it.
 280  */
 281 static uint64_t
 282 dmu_zfetch_fetch(dnode_t *dn, uint64_t blkid, uint64_t nblks)
 283 {
 284         uint64_t        fetchsz;
 285         uint64_t        i;
 286 
 287         fetchsz = dmu_zfetch_fetchsz(dn, blkid, nblks);
 288 
 289         for (i = 0; i < fetchsz; i++) {
 290                 dbuf_prefetch(dn, blkid + i);
 291         }
 292 
 293         return (fetchsz);
 294 }
 295 
 296 /*
 297  * this function returns the number of blocks that would be prefetched, based
 298  * upon the supplied dnode, blockid, and nblks.  This is used so that we can
 299  * update streams in place, and then prefetch with their old value after the
 300  * fact.  This way, we can delay the prefetch, but subsequent accesses to the
 301  * stream won't result in the same data being prefetched multiple times.
 302  */
 303 static uint64_t
 304 dmu_zfetch_fetchsz(dnode_t *dn, uint64_t blkid, uint64_t nblks)
 305 {
 306         uint64_t        fetchsz;
 307 
 308         if (blkid > dn->dn_maxblkid) {
 309                 return (0);
 310         }




   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2013 by Delphix. All rights reserved.
  28  */
  29 
  30 #include <sys/zfs_context.h>
  31 #include <sys/dnode.h>
  32 #include <sys/dmu_objset.h>
  33 #include <sys/dmu_zfetch.h>
  34 #include <sys/dmu.h>
  35 #include <sys/dbuf.h>
  36 #include <sys/kstat.h>
  37 
  38 /*
  39  * I'm against tune-ables, but these should probably exist as tweakable globals
  40  * until we can get this working the way we want it to.
  41  */
  42 
  43 int zfs_prefetch_disable = 0;
  44 
  45 /* max # of streams per zfetch */
  46 uint32_t        zfetch_max_streams = 8;
  47 /* min time before stream reclaim */
  48 uint32_t        zfetch_min_sec_reap = 2;
  49 /* max number of blocks to fetch at a time */


 274 
 275         list_create(&zf->zf_stream, sizeof (zstream_t),
 276             offsetof(zstream_t, zst_node));
 277 
 278         rw_init(&zf->zf_rwlock, NULL, RW_DEFAULT, NULL);
 279 }
 280 
 281 /*
 282  * This function computes the actual size, in blocks, that can be prefetched,
 283  * and fetches it.
 284  */
 285 static uint64_t
 286 dmu_zfetch_fetch(dnode_t *dn, uint64_t blkid, uint64_t nblks)
 287 {
 288         uint64_t        fetchsz;
 289         uint64_t        i;
 290 
 291         fetchsz = dmu_zfetch_fetchsz(dn, blkid, nblks);
 292 
 293         for (i = 0; i < fetchsz; i++) {
 294                 dbuf_prefetch(dn, blkid + i, ZIO_PRIORITY_ASYNC_READ);
 295         }
 296 
 297         return (fetchsz);
 298 }
 299 
 300 /*
 301  * this function returns the number of blocks that would be prefetched, based
 302  * upon the supplied dnode, blockid, and nblks.  This is used so that we can
 303  * update streams in place, and then prefetch with their old value after the
 304  * fact.  This way, we can delay the prefetch, but subsequent accesses to the
 305  * stream won't result in the same data being prefetched multiple times.
 306  */
 307 static uint64_t
 308 dmu_zfetch_fetchsz(dnode_t *dn, uint64_t blkid, uint64_t nblks)
 309 {
 310         uint64_t        fetchsz;
 311 
 312         if (blkid > dn->dn_maxblkid) {
 313                 return (0);
 314         }