changeset 668:e188f5c2824e

objstore: warn about missing vol ops & initobj op during vol import/creation Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Mon, 04 Mar 2019 17:08:30 -0500
parents 10364796fb99
children c0730cae0a8e
files src/objstore/vol.c
diffstat 1 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/objstore/vol.c	Mon Mar 04 16:56:29 2019 -0500
+++ b/src/objstore/vol.c	Mon Mar 04 17:08:30 2019 -0500
@@ -159,6 +159,21 @@
 	mem_cache_free(vol_cache, vol);
 }
 
+static void check_vol_ops(struct objstore *vol)
+{
+	/*
+	 * We warn here (instead of when we try to use the ops) to avoid
+	 * spamming the log with these messages.  We also don't do anything
+	 * beyond issuing the warning.
+	 */
+	if (!vol->ops)
+		cmn_err(CE_INFO, "Volume ops are required (backend: %s)",
+			vol->vdev->def->name);
+	else if (!vol->ops->initobj)
+		cmn_err(CE_INFO, "Object init function is required (backend: %s)",
+			vol->vdev->def->name);
+}
+
 struct objstore *objstore_vol_create(struct objstore_vdev *vdev,
 				     const char *name)
 {
@@ -176,6 +191,8 @@
 	if (ret)
 		goto err;
 
+	check_vol_ops(vol);
+
 	MXLOCK(&loaded_vols.lock);
 	rb_add(&loaded_vols.tree, vol_getref(vol));
 	MXUNLOCK(&loaded_vols.lock);
@@ -206,6 +223,8 @@
 	if (ret)
 		goto err;
 
+	check_vol_ops(vol);
+
 	MXLOCK(&loaded_vols.lock);
 	rb_add(&loaded_vols.tree, vol);
 	MXUNLOCK(&loaded_vols.lock);