Skip to content

Commit

Permalink
FreeBSD: bring back possibility to rewind the checkpoint from bootloader
Browse files Browse the repository at this point in the history
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: f2c027b

Originally reviewed by:		tsoome, allanjude
Originally reviewed by:		kevans (ok from high-level overview)

Signed-off-by: Mariusz Zaborski <oshogbo@vexillium.org>
  • Loading branch information
oshogbo committed Mar 11, 2021
1 parent f5ada65 commit eb7b61e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion module/os/freebsd/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,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)
Expand All @@ -1305,6 +1317,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));
Expand All @@ -1318,6 +1331,8 @@ zfs_mount(vfs_t *vfsp)
secpolicy_fs_mount_clearopts(cr, vfsp);
}

fetch_osname_options(osname, &checkpointrewind);

/*
* Check for mount privilege?
*
Expand Down Expand Up @@ -1396,7 +1411,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;
}
Expand Down

0 comments on commit eb7b61e

Please sign in to comment.