#include <obd_target.h>
#include <obd_support.h>
+#include <lu_object.h>
/**
* Initialize the pool data structures at startup.
* \retval negative error number on failure
*/
#define POOL_INIT_COUNT 2
-int tgt_pool_init(struct lu_tgt_pool *op, unsigned int count)
+int lu_tgt_pool_init(struct lu_tgt_pool *op, unsigned int count)
{
ENTRY;
EXIT;
return 0;
}
-EXPORT_SYMBOL(tgt_pool_init);
+EXPORT_SYMBOL(lu_tgt_pool_init);
/**
* Increase the op_array size to hold more targets in this pool.
* \retval 0 on success
* \retval negative error number on failure.
*/
-int tgt_pool_extend(struct lu_tgt_pool *op, unsigned int min_count)
+int lu_tgt_pool_extend(struct lu_tgt_pool *op, unsigned int min_count)
{
__u32 *new;
__u32 new_size;
return 0;
}
-EXPORT_SYMBOL(tgt_pool_extend);
+EXPORT_SYMBOL(lu_tgt_pool_extend);
/**
* Add a new target to an existing pool.
* \retval 0 if target could be added to the pool
* \retval negative error if target \a idx was not added
*/
-int tgt_pool_add(struct lu_tgt_pool *op, __u32 idx, unsigned int min_count)
+int lu_tgt_pool_add_lock(struct lu_tgt_pool *op, __u32 idx,
+ unsigned int min_count, bool lock)
{
unsigned int i;
int rc = 0;
ENTRY;
- down_write(&op->op_rw_sem);
-
- rc = tgt_pool_extend(op, min_count);
- if (rc)
- GOTO(out, rc);
+ if (lock)
+ down_write(&op->op_rw_sem);
/* search ost in pool array */
for (i = 0; i < op->op_count; i++) {
if (op->op_array[i] == idx)
GOTO(out, rc = -EEXIST);
}
+
+ rc = lu_tgt_pool_extend(op, min_count);
+ if (rc)
+ GOTO(out, rc);
+
/* ost not found we add it */
op->op_array[op->op_count] = idx;
op->op_count++;
EXIT;
out:
- up_write(&op->op_rw_sem);
+ if (lock)
+ up_write(&op->op_rw_sem);
return rc;
}
-EXPORT_SYMBOL(tgt_pool_add);
+EXPORT_SYMBOL(lu_tgt_pool_add_lock);
/**
* Remove an existing pool from the system.
* \retval 0 on success
* \retval negative error number on failure
*/
-int tgt_pool_remove(struct lu_tgt_pool *op, __u32 idx)
+int lu_tgt_pool_remove(struct lu_tgt_pool *op, __u32 idx)
{
unsigned int i;
ENTRY;
up_write(&op->op_rw_sem);
RETURN(-EINVAL);
}
-EXPORT_SYMBOL(tgt_pool_remove);
+EXPORT_SYMBOL(lu_tgt_pool_remove);
-int tgt_check_index(int idx, struct lu_tgt_pool *osts)
+int lu_tgt_check_index(int idx, struct lu_tgt_pool *osts)
{
- int rc, i;
+ int i, rc = -ENOENT;
ENTRY;
down_read(&osts->op_rw_sem);
if (osts->op_array[i] == idx)
GOTO(out, rc = 0);
}
- rc = -ENOENT;
EXIT;
out:
up_read(&osts->op_rw_sem);
return rc;
}
-EXPORT_SYMBOL(tgt_check_index);
+EXPORT_SYMBOL(lu_tgt_check_index);
/**
* Free the pool after it was emptied and removed from /proc.
* deleted from memory.
*
* \param[in] op pool to be freed.
- *
- * \retval 0 on success or if pool was already freed
*/
-int tgt_pool_free(struct lu_tgt_pool *op)
+void lu_tgt_pool_free(struct lu_tgt_pool *op)
{
ENTRY;
if (op->op_size == 0)
- RETURN(0);
+ RETURN_EXIT;
down_write(&op->op_rw_sem);
op->op_size = 0;
up_write(&op->op_rw_sem);
- RETURN(0);
+ EXIT;
}
-EXPORT_SYMBOL(tgt_pool_free);
+EXPORT_SYMBOL(lu_tgt_pool_free);