From patchwork Tue Aug 23 19:27:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leann Ogasawara X-Patchwork-Id: 111172 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 7A1F4B6F69 for ; Wed, 24 Aug 2011 05:27:53 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1QvwdM-0003pQ-Pd; Tue, 23 Aug 2011 19:27:36 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1QvwdK-0003pL-2O for kernel-team@lists.ubuntu.com; Tue, 23 Aug 2011 19:27:34 +0000 Received: from c-24-21-156-70.hsd1.or.comcast.net ([24.21.156.70] helo=[192.168.1.3]) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QvwdJ-0002OT-Mt for kernel-team@lists.ubuntu.com; Tue, 23 Aug 2011 19:27:34 +0000 Subject: [Hardy][PATCH 1/1] splice: fix infinite loop in generic_file_splice_read() From: Leann Ogasawara To: kernel-team Date: Tue, 23 Aug 2011 12:27:31 -0700 X-Mailer: Evolution 3.1.5- Message-ID: <1314127653.2020.14.camel@adamo> Mime-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com BugLink: http://bugs.launchpad.net/bugs/790557 SRU Justification: Impact: Without the fix, users can experience "sporadic kernel lockups on a Ubuntu Hardy LTS fileserver which produces serious downtimes." Fix: upstream commit 8191ecd1d14c6914c660dfa007154860a7908857 User has built their own Hardy kernel with the above patch applied. They can confirm they no longer experience the sporadic lockups on their production system. This is a clean cherry-pick from upstream. Please consider for Hardy SRU. Thanks, Leann From 8cd7c215bccee7dcd8b8d70fa335657013a65df1 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 10 Apr 2008 08:24:25 +0200 Subject: [PATCH] splice: fix infinite loop in generic_file_splice_read() BugLink: http://bugs.launchpad.net/bugs/790557 There's a quirky loop in generic_file_splice_read() that could go on indefinitely, if the file splice returns 0 permanently (and not just as a temporary condition). Get rid of the loop and pass back -EAGAIN correctly from __generic_file_splice_read(), so we handle that condition properly as well. Signed-off-by: Jens Axboe (cherry picked from commit 8191ecd1d14c6914c660dfa007154860a7908857) Signed-off-by: Leann Ogasawara --- fs/splice.c | 31 ++++++------------------------- 1 files changed, 6 insertions(+), 25 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index ef9fc8f..b2872d7 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -364,8 +364,10 @@ __generic_file_splice_read(struct file *in, loff_t *ppos, * for an in-flight io page */ if (flags & SPLICE_F_NONBLOCK) { - if (TestSetPageLocked(page)) + if (TestSetPageLocked(page)) { + error = -EAGAIN; break; + } } else lock_page(page); @@ -473,9 +475,8 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, struct pipe_inode_info *pipe, size_t len, unsigned int flags) { - ssize_t spliced; - int ret; loff_t isize, left; + int ret; isize = i_size_read(in->f_mapping->host); if (unlikely(*ppos >= isize)) @@ -485,29 +486,9 @@ ssize_t generic_file_splice_read(struct file *in, loff_t *ppos, if (unlikely(left < len)) len = left; - ret = 0; - spliced = 0; - while (len && !spliced) { - ret = __generic_file_splice_read(in, ppos, pipe, len, flags); - - if (ret < 0) - break; - else if (!ret) { - if (spliced) - break; - if (flags & SPLICE_F_NONBLOCK) { - ret = -EAGAIN; - break; - } - } - + ret = __generic_file_splice_read(in, ppos, pipe, len, flags); + if (ret > 0) *ppos += ret; - len -= ret; - spliced += ret; - } - - if (spliced) - return spliced; return ret; }