From patchwork Mon Dec 15 05:27:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 5490581 Return-Path: X-Original-To: patchwork-linux-nfs@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 37040BEEA8 for ; Mon, 15 Dec 2014 05:30:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5E856209E7 for ; Mon, 15 Dec 2014 05:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 84B8E209E5 for ; Mon, 15 Dec 2014 05:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751855AbaLOF3o (ORCPT ); Mon, 15 Dec 2014 00:29:44 -0500 Received: from mail-pd0-f180.google.com ([209.85.192.180]:58621 "EHLO mail-pd0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751428AbaLOF1j (ORCPT ); Mon, 15 Dec 2014 00:27:39 -0500 Received: by mail-pd0-f180.google.com with SMTP id w10so10964026pde.11 for ; Sun, 14 Dec 2014 21:27:38 -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=tZ5La2WkwQVbLOTRKEDCDXn8qIyeow+5XSBorYfrpXA=; b=D200jOYjH8mz1emFQd1p5tbo7NTJrEND9UEIlX2hzpvNfwXv9y57F6l8qSVHuwNiQ7 r1fFgUyZXMOxbJRJ+MkcIAOCu4HW6l9hVwWV9LDtVEnOHB0IxwouVkx6Ggeqei9QdsKh SNySnBcJVyQaiLa8pL3mJ4x4zCcS0BcMyY1N5fV1JEbSGq6gE9IBy68WsLfBk/aYp5nM 4r1SviToh1KrjjpYisKew+D0KKfFaCmVT5VCipxhANP3AvfhgedZ1oB+2jOi/B9XgIeV QXluqz2Q+d6m/uwPqpeCEWV9JFWZxj817khM3dGI71U3fOy5H1qtFAMqWh5C0Rk94kRS h/sQ== X-Gm-Message-State: ALoCoQkvf16/C8qb9zqnBOqnGEd7HUmZTSQ5uAB6gJvWOpGbmFFFBAK+P0pkNcmBXwOYMEpuaW7M X-Received: by 10.66.119.239 with SMTP id kx15mr27818023pab.138.1418621258508; Sun, 14 Dec 2014 21:27:38 -0800 (PST) Received: from mew.localdomain ([72.192.100.38]) by mx.google.com with ESMTPSA id f12sm7915174pdm.90.2014.12.14.21.27.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 14 Dec 2014 21:27:37 -0800 (PST) From: Omar Sandoval To: Alexander Viro , Andrew Morton , Trond Myklebust , Christoph Hellwig , David Sterba , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Omar Sandoval Subject: [PATCH 7/8] swap: use direct I/O for SWP_FILE swap_readpage Date: Sun, 14 Dec 2014 21:27:01 -0800 Message-Id: X-Mailer: git-send-email 2.1.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@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=ham 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. Signed-off-by: Omar Sandoval --- mm/page_io.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/mm/page_io.c b/mm/page_io.c index 4741248..956307c 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -346,12 +346,33 @@ 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 iov_iter to; + struct bio_vec bv = { + .bv_page = page, + .bv_len = PAGE_SIZE, + .bv_offset = 0, + }; + + iov_iter_bvec(&to, ITER_BVEC | READ, &bv, 1, PAGE_SIZE); - ret = mapping->a_ops->readpage(swap_file, page); - if (!ret) + init_sync_kiocb(&kiocb, swap_file); + kiocb.ki_pos = page_file_offset(page); + kiocb.ki_nbytes = PAGE_SIZE; + + 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; }