Print this page
4347 ZPL can use dmu_tx_assign(TXG_WAIT)
Reviewed by: George Wilson <george.wilson@delphix.com>
Reviewed by: Adam Leventhal <ahl@delphix.com>


 920         znode_t *xzp;
 921         dmu_tx_t *tx;
 922         int error;
 923         zfs_acl_ids_t acl_ids;
 924         boolean_t fuid_dirtied;
 925         uint64_t parent;
 926 
 927         *xvpp = NULL;
 928 
 929         if (error = zfs_zaccess(zp, ACE_WRITE_NAMED_ATTRS, 0, B_FALSE, cr))
 930                 return (error);
 931 
 932         if ((error = zfs_acl_ids_create(zp, IS_XATTR, vap, cr, NULL,
 933             &acl_ids)) != 0)
 934                 return (error);
 935         if (zfs_acl_ids_overquota(zfsvfs, &acl_ids)) {
 936                 zfs_acl_ids_free(&acl_ids);
 937                 return (SET_ERROR(EDQUOT));
 938         }
 939 
 940 top:
 941         tx = dmu_tx_create(zfsvfs->z_os);
 942         dmu_tx_hold_sa_create(tx, acl_ids.z_aclp->z_acl_bytes +
 943             ZFS_SA_BASE_ATTR_SIZE);
 944         dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_TRUE);
 945         dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL);
 946         fuid_dirtied = zfsvfs->z_fuid_dirty;
 947         if (fuid_dirtied)
 948                 zfs_fuid_txhold(zfsvfs, tx);
 949         error = dmu_tx_assign(tx, TXG_NOWAIT);
 950         if (error) {
 951                 if (error == ERESTART) {
 952                         dmu_tx_wait(tx);
 953                         dmu_tx_abort(tx);
 954                         goto top;
 955                 }
 956                 zfs_acl_ids_free(&acl_ids);
 957                 dmu_tx_abort(tx);
 958                 return (error);
 959         }
 960         zfs_mknode(zp, vap, tx, cr, IS_XATTR, &xzp, &acl_ids);
 961 
 962         if (fuid_dirtied)
 963                 zfs_fuid_sync(zfsvfs, tx);
 964 
 965 #ifdef DEBUG
 966         error = sa_lookup(xzp->z_sa_hdl, SA_ZPL_PARENT(zfsvfs),
 967             &parent, sizeof (parent));
 968         ASSERT(error == 0 && parent == zp->z_id);
 969 #endif
 970 
 971         VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_XATTR(zfsvfs), &xzp->z_id,
 972             sizeof (xzp->z_id), tx));
 973 
 974         (void) zfs_log_create(zfsvfs->z_log, tx, TX_MKXATTR, zp,
 975             xzp, "", NULL, acl_ids.z_fuidp, vap);




 920         znode_t *xzp;
 921         dmu_tx_t *tx;
 922         int error;
 923         zfs_acl_ids_t acl_ids;
 924         boolean_t fuid_dirtied;
 925         uint64_t parent;
 926 
 927         *xvpp = NULL;
 928 
 929         if (error = zfs_zaccess(zp, ACE_WRITE_NAMED_ATTRS, 0, B_FALSE, cr))
 930                 return (error);
 931 
 932         if ((error = zfs_acl_ids_create(zp, IS_XATTR, vap, cr, NULL,
 933             &acl_ids)) != 0)
 934                 return (error);
 935         if (zfs_acl_ids_overquota(zfsvfs, &acl_ids)) {
 936                 zfs_acl_ids_free(&acl_ids);
 937                 return (SET_ERROR(EDQUOT));
 938         }
 939 

 940         tx = dmu_tx_create(zfsvfs->z_os);
 941         dmu_tx_hold_sa_create(tx, acl_ids.z_aclp->z_acl_bytes +
 942             ZFS_SA_BASE_ATTR_SIZE);
 943         dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_TRUE);
 944         dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL);
 945         fuid_dirtied = zfsvfs->z_fuid_dirty;
 946         if (fuid_dirtied)
 947                 zfs_fuid_txhold(zfsvfs, tx);
 948         error = dmu_tx_assign(tx, TXG_WAIT);
 949         if (error) {





 950                 zfs_acl_ids_free(&acl_ids);
 951                 dmu_tx_abort(tx);
 952                 return (error);
 953         }
 954         zfs_mknode(zp, vap, tx, cr, IS_XATTR, &xzp, &acl_ids);
 955 
 956         if (fuid_dirtied)
 957                 zfs_fuid_sync(zfsvfs, tx);
 958 
 959 #ifdef DEBUG
 960         error = sa_lookup(xzp->z_sa_hdl, SA_ZPL_PARENT(zfsvfs),
 961             &parent, sizeof (parent));
 962         ASSERT(error == 0 && parent == zp->z_id);
 963 #endif
 964 
 965         VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_XATTR(zfsvfs), &xzp->z_id,
 966             sizeof (xzp->z_id), tx));
 967 
 968         (void) zfs_log_create(zfsvfs->z_log, tx, TX_MKXATTR, zp,
 969             xzp, "", NULL, acl_ids.z_fuidp, vap);