#include <linux/atomic.h>
#include <linux/kstrtox.h>
#include <linux/proc_fs.h>
+#include <linux/wait.h>
/*
* Each cache requires:
/* fields for communication over channel */
struct list_head queue;
spinlock_t queue_lock;
+ wait_queue_head_t queue_wait;
atomic_t writers; /* how many time is /channel open */
time64_t last_close; /* if no writers, when did last close */
spin_lock_init(&cd->hash_lock);
INIT_LIST_HEAD(&cd->queue);
spin_lock_init(&cd->queue_lock);
+ init_waitqueue_head(&cd->queue_wait);
spin_lock(&cache_list_lock);
cd->nextcheck = 0;
cd->entries = 0;
return ret;
}
-static DECLARE_WAIT_QUEUE_HEAD(queue_wait);
-
static __poll_t cache_poll(struct file *filp, poll_table *wait,
struct cache_detail *cd)
{
struct cache_reader *rp = filp->private_data;
struct cache_queue *cq;
- poll_wait(filp, &queue_wait, wait);
+ poll_wait(filp, &cd->queue_wait, wait);
/* alway allow write */
mask = EPOLLOUT | EPOLLWRNORM;
/* Lost a race, no longer PENDING, so don't enqueue */
ret = -EAGAIN;
spin_unlock(&detail->queue_lock);
- wake_up(&queue_wait);
+ wake_up(&detail->queue_wait);
if (ret == -EAGAIN) {
kfree(buf);
kfree(crq);