From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f177.google.com (mail-pd0-f177.google.com [209.85.192.177]) by kanga.kvack.org (Postfix) with ESMTP id 184166B0078 for ; Mon, 15 Dec 2014 00:27:41 -0500 (EST) Received: by mail-pd0-f177.google.com with SMTP id ft15so10908360pdb.36 for ; Sun, 14 Dec 2014 21:27:40 -0800 (PST) Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com. [209.85.220.51]) by mx.google.com with ESMTPS id l1si12342669pdg.110.2014.12.14.21.27.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 14 Dec 2014 21:27:39 -0800 (PST) Received: by mail-pa0-f51.google.com with SMTP id ey11so11154786pad.38 for ; Sun, 14 Dec 2014 21:27:38 -0800 (PST) From: 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: In-Reply-To: References: In-Reply-To: References: Sender: owner-linux-mm@kvack.org List-ID: 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 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; } -- 2.1.3 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org