From patchwork Wed Dec 10 01:45:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 5466281 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3319DBEEA8 for ; Wed, 10 Dec 2014 01:53:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B7BE520125 for ; Wed, 10 Dec 2014 01:53:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D236820121 for ; Wed, 10 Dec 2014 01:53:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752679AbaLJBqq (ORCPT ); Tue, 9 Dec 2014 20:46:46 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:40935 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753661AbaLJBqm (ORCPT ); Tue, 9 Dec 2014 20:46:42 -0500 Received: by mail-pa0-f45.google.com with SMTP id lf10so1134801pab.32 for ; Tue, 09 Dec 2014 17:46:41 -0800 (PST) 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:in-reply-to:references; bh=SCu1MZf5AJBBZe2iQb42VLGlQXVin99eLkH27Lg7liI=; b=cAhONAxT3WFWl79yRmL4icrKHPW3Ltjc2W0fm4R3ZX+vGdjVurMTgdr73Yd9mSLWaC eP5HFvqAV0kG5ZuyOJdEpzgw0P6Tzuop5Kj5+SY87q/3YKuKHUEX+699fT1FSaI5OyrM RVAdLECk8k9IpbAK4tCKm0h44O0DXVWB+60ZCGpwGNRbbfaYjFyFEt0A73lmPJxWMu9J bUiaKzMJ+gVjm4sctAxvmyxaiwORzL3W5nQQA7JRrcTtux5cyp7qX5szlkp4iYS6QIn/ Gup7t7wXaaLiwg38UXPtrNRvYtWi9LxijsF6MMvA81hO+wzX5EpR3tfiJoJ0Cpm9fDr0 ca2g== X-Gm-Message-State: ALoCoQmywJlknIQj+V7EwmQDK7DlEK8X4/mG/MjmZewfSA7NFBTLNaCtbG9+6sDuQQl7cUTtZ1mR X-Received: by 10.68.196.231 with SMTP id ip7mr2558519pbc.94.1418176001528; Tue, 09 Dec 2014 17:46:41 -0800 (PST) Received: from mew.localdomain (c-24-19-133-29.hsd1.wa.comcast.net. [24.19.133.29]) by mx.google.com with ESMTPSA id on1sm2602957pdb.32.2014.12.09.17.46.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Dec 2014 17:46:40 -0800 (PST) From: Omar Sandoval To: Alexander Viro , Andrew Morton , Chris Mason , Josef Bacik , Trond Myklebust , Christoph Hellwig , David Sterba , linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Omar Sandoval , Mel Gorman Subject: [RFC PATCH v3 3/7] swap: use direct I/O for SWP_FILE swap_readpage Date: Tue, 9 Dec 2014 17:45:44 -0800 Message-Id: <9c1d4746d1e7e41114496be8912cb74e36d5df48.1418173063.git.osandov@osandov.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Nov 17, 2014 at 07:48:17AM -0800, Christoph Hellwig wrote: > With the new iov_iter infrastructure that supprots direct I/O to kernel > pages please get rid of the ->readpage hack first. I'm still utterly > disapoined that this crap ever got merged. Cc: Mel Gorman Signed-off-by: Omar Sandoval --- mm/page_io.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index 955db8b..10715e0 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -283,8 +283,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc, set_page_writeback(page); unlock_page(page); - ret = mapping->a_ops->direct_IO(ITER_BVEC | WRITE, - &kiocb, &from, + ret = mapping->a_ops->direct_IO(WRITE, &kiocb, &from, kiocb.ki_pos); if (ret == PAGE_SIZE) { count_vm_event(PSWPOUT); @@ -348,12 +347,37 @@ int swap_readpage(struct page *page) } if (sis->flags & SWP_FILE) { + struct kiocb kiocb; struct file *swap_file = sis->swap_file; struct address_space *mapping = swap_file->f_mapping; + struct bio_vec bv = { + .bv_page = page, + .bv_len = PAGE_SIZE, + .bv_offset = 0, + }; + struct iov_iter to = { + .type = ITER_BVEC | READ, + .count = PAGE_SIZE, + .iov_offset = 0, + .nr_segs = 1, + }; + to.bvec = &bv; /* older gcc versions are broken */ + + init_sync_kiocb(&kiocb, swap_file); + kiocb.ki_pos = page_file_offset(page); + kiocb.ki_nbytes = PAGE_SIZE; - ret = mapping->a_ops->readpage(swap_file, page); - if (!ret) + ret = mapping->a_ops->direct_IO(READ, &kiocb, &to, + kiocb.ki_pos); + if (ret == PAGE_SIZE) { + SetPageUptodate(page); count_vm_event(PSWPIN); + ret = 0; + } else { + ClearPageUptodate(page); + SetPageError(page); + } + unlock_page(page); return ret; }