text stringlengths 0 14.1k |
|---|
void |
zpool_explain_recover(libzfs_handle_t *hdl, const char *name, int reason, |
nvlist_t *config) |
{ |
int64_t loss = -1; |
uint64_t edata = UINT64_MAX; |
uint64_t rewindto; |
struct tm t; |
char timestr[128]; |
if (!hdl->libzfs_printerr) |
return; |
if (reason >= 0) |
(void) printf(dgettext(TEXT_DOMAIN, ""action: "")); |
else |
(void) printf(dgettext(TEXT_DOMAIN, ""\t"")); |
/* All attempted rewinds failed if ZPOOL_CONFIG_LOAD_TIME missing */ |
if (nvlist_lookup_uint64(config, |
ZPOOL_CONFIG_LOAD_TIME, &rewindto) != 0) |
goto no_info; |
(void) nvlist_lookup_int64(config, ZPOOL_CONFIG_REWIND_TIME, &loss); |
(void) nvlist_lookup_uint64(config, ZPOOL_CONFIG_LOAD_DATA_ERRORS, |
&edata); |
(void) printf(dgettext(TEXT_DOMAIN, |
""Recovery is possible, but will result in some data loss.\n"")); |
if (localtime_r((time_t *)&rewindto, &t) != NULL && |
strftime(timestr, 128, ""%F"", &t) != 0) { |
(void) printf(dgettext(TEXT_DOMAIN, |
""\tReturning the pool to its state as of %s\n"" |
""\tshould correct the problem. ""), |
timestr); |
} else { |
(void) printf(dgettext(TEXT_DOMAIN, |
""\tReverting the pool to an earlier state "" |
""should correct the problem.\n\t"")); |
} |
if (loss > 120) { |
(void) printf(dgettext(TEXT_DOMAIN, |
""Approximately "" FI64 "" minutes of data\n"" |
""\tmust be discarded, irreversibly. ""), (loss + 30) / 60); |
} else if (loss > 0) { |
(void) printf(dgettext(TEXT_DOMAIN, |
""Approximately "" FI64 "" seconds of data\n"" |
""\tmust be discarded, irreversibly. ""), loss); |
} |
if (edata != 0 && edata != UINT64_MAX) { |
if (edata == 1) { |
(void) printf(dgettext(TEXT_DOMAIN, |
""After rewind, at least\n"" |
""\tone persistent user-data error will remain. "")); |
} else { |
(void) printf(dgettext(TEXT_DOMAIN, |
""After rewind, several\n"" |
""\tpersistent user-data errors will remain. "")); |
} |
} |
(void) printf(dgettext(TEXT_DOMAIN, |
""Recovery can be attempted\n\tby executing 'zpool %s -F %s'. ""), |
reason >= 0 ? ""clear"" : ""import"", name); |
(void) printf(dgettext(TEXT_DOMAIN, |
""A scrub of the pool\n"" |
""\tis strongly recommended after recovery.\n"")); |
return; |
no_info: |
(void) printf(dgettext(TEXT_DOMAIN, |
""Destroy and re-create the pool from\n\ta backup source.\n"")); |
} |
/* |
* zpool_import() is a contracted interface. Should be kept the same |
* if possible. |
* |
* Applications should use zpool_import_props() to import a pool with |
* new properties value to be set. |
*/ |
int |
zpool_import(libzfs_handle_t *hdl, nvlist_t *config, const char *newname, |
char *altroot) |
{ |
nvlist_t *props = NULL; |
int ret; |
if (altroot != NULL) { |
if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0) { |
return (zfs_error_fmt(hdl, EZFS_NOMEM, |
dgettext(TEXT_DOMAIN, ""cannot import '%s'""), |
newname)); |
} |
if (nvlist_add_string(props, |
zpool_prop_to_name(ZPOOL_PROP_ALTROOT), altroot) != 0 || |
nvlist_add_string(props, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.