struct list_head node;
};
+
//
// List of all of the user streams
//
return 0;
} else {
kfree(old);
- old=0;
+ *op = 0 ;
return resize_op(op,buf_len);
}
}
wake_up_interruptible(&(s->user_wait_queue));
// wait for someone to give us a response
- wait_event_interruptible(s->host_wait_queue, !(s->waiting));
+ while (wait_event_interruptible(s->host_wait_queue, (s->waiting == 0)) != 0) {}
// reacquire the lock for our called
spin_lock_irqsave(&(s->lock), *flags);
//
static int do_response_to_request(struct user_keyed_stream *s, unsigned long *flags)
{
+
if (!(s->waiting)) {
printk("palacios: user keyed stream response while no request is in progress on %s\n",s->url);
return -1;
{
struct user_keyed_stream *s = (struct user_keyed_stream *) (filp->private_data);
unsigned long flags;
- unsigned int mask = 0;
if (!s) {
return POLLERR;
}
-
- poll_wait(filp, &(s->user_wait_queue), wait);
spin_lock_irqsave(&(s->lock), flags);
+
if (s->waiting) {
- mask |= POLLIN | POLLRDNORM;
+ spin_unlock_irqrestore(&(s->lock), flags);
+ return POLLIN | POLLRDNORM;
}
- spin_unlock_irqrestore(&(s->lock), flags);
+
+ poll_wait(filp, &(s->user_wait_queue), wait);
- return mask;
+ spin_unlock_irqrestore(&(s->lock), flags);
+
+ return 0;
}
size = sizeof(struct palacios_user_keyed_stream_op) + s->op->buf_len;
- if (copy_to_user(argp, &size, sizeof(uint64_t))) {
+ if (copy_to_user((void * __user) argp, &size, sizeof(uint64_t))) {
spin_unlock_irqrestore(&(s->lock), flags);
printk("palacios: palacios user key size request failed to copy data\n");
return -EFAULT;
size = sizeof(struct palacios_user_keyed_stream_op) + s->op->buf_len;
- if (copy_to_user(argp, s->op, size)) {
+ if (copy_to_user((void __user *) argp, s->op, size)) {
spin_unlock_irqrestore(&(s->lock), flags);
printk("palacios: palacios user key pull request failed to copy data\n");
return -EFAULT;
return 0;
}
- if (copy_from_user(&size, argp, sizeof(uint64_t))) {
+ if (copy_from_user(&size, (void __user *) argp, sizeof(uint64_t))) {
printk("palacios: palacios user key push response failed to copy size\n");
spin_unlock_irqrestore(&(s->lock), flags);
return -EFAULT;
return -EFAULT;
}
- if (copy_from_user(&(s->op), argp, size)) {
+ if (copy_from_user(s->op, (void __user *) argp, size)) {
spin_unlock_irqrestore(&(s->lock), flags);
return -EFAULT;
}
spin_lock_irqsave(&(user_streams->lock),f1);
spin_lock_irqsave(&(s->lock), f2);
- // FIXME Need to handle case of a pending request
-
list_del(&(s->node));
spin_unlock_irqrestore(&(s->lock), f2);
return NULL;
}
-
s->otype = ot==V3_KS_WR_ONLY_CREATE ? V3_KS_WR_ONLY : ot;
spin_unlock_irqrestore(&(s->lock), flags);
{
unsigned long flags;
struct user_keyed_stream *s = (struct user_keyed_stream *) stream;
- struct palacios_user_keyed_stream_op *op;
uint64_t len = strlen(key)+1;
void *user_key;
spin_lock_irqsave(&(s->lock), flags);
+
if (resize_op(&(s->op),len)) {
spin_unlock_irqrestore(&(s->lock),flags);
printk("palacios: cannot resize op in opening key %s on user keyed stream %s\n",key,s->url);
return NULL;
}
- op = s->op;
-
- op->type = PALACIOS_KSTREAM_OPEN_KEY;
- op->buf_len = len;
- strncpy(op->buf,key,len);
+ s->op->type = PALACIOS_KSTREAM_OPEN_KEY;
+ s->op->buf_len = len;
+ strncpy(s->op->buf,key,len);
-
// enter with it locked
if (do_request_to_response(s,&flags)) {
spin_unlock_irqrestore(&(s->lock),flags);
user_key=s->op->user_key;
spin_unlock_irqrestore(&(s->lock),flags);
-
+
return user_key;
}
static void close_key_user(v3_keyed_stream_t stream, v3_keyed_stream_key_t key)
{
struct user_keyed_stream *s = (struct user_keyed_stream *) stream;
- struct palacios_user_keyed_stream_op *op;
uint64_t len = 0;
unsigned long flags;
return;
}
- op = s->op;
-
- op->type = PALACIOS_KSTREAM_CLOSE_KEY;
- op->buf_len = len;
- op->user_key = key;
+ s->op->type = PALACIOS_KSTREAM_CLOSE_KEY;
+ s->op->buf_len = len;
+ s->op->user_key = key;
// enter with it locked
if (do_request_to_response(s,&flags)) {
// return with it locked
spin_unlock_irqrestore(&(s->lock),flags);
-
+
return;
}
{
struct user_keyed_stream *s = (struct user_keyed_stream *) stream;
- struct palacios_user_keyed_stream_op *op;
uint64_t len = 0 ;
sint64_t xfer;
unsigned long flags;
return -1;
}
- op = s->op;
-
- op->type = PALACIOS_KSTREAM_READ_KEY;
- op->buf_len = len;
- op->user_key = key;
+ s->op->type = PALACIOS_KSTREAM_READ_KEY;
+ s->op->buf_len = len ;
+ s->op->xfer = rlen;
+ s->op->user_key = key;
// enter with it locked
if (do_request_to_response(s,&flags)) {
}
// return with it locked
- if (op->xfer>0) {
- memcpy(buf,op->buf,op->xfer);
+
+ if (s->op->xfer>0) {
+ memcpy(buf,s->op->buf,s->op->xfer);
}
- xfer=op->xfer;
+ xfer=s->op->xfer;
spin_unlock_irqrestore(&(s->lock),flags);
op = s->op;
- op->type = PALACIOS_KSTREAM_WRITE_KEY;
- op->buf_len = len;
- op->user_key = key;
+ s->op->type = PALACIOS_KSTREAM_WRITE_KEY;
+ s->op->buf_len = len;
+ s->op->xfer = wlen;
+ s->op->user_key = key;
- memcpy(op->buf,buf,wlen);
+ memcpy(s->op->buf,buf,wlen);
// enter with it locked
if (do_request_to_response(s,&flags)) {
}
// return with it locked
- xfer=op->xfer;
+ xfer=s->op->xfer;
spin_unlock_irqrestore(&(s->lock),flags);