1302 /* |
1302 /* |
1303 * Truncate regular files if requested. |
1303 * Truncate regular files if requested. |
1304 */ |
1304 */ |
1305 if ((ZTOV(zp)->v_type == VREG) && |
1305 if ((ZTOV(zp)->v_type == VREG) && |
1306 (vap->va_mask & AT_SIZE) && (vap->va_size == 0)) { |
1306 (vap->va_mask & AT_SIZE) && (vap->va_size == 0)) { |
|
1307 /* we can't hold any locks when calling zfs_freesp() */ |
|
1308 zfs_dirent_unlock(dl); |
|
1309 dl = NULL; |
1307 error = zfs_freesp(zp, 0, 0, mode, TRUE); |
1310 error = zfs_freesp(zp, 0, 0, mode, TRUE); |
1308 if (error == ERESTART && |
|
1309 zfsvfs->z_assign == TXG_NOWAIT) { |
|
1310 /* NB: we already did dmu_tx_wait() */ |
|
1311 zfs_dirent_unlock(dl); |
|
1312 VN_RELE(ZTOV(zp)); |
|
1313 goto top; |
|
1314 } |
|
1315 |
|
1316 if (error == 0) { |
1311 if (error == 0) { |
1317 vnevent_create(ZTOV(zp), ct); |
1312 vnevent_create(ZTOV(zp), ct); |
1318 } |
1313 } |
1319 } |
1314 } |
1320 } |
1315 } |
1440 * allow for either case. |
1435 * allow for either case. |
1441 */ |
1436 */ |
1442 tx = dmu_tx_create(zfsvfs->z_os); |
1437 tx = dmu_tx_create(zfsvfs->z_os); |
1443 dmu_tx_hold_zap(tx, dzp->z_id, FALSE, name); |
1438 dmu_tx_hold_zap(tx, dzp->z_id, FALSE, name); |
1444 dmu_tx_hold_bonus(tx, zp->z_id); |
1439 dmu_tx_hold_bonus(tx, zp->z_id); |
1445 if (may_delete_now) |
1440 if (may_delete_now) { |
1446 dmu_tx_hold_free(tx, zp->z_id, 0, DMU_OBJECT_END); |
1441 toobig = |
|
1442 zp->z_phys->zp_size > zp->z_blksz * DMU_MAX_DELETEBLKCNT; |
|
1443 /* if the file is too big, only hold_free a token amount */ |
|
1444 dmu_tx_hold_free(tx, zp->z_id, 0, |
|
1445 (toobig ? DMU_MAX_ACCESS : DMU_OBJECT_END)); |
|
1446 } |
1447 |
1447 |
1448 /* are there any extended attributes? */ |
1448 /* are there any extended attributes? */ |
1449 if ((xattr_obj = zp->z_phys->zp_xattr) != 0) { |
1449 if ((xattr_obj = zp->z_phys->zp_xattr) != 0) { |
1450 /* XXX - do we need this if we are deleting? */ |
1450 /* XXX - do we need this if we are deleting? */ |
1451 dmu_tx_hold_bonus(tx, xattr_obj); |
1451 dmu_tx_hold_bonus(tx, xattr_obj); |
1485 goto out; |
1485 goto out; |
1486 } |
1486 } |
1487 |
1487 |
1488 if (unlinked) { |
1488 if (unlinked) { |
1489 mutex_enter(&vp->v_lock); |
1489 mutex_enter(&vp->v_lock); |
1490 delete_now = may_delete_now && |
1490 delete_now = may_delete_now && !toobig && |
1491 vp->v_count == 1 && !vn_has_cached_data(vp) && |
1491 vp->v_count == 1 && !vn_has_cached_data(vp) && |
1492 zp->z_phys->zp_xattr == xattr_obj && |
1492 zp->z_phys->zp_xattr == xattr_obj && |
1493 zp->z_phys->zp_acl.z_acl_extern_obj == acl_obj; |
1493 zp->z_phys->zp_acl.z_acl_extern_obj == acl_obj; |
1494 mutex_exit(&vp->v_lock); |
1494 mutex_exit(&vp->v_lock); |
1495 } |
1495 } |
2449 * XXX - Note, we are not providing any open |
2449 * XXX - Note, we are not providing any open |
2450 * mode flags here (like FNDELAY), so we may |
2450 * mode flags here (like FNDELAY), so we may |
2451 * block if there are locks present... this |
2451 * block if there are locks present... this |
2452 * should be addressed in openat(). |
2452 * should be addressed in openat(). |
2453 */ |
2453 */ |
2454 do { |
2454 /* XXX - would it be OK to generate a log record here? */ |
2455 err = zfs_freesp(zp, vap->va_size, 0, 0, FALSE); |
2455 err = zfs_freesp(zp, vap->va_size, 0, 0, FALSE); |
2456 /* NB: we already did dmu_tx_wait() if necessary */ |
|
2457 } while (err == ERESTART && zfsvfs->z_assign == TXG_NOWAIT); |
|
2458 if (err) { |
2456 if (err) { |
2459 ZFS_EXIT(zfsvfs); |
2457 ZFS_EXIT(zfsvfs); |
2460 return (err); |
2458 return (err); |
2461 } |
2459 } |
2462 } |
2460 } |
2723 ZFS_TIME_ENCODE(&vap->va_atime, pzp->zp_atime); |
2721 ZFS_TIME_ENCODE(&vap->va_atime, pzp->zp_atime); |
2724 |
2722 |
2725 if (mask & AT_MTIME) |
2723 if (mask & AT_MTIME) |
2726 ZFS_TIME_ENCODE(&vap->va_mtime, pzp->zp_mtime); |
2724 ZFS_TIME_ENCODE(&vap->va_mtime, pzp->zp_mtime); |
2727 |
2725 |
|
2726 /* XXX - shouldn't this be done *before* the ATIME/MTIME checks? */ |
2728 if (mask & AT_SIZE) |
2727 if (mask & AT_SIZE) |
2729 zfs_time_stamper_locked(zp, CONTENT_MODIFIED, tx); |
2728 zfs_time_stamper_locked(zp, CONTENT_MODIFIED, tx); |
2730 else if (mask != 0) |
2729 else if (mask != 0) |
2731 zfs_time_stamper_locked(zp, STATE_CHANGED, tx); |
2730 zfs_time_stamper_locked(zp, STATE_CHANGED, tx); |
2732 /* |
2731 /* |