Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-15940 client: add snapshot support to pil4dfs #15699

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 40 additions & 2 deletions src/client/dfuse/pil4dfs/int_dfs.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2022-2024 Intel Corporation.

Check failure on line 2 in src/client/dfuse/pil4dfs/int_dfs.c

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -574,7 +574,10 @@
char *fs_root = NULL;
char *pool = NULL;
char *container = NULL;
char *snap_name = NULL;
size_t len_snap = 0;
size_t len_fs_root, len_pool, len_container;
daos_epoch_t snap_epoch = 0;

/* Add the mount if env D_IL_MOUNT_POINT is set. */
rc = d_agetenv_str(&fs_root, "D_IL_MOUNT_POINT");
Expand Down Expand Up @@ -628,6 +631,21 @@
D_GOTO(out, rc = ENAMETOOLONG);
}

rc = d_agetenv_str(&snap_name, "D_IL_SNAP");
if (snap_name) {
D_DEBUG(DB_ANY, "D_IL_SNAP is set to %s.\n", snap_name);

len_snap = strnlen(snap_name, DAOS_SNAPSHOT_MAX_LEN);
if (len_snap >= DAOS_SNAPSHOT_MAX_LEN) {
D_FATAL("D_IL_SNAP is too long.\n");
D_GOTO(out, rc = ENAMETOOLONG);
}
}

rc = d_getenv_uint64_t("D_IL_SNAP_EPOCH", &snap_epoch);
if (rc != -DER_NONEXIST)
D_DEBUG(DB_ANY, "D_IL_SNAP_EPOCH is set to "DF_U64".\n", snap_epoch);

D_STRNDUP(dfs_list[num_dfs].fs_root, fs_root, len_fs_root);
if (dfs_list[num_dfs].fs_root == NULL)
D_GOTO(out, rc = ENOMEM);
Expand All @@ -640,6 +658,13 @@
if (dfs_list[num_dfs].cont == NULL)
D_GOTO(free_pool, rc = ENOMEM);

if (snap_name != NULL) {
D_STRNDUP(dfs_list[num_dfs].snap_name, snap_name, len_snap);
if (dfs_list[num_dfs].snap_name == NULL)
D_GOTO(free_pool, rc = ENOMEM);
}

dfs_list[num_dfs].snap_epoch = snap_epoch;
dfs_list[num_dfs].dcache = NULL;
dfs_list[num_dfs].len_fs_root = (int)len_fs_root;
atomic_init(&dfs_list[num_dfs].inited, 0);
Expand Down Expand Up @@ -701,6 +726,8 @@
atomic_init(&pt_dfs_mt->inited, 0);
pt_dfs_mt->pool = NULL;
pt_dfs_mt->cont = NULL;
pt_dfs_mt->snap_name = NULL;
pt_dfs_mt->snap_epoch = 0;
D_STRNDUP(pt_dfs_mt->fs_root, fs_entry->mnt_dir, pt_dfs_mt->len_fs_root);
if (pt_dfs_mt->fs_root == NULL)
D_GOTO(out, rc = ENOMEM);
Expand Down Expand Up @@ -4280,7 +4307,9 @@
"D_LOG_MASK",
"D_IL_COMPATIBLE",
"D_IL_NO_DCACHE_BASH",
"D_IL_BYPASS_LIST"};
"D_IL_BYPASS_LIST",
"D_IL_SNAP",
"D_IL_SNAP_EPOCH"};

/* Environmental variables could be cleared in some applications. To make sure all libpil4dfs
* related env properly set, we intercept execve and its variants to check envp[] and append our
Expand Down Expand Up @@ -7462,7 +7491,16 @@
DL_ERROR(rc, "failed to open container");
D_GOTO(out_err_cont_open, rc);
}
rc = dfs_mount(dfs_list[idx].poh, dfs_list[idx].coh, O_RDWR, &dfs_list[idx].dfs);

/**
* mount a snapshot if an epoch or snapshot name is passed, otherwise just a regular mount
*/
if (dfs_list[idx].snap_epoch != 0 || dfs_list[idx].snap_name != NULL)
rc = dfs_mount_snap(dfs_list[idx].poh, dfs_list[idx].coh, O_RDONLY,
dfs_list[idx].snap_epoch, dfs_list[idx].snap_name,
&dfs_list[idx].dfs);
else
rc = dfs_mount(dfs_list[idx].poh, dfs_list[idx].coh, O_RDWR, &dfs_list[idx].dfs);
if (rc != 0) {
DS_ERROR(rc, "failed to mount dfs");
D_GOTO(out_err_mt, rc);
Expand Down
2 changes: 2 additions & 0 deletions src/client/dfuse/pil4dfs/pil4dfs_int.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright 2024 Intel Corporation.

Check failure on line 2 in src/client/dfuse/pil4dfs/pil4dfs_int.h

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -90,6 +90,8 @@
_Atomic uint32_t inited;
char *pool, *cont;
char *fs_root;
char *snap_name;
daos_epoch_t snap_epoch;
};

#endif
2 changes: 1 addition & 1 deletion src/include/daos_fs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright 2018-2024 Intel Corporation.

Check failure on line 2 in src/include/daos_fs.h

View workflow job for this annotation

GitHub Actions / Copyright check

Copyright out of date
*
* SPDX-License-Identifier: BSD-2-Clause-Patent
*/
Expand Down Expand Up @@ -291,7 +291,7 @@
* \param[in] coh Container open handle.
* \param[in] flags Mount flags for future use, will be O_RDONLY by definition.
* \param[in] epoch Epoch associated with the snapshot to mount.
* If a null epoch is passed, then the snapshot is looked up by \a name.
* If a zero epoch is passed, then the snapshot is looked up by \a name.
* \param[in] name Optional name of the snapshot to mount, only valid when \a epoch is set
* to 0.
* \param[out] dfs Pointer to the file system object created.
Expand Down
Loading