]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/zfs_vnops.c
Update for cppcheck v1.80
[mirror_zfs.git] / module / zfs / zfs_vnops.c
index c065c0c59b18023863ee869750c6647b769116cb..a60cd619838a4908bc64aac1f8834bafe7cfd4c7 100644 (file)
@@ -482,8 +482,10 @@ zfs_read(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
 
        /*
         * If we're in FRSYNC mode, sync out this znode before reading it.
+        * Only do this for non-snapshots.
         */
-       if (ioflag & FRSYNC || zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS)
+       if (zfsvfs->z_log &&
+           (ioflag & FRSYNC || zfsvfs->z_os->os_sync == ZFS_SYNC_ALWAYS))
                zil_commit(zfsvfs->z_log, zp->z_id);
 
        /*
@@ -834,14 +836,14 @@ zfs_write(struct inode *ip, uio_t *uio, int ioflag, cred_t *cr)
                            aiov->iov_base != abuf->b_data)) {
                                ASSERT(xuio);
                                dmu_write(zfsvfs->z_os, zp->z_id, woff,
-                                   // cppcheck-suppress nullPointer
+                                   /* cppcheck-suppress nullPointer */
                                    aiov->iov_len, aiov->iov_base, tx);
                                dmu_return_arcbuf(abuf);
                                xuio_stat_wbuf_copied();
                        } else {
                                ASSERT(xuio || tx_bytes == max_blksz);
-                               dmu_assign_arcbuf(sa_get_db(zp->z_sa_hdl),
-                                   woff, abuf, tx);
+                               dmu_assign_arcbuf_by_dbuf(
+                                   sa_get_db(zp->z_sa_hdl), woff, abuf, tx);
                        }
                        ASSERT(tx_bytes <= uio->uio_resid);
                        uioskip(uio, tx_bytes);
@@ -1002,7 +1004,6 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio)
        uint64_t object = lr->lr_foid;
        uint64_t offset = lr->lr_offset;
        uint64_t size = lr->lr_length;
-       blkptr_t *bp = &lr->lr_blkptr;
        dmu_buf_t *db;
        zgd_t *zgd;
        int error = 0;
@@ -1049,7 +1050,7 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio)
        } else { /* indirect write */
                /*
                 * Have to lock the whole block to ensure when it's
-                * written out and it's checksum is being calculated
+                * written out and its checksum is being calculated
                 * that no one can change the data. We need to re-check
                 * blocksize after we get the lock in case it's changed!
                 */
@@ -1079,11 +1080,7 @@ zfs_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio)
                            DMU_READ_NO_PREFETCH);
 
                if (error == 0) {
-                       blkptr_t *obp = dmu_buf_get_blkptr(db);
-                       if (obp) {
-                               ASSERT(BP_IS_HOLE(bp));
-                               *bp = *obp;
-                       }
+                       blkptr_t *bp = &lr->lr_blkptr;
 
                        zgd->zgd_db = db;
                        zgd->zgd_bp = bp;
@@ -2740,12 +2737,12 @@ zfs_setattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr)
        if ((zp->z_pflags & ZFS_IMMUTABLE) &&
            ((mask & (ATTR_SIZE|ATTR_UID|ATTR_GID|ATTR_MTIME|ATTR_MODE)) ||
            ((mask & ATTR_XVATTR) && XVA_ISSET_REQ(xvap, XAT_CREATETIME)))) {
-               err = EPERM;
+               err = SET_ERROR(EPERM);
                goto out3;
        }
 
        if ((mask & ATTR_SIZE) && (zp->z_pflags & ZFS_READONLY)) {
-               err = EPERM;
+               err = SET_ERROR(EPERM);
                goto out3;
        }
 
@@ -2760,7 +2757,7 @@ zfs_setattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr)
                    TIMESPEC_OVERFLOW(&vap->va_atime)) ||
                    ((mask & ATTR_MTIME) &&
                    TIMESPEC_OVERFLOW(&vap->va_mtime))) {
-                       err = EOVERFLOW;
+                       err = SET_ERROR(EOVERFLOW);
                        goto out3;
                }
        }
@@ -2771,7 +2768,7 @@ top:
 
        /* Can this be moved to before the top label? */
        if (zfs_is_readonly(zfsvfs)) {
-               err = EROFS;
+               err = SET_ERROR(EROFS);
                goto out3;
        }
 
@@ -2932,7 +2929,7 @@ top:
 
                if (XVA_ISSET_REQ(xvap, XAT_REPARSE)) {
                        mutex_exit(&zp->z_lock);
-                       err = EPERM;
+                       err = SET_ERROR(EPERM);
                        goto out3;
                }
 
@@ -3002,7 +2999,7 @@ top:
                            zfs_fuid_overquota(zfsvfs, B_FALSE, new_kuid)) {
                                if (attrzp)
                                        iput(ZTOI(attrzp));
-                               err = EDQUOT;
+                               err = SET_ERROR(EDQUOT);
                                goto out2;
                        }
                }
@@ -3014,7 +3011,7 @@ top:
                            zfs_fuid_overquota(zfsvfs, B_TRUE, new_kgid)) {
                                if (attrzp)
                                        iput(ZTOI(attrzp));
-                               err = EDQUOT;
+                               err = SET_ERROR(EDQUOT);
                                goto out2;
                        }
                }
@@ -3159,7 +3156,7 @@ top:
                    &atime, sizeof (atime));
        }
 
-       if (mask & ATTR_MTIME) {
+       if (mask & (ATTR_MTIME | ATTR_SIZE)) {
                ZFS_TIME_ENCODE(&vap->va_mtime, mtime);
                ZTOI(zp)->i_mtime = timespec_trunc(vap->va_mtime,
                    ZTOI(zp)->i_sb->s_time_gran);
@@ -3168,7 +3165,7 @@ top:
                    mtime, sizeof (mtime));
        }
 
-       if (mask & ATTR_CTIME) {
+       if (mask & (ATTR_CTIME | ATTR_SIZE)) {
                ZFS_TIME_ENCODE(&vap->va_ctime, ctime);
                ZTOI(zp)->i_ctime = timespec_trunc(vap->va_ctime,
                    ZTOI(zp)->i_sb->s_time_gran);
@@ -4566,7 +4563,7 @@ convoff(struct inode *ip, flock64_t *lckdat, int  whence, offset_t offset)
        int error;
 
        if ((lckdat->l_whence == 2) || (whence == 2)) {
-               if ((error = zfs_getattr(ip, &vap, 0, CRED()) != 0))
+               if ((error = zfs_getattr(ip, &vap, 0, CRED())))
                        return (error);
        }