Skip to content

Commit

Permalink
Make xattr dir truncate and remove in one tx
Browse files Browse the repository at this point in the history
We need truncate and remove be in the same tx when doing zfs_rmnode on xattr
dir. Otherwise, if we truncate and crash, we'll end up with inconsistent zap
object on the delete queue. We do this by skipping dmu_free_long_range and let
zfs_znode_delete to do the work.

Signed-off-by: Chunwei Chen <[email protected]>
  • Loading branch information
tuxoko committed Dec 21, 2015
1 parent 16f7d95 commit cb57b43
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions module/zfs/zfs_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,18 +629,23 @@ zfs_rmnode(znode_t *zp)

return;
}
}

/*
* Free up all the data in the file.
*/
error = dmu_free_long_range(os, zp->z_id, 0, DMU_OBJECT_END);
if (error) {
} else {
/*
* Not enough space. Leave the file in the unlinked set.
* Free up all the data in the file.
* We don't do this for xattr dir, because we need truncate and
* remove be in the same tx as in zfs_znode_delete. Otherwise,
* if we crash here, we'll end up with inconsistent zap object
* on the delete queue.
*/
zfs_znode_dmu_fini(zp);
return;
error = dmu_free_long_range(os, zp->z_id, 0, DMU_OBJECT_END);
if (error) {
/*
* Not enough space. Leave the file in the unlinked
* set.
*/
zfs_znode_dmu_fini(zp);
return;
}
}

/*
Expand Down

0 comments on commit cb57b43

Please sign in to comment.