- 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;
-
- OBD_ALLOC(data->uuid, nob);
- if (data == NULL)
- goto fail_1;
-
- memcpy(data->uuid, uuid, nob);
- data->nid = nid;
- data->nal = nal;
- data->ni = *nip;
-
- spin_lock (&g_uuid_lock);
-
- list_add(&data->head, &g_uuid_list);
-
- 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 */
-int class_del_uuid (char *uuid)
-{
- struct list_head deathrow;
- struct list_head *tmp;
- struct list_head *n;
- struct uuid_nid_data *data;
-
- INIT_LIST_HEAD (&deathrow);
-
- spin_lock (&g_uuid_lock);
-
- list_for_each_safe(tmp, n, &g_uuid_list) {
- data = list_entry(tmp, struct uuid_nid_data, head);
-
- if (uuid == NULL || strcmp(data->uuid, uuid) == 0) {
- list_del (&data->head);
- list_add (&data->head, &deathrow);
- if (uuid)
- break;
- }
- }
-
- spin_unlock (&g_uuid_lock);
-
- if (list_empty (&deathrow))
- 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));
-
- return 0;
+ struct uuid_nid_data *entry;
+ int found = 0;
+
+ ENTRY;
+
+ CDEBUG(D_INFO, "check if uuid %s has %s.\n",
+ obd_uuid2str(uuid), libcfs_nid2str(nid));
+
+ spin_lock(&g_uuid_lock);
+ list_for_each_entry(entry, &g_uuid_list, un_list) {
+ int i;
+
+ if (!obd_uuid_equals(&entry->un_uuid, uuid))
+ continue;
+
+ /* found the uuid, check if it has @nid */
+ for (i = 0; i < entry->un_nid_count; i++) {
+ if (entry->un_nids[i] == nid) {
+ found = 1;
+ break;
+ }
+ }
+ break;
+ }
+ spin_unlock(&g_uuid_lock);
+ RETURN(found);