view src/objstore/include/nomad/objstore.h @ 105:cd8f74fb7a65

objstore: associate each created volume with a volume group Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net> Signed-off-by: Steve Dougherty <steve@asksteved.com>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Sat, 17 Oct 2015 15:27:39 -0400
parents 40b4277fb1e1
children 2b39a5cf338b
line wrap: on
line source

/*
 * Copyright (c) 2015 Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#ifndef __NOMAD_OBJSTORE_H
#define __NOMAD_OBJSTORE_H

#include <sys/list.h>

#include <nomad/types.h>
#include <nomad/mutex.h>

enum objstore_mode {
	OS_MODE_CACHE,
	OS_MODE_STORE,
};

struct objstore {
	list_node_t node;

	pthread_mutex_t lock;
	const char *name;
	list_t vols;		/* list of volumes */
};

struct objstore_vol_def;

struct objstore_vol {
	list_node_t vg_list;
	struct objstore *vg;

	const struct objstore_vol_def *def;

	struct nuuid uuid;
	const char *path;
	enum objstore_mode mode;

	void *private;
};

extern int objstore_init(void);

/* volume group management */
extern struct objstore *objstore_vg_create(const char *name);

/* volume management */
extern struct objstore_vol *objstore_vol_create(struct objstore *vg,
						const char *path,
						enum objstore_mode mode);
extern struct objstore_vol *objstore_vol_load(struct objstore *vg,
					      struct nuuid *uuid,
					      const char *path);

/* volume operations */
extern int objstore_getroot(struct objstore_vol *store, struct nobjhndl *hndl);

/* object operations */
extern int objstore_obj_getattr(struct objstore_vol *store,
				const struct nobjhndl *hndl,
				struct nattr *attr);

#endif