diff options
Diffstat (limited to 'fs/timerfd.c')
-rw-r--r-- | fs/timerfd.c | 25 |
1 files changed, 4 insertions, 21 deletions
diff --git a/fs/timerfd.c b/fs/timerfd.c index 98158de91d24..b86ab8eff79a 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c | |||
@@ -110,31 +110,14 @@ static ssize_t timerfd_read(struct file *file, char __user *buf, size_t count, | |||
110 | struct timerfd_ctx *ctx = file->private_data; | 110 | struct timerfd_ctx *ctx = file->private_data; |
111 | ssize_t res; | 111 | ssize_t res; |
112 | u64 ticks = 0; | 112 | u64 ticks = 0; |
113 | DECLARE_WAITQUEUE(wait, current); | ||
114 | 113 | ||
115 | if (count < sizeof(ticks)) | 114 | if (count < sizeof(ticks)) |
116 | return -EINVAL; | 115 | return -EINVAL; |
117 | spin_lock_irq(&ctx->wqh.lock); | 116 | spin_lock_irq(&ctx->wqh.lock); |
118 | res = -EAGAIN; | 117 | if (file->f_flags & O_NONBLOCK) |
119 | if (!ctx->ticks && !(file->f_flags & O_NONBLOCK)) { | 118 | res = -EAGAIN; |
120 | __add_wait_queue(&ctx->wqh, &wait); | 119 | else |
121 | for (res = 0;;) { | 120 | res = wait_event_interruptible_locked_irq(ctx->wqh, ctx->ticks); |
122 | set_current_state(TASK_INTERRUPTIBLE); | ||
123 | if (ctx->ticks) { | ||
124 | res = 0; | ||
125 | break; | ||
126 | } | ||
127 | if (signal_pending(current)) { | ||
128 | res = -ERESTARTSYS; | ||
129 | break; | ||
130 | } | ||
131 | spin_unlock_irq(&ctx->wqh.lock); | ||
132 | schedule(); | ||
133 | spin_lock_irq(&ctx->wqh.lock); | ||
134 | } | ||
135 | __remove_wait_queue(&ctx->wqh, &wait); | ||
136 | __set_current_state(TASK_RUNNING); | ||
137 | } | ||
138 | if (ctx->ticks) { | 121 | if (ctx->ticks) { |
139 | ticks = ctx->ticks; | 122 | ticks = ctx->ticks; |
140 | if (ctx->expired && ctx->tintv.tv64) { | 123 | if (ctx->expired && ctx->tintv.tv64) { |