Skip to content

Commit

Permalink
Fix zfs_rmnode() unlink / rollback issue
Browse files Browse the repository at this point in the history
If a has rollback has occurred while a file is open and unlinked.
Then when the file is closed post rollback it will not exist in the
rolled back version of the unlinked object.  Therefore, the call to
zap_remove_int() may correctly return ENOENT and should be allowed.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes openzfs#6812 
Closes openzfs#9739
  • Loading branch information
behlendorf authored and jsai20 committed Mar 30, 2021
1 parent 01886d9 commit 44f7124
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions module/os/linux/zfs/zfs_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,9 +739,15 @@ zfs_rmnode(znode_t *zp)
zfs_unlinked_add(xzp, tx);
}

/* Remove this znode from the unlinked set */
VERIFY3U(0, ==,
zap_remove_int(zfsvfs->z_os, zfsvfs->z_unlinkedobj, zp->z_id, tx));
/*
* Remove this znode from the unlinked set. If a has rollback has
* occurred while a file is open and unlinked. Then when the file
* is closed post rollback it will not exist in the rolled back
* version of the unlinked object.
*/
error = zap_remove_int(zfsvfs->z_os, zfsvfs->z_unlinkedobj,
zp->z_id, tx);
VERIFY(error == 0 || error == ENOENT);

dataset_kstats_update_nunlinked_kstat(&zfsvfs->z_kstat, 1);

Expand Down

0 comments on commit 44f7124

Please sign in to comment.