Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757932AbYGDNMx (ORCPT ); Fri, 4 Jul 2008 09:12:53 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753162AbYGDNMq (ORCPT ); Fri, 4 Jul 2008 09:12:46 -0400 Received: from yw-out-2324.google.com ([74.125.46.30]:3550 "EHLO yw-out-2324.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752978AbYGDNMp (ORCPT ); Fri, 4 Jul 2008 09:12:45 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; b=YSA3TeX5mA1Ed1gmEOyFsWOZODiI2jYHjjIFDjUYVzV/hHTH86Z272O3KRGma8h8gV xrcrpykYtv4fW+UXec6/YgSyxaFf5dn3yb7oXQ6HjQSdFA3n454KyTomZMX3JC4CQkPi ucZMRQ4Qz6s1be16U+UBy3fvE+EVRsyWrOuns= From: Vitaly Mayatskikh To: Vitaly Mayatskikh Cc: linux-kernel@vger.kernel.org, Anton Blanchard , Paul Mackerras Subject: Re: [PATCH] PowerPC: honor O_NONBLOCK flag for rtas error_log References: Date: Fri, 04 Jul 2008 15:12:36 +0200 In-Reply-To: (Vitaly Mayatskikh's message of "Fri, 04 Jul 2008 15:06:27 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2167 Lines: 69 Vitaly Mayatskikh writes: > 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) Sorry, wrong patch :( Signed-off-by: Vitaly Mayatskikh diff --git a/arch/powerpc/platforms/pseries/rtasd.c b/arch/powerpc/platforms/pseries/rtasd.c index 7d3e2b0..3343211 100644 --- a/arch/powerpc/platforms/pseries/rtasd.c +++ b/arch/powerpc/platforms/pseries/rtasd.c @@ -291,21 +291,24 @@ 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; + return error; + + 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); -- wbr, Vitaly -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/