* Handles both TX_REMOVE and TX_RMDIR transactions. */
| 412 | * Handles both TX_REMOVE and TX_RMDIR transactions. |
| 413 | */ |
| 414 | void |
| 415 | zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype, |
| 416 | znode_t *dzp, const char *name, uint64_t foid, boolean_t unlinked) |
| 417 | { |
| 418 | itx_t *itx; |
| 419 | lr_remove_t *lr; |
| 420 | size_t namesize = strlen(name) + 1; |
| 421 | |
| 422 | if (zil_replaying(zilog, tx) || zfs_xattr_owner_unlinked(dzp)) |
| 423 | return; |
| 424 | |
| 425 | itx = zil_itx_create(txtype, sizeof (*lr) + namesize); |
| 426 | lr = (lr_remove_t *)&itx->itx_lr; |
| 427 | lr->lr_doid = dzp->z_id; |
| 428 | bcopy(name, (char *)(lr + 1), namesize); |
| 429 | |
| 430 | itx->itx_oid = foid; |
| 431 | |
| 432 | /* |
| 433 | * Object ids can be re-instantiated in the next txg so |
| 434 | * remove any async transactions to avoid future leaks. |
| 435 | * This can happen if a fsync occurs on the re-instantiated |
| 436 | * object for a WR_INDIRECT or WR_NEED_COPY write, which gets |
| 437 | * the new file data and flushes a write record for the old object. |
| 438 | */ |
| 439 | if (unlinked) { |
| 440 | ASSERT((txtype & ~TX_CI) == TX_REMOVE); |
| 441 | zil_remove_async(zilog, foid); |
| 442 | } |
| 443 | zil_itx_assign(zilog, itx, tx); |
| 444 | } |
| 445 | |
| 446 | /* |
| 447 | * Handles TX_LINK transactions. |
no test coverage detected