static int match_nosquash_list(cfs_rw_semaphore_t *sem, cfs_list_t *nidlist, lnet_nid_t peernid) { int rc; ENTRY; cfs_down_read(sem); rc = cfs_match_nid(peernid, nidlist); cfs_up_read(sem); RETURN(rc); }
static int libcfs_ioctl_int(struct cfs_psdev_file *pfile,unsigned long cmd, void *arg, struct libcfs_ioctl_data *data) { int err = -EINVAL; ENTRY; switch (cmd) { case IOC_LIBCFS_CLEAR_DEBUG: libcfs_debug_clear_buffer(); RETURN(0); /* * case IOC_LIBCFS_PANIC: * Handled in arch/cfs_module.c */ case IOC_LIBCFS_MARK_DEBUG: if (data->ioc_inlbuf1 == NULL || data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0') RETURN(-EINVAL); libcfs_debug_mark_buffer(data->ioc_inlbuf1); RETURN(0); #if LWT_SUPPORT case IOC_LIBCFS_LWT_CONTROL: err = lwt_control ((data->ioc_flags & 1) != 0, (data->ioc_flags & 2) != 0); break; case IOC_LIBCFS_LWT_SNAPSHOT: { cfs_cycles_t now; int ncpu; int total_size; err = lwt_snapshot (&now, &ncpu, &total_size, data->ioc_pbuf1, data->ioc_plen1); data->ioc_u64[0] = now; data->ioc_u32[0] = ncpu; data->ioc_u32[1] = total_size; /* Hedge against broken user/kernel typedefs (e.g. cycles_t) */ data->ioc_u32[2] = sizeof(lwt_event_t); data->ioc_u32[3] = offsetof(lwt_event_t, lwte_where); if (err == 0 && libcfs_ioctl_popdata(arg, data, sizeof (*data))) err = -EFAULT; break; } case IOC_LIBCFS_LWT_LOOKUP_STRING: err = lwt_lookup_string (&data->ioc_count, data->ioc_pbuf1, data->ioc_pbuf2, data->ioc_plen2); if (err == 0 && libcfs_ioctl_popdata(arg, data, sizeof (*data))) err = -EFAULT; break; #endif case IOC_LIBCFS_MEMHOG: if (pfile->private_data == NULL) { err = -EINVAL; } else { kportal_memhog_free(pfile->private_data); /* XXX The ioc_flags is not GFP flags now, need to be fixed */ err = kportal_memhog_alloc(pfile->private_data, data->ioc_count, data->ioc_flags); if (err != 0) kportal_memhog_free(pfile->private_data); } break; case IOC_LIBCFS_PING_TEST: { extern void (kping_client)(struct libcfs_ioctl_data *); void (*ping)(struct libcfs_ioctl_data *); CDEBUG(D_IOCTL, "doing %d pings to nid %s (%s)\n", data->ioc_count, libcfs_nid2str(data->ioc_nid), libcfs_nid2str(data->ioc_nid)); ping = PORTAL_SYMBOL_GET(kping_client); if (!ping) CERROR("PORTAL_SYMBOL_GET failed\n"); else { ping(data); PORTAL_SYMBOL_PUT(kping_client); } RETURN(0); } default: { struct libcfs_ioctl_handler *hand; err = -EINVAL; cfs_down_read(&ioctl_list_sem); cfs_list_for_each_entry_typed(hand, &ioctl_list, struct libcfs_ioctl_handler, item) { err = hand->handle_ioctl(cmd, data); if (err != -EINVAL) { if (err == 0) err = libcfs_ioctl_popdata(arg, data, sizeof (*data)); break; } } cfs_up_read(&ioctl_list_sem); break; } } RETURN(err); }
int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) { struct obd_import *imp; struct ptlrpc_request *req; struct lgssd_ioctl_param param; struct obd_device *obd; char obdname[64]; long lsize; int rc; if (count != sizeof(param)) { CERROR("ioctl size %lu, expect %lu, please check lgss_keyring " "version\n", count, (unsigned long) sizeof(param)); RETURN(-EINVAL); } if (cfs_copy_from_user(¶m, buffer, sizeof(param))) { CERROR("failed copy data from lgssd\n"); RETURN(-EFAULT); } if (param.version != GSSD_INTERFACE_VERSION) { CERROR("gssd interface version %d (expect %d)\n", param.version, GSSD_INTERFACE_VERSION); RETURN(-EINVAL); } /* take name */ if (strncpy_from_user(obdname, param.uuid, sizeof(obdname)) <= 0) { CERROR("Invalid obdname pointer\n"); RETURN(-EFAULT); } obd = class_name2obd(obdname); if (!obd) { CERROR("no such obd %s\n", obdname); RETURN(-EINVAL); } if (unlikely(!obd->obd_set_up)) { CERROR("obd %s not setup\n", obdname); RETURN(-EINVAL); } cfs_spin_lock(&obd->obd_dev_lock); if (obd->obd_stopping) { CERROR("obd %s has stopped\n", obdname); cfs_spin_unlock(&obd->obd_dev_lock); RETURN(-EINVAL); } if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) && strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) && strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME)) { CERROR("obd %s is not a client device\n", obdname); cfs_spin_unlock(&obd->obd_dev_lock); RETURN(-EINVAL); } cfs_spin_unlock(&obd->obd_dev_lock); cfs_down_read(&obd->u.cli.cl_sem); if (obd->u.cli.cl_import == NULL) { CERROR("obd %s: import has gone\n", obd->obd_name); cfs_up_read(&obd->u.cli.cl_sem); RETURN(-EINVAL); } imp = class_import_get(obd->u.cli.cl_import); cfs_up_read(&obd->u.cli.cl_sem); if (imp->imp_deactive) { CERROR("import has been deactivated\n"); class_import_put(imp); RETURN(-EINVAL); } req = ptlrpc_request_alloc_pack(imp, &RQF_SEC_CTX, LUSTRE_OBD_VERSION, SEC_CTX_INIT); if (req == NULL) { param.status = -ENOMEM; goto out_copy; } if (req->rq_cli_ctx->cc_sec->ps_id != param.secid) { CWARN("original secid %d, now has changed to %d, " "cancel this negotiation\n", param.secid, req->rq_cli_ctx->cc_sec->ps_id); param.status = -EINVAL; goto out_copy; } /* get token */ rc = ctx_init_pack_request(imp, req, param.lustre_svc, param.uid, param.gid, param.send_token_size, param.send_token); if (rc) { param.status = rc; goto out_copy; } ptlrpc_request_set_replen(req); rc = ptlrpc_queue_wait(req); if (rc) { /* If any _real_ denial be made, we expect server return * -EACCES reply or return success but indicate gss error * inside reply messsage. All other errors are treated as * timeout, caller might try the negotiation repeatedly, * leave recovery decisions to general ptlrpc layer. * * FIXME maybe some other error code shouldn't be treated * as timeout. */ param.status = rc; if (rc != -EACCES) param.status = -ETIMEDOUT; goto out_copy; } LASSERT(req->rq_repdata); lsize = ctx_init_parse_reply(req->rq_repdata, ptlrpc_rep_need_swab(req), param.reply_buf, param.reply_buf_size); if (lsize < 0) { param.status = (int) lsize; goto out_copy; } param.status = 0; param.reply_length = lsize; out_copy: if (cfs_copy_to_user(buffer, ¶m, sizeof(param))) rc = -EFAULT; else rc = 0; class_import_put(imp); ptlrpc_req_finished(req); RETURN(rc); }