Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/zfs/zfs_vnops.c
          +++ new/usr/src/uts/common/fs/zfs/zfs_vnops.c
↓ open down ↓ 678 lines elided ↑ open up ↑
 679  679          /*
 680  680           * Fasttrack empty write
 681  681           */
 682  682          n = start_resid;
 683  683          if (n == 0)
 684  684                  return (0);
 685  685  
 686  686          if (limit == RLIM64_INFINITY || limit > MAXOFFSET_T)
 687  687                  limit = MAXOFFSET_T;
 688  688  
 689      -        /*
 690      -         * Pre-fault the pages to ensure slow (eg NFS) pages
 691      -         * don't hold up txg.
 692      -         * Skip this if uio contains loaned arc_buf.
 693      -         */
 694      -        if ((uio->uio_extflg == UIO_XUIO) &&
 695      -            (((xuio_t *)uio)->xu_type == UIOTYPE_ZEROCOPY))
 696      -                xuio = (xuio_t *)uio;
 697      -        else
 698      -                uio_prefaultpages(n, uio);
 699      -
 700  689          ZFS_ENTER(zfsvfs);
 701  690          ZFS_VERIFY_ZP(zp);
 702  691  
 703  692          SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL, &mtime, 16);
 704  693          SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL, &ctime, 16);
 705  694          SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_SIZE(zfsvfs), NULL,
 706  695              &zp->z_size, 8);
 707  696          SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zfsvfs), NULL,
 708  697              &zp->z_pflags, 8);
 709  698  
↓ open down ↓ 32 lines elided ↑ open up ↑
 742  731           * Check for mandatory locks before calling zfs_range_lock()
 743  732           * in order to prevent a deadlock with locks set via fcntl().
 744  733           */
 745  734          if (MANDMODE((mode_t)zp->z_mode) &&
 746  735              (error = chklock(vp, FWRITE, woff, n, uio->uio_fmode, ct)) != 0) {
 747  736                  ZFS_EXIT(zfsvfs);
 748  737                  return (error);
 749  738          }
 750  739  
 751  740          /*
      741 +         * Pre-fault the pages to ensure slow (eg NFS) pages
      742 +         * don't hold up txg.
      743 +         * Skip this if uio contains loaned arc_buf.
      744 +         */
      745 +        if ((uio->uio_extflg == UIO_XUIO) &&
      746 +            (((xuio_t *)uio)->xu_type == UIOTYPE_ZEROCOPY))
      747 +                xuio = (xuio_t *)uio;
      748 +        else
      749 +                uio_prefaultpages(MIN(n, max_blksz), uio);
      750 +
      751 +        /*
 752  752           * If in append mode, set the io offset pointer to eof.
 753  753           */
 754  754          if (ioflag & FAPPEND) {
 755  755                  /*
 756  756                   * Obtain an appending range lock to guarantee file append
 757  757                   * semantics.  We reset the write offset once we have the lock.
 758  758                   */
 759  759                  rl = zfs_range_lock(zp, 0, n, RL_APPEND);
 760  760                  woff = rl->r_off;
 761  761                  if (rl->r_len == UINT64_MAX) {
↓ open down ↓ 223 lines elided ↑ open up ↑
 985  985                  prev_error = error;
 986  986                  error = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx);
 987  987  
 988  988                  zfs_log_write(zilog, tx, TX_WRITE, zp, woff, tx_bytes, ioflag);
 989  989                  dmu_tx_commit(tx);
 990  990  
 991  991                  if (prev_error != 0 || error != 0)
 992  992                          break;
 993  993                  ASSERT(tx_bytes == nbytes);
 994  994                  n -= nbytes;
      995 +
      996 +                if (!xuio && n > 0)
      997 +                        uio_prefaultpages(MIN(n, max_blksz), uio);
 995  998          }
 996  999  
 997 1000          zfs_range_unlock(rl);
 998 1001  
 999 1002          /*
1000 1003           * If we're in replay mode, or we made no progress, return error.
1001 1004           * Otherwise, it's at least a partial write, so it's successful.
1002 1005           */
1003 1006          if (zfsvfs->z_replay || uio->uio_resid == start_resid) {
1004 1007                  ZFS_EXIT(zfsvfs);
↓ open down ↓ 3246 lines elided ↑ open up ↑
4251 4254                  int count = 0;
4252 4255  
4253 4256                  SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_MTIME(zfsvfs), NULL,
4254 4257                      &mtime, 16);
4255 4258                  SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CTIME(zfsvfs), NULL,
4256 4259                      &ctime, 16);
4257 4260                  SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_FLAGS(zfsvfs), NULL,
4258 4261                      &zp->z_pflags, 8);
4259 4262                  zfs_tstamp_update_setup(zp, CONTENT_MODIFIED, mtime, ctime,
4260 4263                      B_TRUE);
4261      -                err = sa_bulk_update(zp->z_sa_hdl, bulk, count, tx);
4262      -
4263 4264                  zfs_log_write(zfsvfs->z_log, tx, TX_WRITE, zp, off, len, 0);
4264 4265          }
4265 4266          dmu_tx_commit(tx);
4266 4267  
4267 4268  out:
4268 4269          pvn_write_done(pp, (err ? B_ERROR : 0) | flags);
4269 4270          if (offp)
4270 4271                  *offp = off;
4271 4272          if (lenp)
4272 4273                  *lenp = len;
↓ open down ↓ 515 lines elided ↑ open up ↑
4788 4789  static int
4789 4790  zfs_delmap(vnode_t *vp, offset_t off, struct as *as, caddr_t addr,
4790 4791      size_t len, uint_t prot, uint_t maxprot, uint_t flags, cred_t *cr,
4791 4792      caller_context_t *ct)
4792 4793  {
4793 4794          uint64_t pages = btopr(len);
4794 4795  
4795 4796          ASSERT3U(VTOZ(vp)->z_mapcnt, >=, pages);
4796 4797          atomic_add_64(&VTOZ(vp)->z_mapcnt, -pages);
4797 4798  
     4799 +        if ((flags & MAP_SHARED) && (prot & PROT_WRITE) &&
     4800 +            vn_has_cached_data(vp))
     4801 +                (void) VOP_PUTPAGE(vp, off, len, B_ASYNC, cr, ct);
     4802 +
4798 4803          return (0);
4799 4804  }
4800 4805  
4801 4806  /*
4802 4807   * Free or allocate space in a file.  Currently, this function only
4803 4808   * supports the `F_FREESP' command.  However, this command is somewhat
4804 4809   * misnamed, as its functionality includes the ability to allocate as
4805 4810   * well as free space.
4806 4811   *
4807 4812   *      IN:     vp      - vnode of file to free data in.
↓ open down ↓ 569 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX