]> git.proxmox.com Git - mirror_zfs.git/blobdiff - module/zfs/zfs_znode.c
cstyle: Resolve C style issues
[mirror_zfs.git] / module / zfs / zfs_znode.c
index fae32ad9a098214f6792dfd0f6d9e8105225c9d8..abf6222f2fb02163239dc3cc96fe18c7540c93a3 100644 (file)
@@ -20,7 +20,7 @@
  */
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
  */
 
 /* Portions Copyright 2007 Jeremy Teo */
@@ -440,7 +440,7 @@ zfs_znode_alloc(zfs_sb_t *zsb, dmu_buf_t *db, int blksz,
 error:
        unlock_new_inode(ip);
        iput(ip);
-       return NULL;
+       return (NULL);
 }
 
 /*
@@ -647,7 +647,7 @@ zfs_mknode(znode_t *dzp, vattr_t *vap, dmu_tx_t *tx, cred_t *cr,
         * order for  DMU_OT_ZNODE is critical since it needs to be constructed
         * in the old znode_phys_t format.  Don't change this ordering
         */
-       sa_attrs = kmem_alloc(sizeof(sa_bulk_attr_t) * ZPL_END, KM_PUSHPAGE);
+       sa_attrs = kmem_alloc(sizeof (sa_bulk_attr_t) * ZPL_END, KM_PUSHPAGE);
 
        if (obj_type == DMU_OT_ZNODE) {
                SA_ADD_BULK_ATTR(sa_attrs, cnt, SA_ZPL_ATIME(zsb),
@@ -749,14 +749,13 @@ zfs_mknode(znode_t *dzp, vattr_t *vap, dmu_tx_t *tx, cred_t *cr,
                err = zfs_aclset_common(*zpp, acl_ids->z_aclp, cr, tx);
                ASSERT0(err);
        }
-       kmem_free(sa_attrs, sizeof(sa_bulk_attr_t) * ZPL_END);
+       kmem_free(sa_attrs, sizeof (sa_bulk_attr_t) * ZPL_END);
        ZFS_OBJ_HOLD_EXIT(zsb, obj);
 }
 
 /*
- * zfs_xvattr_set only updates the in-core attributes
- * it is assumed the caller will be doing an sa_bulk_update
- * to push the changes out
+ * Update in-core attributes.  It is assumed the caller will be doing an
+ * sa_bulk_update to push the changes out.
  */
 void
 zfs_xvattr_set(znode_t *zp, xvattr_t *xvap, dmu_tx_t *tx)
@@ -881,7 +880,7 @@ again:
                sa_buf_rele(db, NULL);
                ZFS_OBJ_HOLD_EXIT(zsb, obj_num);
                iput(ip);
-               return (EINVAL);
+               return (SET_ERROR(EINVAL));
        }
 
        hdl = dmu_buf_get_user(db);
@@ -913,7 +912,7 @@ again:
                mutex_enter(&zp->z_lock);
                ASSERT3U(zp->z_id, ==, obj_num);
                if (zp->z_unlinked) {
-                       err = ENOENT;
+                       err = SET_ERROR(ENOENT);
                } else {
                        igrab(ZTOI(zp));
                        *zpp = zp;
@@ -941,7 +940,7 @@ again:
        zp = zfs_znode_alloc(zsb, db, doi.doi_data_block_size,
            doi.doi_bonus_type, obj_num, NULL, NULL);
        if (zp == NULL) {
-               err = ENOENT;
+               err = SET_ERROR(ENOENT);
        } else {
                *zpp = zp;
        }
@@ -997,7 +996,7 @@ zfs_rezget(znode_t *zp)
            doi.doi_bonus_size < sizeof (znode_phys_t)))) {
                sa_buf_rele(db, NULL);
                ZFS_OBJ_HOLD_EXIT(zsb, obj_num);
-               return (EINVAL);
+               return (SET_ERROR(EINVAL));
        }
 
        zfs_znode_sa_init(zsb, zp, db, doi.doi_bonus_type, NULL);
@@ -1023,7 +1022,7 @@ zfs_rezget(znode_t *zp)
        if (sa_bulk_lookup(zp->z_sa_hdl, bulk, count)) {
                zfs_znode_dmu_fini(zp);
                ZFS_OBJ_HOLD_EXIT(zsb, obj_num);
-               return (EIO);
+               return (SET_ERROR(EIO));
        }
 
        zp->z_mode = mode;
@@ -1031,7 +1030,7 @@ zfs_rezget(znode_t *zp)
        if (gen != zp->z_gen) {
                zfs_znode_dmu_fini(zp);
                ZFS_OBJ_HOLD_EXIT(zsb, obj_num);
-               return (EIO);
+               return (SET_ERROR(EIO));
        }
 
        zp->z_unlinked = (zp->z_links == 0);
@@ -1124,6 +1123,8 @@ zfs_tstamp_update_setup(znode_t *zp, uint_t flag, uint64_t mtime[2],
 
        if (flag & ATTR_ATIME) {
                ZFS_TIME_ENCODE(&now, zp->z_atime);
+               ZTOI(zp)->i_atime.tv_sec = zp->z_atime[0];
+               ZTOI(zp)->i_atime.tv_nsec = zp->z_atime[1];
        }
 
        if (flag & ATTR_MTIME) {
@@ -1183,8 +1184,7 @@ zfs_grow_blocksize(znode_t *zp, uint64_t size, dmu_tx_t *tx)
  *     IN:     zp      - znode of file to free data in.
  *             end     - new end-of-file
  *
- *     RETURN: 0 if success
- *             error code if failure
+ *     RETURN: 0 on success, error code on failure
  */
 static int
 zfs_extend(znode_t *zp, uint64_t end)
@@ -1207,7 +1207,6 @@ zfs_extend(znode_t *zp, uint64_t end)
                zfs_range_unlock(rl);
                return (0);
        }
-top:
        tx = dmu_tx_create(zsb->z_os);
        dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
        zfs_sa_upgrade_txholds(tx, zp);
@@ -1227,13 +1226,8 @@ top:
                newblksz = 0;
        }
 
-       error = dmu_tx_assign(tx, TXG_NOWAIT);
+       error = dmu_tx_assign(tx, TXG_WAIT);
        if (error) {
-               if (error == ERESTART) {
-                       dmu_tx_wait(tx);
-                       dmu_tx_abort(tx);
-                       goto top;
-               }
                dmu_tx_abort(tx);
                zfs_range_unlock(rl);
                return (error);
@@ -1261,8 +1255,7 @@ top:
  *             off     - start of section to free.
  *             len     - length of section to free.
  *
- *     RETURN: 0 if success
- *             error code if failure
+ *     RETURN: 0 on success, error code on failure
  */
 static int
 zfs_free_range(znode_t *zp, uint64_t off, uint64_t len)
@@ -1300,8 +1293,7 @@ zfs_free_range(znode_t *zp, uint64_t off, uint64_t len)
  *     IN:     zp      - znode of file to free data in.
  *             end     - new end-of-file.
  *
- *     RETURN: 0 if success
- *             error code if failure
+ *     RETURN: 0 on success, error code on failure
  */
 static int
 zfs_trunc(znode_t *zp, uint64_t end)
@@ -1374,8 +1366,7 @@ top:
  *             flag    - current file open mode flags.
  *             log     - TRUE if this action should be logged
  *
- *     RETURN: 0 if success
- *             error code if failure
+ *     RETURN: 0 on success, error code on failure
  */
 int
 zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
@@ -1408,7 +1399,7 @@ zfs_freesp(znode_t *zp, uint64_t off, uint64_t len, int flag, boolean_t log)
        if (ip->i_flock && mandatory_lock(ip)) {
                uint64_t length = (len ? len : zp->z_size - off);
                if (!lock_may_write(ip, off, length))
-                       return (EAGAIN);
+                       return (SET_ERROR(EAGAIN));
        }
 
        if (len == 0) {
@@ -1424,13 +1415,8 @@ log:
        tx = dmu_tx_create(zsb->z_os);
        dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
        zfs_sa_upgrade_txholds(tx, zp);
-       error = dmu_tx_assign(tx, TXG_NOWAIT);
+       error = dmu_tx_assign(tx, TXG_WAIT);
        if (error) {
-               if (error == ERESTART) {
-                       dmu_tx_wait(tx);
-                       dmu_tx_abort(tx);
-                       goto log;
-               }
                dmu_tx_abort(tx);
                return (error);
        }
@@ -1629,7 +1615,7 @@ zfs_grab_sa_handle(objset_t *osp, uint64_t obj, sa_handle_t **hdlp,
            (doi.doi_bonus_type == DMU_OT_ZNODE &&
            doi.doi_bonus_size < sizeof (znode_phys_t))) {
                sa_buf_rele(*db, tag);
-               return (ENOTSUP);
+               return (SET_ERROR(ENOTSUP));
        }
 
        error = sa_handle_get(osp, obj, NULL, SA_HDL_PRIVATE, hdlp);