Skip to content

Commit

Permalink
open pool (openzfs#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahrens authored Apr 23, 2021
1 parent 6a15ce2 commit 3b7f646
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/zfs_object_agent/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ impl Pool {
&format!("zfs/{}/PendingFreesLog", guid),
),
pending_object: None,
pending_object_min_block: BlockID(1),
pending_object_min_block: BlockID(0),
pending_object_max_block: None,
pending_flushes: Vec::new(),
stats: PoolStatsPhys::default(),
Expand Down
3 changes: 3 additions & 0 deletions include/sys/vdev_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,9 @@ extern vdev_ops_t vdev_spare_ops;
extern vdev_ops_t vdev_indirect_ops;
extern vdev_ops_t vdev_object_store_ops;

void object_store_begin_txg(spa_t *, uint64_t);


/*
* Common size functions
*/
Expand Down
38 changes: 33 additions & 5 deletions module/os/linux/zfs/vdev_object_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ agent_read_block(vdev_object_store_t *vos, zio_t *zio)
spa_guid(zio->io_spa),
zio->io_offset);
agent_request_zio(vos, zio, nv);
fnvlist_free(nv);
}

static void
Expand All @@ -224,6 +225,7 @@ agent_write_block(vdev_object_store_t *vos, zio_t *zio)
zio->io_offset,
zio->io_size);
agent_request_zio(vos, zio, nv);
fnvlist_free(nv);
}

static void
Expand All @@ -239,6 +241,7 @@ agent_create_pool(vdev_t *vd, vdev_object_store_t *vos)
spa_name(vd->vdev_spa),
vd->vdev_path);
agent_request(vos, nv);
fnvlist_free(nv);
}

static void
Expand All @@ -252,6 +255,28 @@ agent_open_pool(vdev_t *vd, vdev_object_store_t *vos)
spa_guid(vd->vdev_spa),
vd->vdev_path);
agent_request(vos, nv);
fnvlist_free(nv);
}

static void
agent_begin_txg(vdev_object_store_t *vos, uint64_t txg)
{
nvlist_t *nv = fnvlist_alloc();
fnvlist_add_string(nv, AGENT_TYPE, AGENT_TYPE_BEGIN_TXG);
fnvlist_add_uint64(nv, AGENT_TXG, txg);
zfs_dbgmsg("agent_begin_txg(%llu)",
txg);
agent_request(vos, nv);
fnvlist_free(nv);
}

void
object_store_begin_txg(spa_t *spa, uint64_t txg)
{
vdev_t *vd = spa->spa_root_vdev->vdev_child[0];
ASSERT3P(vd->vdev_ops, ==, &vdev_object_store_ops);
vdev_object_store_t *vos = vd->vdev_tsd;
agent_begin_txg(vos, txg);
}

static void
Expand Down Expand Up @@ -283,7 +308,9 @@ agent_reader(void *arg)
const char *type = fnvlist_lookup_string(nv, AGENT_TYPE);
zfs_dbgmsg("got response from agent type=%s", type);
// XXX debug message the nvlist
if (strcmp(type, "pool open done") == 0) {
if (strcmp(type, "pool create done") == 0) {
zfs_dbgmsg("got pool create done");
} else if (strcmp(type, "pool open done") == 0) {
zfs_dbgmsg("got pool open done");
} else if (strcmp(type, "read done") == 0) {
uint64_t req = fnvlist_lookup_uint64(nv,
Expand Down Expand Up @@ -381,11 +408,12 @@ vdev_object_store_open(vdev_t *vd, uint64_t *psize, uint64_t *max_psize,

if (vd->vdev_spa->spa_load_state == SPA_LOAD_CREATE) {
agent_create_pool(vd, vos);
} else {
agent_open_pool(vd, vos);
// XXX wait for response from agent
delay(hz * 5);
}
agent_open_pool(vd, vos);
// XXX wait for response from agent
delay(hz * 10);
delay(hz * 5);

skip_open:

Expand Down Expand Up @@ -420,7 +448,7 @@ vdev_object_store_close(vdev_t *vd)
static void
vdev_object_store_io_strategy(void *arg)
{
zio_t *zio = (zio_t *)arg;
zio_t *zio = arg;
vdev_t *vd = zio->io_vd;
vdev_object_store_t *vos = vd->vdev_tsd;

Expand Down
6 changes: 6 additions & 0 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -9172,6 +9172,12 @@ spa_sync(spa_t *spa, uint64_t txg)

VERIFY(spa_writeable(spa));

#ifdef _KERNEL
if (!spa_normal_class(spa)->mc_ops->msop_block_based) {
object_store_begin_txg(spa, txg);
}
#endif

/*
* Wait for i/os issued in open context that need to complete
* before this txg syncs.
Expand Down

0 comments on commit 3b7f646

Please sign in to comment.