aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMariusz Zaborski <oshogbo@FreeBSD.org>2021-03-13 11:56:17 +0000
committerMariusz Zaborski <oshogbo@FreeBSD.org>2021-03-18 23:02:57 +0000
commitc145b7954656601d92f578b08183fbf78e1a249b (patch)
treea601018799c0c7a7ca951c54be0028cda05225d3
parent11660fa28fd39a644cb7d30a4378cf4751b89f15 (diff)
downloadsrc-c145b7954656601d92f578b08183fbf78e1a249b.tar.gz
src-c145b7954656601d92f578b08183fbf78e1a249b.zip
zfs: bring back possibility to rewind the checkpoint from
Add parsing of the rewind options. When I was upstreaming the change [1], I omitted the part where we detect that the pool should be rewind. When the FreeBSD repo has synced with the OpenZFS, this part of the code was removed. [1] FreeBSD repo: 277f38abffc6a8160b5044128b5b2c620fbb970c [2] OpenZFS repo: f2c027bd6a003ec5793f8716e6189c389c60f47a Originally reviewed by: tsoome, allanjude Originally reviewed by: kevans (ok from high-level overview) Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org> PR: 254152 Approved by: re(gjb) Reported by: Zhenlei Huang <zlei.huang at gmail.com> Obtained from: https://github.com/openzfs/zfs/pull/11730 (cherry picked from commit 653ed678c70376b15cdc42daafa7b4554570cea2) (cherry picked from commit 6bbca5ca3a6634fc10b93da203df2ae92cf60b61)
-rw-r--r--sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
index 7bc6b83d0272..a537342f9678 100644
--- a/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
+++ b/sys/contrib/openzfs/module/os/freebsd/zfs/zfs_vfsops.c
@@ -1291,6 +1291,18 @@ getpoolname(const char *osname, char *poolname)
return (0);
}
+static void
+fetch_osname_options(char *name, bool *checkpointrewind)
+{
+
+ if (name[0] == '!') {
+ *checkpointrewind = true;
+ memmove(name, name + 1, strlen(name));
+ } else {
+ *checkpointrewind = false;
+ }
+}
+
/*ARGSUSED*/
static int
zfs_mount(vfs_t *vfsp)
@@ -1301,6 +1313,7 @@ zfs_mount(vfs_t *vfsp)
char *osname;
int error = 0;
int canwrite;
+ bool checkpointrewind;
if (vfs_getopt(vfsp->mnt_optnew, "from", (void **)&osname, NULL))
return (SET_ERROR(EINVAL));
@@ -1314,6 +1327,8 @@ zfs_mount(vfs_t *vfsp)
secpolicy_fs_mount_clearopts(cr, vfsp);
}
+ fetch_osname_options(osname, &checkpointrewind);
+
/*
* Check for mount privilege?
*
@@ -1392,7 +1407,7 @@ zfs_mount(vfs_t *vfsp)
error = getpoolname(osname, pname);
if (error == 0)
- error = spa_import_rootpool(pname, false);
+ error = spa_import_rootpool(pname, checkpointrewind);
if (error)
goto out;
}