Print this page
6281 prefetching should apply to 1MB reads
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Reviewed by: Alexander Motin <mav@freebsd.org>
Reviewed by: Dan McDonald <danmcd@omniti.com>
Reviewed by: Justin Gibbs <gibbs@scsiguy.com>
Reviewed by: Xin Li <delphij@freebsd.org>
Approved by: Gordon Ross <gordon.ross@nexenta.com>
5987 zfs prefetch code needs work
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Paul Dagnelie <pcd@delphix.com>
Approved by: Gordon Ross <gordon.ross@nexenta.com>
NEX-4582 update wrc test cases for allow to use write back cache per tree of datasets
Reviewed by: Steve Peng <steve.peng@nexenta.com>
Reviewed by: Alex Aizman <alex.aizman@nexenta.com>
5960 zfs recv should prefetch indirect blocks
5925 zfs receive -o origin=
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/dmu_zfetch.c
          +++ new/usr/src/uts/common/fs/zfs/dmu_zfetch.c
↓ open down ↓ 203 lines elided ↑ open up ↑
 204  204   *   TRUE -- prefetch predicted data blocks plus following indirect blocks.
 205  205   */
 206  206  void
 207  207  dmu_zfetch(zfetch_t *zf, uint64_t blkid, uint64_t nblks, boolean_t fetch_data)
 208  208  {
 209  209          zstream_t *zs;
 210  210          int64_t pf_start, ipf_start, ipf_istart, ipf_iend;
 211  211          int64_t pf_ahead_blks, max_blks;
 212  212          int epbs, max_dist_blks, pf_nblks, ipf_nblks;
 213  213          uint64_t end_of_access_blkid = blkid + nblks;
 214      -        spa_t *spa = zf->zf_dnode->dn_objset->os_spa;
 215  214  
 216  215          if (zfs_prefetch_disable)
 217  216                  return;
 218  217  
 219  218          /*
 220      -         * If we haven't yet loaded the indirect vdevs' mappings, we
 221      -         * can only read from blocks that we carefully ensure are on
 222      -         * concrete vdevs (or previously-loaded indirect vdevs).  So we
 223      -         * can't allow the predictive prefetcher to attempt reads of other
 224      -         * blocks (e.g. of the MOS's dnode obejct).
 225      -         */
 226      -        if (!spa_indirect_vdevs_loaded(spa))
 227      -                return;
 228      -
 229      -        /*
 230  219           * As a fast path for small (single-block) files, ignore access
 231  220           * to the first block.
 232  221           */
 233  222          if (blkid == 0)
 234  223                  return;
 235  224  
 236  225          rw_enter(&zf->zf_rwlock, RW_READER);
 237  226  
 238      -        /*
 239      -         * Find matching prefetch stream.  Depending on whether the accesses
 240      -         * are block-aligned, first block of the new access may either follow
 241      -         * the last block of the previous access, or be equal to it.
 242      -         */
 243  227          for (zs = list_head(&zf->zf_stream); zs != NULL;
 244  228              zs = list_next(&zf->zf_stream, zs)) {
 245      -                if (blkid == zs->zs_blkid || blkid + 1 == zs->zs_blkid) {
      229 +                if (blkid == zs->zs_blkid) {
 246  230                          mutex_enter(&zs->zs_lock);
 247  231                          /*
 248  232                           * zs_blkid could have changed before we
 249  233                           * acquired zs_lock; re-check them here.
 250  234                           */
 251      -                        if (blkid == zs->zs_blkid) {
 252      -                                break;
 253      -                        } else if (blkid + 1 == zs->zs_blkid) {
 254      -                                blkid++;
 255      -                                nblks--;
 256      -                                if (nblks == 0) {
 257      -                                        /* Already prefetched this before. */
 258      -                                        mutex_exit(&zs->zs_lock);
 259      -                                        rw_exit(&zf->zf_rwlock);
 260      -                                        return;
 261      -                                }
 262      -                                break;
      235 +                        if (blkid != zs->zs_blkid) {
      236 +                                mutex_exit(&zs->zs_lock);
      237 +                                continue;
 263  238                          }
 264      -                        mutex_exit(&zs->zs_lock);
      239 +                        break;
 265  240                  }
 266  241          }
 267  242  
 268  243          if (zs == NULL) {
 269  244                  /*
 270  245                   * This access is not part of any existing stream.  Create
 271  246                   * a new stream for it.
 272  247                   */
 273  248                  ZFETCHSTAT_BUMP(zfetchstat_misses);
 274  249                  if (rw_tryupgrade(&zf->zf_rwlock))
↓ open down ↓ 83 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX