From patchwork Thu Oct 27 11:41:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 9399531 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AAA3460233 for ; Thu, 27 Oct 2016 14:34:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9370A2A2FF for ; Thu, 27 Oct 2016 14:34:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8806B2A305; Thu, 27 Oct 2016 14:34:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F6C92A2FF for ; Thu, 27 Oct 2016 14:34:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942595AbcJ0OWJ (ORCPT ); Thu, 27 Oct 2016 10:22:09 -0400 Received: from mail-pf0-f177.google.com ([209.85.192.177]:34126 "EHLO mail-pf0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030224AbcJ0OVx (ORCPT ); Thu, 27 Oct 2016 10:21:53 -0400 Received: by mail-pf0-f177.google.com with SMTP id n85so18682750pfi.1 for ; Thu, 27 Oct 2016 07:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Ep5b+cLkYqXDVdxz7fLfzrraA7N7M6kPIrFdpIwgxEg=; b=Q69QsrSUgsEI5wFmB0iBRz5wFc3bNUoJvgjQure1fgk/QCeZiATL/OEkQsJhNxEdXk fu7n/oKrD4KYH+p7IZxSiinBPDgayFVWjISp+VMBe0yXOp3xlgv04M69xU3ild0mZYrn Nu4kaKwyDk8j1HDQBSw+ObJXVoGA9oLr3/PrOFIDsXPnEPkUSEooPxC46ipXwkrBLkWl UB0DTQyJYqL8FfT7gyunkjVRt6lEj/8qM7qpohfyDuNwLTizv+xA2H+mpTon5rNkHCuc 9ze8rczXOtKrge4zk/eJUZxlSjA7lJvvo1s7N6pMSiQRZj+fHsDo8Eb1d63Vgv74+EdH iwVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ep5b+cLkYqXDVdxz7fLfzrraA7N7M6kPIrFdpIwgxEg=; b=lVZMZ+zJMWLPN3bMq6yNRVIYFiAnwBHr1GR9qjWH+N7Ig8OiOB74JMwcQ4TdZhUTPa UZzUmFpwxpuKLqyKBASK8vC3Zyt+DjhEH9+/AN6d+oRI2bvfKKDo9pmQPrCEkSOOv6qB lcyCDL1rlha75cxiVzcD3FQFOYuV0ZQkLpnXDtZAhImiYOVhrkZOpw7TM3h1nzM9GBHA HbyFmma2hE44wmQYNGLxJ1X6hPuL3BLh86RBniryB2jVG19LjPOqS/AW5Q96C37t9ie+ Z6ucnZBfUl6/YoFBo3R0bNrWUE3n2EWX5vDAsDaJ4CHvyLvqs1L/a76k3tiGXEjurNVs BOtw== X-Gm-Message-State: ABUngvftKG3k7RXw7JSsqJuXtRLul732lkiV7xnrlHn/IfDZX0Y7KPnkIf85M8o7JJtY2A== X-Received: by 10.99.209.5 with SMTP id k5mr11502995pgg.13.1477568972101; Thu, 27 Oct 2016 04:49:32 -0700 (PDT) Received: from localhost ([128.199.137.77]) by smtp.gmail.com with ESMTPSA id h85sm11249928pfj.89.2016.10.27.04.49.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Oct 2016 04:49:31 -0700 (PDT) From: Eryu Guan To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Eryu Guan Subject: [PATCH] mm/filemap: don't check partially uptodate page for pipes Date: Thu, 27 Oct 2016 19:41:59 +0800 Message-Id: <1477568519-7891-1-git-send-email-guaneryu@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After commit 82c156f85384 ("switch generic_file_splice_read() to use of ->read_iter()") I started noticing some test failures of sendfile(2) and splice(2) (sendfile0N and splice01 from LTP) when testing on sub-page block size filesystems (tested both XFS and ext4), these syscalls start to return EIO in the tests. e.g. sendfile02 1 TFAIL : sendfile02.c:133: sendfile(2) failed to return expected value, expected: 26, got: -1 sendfile02 2 TFAIL : sendfile02.c:133: sendfile(2) failed to return expected value, expected: 24, got: -1 sendfile02 3 TFAIL : sendfile02.c:133: sendfile(2) failed to return expected value, expected: 22, got: -1 sendfile02 4 TFAIL : sendfile02.c:133: sendfile(2) failed to return expected value, expected: 20, got: -1 This is because that in sub-page block size cases, we don't need the whole page to be uptodate, only the part we care about is uptodate is OK (if fs has ->is_partially_uptodate defined). But page_cache_pipe_buf_confirm() doesn't have the ability to check the partially-uptodate case, it needs the whole page to be uptodate. So it returns EIO in this case. Prior to the change, generic_file_splice_read() doesn't allow partially-uptodate page either, so it worked fine. Fix it by skipping the partially-uptodate check if we're working on a pipe in do_generic_file_read(), so we read the whole page from disk as long as the page is not uptodate. Signed-off-by: Eryu Guan --- I think the other way to fix it is to add the ability to check & allow partially-uptodate page to page_cache_pipe_buf_confirm(), but that is much harder to do and seems gain little. mm/filemap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 849f459..ae9ef9a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1734,6 +1734,8 @@ static ssize_t do_generic_file_read(struct file *filp, loff_t *ppos, if (inode->i_blkbits == PAGE_SHIFT || !mapping->a_ops->is_partially_uptodate) goto page_not_up_to_date; + if (unlikely(iter->type & ITER_PIPE)) + goto page_not_up_to_date; if (!trylock_page(page)) goto page_not_up_to_date; /* Did it get truncated before we got the lock? */