summaryrefslogtreecommitdiffstats
path: root/include/sys
diff options
context:
space:
mode:
authorPaul Dagnelie <[email protected]>2020-04-01 10:02:06 -0700
committerGitHub <[email protected]>2020-04-01 10:02:06 -0700
commit5a42ef04fd390dc96fbbf31bc9f3d05695998211 (patch)
treeee4aec968084618faa92988b08a3c41c9b904327 /include/sys
parentc9e3efdb3a6111b9795becc6594b3c52ba004522 (diff)
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: John Gallagher <[email protected]> Signed-off-by: Paul Dagnelie <[email protected]> Closes #9707
Diffstat (limited to 'include/sys')
-rw-r--r--include/sys/dsl_dir.h8
-rw-r--r--include/sys/fs/zfs.h12
2 files changed, 20 insertions, 0 deletions
diff --git a/include/sys/dsl_dir.h b/include/sys/dsl_dir.h
index bb6921027..88fd61035 100644
--- a/include/sys/dsl_dir.h
+++ b/include/sys/dsl_dir.h
@@ -121,6 +121,11 @@ struct dsl_dir {
bplist_t dd_pending_frees;
bplist_t dd_pending_allocs;
+ kmutex_t dd_activity_lock;
+ kcondvar_t dd_activity_cv;
+ boolean_t dd_activity_cancelled;
+ uint64_t dd_activity_waiters;
+
/* protected by dd_lock; keep at end of struct for better locality */
char dd_myname[ZFS_MAX_DATASET_NAME_LEN];
};
@@ -192,6 +197,9 @@ boolean_t dsl_dir_is_zapified(dsl_dir_t *dd);
void dsl_dir_livelist_open(dsl_dir_t *dd, uint64_t obj);
void dsl_dir_livelist_close(dsl_dir_t *dd);
void dsl_dir_remove_livelist(dsl_dir_t *dd, dmu_tx_t *tx, boolean_t total);
+int dsl_dir_wait(dsl_dir_t *dd, dsl_dataset_t *ds, zfs_wait_activity_t activity,
+ boolean_t *waited);
+void dsl_dir_cancel_waiters(dsl_dir_t *dd);
/* internal reserved dir name */
#define MOS_DIR_NAME "$MOS"
diff --git a/include/sys/fs/zfs.h b/include/sys/fs/zfs.h
index 3484b13e3..477356aa7 100644
--- a/include/sys/fs/zfs.h
+++ b/include/sys/fs/zfs.h
@@ -1282,6 +1282,7 @@ typedef enum zfs_ioc {
ZFS_IOC_REDACT, /* 0x5a51 */
ZFS_IOC_GET_BOOKMARK_PROPS, /* 0x5a52 */
ZFS_IOC_WAIT, /* 0x5a53 */
+ ZFS_IOC_WAIT_FS, /* 0x5a54 */
/*
* Per-platform (Optional) - 6/128 numbers reserved.
@@ -1358,6 +1359,11 @@ typedef enum {
ZPOOL_WAIT_NUM_ACTIVITIES
} zpool_wait_activity_t;
+typedef enum {
+ ZFS_WAIT_DELETEQ,
+ ZFS_WAIT_NUM_ACTIVITIES
+} zfs_wait_activity_t;
+
/*
* Bookmark name values.
*/
@@ -1416,6 +1422,12 @@ typedef enum {
#define ZPOOL_WAIT_WAITED "wait_waited"
/*
+ * The following are names used when invoking ZFS_IOC_WAIT_FS.
+ */
+#define ZFS_WAIT_ACTIVITY "wait_activity"
+#define ZFS_WAIT_WAITED "wait_waited"
+
+/*
* Flags for ZFS_IOC_VDEV_SET_STATE
*/
#define ZFS_ONLINE_CHECKREMOVE 0x1