Print this page
3742 zfs comments need cleaner, more consistent style
Submitted by:   Will Andrews <willa@spectralogic.com>
Submitted by:   Alan Somers <alans@spectralogic.com>
Reviewed by:    Matthew Ahrens <mahrens@delphix.com>
Reviewed by:    George Wilson <george.wilson@delphix.com>
Reviewed by:    Eric Schrock <eric.schrock@delphix.com>

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 ↓ 83 lines elided ↑ open up ↑
  84   84   * Programming rules.
  85   85   *
  86   86   * Each vnode op performs some logical unit of work.  To do this, the ZPL must
  87   87   * properly lock its in-core state, create a DMU transaction, do the work,
  88   88   * record this work in the intent log (ZIL), commit the DMU transaction,
  89   89   * and wait for the intent log to commit if it is a synchronous operation.
  90   90   * Moreover, the vnode ops must work in both normal and log replay context.
  91   91   * The ordering of events is important to avoid deadlocks and references
  92   92   * to freed memory.  The example below illustrates the following Big Rules:
  93   93   *
  94      - *  (1) A check must be made in each zfs thread for a mounted file system.
       94 + *  (1) A check must be made in each zfs thread for a mounted file system.
  95   95   *      This is done avoiding races using ZFS_ENTER(zfsvfs).
  96      - *      A ZFS_EXIT(zfsvfs) is needed before all returns.  Any znodes
  97      - *      must be checked with ZFS_VERIFY_ZP(zp).  Both of these macros
  98      - *      can return EIO from the calling function.
       96 + *      A ZFS_EXIT(zfsvfs) is needed before all returns.  Any znodes
       97 + *      must be checked with ZFS_VERIFY_ZP(zp).  Both of these macros
       98 + *      can return EIO from the calling function.
  99   99   *
 100  100   *  (2) VN_RELE() should always be the last thing except for zil_commit()
 101  101   *      (if necessary) and ZFS_EXIT(). This is for 3 reasons:
 102  102   *      First, if it's the last reference, the vnode/znode
 103  103   *      can be freed, so the zp may point to freed memory.  Second, the last
 104  104   *      reference will call zfs_zinactive(), which may induce a lot of work --
 105  105   *      pushing cached pages (which acquires range locks) and syncing out
 106  106   *      cached atime changes.  Third, zfs_zinactive() may require a new tx,
 107  107   *      which could deadlock the system if you were already holding one.
 108  108   *      If you must call VN_RELE() within a tx then use VN_RELE_ASYNC().
↓ open down ↓ 11 lines elided ↑ open up ↑
 120  120   *      Thread B is in an already-assigned tx, and blocks for this lock.
 121  121   *      Thread A calls dmu_tx_assign(TXG_WAIT) and blocks in txg_wait_open()
 122  122   *      forever, because the previous txg can't quiesce until B's tx commits.
 123  123   *
 124  124   *      If dmu_tx_assign() returns ERESTART and zfsvfs->z_assign is TXG_NOWAIT,
 125  125   *      then drop all locks, call dmu_tx_wait(), and try again.
 126  126   *
 127  127   *  (5) If the operation succeeded, generate the intent log entry for it
 128  128   *      before dropping locks.  This ensures that the ordering of events
 129  129   *      in the intent log matches the order in which they actually occurred.
 130      - *      During ZIL replay the zfs_log_* functions will update the sequence
      130 + *      During ZIL replay the zfs_log_* functions will update the sequence
 131  131   *      number to indicate the zil transaction has replayed.
 132  132   *
 133  133   *  (6) At the end of each vnode op, the DMU tx must always commit,
 134  134   *      regardless of whether there were any errors.
 135  135   *
 136  136   *  (7) After dropping all locks, invoke zil_commit(zilog, foid)
 137  137   *      to ensure that synchronous semantics are provided when necessary.
 138  138   *
 139  139   * In general, this is how things should be ordered in each vnode op:
 140  140   *
↓ open down ↓ 236 lines elided ↑ open up ↑
 377  377  }
 378  378  
 379  379  /*
 380  380   * When a file is memory mapped, we must keep the IO data synchronized
 381  381   * between the DMU cache and the memory mapped pages.  What this means:
 382  382   *
 383  383   * On Read:     We "read" preferentially from memory mapped pages,
 384  384   *              else we default from the dmu buffer.
 385  385   *
 386  386   * NOTE: We will always "break up" the IO into PAGESIZE uiomoves when
 387      - *      the file is memory mapped.
      387 + *       the file is memory mapped.
 388  388   */
 389  389  static int
 390  390  mappedread(vnode_t *vp, int nbytes, uio_t *uio)
 391  391  {
 392  392          znode_t *zp = VTOZ(vp);
 393  393          objset_t *os = zp->z_zfsvfs->z_os;
 394  394          int64_t start, off;
 395  395          int len = nbytes;
 396  396          int error = 0;
 397  397  
↓ open down ↓ 28 lines elided ↑ open up ↑
 426  426   *
 427  427   *      IN:     vp      - vnode of file to be read from.
 428  428   *              uio     - structure supplying read location, range info,
 429  429   *                        and return buffer.
 430  430   *              ioflag  - SYNC flags; used to provide FRSYNC semantics.
 431  431   *              cr      - credentials of caller.
 432  432   *              ct      - caller context
 433  433   *
 434  434   *      OUT:    uio     - updated offset and range, buffer filled.
 435  435   *
 436      - *      RETURN: 0 if success
 437      - *              error code if failure
      436 + *      RETURN: 0 on success, error code on failure.
 438  437   *
 439  438   * Side Effects:
 440  439   *      vp - atime updated if byte count > 0
 441  440   */
 442  441  /* ARGSUSED */
 443  442  static int
 444  443  zfs_read(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
 445  444  {
 446  445          znode_t         *zp = VTOZ(vp);
 447  446          zfsvfs_t        *zfsvfs = zp->z_zfsvfs;
↓ open down ↓ 115 lines elided ↑ open up ↑
 563  562          ZFS_EXIT(zfsvfs);
 564  563          return (error);
 565  564  }
 566  565  
 567  566  /*
 568  567   * Write the bytes to a file.
 569  568   *
 570  569   *      IN:     vp      - vnode of file to be written to.
 571  570   *              uio     - structure supplying write location, range info,
 572  571   *                        and data buffer.
 573      - *              ioflag  - FAPPEND flag set if in append mode.
      572 + *              ioflag  - FAPPEND, FSYNC, and/or FDSYNC.  FAPPEND is
      573 + *                        set if in append mode.
 574  574   *              cr      - credentials of caller.
 575  575   *              ct      - caller context (NFS/CIFS fem monitor only)
 576  576   *
 577  577   *      OUT:    uio     - updated offset and range.
 578  578   *
 579      - *      RETURN: 0 if success
 580      - *              error code if failure
      579 + *      RETURN: 0 on success, error code on failure.
 581  580   *
 582  581   * Timestamps:
 583  582   *      vp - ctime|mtime updated if byte count > 0
 584  583   */
 585  584  
 586  585  /* ARGSUSED */
 587  586  static int
 588  587  zfs_write(vnode_t *vp, uio_t *uio, int ioflag, cred_t *cr, caller_context_t *ct)
 589  588  {
 590  589          znode_t         *zp = VTOZ(vp);
↓ open down ↓ 550 lines elided ↑ open up ↑
1141 1140   *              pnp     - full pathname to lookup [UNUSED].
1142 1141   *              flags   - LOOKUP_XATTR set if looking for an attribute.
1143 1142   *              rdir    - root directory vnode [UNUSED].
1144 1143   *              cr      - credentials of caller.
1145 1144   *              ct      - caller context
1146 1145   *              direntflags - directory lookup flags
1147 1146   *              realpnp - returned pathname.
1148 1147   *
1149 1148   *      OUT:    vpp     - vnode of located entry, NULL if not found.
1150 1149   *
1151      - *      RETURN: 0 if success
1152      - *              error code if failure
     1150 + *      RETURN: 0 on success, error code on failure.
1153 1151   *
1154 1152   * Timestamps:
1155 1153   *      NA
1156 1154   */
1157 1155  /* ARGSUSED */
1158 1156  static int
1159 1157  zfs_lookup(vnode_t *dvp, char *nm, vnode_t **vpp, struct pathname *pnp,
1160 1158      int flags, vnode_t *rdir, cred_t *cr,  caller_context_t *ct,
1161 1159      int *direntflags, pathname_t *realpnp)
1162 1160  {
↓ open down ↓ 120 lines elided ↑ open up ↑
1283 1281   *              vap     - attributes of new file.
1284 1282   *              excl    - flag indicating exclusive or non-exclusive mode.
1285 1283   *              mode    - mode to open file with.
1286 1284   *              cr      - credentials of caller.
1287 1285   *              flag    - large file flag [UNUSED].
1288 1286   *              ct      - caller context
1289 1287   *              vsecp   - ACL to be set
1290 1288   *
1291 1289   *      OUT:    vpp     - vnode of created or trunc'd entry.
1292 1290   *
1293      - *      RETURN: 0 if success
1294      - *              error code if failure
     1291 + *      RETURN: 0 on success, error code on failure.
1295 1292   *
1296 1293   * Timestamps:
1297 1294   *      dvp - ctime|mtime updated if new entry created
1298 1295   *       vp - ctime|mtime always, atime if new
1299 1296   */
1300 1297  
1301 1298  /* ARGSUSED */
1302 1299  static int
1303 1300  zfs_create(vnode_t *dvp, char *name, vattr_t *vap, vcexcl_t excl,
1304 1301      int mode, vnode_t **vpp, cred_t *cr, int flag, caller_context_t *ct,
↓ open down ↓ 229 lines elided ↑ open up ↑
1534 1531  
1535 1532  /*
1536 1533   * Remove an entry from a directory.
1537 1534   *
1538 1535   *      IN:     dvp     - vnode of directory to remove entry from.
1539 1536   *              name    - name of entry to remove.
1540 1537   *              cr      - credentials of caller.
1541 1538   *              ct      - caller context
1542 1539   *              flags   - case flags
1543 1540   *
1544      - *      RETURN: 0 if success
1545      - *              error code if failure
     1541 + *      RETURN: 0 on success, error code on failure.
1546 1542   *
1547 1543   * Timestamps:
1548 1544   *      dvp - ctime|mtime
1549 1545   *       vp - ctime (if nlink > 0)
1550 1546   */
1551 1547  
1552 1548  uint64_t null_xattr = 0;
1553 1549  
1554 1550  /*ARGSUSED*/
1555 1551  static int
↓ open down ↓ 209 lines elided ↑ open up ↑
1765 1761  
1766 1762  /*
1767 1763   * Create a new directory and insert it into dvp using the name
1768 1764   * provided.  Return a pointer to the inserted directory.
1769 1765   *
1770 1766   *      IN:     dvp     - vnode of directory to add subdir to.
1771 1767   *              dirname - name of new directory.
1772 1768   *              vap     - attributes of new directory.
1773 1769   *              cr      - credentials of caller.
1774 1770   *              ct      - caller context
     1771 + *              flags   - case flags
1775 1772   *              vsecp   - ACL to be set
1776 1773   *
1777 1774   *      OUT:    vpp     - vnode of created directory.
1778 1775   *
1779      - *      RETURN: 0 if success
1780      - *              error code if failure
     1776 + *      RETURN: 0 on success, error code on failure.
1781 1777   *
1782 1778   * Timestamps:
1783 1779   *      dvp - ctime|mtime updated
1784 1780   *       vp - ctime|mtime|atime updated
1785 1781   */
1786 1782  /*ARGSUSED*/
1787 1783  static int
1788 1784  zfs_mkdir(vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp, cred_t *cr,
1789 1785      caller_context_t *ct, int flags, vsecattr_t *vsecp)
1790 1786  {
↓ open down ↓ 159 lines elided ↑ open up ↑
1950 1946   * directory is the same as the subdir to be removed, the
1951 1947   * remove will fail.
1952 1948   *
1953 1949   *      IN:     dvp     - vnode of directory to remove from.
1954 1950   *              name    - name of directory to be removed.
1955 1951   *              cwd     - vnode of current working directory.
1956 1952   *              cr      - credentials of caller.
1957 1953   *              ct      - caller context
1958 1954   *              flags   - case flags
1959 1955   *
1960      - *      RETURN: 0 if success
1961      - *              error code if failure
     1956 + *      RETURN: 0 on success, error code on failure.
1962 1957   *
1963 1958   * Timestamps:
1964 1959   *      dvp - ctime|mtime updated
1965 1960   */
1966 1961  /*ARGSUSED*/
1967 1962  static int
1968 1963  zfs_rmdir(vnode_t *dvp, char *name, vnode_t *cwd, cred_t *cr,
1969 1964      caller_context_t *ct, int flags)
1970 1965  {
1971 1966          znode_t         *dzp = VTOZ(dvp);
↓ open down ↓ 97 lines elided ↑ open up ↑
2069 2064          if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
2070 2065                  zil_commit(zilog, 0);
2071 2066  
2072 2067          ZFS_EXIT(zfsvfs);
2073 2068          return (error);
2074 2069  }
2075 2070  
2076 2071  /*
2077 2072   * Read as many directory entries as will fit into the provided
2078 2073   * buffer from the given directory cursor position (specified in
2079      - * the uio structure.
     2074 + * the uio structure).
2080 2075   *
2081 2076   *      IN:     vp      - vnode of directory to read.
2082 2077   *              uio     - structure supplying read location, range info,
2083 2078   *                        and return buffer.
2084 2079   *              cr      - credentials of caller.
2085 2080   *              ct      - caller context
2086 2081   *              flags   - case flags
2087 2082   *
2088 2083   *      OUT:    uio     - updated offset and range, buffer filled.
2089 2084   *              eofp    - set to true if end-of-file detected.
2090 2085   *
2091      - *      RETURN: 0 if success
2092      - *              error code if failure
     2086 + *      RETURN: 0 on success, error code on failure.
2093 2087   *
2094 2088   * Timestamps:
2095 2089   *      vp - atime updated
2096 2090   *
2097 2091   * Note that the low 4 bits of the cookie returned by zap is always zero.
2098 2092   * This allows us to use the low range for "special" directory entries:
2099 2093   * We use 0 for '.', and 1 for '..'.  If this is the root of the filesystem,
2100 2094   * we use the offset 2 for the '.zfs' directory.
2101 2095   */
2102 2096  /* ARGSUSED */
↓ open down ↓ 298 lines elided ↑ open up ↑
2401 2395   *
2402 2396   *      IN:     vp      - vnode of file.
2403 2397   *              vap     - va_mask identifies requested attributes.
2404 2398   *                        If AT_XVATTR set, then optional attrs are requested
2405 2399   *              flags   - ATTR_NOACLCHECK (CIFS server context)
2406 2400   *              cr      - credentials of caller.
2407 2401   *              ct      - caller context
2408 2402   *
2409 2403   *      OUT:    vap     - attribute values.
2410 2404   *
2411      - *      RETURN: 0 (always succeeds)
     2405 + *      RETURN: 0 (always succeeds).
2412 2406   */
2413 2407  /* ARGSUSED */
2414 2408  static int
2415 2409  zfs_getattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
2416 2410      caller_context_t *ct)
2417 2411  {
2418 2412          znode_t *zp = VTOZ(vp);
2419 2413          zfsvfs_t *zfsvfs = zp->z_zfsvfs;
2420 2414          int     error = 0;
2421 2415          uint64_t links;
↓ open down ↓ 181 lines elided ↑ open up ↑
2603 2597   * vattr structure.
2604 2598   *
2605 2599   *      IN:     vp      - vnode of file to be modified.
2606 2600   *              vap     - new attribute values.
2607 2601   *                        If AT_XVATTR set, then optional attrs are being set
2608 2602   *              flags   - ATTR_UTIME set if non-default time values provided.
2609 2603   *                      - ATTR_NOACLCHECK (CIFS context only).
2610 2604   *              cr      - credentials of caller.
2611 2605   *              ct      - caller context
2612 2606   *
2613      - *      RETURN: 0 if success
2614      - *              error code if failure
     2607 + *      RETURN: 0 on success, error code on failure.
2615 2608   *
2616 2609   * Timestamps:
2617 2610   *      vp - ctime updated, mtime updated if size changed.
2618 2611   */
2619 2612  /* ARGSUSED */
2620 2613  static int
2621 2614  zfs_setattr(vnode_t *vp, vattr_t *vap, int flags, cred_t *cr,
2622      -        caller_context_t *ct)
     2615 +    caller_context_t *ct)
2623 2616  {
2624 2617          znode_t         *zp = VTOZ(vp);
2625 2618          zfsvfs_t        *zfsvfs = zp->z_zfsvfs;
2626 2619          zilog_t         *zilog;
2627 2620          dmu_tx_t        *tx;
2628 2621          vattr_t         oldva;
2629 2622          xvattr_t        tmpxvattr;
2630 2623          uint_t          mask = vap->va_mask;
2631 2624          uint_t          saved_mask = 0;
2632 2625          int             trim_mask = 0;
↓ open down ↓ 572 lines elided ↑ open up ↑
3205 3198          }
3206 3199  out:
3207 3200          if (err == 0 && attrzp) {
3208 3201                  err2 = sa_bulk_update(attrzp->z_sa_hdl, xattr_bulk,
3209 3202                      xattr_count, tx);
3210 3203                  ASSERT(err2 == 0);
3211 3204          }
3212 3205  
3213 3206          if (attrzp)
3214 3207                  VN_RELE(ZTOV(attrzp));
     3208 +
3215 3209          if (aclp)
3216 3210                  zfs_acl_free(aclp);
3217 3211  
3218 3212          if (fuidp) {
3219 3213                  zfs_fuid_info_free(fuidp);
3220 3214                  fuidp = NULL;
3221 3215          }
3222 3216  
3223 3217          if (err) {
3224 3218                  dmu_tx_abort(tx);
↓ open down ↓ 114 lines elided ↑ open up ↑
3339 3333   * directory.  Change the entry name as indicated.
3340 3334   *
3341 3335   *      IN:     sdvp    - Source directory containing the "old entry".
3342 3336   *              snm     - Old entry name.
3343 3337   *              tdvp    - Target directory to contain the "new entry".
3344 3338   *              tnm     - New entry name.
3345 3339   *              cr      - credentials of caller.
3346 3340   *              ct      - caller context
3347 3341   *              flags   - case flags
3348 3342   *
3349      - *      RETURN: 0 if success
3350      - *              error code if failure
     3343 + *      RETURN: 0 on success, error code on failure.
3351 3344   *
3352 3345   * Timestamps:
3353 3346   *      sdvp,tdvp - ctime|mtime updated
3354 3347   */
3355 3348  /*ARGSUSED*/
3356 3349  static int
3357 3350  zfs_rename(vnode_t *sdvp, char *snm, vnode_t *tdvp, char *tnm, cred_t *cr,
3358 3351      caller_context_t *ct, int flags)
3359 3352  {
3360 3353          znode_t         *tdzp, *szp, *tzp;
↓ open down ↓ 326 lines elided ↑ open up ↑
3687 3680          ZFS_EXIT(zfsvfs);
3688 3681          return (error);
3689 3682  }
3690 3683  
3691 3684  /*
3692 3685   * Insert the indicated symbolic reference entry into the directory.
3693 3686   *
3694 3687   *      IN:     dvp     - Directory to contain new symbolic link.
3695 3688   *              link    - Name for new symlink entry.
3696 3689   *              vap     - Attributes of new entry.
3697      - *              target  - Target path of new symlink.
3698 3690   *              cr      - credentials of caller.
3699 3691   *              ct      - caller context
3700 3692   *              flags   - case flags
3701 3693   *
3702      - *      RETURN: 0 if success
3703      - *              error code if failure
     3694 + *      RETURN: 0 on success, error code on failure.
3704 3695   *
3705 3696   * Timestamps:
3706 3697   *      dvp - ctime|mtime updated
3707 3698   */
3708 3699  /*ARGSUSED*/
3709 3700  static int
3710 3701  zfs_symlink(vnode_t *dvp, char *name, vattr_t *vap, char *link, cred_t *cr,
3711 3702      caller_context_t *ct, int flags)
3712 3703  {
3713 3704          znode_t         *zp, *dzp = VTOZ(dvp);
↓ open down ↓ 125 lines elided ↑ open up ↑
3839 3830  
3840 3831          ZFS_EXIT(zfsvfs);
3841 3832          return (error);
3842 3833  }
3843 3834  
3844 3835  /*
3845 3836   * Return, in the buffer contained in the provided uio structure,
3846 3837   * the symbolic path referred to by vp.
3847 3838   *
3848 3839   *      IN:     vp      - vnode of symbolic link.
3849      - *              uoip    - structure to contain the link path.
     3840 + *              uio     - structure to contain the link path.
3850 3841   *              cr      - credentials of caller.
3851 3842   *              ct      - caller context
3852 3843   *
3853      - *      OUT:    uio     - structure to contain the link path.
     3844 + *      OUT:    uio     - structure containing the link path.
3854 3845   *
3855      - *      RETURN: 0 if success
3856      - *              error code if failure
     3846 + *      RETURN: 0 on success, error code on failure.
3857 3847   *
3858 3848   * Timestamps:
3859 3849   *      vp - atime updated
3860 3850   */
3861 3851  /* ARGSUSED */
3862 3852  static int
3863 3853  zfs_readlink(vnode_t *vp, uio_t *uio, cred_t *cr, caller_context_t *ct)
3864 3854  {
3865 3855          znode_t         *zp = VTOZ(vp);
3866 3856          zfsvfs_t        *zfsvfs = zp->z_zfsvfs;
↓ open down ↓ 18 lines elided ↑ open up ↑
3885 3875  
3886 3876  /*
3887 3877   * Insert a new entry into directory tdvp referencing svp.
3888 3878   *
3889 3879   *      IN:     tdvp    - Directory to contain new entry.
3890 3880   *              svp     - vnode of new entry.
3891 3881   *              name    - name of new entry.
3892 3882   *              cr      - credentials of caller.
3893 3883   *              ct      - caller context
3894 3884   *
3895      - *      RETURN: 0 if success
3896      - *              error code if failure
     3885 + *      RETURN: 0 on success, error code on failure.
3897 3886   *
3898 3887   * Timestamps:
3899 3888   *      tdvp - ctime|mtime updated
3900 3889   *       svp - ctime updated
3901 3890   */
3902 3891  /* ARGSUSED */
3903 3892  static int
3904 3893  zfs_link(vnode_t *tdvp, vnode_t *svp, char *name, cred_t *cr,
3905 3894      caller_context_t *ct, int flags)
3906 3895  {
↓ open down ↓ 147 lines elided ↑ open up ↑
4054 4043   * Push a page out to disk, klustering if possible.
4055 4044   *
4056 4045   *      IN:     vp      - file to push page to.
4057 4046   *              pp      - page to push.
4058 4047   *              flags   - additional flags.
4059 4048   *              cr      - credentials of caller.
4060 4049   *
4061 4050   *      OUT:    offp    - start of range pushed.
4062 4051   *              lenp    - len of range pushed.
4063 4052   *
4064      - *      RETURN: 0 if success
4065      - *              error code if failure
     4053 + *      RETURN: 0 on success, error code on failure.
4066 4054   *
4067 4055   * NOTE: callers must have locked the page to be pushed.  On
4068 4056   * exit, the page (and all other pages in the kluster) must be
4069 4057   * unlocked.
4070 4058   */
4071 4059  /* ARGSUSED */
4072 4060  static int
4073 4061  zfs_putapage(vnode_t *vp, page_t *pp, u_offset_t *offp,
4074 4062                  size_t *lenp, int flags, cred_t *cr)
4075 4063  {
↓ open down ↓ 101 lines elided ↑ open up ↑
4177 4165   * Copy the portion of the file indicated from pages into the file.
4178 4166   * The pages are stored in a page list attached to the files vnode.
4179 4167   *
4180 4168   *      IN:     vp      - vnode of file to push page data to.
4181 4169   *              off     - position in file to put data.
4182 4170   *              len     - amount of data to write.
4183 4171   *              flags   - flags to control the operation.
4184 4172   *              cr      - credentials of caller.
4185 4173   *              ct      - caller context.
4186 4174   *
4187      - *      RETURN: 0 if success
4188      - *              error code if failure
     4175 + *      RETURN: 0 on success, error code on failure.
4189 4176   *
4190 4177   * Timestamps:
4191 4178   *      vp - ctime|mtime updated
4192 4179   */
4193 4180  /*ARGSUSED*/
4194 4181  static int
4195 4182  zfs_putpage(vnode_t *vp, offset_t off, size_t len, int flags, cred_t *cr,
4196 4183      caller_context_t *ct)
4197 4184  {
4198 4185          znode_t         *zp = VTOZ(vp);
↓ open down ↓ 144 lines elided ↑ open up ↑
4343 4330  }
4344 4331  
4345 4332  /*
4346 4333   * Bounds-check the seek operation.
4347 4334   *
4348 4335   *      IN:     vp      - vnode seeking within
4349 4336   *              ooff    - old file offset
4350 4337   *              noffp   - pointer to new file offset
4351 4338   *              ct      - caller context
4352 4339   *
4353      - *      RETURN: 0 if success
4354      - *              EINVAL if new offset invalid
     4340 + *      RETURN: 0 on success, EINVAL if new offset invalid.
4355 4341   */
4356 4342  /* ARGSUSED */
4357 4343  static int
4358 4344  zfs_seek(vnode_t *vp, offset_t ooff, offset_t *noffp,
4359 4345      caller_context_t *ct)
4360 4346  {
4361 4347          if (vp->v_type == VDIR)
4362 4348                  return (0);
4363 4349          return ((*noffp < 0 || *noffp > MAXOFFSET_T) ? EINVAL : 0);
4364 4350  }
↓ open down ↓ 115 lines elided ↑ open up ↑
4480 4466   *              plsz    - length of provided page list.
4481 4467   *              seg     - segment to obtain pages for.
4482 4468   *              addr    - virtual address of fault.
4483 4469   *              rw      - mode of created pages.
4484 4470   *              cr      - credentials of caller.
4485 4471   *              ct      - caller context.
4486 4472   *
4487 4473   *      OUT:    protp   - protection mode of created pages.
4488 4474   *              pl      - list of pages created.
4489 4475   *
4490      - *      RETURN: 0 if success
4491      - *              error code if failure
     4476 + *      RETURN: 0 on success, error code on failure.
4492 4477   *
4493 4478   * Timestamps:
4494 4479   *      vp - atime updated
4495 4480   */
4496 4481  /* ARGSUSED */
4497 4482  static int
4498 4483  zfs_getpage(vnode_t *vp, offset_t off, size_t len, uint_t *protp,
4499      -        page_t *pl[], size_t plsz, struct seg *seg, caddr_t addr,
4500      -        enum seg_rw rw, cred_t *cr, caller_context_t *ct)
     4484 +    page_t *pl[], size_t plsz, struct seg *seg, caddr_t addr,
     4485 +    enum seg_rw rw, cred_t *cr, caller_context_t *ct)
4501 4486  {
4502 4487          znode_t         *zp = VTOZ(vp);
4503 4488          zfsvfs_t        *zfsvfs = zp->z_zfsvfs;
4504 4489          page_t          **pl0 = pl;
4505 4490          int             err = 0;
4506 4491  
4507 4492          /* we do our own caching, faultahead is unnecessary */
4508 4493          if (pl == NULL)
4509 4494                  return (0);
4510 4495          else if (len > plsz)
↓ open down ↓ 54 lines elided ↑ open up ↑
4565 4550          *pl = NULL;
4566 4551  
4567 4552          ZFS_EXIT(zfsvfs);
4568 4553          return (err);
4569 4554  }
4570 4555  
4571 4556  /*
4572 4557   * Request a memory map for a section of a file.  This code interacts
4573 4558   * with common code and the VM system as follows:
4574 4559   *
4575      - *      common code calls mmap(), which ends up in smmap_common()
4576      - *
4577      - *      this calls VOP_MAP(), which takes you into (say) zfs
4578      - *
4579      - *      zfs_map() calls as_map(), passing segvn_create() as the callback
4580      - *
4581      - *      segvn_create() creates the new segment and calls VOP_ADDMAP()
4582      - *
4583      - *      zfs_addmap() updates z_mapcnt
     4560 + * - common code calls mmap(), which ends up in smmap_common()
     4561 + * - this calls VOP_MAP(), which takes you into (say) zfs
     4562 + * - zfs_map() calls as_map(), passing segvn_create() as the callback
     4563 + * - segvn_create() creates the new segment and calls VOP_ADDMAP()
     4564 + * - zfs_addmap() updates z_mapcnt
4584 4565   */
4585 4566  /*ARGSUSED*/
4586 4567  static int
4587 4568  zfs_map(vnode_t *vp, offset_t off, struct as *as, caddr_t *addrp,
4588 4569      size_t len, uchar_t prot, uchar_t maxprot, uint_t flags, cred_t *cr,
4589 4570      caller_context_t *ct)
4590 4571  {
4591 4572          znode_t *zp = VTOZ(vp);
4592 4573          zfsvfs_t *zfsvfs = zp->z_zfsvfs;
4593 4574          segvn_crargs_t  vn_a;
↓ open down ↓ 121 lines elided ↑ open up ↑
4715 4696   * well as free space.
4716 4697   *
4717 4698   *      IN:     vp      - vnode of file to free data in.
4718 4699   *              cmd     - action to take (only F_FREESP supported).
4719 4700   *              bfp     - section of file to free/alloc.
4720 4701   *              flag    - current file open mode flags.
4721 4702   *              offset  - current file offset.
4722 4703   *              cr      - credentials of caller [UNUSED].
4723 4704   *              ct      - caller context.
4724 4705   *
4725      - *      RETURN: 0 if success
4726      - *              error code if failure
     4706 + *      RETURN: 0 on success, error code on failure.
4727 4707   *
4728 4708   * Timestamps:
4729 4709   *      vp - ctime|mtime updated
4730 4710   */
4731 4711  /* ARGSUSED */
4732 4712  static int
4733 4713  zfs_space(vnode_t *vp, int cmd, flock64_t *bfp, int flag,
4734 4714      offset_t offset, cred_t *cr, caller_context_t *ct)
4735 4715  {
4736 4716          znode_t         *zp = VTOZ(vp);
↓ open down ↓ 194 lines elided ↑ open up ↑
4931 4911          error = zfs_setacl(zp, vsecp, skipaclchk, cr);
4932 4912  
4933 4913          if (zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
4934 4914                  zil_commit(zilog, 0);
4935 4915  
4936 4916          ZFS_EXIT(zfsvfs);
4937 4917          return (error);
4938 4918  }
4939 4919  
4940 4920  /*
4941      - * Tunable, both must be a power of 2.
4942      - *
4943      - * zcr_blksz_min: the smallest read we may consider to loan out an arcbuf
4944      - * zcr_blksz_max: if set to less than the file block size, allow loaning out of
4945      - *                an arcbuf for a partial block read
     4921 + * The smallest read we may consider to loan out an arcbuf.
     4922 + * This must be a power of 2.
4946 4923   */
4947 4924  int zcr_blksz_min = (1 << 10);  /* 1K */
     4925 +/*
     4926 + * If set to less than the file block size, allow loaning out of an
     4927 + * arcbuf for a partial block read.  This must be a power of 2.
     4928 + */
4948 4929  int zcr_blksz_max = (1 << 17);  /* 128K */
4949 4930  
4950 4931  /*ARGSUSED*/
4951 4932  static int
4952 4933  zfs_reqzcbuf(vnode_t *vp, enum uio_rw ioflag, xuio_t *xuio, cred_t *cr,
4953 4934      caller_context_t *ct)
4954 4935  {
4955 4936          znode_t *zp = VTOZ(vp);
4956 4937          zfsvfs_t *zfsvfs = zp->z_zfsvfs;
4957 4938          int max_blksz = zfsvfs->z_max_blksz;
↓ open down ↓ 253 lines elided ↑ open up ↑
5211 5192          VOPNAME_FID,            { .vop_fid = zfs_fid },
5212 5193          VOPNAME_PATHCONF,       { .vop_pathconf = zfs_pathconf },
5213 5194          VOPNAME_GETSECATTR,     { .vop_getsecattr = zfs_getsecattr },
5214 5195          VOPNAME_SETSECATTR,     { .vop_setsecattr = zfs_setsecattr },
5215 5196          VOPNAME_VNEVENT,        { .vop_vnevent = fs_vnevent_support },
5216 5197          NULL,                   NULL
5217 5198  };
5218 5199  
5219 5200  /*
5220 5201   * Extended attribute directory vnode operations template
5221      - *      This template is identical to the directory vnodes
5222      - *      operation template except for restricted operations:
5223      - *              VOP_MKDIR()
5224      - *              VOP_SYMLINK()
     5202 + *
     5203 + * This template is identical to the directory vnodes
     5204 + * operation template except for restricted operations:
     5205 + *      VOP_MKDIR()
     5206 + *      VOP_SYMLINK()
     5207 + *
5225 5208   * Note that there are other restrictions embedded in:
5226 5209   *      zfs_create()    - restrict type to VREG
5227 5210   *      zfs_link()      - no links into/out of attribute space
5228 5211   *      zfs_rename()    - no moves into/out of attribute space
5229 5212   */
5230 5213  vnodeops_t *zfs_xdvnodeops;
5231 5214  const fs_operation_def_t zfs_xdvnodeops_template[] = {
5232 5215          VOPNAME_OPEN,           { .vop_open = zfs_open },
5233 5216          VOPNAME_CLOSE,          { .vop_close = zfs_close },
5234 5217          VOPNAME_IOCTL,          { .vop_ioctl = zfs_ioctl },
↓ open down ↓ 32 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX