orangefs: don't reinvent completion.h...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Mike Marshall <hubcap@omnibond.com>
This commit is contained in:
Родитель
4f55e39732
Коммит
2a9e5c2260
|
@ -398,6 +398,17 @@ static ssize_t orangefs_devreq_write_iter(struct kiocb *iocb,
|
||||||
}
|
}
|
||||||
|
|
||||||
wakeup:
|
wakeup:
|
||||||
|
/*
|
||||||
|
* tell the vfs op waiting on a waitqueue
|
||||||
|
* that this op is done
|
||||||
|
*/
|
||||||
|
spin_lock(&op->lock);
|
||||||
|
if (unlikely(op_state_given_up(op))) {
|
||||||
|
spin_unlock(&op->lock);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
set_op_state_serviced(op);
|
||||||
|
spin_unlock(&op->lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this operation is an I/O operation we need to wait
|
* If this operation is an I/O operation we need to wait
|
||||||
|
@ -411,61 +422,17 @@ wakeup:
|
||||||
* the buffers are done being used.
|
* the buffers are done being used.
|
||||||
*/
|
*/
|
||||||
if (op->downcall.type == ORANGEFS_VFS_OP_FILE_IO) {
|
if (op->downcall.type == ORANGEFS_VFS_OP_FILE_IO) {
|
||||||
DEFINE_WAIT(wait_entry);
|
long n = wait_for_completion_interruptible_timeout(&op->done,
|
||||||
|
op_timeout_secs * HZ);
|
||||||
/*
|
if (unlikely(n < 0)) {
|
||||||
* tell the vfs op waiting on a waitqueue
|
gossip_debug(GOSSIP_DEV_DEBUG,
|
||||||
* that this op is done
|
"%s: signal on I/O wait, aborting\n",
|
||||||
*/
|
__func__);
|
||||||
spin_lock(&op->lock);
|
} else if (unlikely(n == 0)) {
|
||||||
if (unlikely(op_state_given_up(op))) {
|
gossip_debug(GOSSIP_DEV_DEBUG,
|
||||||
spin_unlock(&op->lock);
|
"%s: timed out.\n",
|
||||||
goto out;
|
__func__);
|
||||||
}
|
}
|
||||||
set_op_state_serviced(op);
|
|
||||||
spin_unlock(&op->lock);
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
spin_lock(&op->lock);
|
|
||||||
prepare_to_wait_exclusive(
|
|
||||||
&op->io_completion_waitq,
|
|
||||||
&wait_entry,
|
|
||||||
TASK_INTERRUPTIBLE);
|
|
||||||
if (op->io_completed) {
|
|
||||||
spin_unlock(&op->lock);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
spin_unlock(&op->lock);
|
|
||||||
if (unlikely(signal_pending(current))) {
|
|
||||||
gossip_debug(GOSSIP_DEV_DEBUG,
|
|
||||||
"%s: signal on I/O wait, aborting\n",
|
|
||||||
__func__);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!schedule_timeout(op_timeout_secs * HZ)) {
|
|
||||||
gossip_debug(GOSSIP_DEV_DEBUG,
|
|
||||||
"%s: timed out.\n",
|
|
||||||
__func__);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
spin_lock(&op->lock);
|
|
||||||
finish_wait(&op->io_completion_waitq, &wait_entry);
|
|
||||||
spin_unlock(&op->lock);
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* tell the vfs op waiting on a waitqueue that
|
|
||||||
* this op is done -
|
|
||||||
* for every other operation (i.e. non-I/O), we need to
|
|
||||||
* wake up the callers for downcall completion
|
|
||||||
* notification
|
|
||||||
*/
|
|
||||||
spin_lock(&op->lock);
|
|
||||||
if (!op_state_given_up(op))
|
|
||||||
set_op_state_serviced(op);
|
|
||||||
spin_unlock(&op->lock);
|
|
||||||
}
|
}
|
||||||
out:
|
out:
|
||||||
op_release(op);
|
op_release(op);
|
||||||
|
|
|
@ -16,10 +16,7 @@
|
||||||
|
|
||||||
#define wake_up_daemon_for_return(op) \
|
#define wake_up_daemon_for_return(op) \
|
||||||
do { \
|
do { \
|
||||||
spin_lock(&op->lock); \
|
complete(&op->done); \
|
||||||
op->io_completed = 1; \
|
|
||||||
spin_unlock(&op->lock); \
|
|
||||||
wake_up_interruptible(&op->io_completion_waitq);\
|
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -119,7 +119,6 @@ struct orangefs_kernel_op_s *op_alloc(__s32 type)
|
||||||
spin_lock_init(&new_op->lock);
|
spin_lock_init(&new_op->lock);
|
||||||
init_waitqueue_head(&new_op->waitq);
|
init_waitqueue_head(&new_op->waitq);
|
||||||
|
|
||||||
init_waitqueue_head(&new_op->io_completion_waitq);
|
|
||||||
atomic_set(&new_op->ref_count, 1);
|
atomic_set(&new_op->ref_count, 1);
|
||||||
|
|
||||||
orangefs_op_initialize(new_op);
|
orangefs_op_initialize(new_op);
|
||||||
|
|
|
@ -201,8 +201,7 @@ struct orangefs_kernel_op_s {
|
||||||
wait_queue_head_t waitq;
|
wait_queue_head_t waitq;
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
|
|
||||||
int io_completed;
|
struct completion done;
|
||||||
wait_queue_head_t io_completion_waitq;
|
|
||||||
|
|
||||||
atomic_t ref_count;
|
atomic_t ref_count;
|
||||||
|
|
||||||
|
|
|
@ -597,7 +597,7 @@ void orangefs_op_initialize(struct orangefs_kernel_op_s *op)
|
||||||
{
|
{
|
||||||
if (op) {
|
if (op) {
|
||||||
spin_lock(&op->lock);
|
spin_lock(&op->lock);
|
||||||
op->io_completed = 0;
|
init_completion(&op->done);
|
||||||
|
|
||||||
op->upcall.type = ORANGEFS_VFS_OP_INVALID;
|
op->upcall.type = ORANGEFS_VFS_OP_INVALID;
|
||||||
op->downcall.type = ORANGEFS_VFS_OP_INVALID;
|
op->downcall.type = ORANGEFS_VFS_OP_INVALID;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче