Commit 3bb815ae authored by Tomasz Zawadzki's avatar Tomasz Zawadzki Committed by Jim Harris
Browse files

lvol: exposed marking lvol bdev as read only



Added set_read_only_lvol_bdev() RPC that marks
lvol bdev as read only.
This enables to create clones off of a base lvol,
without having to create additional lvol bdev with snapshot.

Change-Id: Ic20bbcd8fbebcef157acce44bfa1da035b0da459
Signed-off-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-on: https://review.gerrithub.io/c/440534


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 8a3620ff
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -81,6 +81,11 @@ allows virtual bdevs to be shut down cleanly as opposed to the
previous behavior that didn't differentiate between hotremove and
planned shutdown.

### logical volumes

Logical volume bdev can now be marked as read only using `set_read_only_lvol_bdev` RPC.
This allows for basing clones on top of lvol_bdev without first creating a snapshot.

### log

"trace flags" are now referred to as "log flags" in the SPDK log API.  The
+1 −1
Original line number Diff line number Diff line
@@ -167,7 +167,7 @@ if [ $SPDK_TEST_LVOL -eq 1 ]; then
	test_cases="1,50,51,52,53,100,101,102,150,200,201,250,251,252,253,254,255,"
	test_cases+="300,301,450,451,452,550,551,552,553,"
	test_cases+="600,601,650,651,652,654,655,"
	test_cases+="700,701,702,750,751,752,753,754,755,756,757,758,759,"
	test_cases+="700,701,702,750,751,752,753,754,755,756,757,758,759,760,"
	test_cases+="800,801,802,803,804,10000"
	run_test suite ./test/lvol/lvol.sh --test-cases=$test_cases
	run_test suite ./test/blobstore/blob_io_wait/blob_io_wait.sh
+5 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ The write operation is performed as shown in the diagram below:
![Writing cluster to the clone](lvol_clone_snapshot_write.svg)

User may also create clone of existing snapshot that will be thin provisioned and it will behave in the same way as logical volume from which snapshot is created.
There is no limit of clones and snapshots that may be created as long as there is enough space on logical volume store. Snapshots are read only. Clones may be created only from snapshots.
There is no limit of clones and snapshots that may be created as long as there is enough space on logical volume store. Snapshots are read only. Clones may be created only from snapshots or read only logical volumes.

## Inflation {#lvol_inflation}

@@ -137,6 +137,10 @@ resize_lvol_bdev [-h] name size
    Resize existing lvol bdev
    optional arguments:
    -h, --help  show help
set_read_only_lvol_bdev [-h] name
    Mark lvol bdev as read only
    optional arguments:
    -h, --help  show help
inflate_lvol_bdev [-h] name
    Inflate lvol bdev
    optional arguments:
+3 −0
Original line number Diff line number Diff line
@@ -121,4 +121,7 @@ struct lvol_store_bdev *vbdev_lvol_store_next(struct lvol_store_bdev *prev);
void spdk_lvol_resize(struct spdk_lvol *lvol, uint64_t sz, spdk_lvol_op_complete cb_fn,
		      void *cb_arg);

void spdk_lvol_set_read_only(struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn,
			     void *cb_arg);

#endif /* SPDK_INTERNAL_LVOLSTORE_H */
+40 −0
Original line number Diff line number Diff line
@@ -1158,6 +1158,46 @@ vbdev_lvol_resize(struct spdk_lvol *lvol, uint64_t sz, spdk_lvol_op_complete cb_
	spdk_lvol_resize(req->lvol, req->sz, _vbdev_lvol_resize_cb, req);
}

static void
_vbdev_lvol_set_read_only_cb(void *cb_arg, int lvolerrno)
{
	struct spdk_lvol_req *req = cb_arg;
	struct spdk_lvol *lvol = req->lvol;

	if (lvolerrno != 0) {
		SPDK_ERRLOG("Could not set bdev lvol %s as read only due to error: %d.\n", lvol->name, lvolerrno);
	}

	req->cb_fn(req->cb_arg, lvolerrno);
	free(req);
}

void
vbdev_lvol_set_read_only(struct spdk_lvol *lvol, spdk_lvol_op_complete cb_fn, void *cb_arg)
{
	struct spdk_lvol_req *req;

	if (lvol == NULL) {
		SPDK_ERRLOG("lvol does not exist\n");
		cb_fn(cb_arg, -EINVAL);
		return;
	}

	assert(lvol->bdev != NULL);

	req = calloc(1, sizeof(*req));
	if (req == NULL) {
		cb_fn(cb_arg, -ENOMEM);
		return;
	}

	req->cb_fn = cb_fn;
	req->cb_arg = cb_arg;
	req->lvol = lvol;

	spdk_lvol_set_read_only(lvol, _vbdev_lvol_set_read_only_cb, req);
}

static int
vbdev_lvs_init(void)
{
Loading