From: Vitaly Mayatskikh <v.mayatskih@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Anton Blanchard <anton@au.ibm.com>, Paul Mackerras <paulus@au.ibm.com>
Subject: [PATCH] PowerPC: honor O_NONBLOCK flag for rtas error_log
Date: Fri, 04 Jul 2008 15:06:27 +0200 [thread overview]
Message-ID: <m3iqvlssrw.fsf@gravicappa.englab.brq.redhat.com> (raw)
rtas_log_read() currently doesn't count O_NONBLOCK flag. This sample
code will block on read:
fd = open ("/proc/ppc64/rtas/error_log", O_RDONLY | O_NONBLOCK);
while (1) {
err =read (fd, buf, 4096);
printf("err = %d, errno = %d (%s)\n", err, errno, strerror(errno));
sleep(1);
}
With patched kernel it produces such (correct) output:
err = 2052, errno = 0 (Success)
err = -1, errno = 11 (Resource temporarily unavailable)
err = -1, errno = 11 (Resource temporarily unavailable)
err = -1, errno = 11 (Resource temporarily unavailable)
err = -1, errno = 11 (Resource temporarily unavailable)
Signed-off-by: Vitaly Mayatskikh <v.mayatskih@gmail.com>
diff --git a/arch/powerpc/platforms/pseries/rtasd.c b/arch/powerpc/platforms/pseries/rtasd.c
index 7d3e2b0..f530f68 100644
--- a/arch/powerpc/platforms/pseries/rtasd.c
+++ b/arch/powerpc/platforms/pseries/rtasd.c
@@ -291,22 +291,25 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf,
if (!access_ok(VERIFY_WRITE, buf, count))
return -EFAULT;
- tmp = kmalloc(count, GFP_KERNEL);
- if (!tmp)
- return -ENOMEM;
-
-
spin_lock_irqsave(&rtasd_log_lock, s);
/* if it's 0, then we know we got the last one (the one in NVRAM) */
- if (rtas_log_size == 0 && logging_enabled)
+ if (rtas_log_size == 0 && logging_enabled) {
nvram_clear_error_log();
+ if (file->f_flags & O_NONBLOCK) {
+ spin_unlock_irqrestore(&rtasd_log_lock, s);
+ return -EAGAIN;
+ }
+ }
spin_unlock_irqrestore(&rtasd_log_lock, s);
-
error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
if (error)
goto out;
+ tmp = kmalloc(count, GFP_KERNEL);
+ if (!tmp)
+ return -ENOMEM;
+
spin_lock_irqsave(&rtasd_log_lock, s);
offset = rtas_error_log_buffer_max * (rtas_log_start & LOG_NUMBER_MASK);
memcpy(tmp, &rtas_log_buf[offset], count);
--
wbr, Vitaly
next reply other threads:[~2008-07-04 13:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-04 13:06 Vitaly Mayatskikh [this message]
2008-07-04 13:12 ` Vitaly Mayatskikh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m3iqvlssrw.fsf@gravicappa.englab.brq.redhat.com \
--to=v.mayatskih@gmail.com \
--cc=anton@au.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@au.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®