]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/zfs_vnops.c
Fix typo/etc in module/zfs/zfs_ctldir.c
[mirror_zfs.git] / module / zfs / zfs_vnops.c
index 863adc5950346ffb2e7d85cba72c6ed82748197c..281f58249ad54b43a8cb103963ac5a47099ea1d1 100644 (file)
@@ -439,6 +439,7 @@ int
 zfs_read(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
 {
        int error = 0;
+       boolean_t frsync = B_FALSE;
 
        znode_t *zp = ITOZ(ip);
        zfsvfs_t *zfsvfs = ITOZSB(ip);
@@ -466,12 +467,19 @@ zfs_read(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
                return (0);
        }
 
+#ifdef FRSYNC
        /*
         * If we're in FRSYNC mode, sync out this znode before reading it.
         * Only do this for non-snapshots.
+        *
+        * Some platforms do not support FRSYNC and instead map it
+        * to FSYNC, which results in unnecessary calls to zil_commit. We
+        * only honor FRSYNC requests on platforms which support it.
         */
+       frsync = !!(ioflag & FRSYNC);
+#endif
        if (zfsvfs->z_log &&
-           (ioflag & FRSYNC || zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS))
+           (frsync || zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS))
                zil_commit(zfsvfs->z_log, zp->z_id);
 
        /*
@@ -844,8 +852,13 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
                                xuio_stat_wbuf_copied();
                        } else {
                                ASSERT(xuio || tx_bytes == max_blksz);
-                               dmu_assign_arcbuf_by_dbuf(
+                               error = dmu_assign_arcbuf_by_dbuf(
                                    sa_get_db(zp->z_sa_hdl), woff, abuf, tx);
+                               if (error != 0) {
+                                       dmu_return_arcbuf(abuf);
+                                       dmu_tx_commit(tx);
+                                       break;
+                               }
                        }
                        ASSERT(tx_bytes <= uio->uio_resid);
                        uioskip(uio, tx_bytes);
@@ -976,6 +989,7 @@ zfs_iput_async(struct inode *ip)
                iput(ip);
 }
 
+/* ARGSUSED */
 void
 zfs_get_done(zgd_t *zgd, int error)
 {
@@ -992,9 +1006,6 @@ zfs_get_done(zgd_t *zgd, int error)
         */
        zfs_iput_async(ZTOI(zp));
 
-       if (error == 0 && zgd->zgd_bp)
-               zil_lwb_add_block(zgd->zgd_lwb, zgd->zgd_bp);
-
        kmem_free(zgd, sizeof (zgd_t));
 }
 
@@ -1118,11 +1129,7 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, struct lwb *lwb, zio_t *zio)
                                 * TX_WRITE2 relies on the data previously
                                 * written by the TX_WRITE that caused
                                 * EALREADY.  We zero out the BP because
-                                * it is the old, currently-on-disk BP,
-                                * so there's no need to zio_flush() its
-                                * vdevs (flushing would needlesly hurt
-                                * performance, and doesn't work on
-                                * indirect vdevs).
+                                * it is the old, currently-on-disk BP.
                                 */
                                zgd->zgd_bp = NULL;
                                BP_ZERO(bp);
@@ -1284,7 +1291,7 @@ zfs_lookup(struct inode *dip, char *nm, struct inode **ipp, int flags,
  *             excl    - flag indicating exclusive or non-exclusive mode.
  *             mode    - mode to open file with.
  *             cr      - credentials of caller.
- *             flag    - large file flag [UNUSED].
+ *             flag    - file flag.
  *             vsecp   - ACL to be set
  *
  *     OUT:    ipp     - inode of created or trunc'd entry.
@@ -2703,11 +2710,12 @@ zfs_setattr_dir(znode_t *dzp)
        dmu_tx_t        *tx = NULL;
        uint64_t        uid, gid;
        sa_bulk_attr_t  bulk[4];
-       int             count = 0;
+       int             count;
        int             err;
 
        zap_cursor_init(&zc, os, dzp->z_id);
        while ((err = zap_cursor_retrieve(&zc, &zap)) == 0) {
+               count = 0;
                if (zap.za_integer_length != 8 || zap.za_num_integers != 1) {
                        err = ENXIO;
                        break;
@@ -4859,19 +4867,19 @@ convoff(struct inode *ip, flock64_t *lckdat, int  whence, offset_t offset)
        vattr_t vap;
        int error;
 
-       if ((lckdat->l_whence == 2) || (whence == 2)) {
+       if ((lckdat->l_whence == SEEK_END) || (whence == SEEK_END)) {
                if ((error = zfs_getattr(ip, &vap, 0, CRED())))
                        return (error);
        }
 
        switch (lckdat->l_whence) {
-       case 1:
+       case SEEK_CUR:
                lckdat->l_start += offset;
                break;
-       case 2:
+       case SEEK_END:
                lckdat->l_start += vap.va_size;
                /* FALLTHRU */
-       case 0:
+       case SEEK_SET:
                break;
        default:
                return (SET_ERROR(EINVAL));
@@ -4881,13 +4889,13 @@ convoff(struct inode *ip, flock64_t *lckdat, int  whence, offset_t offset)
                return (SET_ERROR(EINVAL));
 
        switch (whence) {
-       case 1:
+       case SEEK_CUR:
                lckdat->l_start -= offset;
                break;
-       case 2:
+       case SEEK_END:
                lckdat->l_start -= vap.va_size;
                /* FALLTHRU */
-       case 0:
+       case SEEK_SET:
                break;
        default:
                return (SET_ERROR(EINVAL));
@@ -4908,7 +4916,7 @@ convoff(struct inode *ip, flock64_t *lckdat, int  whence, offset_t offset)
  *             bfp     - section of file to free/alloc.
  *             flag    - current file open mode flags.
  *             offset  - current file offset.
- *             cr      - credentials of caller [UNUSED].
+ *             cr      - credentials of caller.
  *
  *     RETURN: 0 on success, error code on failure.
  *
@@ -4942,7 +4950,7 @@ zfs_space(struct inode *ip, int cmd, flock64_t *bfp, int flag,
                return (SET_ERROR(EROFS));
        }
 
-       if ((error = convoff(ip, bfp, 0, offset))) {
+       if ((error = convoff(ip, bfp, SEEK_SET, offset))) {
                ZFS_EXIT(zfsvfs);
                return (error);
        }