1175 (vap->va_type != VREG)) { |
1163 (vap->va_type != VREG)) { |
1176 error = EINVAL; |
1164 error = EINVAL; |
1177 goto out; |
1165 goto out; |
1178 } |
1166 } |
1179 |
1167 |
|
1168 if ((error = zfs_acl_ids_create(dzp, 0, vap, cr, vsecp, |
|
1169 &acl_ids)) != 0) |
|
1170 goto out; |
|
1171 |
1180 tx = dmu_tx_create(os); |
1172 tx = dmu_tx_create(os); |
1181 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
1173 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
1182 if ((aclp && aclp->z_has_fuids) || IS_EPHEMERAL(uid) || |
1174 fuid_dirtied = zfsvfs->z_fuid_dirty; |
1183 IS_EPHEMERAL(gid)) { |
1175 if (fuid_dirtied) { |
1184 if (zfsvfs->z_fuid_obj == 0) { |
1176 if (zfsvfs->z_fuid_obj == 0) { |
1185 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
1177 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
1186 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, |
1178 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, |
1187 FUID_SIZE_ESTIMATE(zfsvfs)); |
1179 FUID_SIZE_ESTIMATE(zfsvfs)); |
1188 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, |
1180 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, |
1193 FUID_SIZE_ESTIMATE(zfsvfs)); |
1185 FUID_SIZE_ESTIMATE(zfsvfs)); |
1194 } |
1186 } |
1195 } |
1187 } |
1196 dmu_tx_hold_bonus(tx, dzp->z_id); |
1188 dmu_tx_hold_bonus(tx, dzp->z_id); |
1197 dmu_tx_hold_zap(tx, dzp->z_id, TRUE, name); |
1189 dmu_tx_hold_zap(tx, dzp->z_id, TRUE, name); |
1198 if ((dzp->z_phys->zp_flags & ZFS_INHERIT_ACE) || aclp) { |
1190 if (acl_ids.z_aclp->z_acl_bytes > ZFS_ACE_SPACE) { |
1199 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, |
1191 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, |
1200 0, SPA_MAXBLOCKSIZE); |
1192 0, SPA_MAXBLOCKSIZE); |
1201 } |
1193 } |
1202 error = dmu_tx_assign(tx, TXG_NOWAIT); |
1194 error = dmu_tx_assign(tx, TXG_NOWAIT); |
1203 if (error) { |
1195 if (error) { |
|
1196 zfs_acl_ids_free(&acl_ids); |
1204 zfs_dirent_unlock(dl); |
1197 zfs_dirent_unlock(dl); |
1205 if (error == ERESTART) { |
1198 if (error == ERESTART) { |
1206 dmu_tx_wait(tx); |
1199 dmu_tx_wait(tx); |
1207 dmu_tx_abort(tx); |
1200 dmu_tx_abort(tx); |
1208 goto top; |
1201 goto top; |
1209 } |
1202 } |
1210 dmu_tx_abort(tx); |
1203 dmu_tx_abort(tx); |
1211 ZFS_EXIT(zfsvfs); |
1204 ZFS_EXIT(zfsvfs); |
1212 if (aclp) |
|
1213 zfs_acl_free(aclp); |
|
1214 return (error); |
1205 return (error); |
1215 } |
1206 } |
1216 zfs_mknode(dzp, vap, tx, cr, 0, &zp, 0, aclp, &fuidp); |
1207 zfs_mknode(dzp, vap, tx, cr, 0, &zp, 0, &acl_ids); |
|
1208 |
|
1209 if (fuid_dirtied) |
|
1210 zfs_fuid_sync(zfsvfs, tx); |
|
1211 |
1217 (void) zfs_link_create(dl, zp, tx, ZNEW); |
1212 (void) zfs_link_create(dl, zp, tx, ZNEW); |
|
1213 |
1218 txtype = zfs_log_create_txtype(Z_FILE, vsecp, vap); |
1214 txtype = zfs_log_create_txtype(Z_FILE, vsecp, vap); |
1219 if (flag & FIGNORECASE) |
1215 if (flag & FIGNORECASE) |
1220 txtype |= TX_CI; |
1216 txtype |= TX_CI; |
1221 zfs_log_create(zilog, tx, txtype, dzp, zp, name, |
1217 zfs_log_create(zilog, tx, txtype, dzp, zp, name, |
1222 vsecp, fuidp, vap); |
1218 vsecp, acl_ids.z_fuidp, vap); |
1223 if (fuidp) |
1219 zfs_acl_ids_free(&acl_ids); |
1224 zfs_fuid_info_free(fuidp); |
|
1225 dmu_tx_commit(tx); |
1220 dmu_tx_commit(tx); |
1226 } else { |
1221 } else { |
1227 int aflags = (flag & FAPPEND) ? V_APPEND : 0; |
1222 int aflags = (flag & FAPPEND) ? V_APPEND : 0; |
1228 |
1223 |
1229 /* |
1224 /* |
1592 zfs_dirent_unlock(dl); |
1585 zfs_dirent_unlock(dl); |
1593 ZFS_EXIT(zfsvfs); |
1586 ZFS_EXIT(zfsvfs); |
1594 return (error); |
1587 return (error); |
1595 } |
1588 } |
1596 |
1589 |
1597 if (vsecp && aclp == NULL) { |
1590 if ((error = zfs_acl_ids_create(dzp, 0, vap, cr, vsecp, |
1598 error = zfs_vsec_2_aclp(zfsvfs, vap->va_type, vsecp, &aclp); |
1591 &acl_ids)) != 0) { |
1599 if (error) { |
1592 zfs_dirent_unlock(dl); |
1600 zfs_dirent_unlock(dl); |
1593 ZFS_EXIT(zfsvfs); |
1601 ZFS_EXIT(zfsvfs); |
1594 return (error); |
1602 return (error); |
1595 } |
1603 } |
1596 |
1604 } |
|
1605 /* |
1597 /* |
1606 * Add a new entry to the directory. |
1598 * Add a new entry to the directory. |
1607 */ |
1599 */ |
1608 tx = dmu_tx_create(zfsvfs->z_os); |
1600 tx = dmu_tx_create(zfsvfs->z_os); |
1609 dmu_tx_hold_zap(tx, dzp->z_id, TRUE, dirname); |
1601 dmu_tx_hold_zap(tx, dzp->z_id, TRUE, dirname); |
1610 dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL); |
1602 dmu_tx_hold_zap(tx, DMU_NEW_OBJECT, FALSE, NULL); |
1611 if ((aclp && aclp->z_has_fuids) || IS_EPHEMERAL(uid) || |
1603 fuid_dirtied = zfsvfs->z_fuid_dirty; |
1612 IS_EPHEMERAL(gid)) { |
1604 if (fuid_dirtied) { |
1613 if (zfsvfs->z_fuid_obj == 0) { |
1605 if (zfsvfs->z_fuid_obj == 0) { |
1614 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
1606 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
1615 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, |
1607 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, |
1616 FUID_SIZE_ESTIMATE(zfsvfs)); |
1608 FUID_SIZE_ESTIMATE(zfsvfs)); |
1617 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, FALSE, NULL); |
1609 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, FALSE, NULL); |
1619 dmu_tx_hold_bonus(tx, zfsvfs->z_fuid_obj); |
1611 dmu_tx_hold_bonus(tx, zfsvfs->z_fuid_obj); |
1620 dmu_tx_hold_write(tx, zfsvfs->z_fuid_obj, 0, |
1612 dmu_tx_hold_write(tx, zfsvfs->z_fuid_obj, 0, |
1621 FUID_SIZE_ESTIMATE(zfsvfs)); |
1613 FUID_SIZE_ESTIMATE(zfsvfs)); |
1622 } |
1614 } |
1623 } |
1615 } |
1624 if ((dzp->z_phys->zp_flags & ZFS_INHERIT_ACE) || aclp) |
1616 if (acl_ids.z_aclp->z_acl_bytes > ZFS_ACE_SPACE) |
1625 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, |
1617 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, |
1626 0, SPA_MAXBLOCKSIZE); |
1618 0, SPA_MAXBLOCKSIZE); |
1627 error = dmu_tx_assign(tx, TXG_NOWAIT); |
1619 error = dmu_tx_assign(tx, TXG_NOWAIT); |
1628 if (error) { |
1620 if (error) { |
|
1621 zfs_acl_ids_free(&acl_ids); |
1629 zfs_dirent_unlock(dl); |
1622 zfs_dirent_unlock(dl); |
1630 if (error == ERESTART) { |
1623 if (error == ERESTART) { |
1631 dmu_tx_wait(tx); |
1624 dmu_tx_wait(tx); |
1632 dmu_tx_abort(tx); |
1625 dmu_tx_abort(tx); |
1633 goto top; |
1626 goto top; |
1634 } |
1627 } |
1635 dmu_tx_abort(tx); |
1628 dmu_tx_abort(tx); |
1636 ZFS_EXIT(zfsvfs); |
1629 ZFS_EXIT(zfsvfs); |
1637 if (aclp) |
|
1638 zfs_acl_free(aclp); |
|
1639 return (error); |
1630 return (error); |
1640 } |
1631 } |
1641 |
1632 |
1642 /* |
1633 /* |
1643 * Create new node. |
1634 * Create new node. |
1644 */ |
1635 */ |
1645 zfs_mknode(dzp, vap, tx, cr, 0, &zp, 0, aclp, &fuidp); |
1636 zfs_mknode(dzp, vap, tx, cr, 0, &zp, 0, &acl_ids); |
1646 |
1637 |
1647 if (aclp) |
1638 if (fuid_dirtied) |
1648 zfs_acl_free(aclp); |
1639 zfs_fuid_sync(zfsvfs, tx); |
1649 |
|
1650 /* |
1640 /* |
1651 * Now put new name in parent dir. |
1641 * Now put new name in parent dir. |
1652 */ |
1642 */ |
1653 (void) zfs_link_create(dl, zp, tx, ZNEW); |
1643 (void) zfs_link_create(dl, zp, tx, ZNEW); |
1654 |
1644 |
1655 *vpp = ZTOV(zp); |
1645 *vpp = ZTOV(zp); |
1656 |
1646 |
1657 txtype = zfs_log_create_txtype(Z_DIR, vsecp, vap); |
1647 txtype = zfs_log_create_txtype(Z_DIR, vsecp, vap); |
1658 if (flags & FIGNORECASE) |
1648 if (flags & FIGNORECASE) |
1659 txtype |= TX_CI; |
1649 txtype |= TX_CI; |
1660 zfs_log_create(zilog, tx, txtype, dzp, zp, dirname, vsecp, fuidp, vap); |
1650 zfs_log_create(zilog, tx, txtype, dzp, zp, dirname, vsecp, |
1661 |
1651 acl_ids.z_fuidp, vap); |
1662 if (fuidp) |
1652 |
1663 zfs_fuid_info_free(fuidp); |
1653 zfs_acl_ids_free(&acl_ids); |
1664 dmu_tx_commit(tx); |
1654 dmu_tx_commit(tx); |
1665 |
1655 |
1666 zfs_dirent_unlock(dl); |
1656 zfs_dirent_unlock(dl); |
1667 |
1657 |
1668 ZFS_EXIT(zfsvfs); |
1658 ZFS_EXIT(zfsvfs); |
2310 xvattr_t tmpxvattr; |
2300 xvattr_t tmpxvattr; |
2311 uint_t mask = vap->va_mask; |
2301 uint_t mask = vap->va_mask; |
2312 uint_t saved_mask; |
2302 uint_t saved_mask; |
2313 int trim_mask = 0; |
2303 int trim_mask = 0; |
2314 uint64_t new_mode; |
2304 uint64_t new_mode; |
|
2305 uint64_t new_uid, new_gid; |
2315 znode_t *attrzp; |
2306 znode_t *attrzp; |
2316 int need_policy = FALSE; |
2307 int need_policy = FALSE; |
2317 int err; |
2308 int err; |
2318 zfs_fuid_info_t *fuidp = NULL; |
2309 zfs_fuid_info_t *fuidp = NULL; |
2319 xvattr_t *xvap = (xvattr_t *)vap; /* vap may be an xvattr_t * */ |
2310 xvattr_t *xvap = (xvattr_t *)vap; /* vap may be an xvattr_t * */ |
2320 xoptattr_t *xoap; |
2311 xoptattr_t *xoap; |
2321 zfs_acl_t *aclp = NULL; |
2312 zfs_acl_t *aclp = NULL; |
2322 boolean_t skipaclchk = (flags & ATTR_NOACLCHECK) ? B_TRUE : B_FALSE; |
2313 boolean_t skipaclchk = (flags & ATTR_NOACLCHECK) ? B_TRUE : B_FALSE; |
|
2314 boolean_t fuid_dirtied = B_FALSE; |
2323 |
2315 |
2324 if (mask == 0) |
2316 if (mask == 0) |
2325 return (0); |
2317 return (0); |
2326 |
2318 |
2327 if (mask & AT_NOSET) |
2319 if (mask & AT_NOSET) |
2608 */ |
2600 */ |
2609 mask = vap->va_mask; |
2601 mask = vap->va_mask; |
2610 |
2602 |
2611 tx = dmu_tx_create(zfsvfs->z_os); |
2603 tx = dmu_tx_create(zfsvfs->z_os); |
2612 dmu_tx_hold_bonus(tx, zp->z_id); |
2604 dmu_tx_hold_bonus(tx, zp->z_id); |
2613 if (((mask & AT_UID) && IS_EPHEMERAL(vap->va_uid)) || |
|
2614 ((mask & AT_GID) && IS_EPHEMERAL(vap->va_gid))) { |
|
2615 if (zfsvfs->z_fuid_obj == 0) { |
|
2616 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
|
2617 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, |
|
2618 FUID_SIZE_ESTIMATE(zfsvfs)); |
|
2619 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, FALSE, NULL); |
|
2620 } else { |
|
2621 dmu_tx_hold_bonus(tx, zfsvfs->z_fuid_obj); |
|
2622 dmu_tx_hold_write(tx, zfsvfs->z_fuid_obj, 0, |
|
2623 FUID_SIZE_ESTIMATE(zfsvfs)); |
|
2624 } |
|
2625 } |
|
2626 |
2605 |
2627 if (mask & AT_MODE) { |
2606 if (mask & AT_MODE) { |
2628 uint64_t pmode = pzp->zp_mode; |
2607 uint64_t pmode = pzp->zp_mode; |
2629 |
2608 |
2630 new_mode = (pmode & S_IFMT) | (vap->va_mode & ~S_IFMT); |
2609 new_mode = (pmode & S_IFMT) | (vap->va_mode & ~S_IFMT); |
2653 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, |
2632 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, |
2654 0, aclp->z_acl_bytes); |
2633 0, aclp->z_acl_bytes); |
2655 } |
2634 } |
2656 } |
2635 } |
2657 |
2636 |
2658 if ((mask & (AT_UID | AT_GID)) && pzp->zp_xattr != 0) { |
2637 if (mask & (AT_UID | AT_GID)) { |
2659 err = zfs_zget(zp->z_zfsvfs, pzp->zp_xattr, &attrzp); |
2638 if (pzp->zp_xattr) { |
2660 if (err) { |
2639 err = zfs_zget(zp->z_zfsvfs, pzp->zp_xattr, &attrzp); |
2661 dmu_tx_abort(tx); |
2640 if (err) { |
2662 ZFS_EXIT(zfsvfs); |
2641 dmu_tx_abort(tx); |
2663 if (aclp) |
2642 ZFS_EXIT(zfsvfs); |
2664 zfs_acl_free(aclp); |
2643 if (aclp) |
2665 return (err); |
2644 zfs_acl_free(aclp); |
2666 } |
2645 return (err); |
2667 dmu_tx_hold_bonus(tx, attrzp->z_id); |
2646 } |
|
2647 dmu_tx_hold_bonus(tx, attrzp->z_id); |
|
2648 } |
|
2649 if (mask & AT_UID) { |
|
2650 new_uid = zfs_fuid_create(zfsvfs, |
|
2651 (uint64_t)vap->va_uid, cr, ZFS_OWNER, &fuidp); |
|
2652 } |
|
2653 if (mask & AT_GID) { |
|
2654 new_gid = zfs_fuid_create(zfsvfs, (uint64_t)vap->va_gid, |
|
2655 cr, ZFS_GROUP, &fuidp); |
|
2656 } |
|
2657 fuid_dirtied = zfsvfs->z_fuid_dirty; |
|
2658 if (fuid_dirtied) { |
|
2659 if (zfsvfs->z_fuid_obj == 0) { |
|
2660 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
|
2661 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, |
|
2662 FUID_SIZE_ESTIMATE(zfsvfs)); |
|
2663 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, |
|
2664 FALSE, NULL); |
|
2665 } else { |
|
2666 dmu_tx_hold_bonus(tx, zfsvfs->z_fuid_obj); |
|
2667 dmu_tx_hold_write(tx, zfsvfs->z_fuid_obj, 0, |
|
2668 FUID_SIZE_ESTIMATE(zfsvfs)); |
|
2669 } |
|
2670 } |
2668 } |
2671 } |
2669 |
2672 |
2670 err = dmu_tx_assign(tx, TXG_NOWAIT); |
2673 err = dmu_tx_assign(tx, TXG_NOWAIT); |
2671 if (err) { |
2674 if (err) { |
2672 if (attrzp) |
2675 if (attrzp) |
2700 mutex_enter(&zp->z_lock); |
2703 mutex_enter(&zp->z_lock); |
2701 |
2704 |
2702 if (mask & AT_MODE) { |
2705 if (mask & AT_MODE) { |
2703 mutex_enter(&zp->z_acl_lock); |
2706 mutex_enter(&zp->z_acl_lock); |
2704 zp->z_phys->zp_mode = new_mode; |
2707 zp->z_phys->zp_mode = new_mode; |
2705 err = zfs_aclset_common(zp, aclp, cr, &fuidp, tx); |
2708 err = zfs_aclset_common(zp, aclp, cr, tx); |
2706 ASSERT3U(err, ==, 0); |
2709 ASSERT3U(err, ==, 0); |
2707 mutex_exit(&zp->z_acl_lock); |
2710 mutex_exit(&zp->z_acl_lock); |
2708 } |
2711 } |
2709 |
2712 |
2710 if (attrzp) |
2713 if (attrzp) |
2711 mutex_enter(&attrzp->z_lock); |
2714 mutex_enter(&attrzp->z_lock); |
2712 |
2715 |
2713 if (mask & AT_UID) { |
2716 if (mask & AT_UID) { |
2714 pzp->zp_uid = zfs_fuid_create(zfsvfs, |
2717 pzp->zp_uid = new_uid; |
2715 vap->va_uid, cr, ZFS_OWNER, tx, &fuidp); |
2718 if (attrzp) |
2716 if (attrzp) { |
2719 attrzp->z_phys->zp_uid = new_uid; |
2717 attrzp->z_phys->zp_uid = zfs_fuid_create(zfsvfs, |
|
2718 vap->va_uid, cr, ZFS_OWNER, tx, &fuidp); |
|
2719 } |
|
2720 } |
2720 } |
2721 |
2721 |
2722 if (mask & AT_GID) { |
2722 if (mask & AT_GID) { |
2723 pzp->zp_gid = zfs_fuid_create(zfsvfs, vap->va_gid, |
2723 pzp->zp_gid = new_gid; |
2724 cr, ZFS_GROUP, tx, &fuidp); |
|
2725 if (attrzp) |
2724 if (attrzp) |
2726 attrzp->z_phys->zp_gid = zfs_fuid_create(zfsvfs, |
2725 attrzp->z_phys->zp_gid = new_gid; |
2727 vap->va_gid, cr, ZFS_GROUP, tx, &fuidp); |
|
2728 } |
2726 } |
2729 |
2727 |
2730 if (aclp) |
2728 if (aclp) |
2731 zfs_acl_free(aclp); |
2729 zfs_acl_free(aclp); |
2732 |
2730 |
2789 VERIFY(dmu_set_bonus(zp->z_dbuf, len, tx) == 0); |
2787 VERIFY(dmu_set_bonus(zp->z_dbuf, len, tx) == 0); |
2790 } |
2788 } |
2791 zfs_xvattr_set(zp, xvap); |
2789 zfs_xvattr_set(zp, xvap); |
2792 } |
2790 } |
2793 |
2791 |
|
2792 if (fuid_dirtied) |
|
2793 zfs_fuid_sync(zfsvfs, tx); |
|
2794 |
2794 if (mask != 0) |
2795 if (mask != 0) |
2795 zfs_log_setattr(zilog, tx, TX_SETATTR, zp, vap, mask, fuidp); |
2796 zfs_log_setattr(zilog, tx, TX_SETATTR, zp, vap, mask, fuidp); |
2796 |
2797 |
2797 if (fuidp) |
2798 if (fuidp) |
2798 zfs_fuid_info_free(fuidp); |
2799 zfs_fuid_info_free(fuidp); |
2799 mutex_exit(&zp->z_lock); |
2800 mutex_exit(&zp->z_lock); |
2800 |
2801 |
|
2802 dmu_tx_commit(tx); |
|
2803 |
2801 if (attrzp) |
2804 if (attrzp) |
2802 VN_RELE(ZTOV(attrzp)); |
2805 VN_RELE(ZTOV(attrzp)); |
2803 |
2806 |
2804 dmu_tx_commit(tx); |
|
2805 |
2807 |
2806 ZFS_EXIT(zfsvfs); |
2808 ZFS_EXIT(zfsvfs); |
2807 return (err); |
2809 return (err); |
2808 } |
2810 } |
2809 |
2811 |
3265 if (error) { |
3268 if (error) { |
3266 ZFS_EXIT(zfsvfs); |
3269 ZFS_EXIT(zfsvfs); |
3267 return (error); |
3270 return (error); |
3268 } |
3271 } |
3269 |
3272 |
|
3273 VERIFY(0 == zfs_acl_ids_create(dzp, 0, vap, cr, NULL, &acl_ids)); |
3270 tx = dmu_tx_create(zfsvfs->z_os); |
3274 tx = dmu_tx_create(zfsvfs->z_os); |
|
3275 fuid_dirtied = zfsvfs->z_fuid_dirty; |
3271 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, MAX(1, len)); |
3276 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, MAX(1, len)); |
3272 dmu_tx_hold_bonus(tx, dzp->z_id); |
3277 dmu_tx_hold_bonus(tx, dzp->z_id); |
3273 dmu_tx_hold_zap(tx, dzp->z_id, TRUE, name); |
3278 dmu_tx_hold_zap(tx, dzp->z_id, TRUE, name); |
3274 if (dzp->z_phys->zp_flags & ZFS_INHERIT_ACE) |
3279 if (acl_ids.z_aclp->z_acl_bytes > ZFS_ACE_SPACE) |
3275 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, SPA_MAXBLOCKSIZE); |
3280 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, SPA_MAXBLOCKSIZE); |
3276 if (IS_EPHEMERAL(crgetuid(cr)) || IS_EPHEMERAL(crgetgid(cr))) { |
3281 if (fuid_dirtied) { |
3277 if (zfsvfs->z_fuid_obj == 0) { |
3282 if (zfsvfs->z_fuid_obj == 0) { |
3278 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
3283 dmu_tx_hold_bonus(tx, DMU_NEW_OBJECT); |
3279 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, |
3284 dmu_tx_hold_write(tx, DMU_NEW_OBJECT, 0, |
3280 FUID_SIZE_ESTIMATE(zfsvfs)); |
3285 FUID_SIZE_ESTIMATE(zfsvfs)); |
3281 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, FALSE, NULL); |
3286 dmu_tx_hold_zap(tx, MASTER_NODE_OBJ, FALSE, NULL); |
3304 * Create a new object for the symlink. |
3310 * Create a new object for the symlink. |
3305 * Put the link content into bonus buffer if it will fit; |
3311 * Put the link content into bonus buffer if it will fit; |
3306 * otherwise, store it just like any other file data. |
3312 * otherwise, store it just like any other file data. |
3307 */ |
3313 */ |
3308 if (sizeof (znode_phys_t) + len <= dmu_bonus_max()) { |
3314 if (sizeof (znode_phys_t) + len <= dmu_bonus_max()) { |
3309 zfs_mknode(dzp, vap, tx, cr, 0, &zp, len, NULL, &fuidp); |
3315 zfs_mknode(dzp, vap, tx, cr, 0, &zp, len, &acl_ids); |
3310 if (len != 0) |
3316 if (len != 0) |
3311 bcopy(link, zp->z_phys + 1, len); |
3317 bcopy(link, zp->z_phys + 1, len); |
3312 } else { |
3318 } else { |
3313 dmu_buf_t *dbp; |
3319 dmu_buf_t *dbp; |
3314 |
3320 |
3315 zfs_mknode(dzp, vap, tx, cr, 0, &zp, 0, NULL, &fuidp); |
3321 zfs_mknode(dzp, vap, tx, cr, 0, &zp, 0, &acl_ids); |
|
3322 |
|
3323 if (fuid_dirtied) |
|
3324 zfs_fuid_sync(zfsvfs, tx); |
3316 /* |
3325 /* |
3317 * Nothing can access the znode yet so no locking needed |
3326 * Nothing can access the znode yet so no locking needed |
3318 * for growing the znode's blocksize. |
3327 * for growing the znode's blocksize. |
3319 */ |
3328 */ |
3320 zfs_grow_blocksize(zp, len, tx); |
3329 zfs_grow_blocksize(zp, len, tx); |
3338 uint64_t txtype = TX_SYMLINK; |
3347 uint64_t txtype = TX_SYMLINK; |
3339 if (flags & FIGNORECASE) |
3348 if (flags & FIGNORECASE) |
3340 txtype |= TX_CI; |
3349 txtype |= TX_CI; |
3341 zfs_log_symlink(zilog, tx, txtype, dzp, zp, name, link); |
3350 zfs_log_symlink(zilog, tx, txtype, dzp, zp, name, link); |
3342 } |
3351 } |
3343 if (fuidp) |
3352 |
3344 zfs_fuid_info_free(fuidp); |
3353 zfs_acl_ids_free(&acl_ids); |
3345 |
3354 |
3346 dmu_tx_commit(tx); |
3355 dmu_tx_commit(tx); |
3347 |
3356 |
3348 zfs_dirent_unlock(dl); |
3357 zfs_dirent_unlock(dl); |
3349 |
3358 |