if (o->od_root_db)
udmu_object_put_dmu_buf(o->od_root_db, root_tag);
if (o->od_objset.os)
- udmu_objset_close(&o->od_objset, 0);
+ udmu_objset_close(&o->od_objset);
RETURN(0);
}
if (o->od_objset.os != NULL)
RETURN(0);
- while (*dev && *dev == '/')
- dev++;
-
- rc = udmu_objset_open(dev, NULL, 0, 0, &o->od_objset);
+ rc = udmu_objset_open(dev, &o->od_objset);
if (rc) {
CERROR("can't open objset %s: %d\n", dev, rc);
RETURN(-rc);
rc = udmu_objset_root(&o->od_objset, &rootdb, root_tag);
if (rc) {
CERROR("udmu_objset_root() failed with error %d\n", rc);
+ udmu_objset_close(&o->od_objset);
RETURN(-rc);
}
o->od_root_db = rootdb;
debug_level = level;
}
-int udmu_objset_open(char *osname, char *import_dir, int import, int force,
- udmu_objset_t *uos)
+int udmu_objset_open(char *osname, udmu_objset_t *uos)
{
int error;
- //char cmd[MAXPATHLEN];
- char *c;
uint64_t version = ZPL_VERSION;
- //int tried_import = FALSE;
memset(uos, 0, sizeof(udmu_objset_t));
- c = strchr(osname, '/');
-
/* Let's try to open the objset */
error = dmu_objset_open(osname, DMU_OST_ZFS, DS_MODE_OWNER, &uos->os);
-#if 0
- if (error == ENOENT && import && !tried_import) {
- /* objset not found, let's try to import the pool */
- udmu_printf(LEVEL_INFO, stdout, "Importing pool %s\n", osname);
-
- if (c != NULL)
- *c = '\0';
-
- snprintf(cmd, sizeof(cmd), "lzpool import%s%s%s %s",
- force ? " -F" : "", import_dir ? " -d " : "",
- import_dir ? import_dir : "", osname);
-
- if (c != NULL)
- *c = '/';
-
- error = system(cmd);
-
- if (error) {
- udmu_printf(LEVEL_CRITICAL, stderr, "\"%s\" failed:"
- " %d\n", cmd, error);
- return(error);
- }
-
- tried_import = TRUE;
- goto top;
- }
-#endif
-
if (error) {
uos->os = NULL;
goto out;
ASSERT(uos->root != 0);
out:
-#if 0
- if (error) {
- if (uos->os == NULL && tried_import) {
- if (c != NULL)
- *c = '\0';
- spa_export(osname, NULL, B_TRUE);
- if (c != NULL)
- *c = '/';
- } else if(uos->os != NULL)
- udmu_objset_close(uos, tried_import);
- }
-#endif
+ if (error && uos->os != NULL)
+ dmu_objset_close(uos->os);
return (error);
}
tx ? tx->tx_txg : 0ULL);
}
-void udmu_objset_close(udmu_objset_t *uos, int export_pool)
+void udmu_objset_close(udmu_objset_t *uos)
{
-
ASSERT(uos->os != NULL);
-#if 0
- spa_t *spa;
- char pool_name[MAXPATHLEN];
- spa = uos->os->os->os_spa;
- spa_config_enter(spa, RW_READER, FTAG);
- strncpy(pool_name, spa_name(spa), sizeof(pool_name));
- spa_config_exit(spa, FTAG);
-#endif
-
+ /* Force a txg sync.
+ This should not be needed, neither for correctness nor safety.
+ Presumably, we are only doing this to force commit callbacks to be called sooner. */
udmu_wait_synced(uos, NULL);
+
/* close the object set */
dmu_objset_close(uos->os);
uos->os = NULL;
-
-#if 0
- if (export_pool)
- spa_export(pool_name, NULL, B_TRUE);
-#endif
}
int udmu_objset_statfs(udmu_objset_t *uos, struct statfs64 *statp)