ptl_nid_t nid;
char *uuid;
__u32 nal;
- ptl_handle_ni_t ni;
};
/* FIXME: This should probably become more elegant than a global linked list */
void class_exit_uuidlist(void)
{
- struct list_head *tmp, *n;
-
- /* Module going => sole user => don't need to lock g_uuid_list */
- list_for_each_safe(tmp, n, &g_uuid_list) {
- struct uuid_nid_data *data =
- list_entry(tmp, struct uuid_nid_data, head);
-
- OBD_FREE(data->uuid, strlen(data->uuid) + 1);
- OBD_FREE(data, sizeof(*data));
- }
+ /* delete all */
+ class_del_uuid(NULL);
}
-int lustre_uuid_to_peer(char *uuid, struct lustre_peer *peer)
+int lustre_uuid_to_peer(char *uuid, __u32 *peer_nal, ptl_nid_t *peer_nid)
{
struct list_head *tmp;
list_entry(tmp, struct uuid_nid_data, head);
if (strcmp(data->uuid, uuid) == 0) {
- peer->peer_nid = data->nid;
- peer->peer_ni = data->ni;
+ *peer_nid = data->nid;
+ *peer_nal = data->nal;
spin_unlock (&g_uuid_lock);
return 0;
int class_add_uuid(char *uuid, __u64 nid, __u32 nal)
{
- const ptl_handle_ni_t *nip;
struct uuid_nid_data *data;
int rc;
int nob = strnlen (uuid, PAGE_SIZE) + 1;
if (nob > PAGE_SIZE)
return -EINVAL;
- nip = kportal_get_ni (nal);
- if (nip == NULL) {
- CERROR("get_ni failed: is the NAL module loaded?\n");
- return -EIO;
- }
-
rc = -ENOMEM;
OBD_ALLOC(data, sizeof(*data));
if (data == NULL)
- goto fail_0;
+ return -ENOMEM;
OBD_ALLOC(data->uuid, nob);
- if (data == NULL)
- goto fail_1;
+ if (data == NULL) {
+ OBD_FREE(data, sizeof(*data));
+ return -ENOMEM;
+ }
+ CDEBUG(D_INFO, "add uuid %s "LPX64" %x\n", uuid, nid, nal);
memcpy(data->uuid, uuid, nob);
data->nid = nid;
data->nal = nal;
- data->ni = *nip;
spin_lock (&g_uuid_lock);
spin_unlock (&g_uuid_lock);
return 0;
-
- fail_1:
- OBD_FREE (data, sizeof (*data));
- fail_0:
- kportal_put_ni (nal);
- return (rc);
}
/* delete only one entry if uuid is specified, otherwise delete all */
spin_unlock (&g_uuid_lock);
- if (list_empty (&deathrow))
+ if (list_empty (&deathrow)) {
+ if (uuid)
+ CERROR("del non-existed uuid %s\n", uuid);
return -EINVAL;
+ }
do {
data = list_entry(deathrow.next, struct uuid_nid_data, head);
list_del (&data->head);
- kportal_put_ni (data->nal);
OBD_FREE(data->uuid, strlen(data->uuid) + 1);
OBD_FREE(data, sizeof(*data));
} while (!list_empty (&deathrow));