mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +03:00
Fix out-of-order ZIL txtype lost on hardlinked files
We should only call zil_remove_async when an object is removed. However, in current implementation, it is called whenever TX_REMOVE is called. In the case of hardlinked file, every unlink will generate TX_REMOVE and causing operations to be dropped even when the object is not removed. We fix this by only calling zil_remove_async when the file is fully unlinked. Reviewed-by: George Wilson <gwilson@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Prakash Surya <prakash.surya@delphix.com> Signed-off-by: Chunwei Chen <david.chen@nutanix.com> Closes #8769 Closes #9061
This commit is contained in:
committed by
Brian Behlendorf
parent
475ebd763a
commit
8e556c5ebc
+14
-1
@@ -380,12 +380,14 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
|
||||
zil_itx_assign(zilog, itx, tx);
|
||||
}
|
||||
|
||||
void zil_remove_async(zilog_t *zilog, uint64_t oid);
|
||||
|
||||
/*
|
||||
* Handles both TX_REMOVE and TX_RMDIR transactions.
|
||||
*/
|
||||
void
|
||||
zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
|
||||
znode_t *dzp, char *name, uint64_t foid)
|
||||
znode_t *dzp, char *name, uint64_t foid, boolean_t unlinked)
|
||||
{
|
||||
itx_t *itx;
|
||||
lr_remove_t *lr;
|
||||
@@ -401,6 +403,17 @@ zfs_log_remove(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
|
||||
|
||||
itx->itx_oid = foid;
|
||||
|
||||
/*
|
||||
* Object ids can be re-instantiated in the next txg so
|
||||
* remove any async transactions to avoid future leaks.
|
||||
* This can happen if a fsync occurs on the re-instantiated
|
||||
* object for a WR_INDIRECT or WR_NEED_COPY write, which gets
|
||||
* the new file data and flushes a write record for the old object.
|
||||
*/
|
||||
if (unlinked) {
|
||||
ASSERT((txtype & ~TX_CI) == TX_REMOVE);
|
||||
zil_remove_async(zilog, foid);
|
||||
}
|
||||
zil_itx_assign(zilog, itx, tx);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user