From patchwork Wed Sep 14 08:37:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 9330879 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 ED177608A0 for ; Wed, 14 Sep 2016 08:37:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE53B29B5B for ; Wed, 14 Sep 2016 08:37:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D236729B61; Wed, 14 Sep 2016 08:37:43 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=unavailable 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 728C629B5E for ; Wed, 14 Sep 2016 08:37:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761208AbcINIhk (ORCPT ); Wed, 14 Sep 2016 04:37:40 -0400 Received: from mail-wm0-f44.google.com ([74.125.82.44]:36150 "EHLO mail-wm0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761026AbcINIh2 (ORCPT ); Wed, 14 Sep 2016 04:37:28 -0400 Received: by mail-wm0-f44.google.com with SMTP id b187so34760703wme.1 for ; Wed, 14 Sep 2016 01:37:27 -0700 (PDT) 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:in-reply-to :references; bh=epc5oFd9MVlBMdfjW9ZpoAQDoIbYTx+NwhUJcx0ngAQ=; b=cQfWxAkbM8mNMjKg2X3Hcf21iyGi1jOkuFvhjirhbBZ4Fh/cf2YlIp2HOBnFGZ2ZUO oZfaXKSkuF0iypvwTmdPN8ZebJ3a6y2AHymZOBL0hzeh0ufo5JnK4fhsAZYBc/i9L8Fx jSbMHl/vLkfHlsAvR/r8E+dFbBM/squ60jEz7SK0QqeZ4pchWVRrgrvPKdFKqtBI9+YQ O/X0pnmlZF1rlB/vMH4u82D9J7TyOXNDeLHg5eB763SLtKh7dn8n/uL7pfl0ZbGj+8Qf fyASbdC/SZNy/YsE8e9s/QBD36PAmoApC0WRpWn57BGAZZNg85cxkE/+Sx+USGtdY83M xBHg== X-Gm-Message-State: AE9vXwObpWraqtDB+qH/DHIAFizkxfLQJlqRWRhEIGqeD3uwEV7/DwUBTf8XqaoVv7QZLGgG X-Received: by 10.194.135.206 with SMTP id pu14mr1351340wjb.143.1473842246744; Wed, 14 Sep 2016 01:37:26 -0700 (PDT) Received: from veci.piliscsaba.szeredi.hu (pool-dsl-2c-0018.externet.hu. [217.173.44.24]) by smtp.gmail.com with ESMTPSA id g184sm9533889wme.15.2016.09.14.01.37.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Sep 2016 01:37:25 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Al Viro Subject: [PATCH 06/11] pipe: no need to confirm page cache buf Date: Wed, 14 Sep 2016 10:37:11 +0200 Message-Id: <1473842236-28655-7-git-send-email-mszeredi@redhat.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1473842236-28655-1-git-send-email-mszeredi@redhat.com> References: <1473842236-28655-1-git-send-email-mszeredi@redhat.com> 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 page_cache_pipe_buf_confirm() is used only in page_cache_pipe_buf_ops. page_cache_pipe_buf_ops is used in two places: 1) __generic_file_splice_read() This iterates all the pages, if not uptodate locks page, and if still not uptodate does ->readpage() which reads the page synchronously. 2) shmem_file_splice_read() This calls shmem_getpage() on individual pages. shmem_getpage() swaps in the page synchronously if not in memory, so it also seems to return an uptodate page. So all pages put into the buffer will be uptodate. Things could happen to that page that make it not uptodate while sitting in the pipe, but it's questionable whether we should care about that. Checking for being uptodate in the face of such page state change is always going to be racy. Signed-off-by: Miklos Szeredi --- fs/splice.c | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index ba7a2240d58c..0ecbe3011796 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -92,51 +92,10 @@ static void page_cache_pipe_buf_release(struct pipe_inode_info *pipe, buf->flags &= ~PIPE_BUF_FLAG_LRU; } -/* - * Check whether the contents of buf is OK to access. Since the content - * is a page cache page, IO may be in flight. - */ -static int page_cache_pipe_buf_confirm(struct pipe_inode_info *pipe, - struct pipe_buffer *buf) -{ - struct page *page = buf->page; - int err; - - if (!PageUptodate(page)) { - lock_page(page); - - /* - * Page got truncated/unhashed. This will cause a 0-byte - * splice, if this is the first page. - */ - if (!page->mapping) { - err = -ENODATA; - goto error; - } - - /* - * Uh oh, read-error from disk. - */ - if (!PageUptodate(page)) { - err = -EIO; - goto error; - } - - /* - * Page is ok afterall, we are done. - */ - unlock_page(page); - } - - return 0; -error: - unlock_page(page); - return err; -} const struct pipe_buf_operations page_cache_pipe_buf_ops = { .can_merge = 0, - .confirm = page_cache_pipe_buf_confirm, + .confirm = generic_pipe_buf_confirm, .release = page_cache_pipe_buf_release, .steal = page_cache_pipe_buf_steal, .get = generic_pipe_buf_get,