* take in count O_NONBLOCK flag for rtas log
@ 2008-09-25 18:38 Vitaly Mayatskikh
2008-09-25 21:13 ` David Howells
2008-09-29 9:24 ` Vitaly Mayatskikh
0 siblings, 2 replies; 4+ messages in thread
From: Vitaly Mayatskikh @ 2008-09-25 18:38 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Paul Mackerras
rtas_log_read() doesn't check file flags for O_NONBLOCK and blocks
non-blocking reader of /proc/ppc64/rtas/error_log if there's no data
available. This patch fixes the problem.
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 c9ffd8c..4f76e3b 100644
--- a/arch/powerpc/platforms/pseries/rtasd.c
+++ b/arch/powerpc/platforms/pseries/rtasd.c
@@ -295,19 +295,29 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf,
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)
- nvram_clear_error_log();
- spin_unlock_irqrestore(&rtasd_log_lock, s);
+ while (rtas_log_size == 0) {
+ if (file->f_flags & O_NONBLOCK) {
+ spin_unlock_irqrestore(&rtasd_log_lock, s);
+ error = -EAGAIN;
+ goto out;
+ }
+ if (!logging_enabled) {
+ spin_unlock_irqrestore(&rtasd_log_lock, s);
+ error = -ENODATA;
+ goto out;
+ } else
+ nvram_clear_error_log();
- error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
- if (error)
- goto out;
+ spin_unlock_irqrestore(&rtasd_log_lock, s);
+ error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
+ if (error)
+ goto out;
+ spin_lock_irqsave(&rtasd_log_lock, s);
+ }
- 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: take in count O_NONBLOCK flag for rtas log
2008-09-25 18:38 take in count O_NONBLOCK flag for rtas log Vitaly Mayatskikh
@ 2008-09-25 21:13 ` David Howells
2008-09-26 8:21 ` Vitaly Mayatskikh
2008-09-29 9:24 ` Vitaly Mayatskikh
1 sibling, 1 reply; 4+ messages in thread
From: David Howells @ 2008-09-25 21:13 UTC (permalink / raw)
To: Vitaly Mayatskikh; +Cc: linuxppc-dev, Paul Mackerras
Vitaly Mayatskikh <v.mayatskih@gmail.com> wrote:
> + if (!logging_enabled) {
> + spin_unlock_irqrestore(&rtasd_log_lock, s);
> + error = -ENODATA;
> + goto out;
> + } else
> + nvram_clear_error_log();
The 'else' here is unnecessary. It's preceded inside the curlies by a goto.
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: take in count O_NONBLOCK flag for rtas log
2008-09-25 21:13 ` David Howells
@ 2008-09-26 8:21 ` Vitaly Mayatskikh
0 siblings, 0 replies; 4+ messages in thread
From: Vitaly Mayatskikh @ 2008-09-26 8:21 UTC (permalink / raw)
To: David Howells; +Cc: linuxppc-dev, Vitaly Mayatskikh, Paul Mackerras
At Thu, 25 Sep 2008 22:13:05 +0100, David Howells wrote:
> > + if (!logging_enabled) {
> > + spin_unlock_irqrestore(&rtasd_log_lock, s);
> > + error = -ENODATA;
> > + goto out;
> > + } else
> > + nvram_clear_error_log();
>
> The 'else' here is unnecessary. It's preceded inside the curlies by a goto.
Right...
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 c9ffd8c..4f76e3b 100644
--- a/arch/powerpc/platforms/pseries/rtasd.c
+++ b/arch/powerpc/platforms/pseries/rtasd.c
@@ -295,19 +295,29 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf,
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)
- nvram_clear_error_log();
- spin_unlock_irqrestore(&rtasd_log_lock, s);
+ while (rtas_log_size == 0) {
+ if (file->f_flags & O_NONBLOCK) {
+ spin_unlock_irqrestore(&rtasd_log_lock, s);
+ error = -EAGAIN;
+ goto out;
+ }
+ if (!logging_enabled) {
+ spin_unlock_irqrestore(&rtasd_log_lock, s);
+ error = -ENODATA;
+ goto out;
+ }
+ nvram_clear_error_log();
- error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
- if (error)
- goto out;
+ spin_unlock_irqrestore(&rtasd_log_lock, s);
+ error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
+ if (error)
+ goto out;
+ spin_lock_irqsave(&rtasd_log_lock, s);
+ }
- 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: take in count O_NONBLOCK flag for rtas log
2008-09-25 18:38 take in count O_NONBLOCK flag for rtas log Vitaly Mayatskikh
2008-09-25 21:13 ` David Howells
@ 2008-09-29 9:24 ` Vitaly Mayatskikh
1 sibling, 0 replies; 4+ messages in thread
From: Vitaly Mayatskikh @ 2008-09-29 9:24 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Paul Mackerras
rtas_log_read() doesn't check file flags for O_NONBLOCK and blocks
non-blocking reader of /proc/ppc64/rtas/error_log if there's no data
available. Patch makes sure that non-blocking reader will never
blocks.
Also rtas_log_read() returns now with ENODATA to prevent suspending of
process in wait_event_interruptible() when logging facility was
switched off and log is already empty.
Acked-by: David Howells <dhowells@redhat.com>
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 c9ffd8c..4f76e3b 100644
--- a/arch/powerpc/platforms/pseries/rtasd.c
+++ b/arch/powerpc/platforms/pseries/rtasd.c
@@ -295,19 +295,29 @@ static ssize_t rtas_log_read(struct file * file, char __user * buf,
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)
- nvram_clear_error_log();
- spin_unlock_irqrestore(&rtasd_log_lock, s);
+ while (rtas_log_size == 0) {
+ if (file->f_flags & O_NONBLOCK) {
+ spin_unlock_irqrestore(&rtasd_log_lock, s);
+ error = -EAGAIN;
+ goto out;
+ }
+ if (!logging_enabled) {
+ spin_unlock_irqrestore(&rtasd_log_lock, s);
+ error = -ENODATA;
+ goto out;
+ }
+ nvram_clear_error_log();
- error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
- if (error)
- goto out;
+ spin_unlock_irqrestore(&rtasd_log_lock, s);
+ error = wait_event_interruptible(rtas_log_wait, rtas_log_size);
+ if (error)
+ goto out;
+ spin_lock_irqsave(&rtasd_log_lock, s);
+ }
- 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
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-09-29 9:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-25 18:38 take in count O_NONBLOCK flag for rtas log Vitaly Mayatskikh
2008-09-25 21:13 ` David Howells
2008-09-26 8:21 ` Vitaly Mayatskikh
2008-09-29 9:24 ` Vitaly Mayatskikh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).