mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Add 'zfs wait' command
Add a mechanism to wait for delete queue to drain. When doing redacted send/recv, many workflows involve deleting files that contain sensitive data. Because of the way zfs handles file deletions, snapshots taken quickly after a rm operation can sometimes still contain the file in question, especially if the file is very large. This can result in issues for redacted send/recv users who expect the deleted files to be redacted in the send streams, and not appear in their clones. This change duplicates much of the zpool wait related logic into a zfs wait command, which can be used to wait until the internal deleteq has been drained. Additional wait activities may be added in the future. Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: John Gallagher <john.gallagher@delphix.com> Signed-off-by: Paul Dagnelie <pcd@delphix.com> Closes #9707
This commit is contained in:
@@ -52,6 +52,8 @@
|
||||
#include <sys/zfs_fuid.h>
|
||||
#include <sys/sa.h>
|
||||
#include <sys/zfs_sa.h>
|
||||
#include <sys/dmu_objset.h>
|
||||
#include <sys/dsl_dir.h>
|
||||
|
||||
/*
|
||||
* zfs_match_find() is used by zfs_dirent_lock() to perform zap lookups
|
||||
@@ -739,6 +741,8 @@ zfs_rmnode(znode_t *zp)
|
||||
zfs_unlinked_add(xzp, tx);
|
||||
}
|
||||
|
||||
mutex_enter(&os->os_dsl_dataset->ds_dir->dd_activity_lock);
|
||||
|
||||
/*
|
||||
* Remove this znode from the unlinked set. If a has rollback has
|
||||
* occurred while a file is open and unlinked. Then when the file
|
||||
@@ -749,6 +753,13 @@ zfs_rmnode(znode_t *zp)
|
||||
zp->z_id, tx);
|
||||
VERIFY(error == 0 || error == ENOENT);
|
||||
|
||||
uint64_t count;
|
||||
if (zap_count(os, zfsvfs->z_unlinkedobj, &count) == 0 && count == 0) {
|
||||
cv_broadcast(&os->os_dsl_dataset->ds_dir->dd_activity_cv);
|
||||
}
|
||||
|
||||
mutex_exit(&os->os_dsl_dataset->ds_dir->dd_activity_lock);
|
||||
|
||||
dataset_kstats_update_nunlinked_kstat(&zfsvfs->z_kstat, 1);
|
||||
|
||||
zfs_znode_delete(zp, tx);
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
#include <sys/zfs_quota.h>
|
||||
#include <sys/sunddi.h>
|
||||
#include <sys/dmu_objset.h>
|
||||
#include <sys/dsl_dir.h>
|
||||
#include <sys/spa_boot.h>
|
||||
#include <sys/objlist.h>
|
||||
#include <sys/zpl.h>
|
||||
@@ -872,6 +873,8 @@ zfsvfs_setup(zfsvfs_t *zfsvfs, boolean_t mounting)
|
||||
"num_entries in unlinked set: %llu",
|
||||
zs.zs_num_entries);
|
||||
zfs_unlinked_drain(zfsvfs);
|
||||
dsl_dir_t *dd = zfsvfs->z_os->os_dsl_dataset->ds_dir;
|
||||
dd->dd_activity_cancelled = B_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1423,6 +1426,8 @@ zfsvfs_teardown(zfsvfs_t *zfsvfs, boolean_t unmounting)
|
||||
txg_wait_synced(dmu_objset_pool(zfsvfs->z_os), 0);
|
||||
}
|
||||
dmu_objset_evict_dbufs(zfsvfs->z_os);
|
||||
dsl_dir_t *dd = os->os_dsl_dataset->ds_dir;
|
||||
dsl_dir_cancel_waiters(dd);
|
||||
|
||||
return (0);
|
||||
}
|
||||
@@ -1813,6 +1818,7 @@ zfs_resume_fs(zfsvfs_t *zfsvfs, dsl_dataset_t *ds)
|
||||
if (err != 0)
|
||||
goto bail;
|
||||
|
||||
ds->ds_dir->dd_activity_cancelled = B_FALSE;
|
||||
VERIFY(zfsvfs_setup(zfsvfs, B_FALSE) == 0);
|
||||
|
||||
zfs_set_fuid_feature(zfsvfs);
|
||||
|
||||
Reference in New Issue
Block a user