From patchwork Fri Aug 12 18:38:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A . Shutemov" X-Patchwork-Id: 9277721 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 DD8CC60780 for ; Fri, 12 Aug 2016 18:45:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1E2928AB6 for ; Fri, 12 Aug 2016 18:45:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C537A28AD2; Fri, 12 Aug 2016 18:45:03 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 51E0428AB6 for ; Fri, 12 Aug 2016 18:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932111AbcHLSod (ORCPT ); Fri, 12 Aug 2016 14:44:33 -0400 Received: from mga04.intel.com ([192.55.52.120]:40885 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752696AbcHLSi4 (ORCPT ); Fri, 12 Aug 2016 14:38:56 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP; 12 Aug 2016 11:38:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,512,1464678000"; d="scan'208";a="1040186544" Received: from black.fi.intel.com ([10.237.72.93]) by fmsmga002.fm.intel.com with ESMTP; 12 Aug 2016 11:38:47 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id C7AD47E9; Fri, 12 Aug 2016 21:38:34 +0300 (EEST) From: "Kirill A. Shutemov" To: "Theodore Ts'o" , Andreas Dilger , Jan Kara , Andrew Morton Cc: Alexander Viro , Hugh Dickins , Andrea Arcangeli , Dave Hansen , Vlastimil Babka , Matthew Wilcox , Ross Zwisler , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv2 30/41] ext4: make ext4_writepage() work on huge pages Date: Fri, 12 Aug 2016 21:38:13 +0300 Message-Id: <1471027104-115213-31-git-send-email-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1471027104-115213-1-git-send-email-kirill.shutemov@linux.intel.com> References: <1471027104-115213-1-git-send-email-kirill.shutemov@linux.intel.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 Change ext4_writepage() and underlying ext4_bio_write_page(). It basically removes assumption on page size, infer it from struct page instead. Signed-off-by: Kirill A. Shutemov --- fs/ext4/inode.c | 10 +++++----- fs/ext4/page-io.c | 11 +++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 3131747199e1..f585f9160a96 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -2020,10 +2020,10 @@ static int ext4_writepage(struct page *page, trace_ext4_writepage(page); size = i_size_read(inode); - if (page->index == size >> PAGE_SHIFT) - len = size & ~PAGE_MASK; - else - len = PAGE_SIZE; + + len = hpage_size(page); + if (page->index + hpage_nr_pages(page) - 1 == size >> PAGE_SHIFT) + len = size & ~hpage_mask(page); page_bufs = page_buffers(page); /* @@ -2047,7 +2047,7 @@ static int ext4_writepage(struct page *page, ext4_bh_delay_or_unwritten)) { redirty_page_for_writepage(wbc, page); if ((current->flags & PF_MEMALLOC) || - (inode->i_sb->s_blocksize == PAGE_SIZE)) { + (inode->i_sb->s_blocksize == hpage_size(page))) { /* * For memory cleaning there's no point in writing only * some buffers. So just bail out. Warn if we came here diff --git a/fs/ext4/page-io.c b/fs/ext4/page-io.c index a6132a730967..952957ee48b7 100644 --- a/fs/ext4/page-io.c +++ b/fs/ext4/page-io.c @@ -415,6 +415,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io, BUG_ON(!PageLocked(page)); BUG_ON(PageWriteback(page)); + BUG_ON(PageTail(page)); if (keep_towrite) set_page_writeback_keepwrite(page); @@ -431,8 +432,14 @@ int ext4_bio_write_page(struct ext4_io_submit *io, * the page size, the remaining memory is zeroed when mapped, and * writes to that region are not written out to the file." */ - if (len < PAGE_SIZE) - zero_user_segment(page, len, PAGE_SIZE); + if (len < hpage_size(page)) { + page += len / PAGE_SIZE; + if (len % PAGE_SIZE) + zero_user_segment(page, len % PAGE_SIZE, PAGE_SIZE); + while (page + 1 == compound_head(page)) + clear_highpage(++page); + page = compound_head(page); + } /* * In the first loop we prepare and mark buffers to submit. We have to * mark all buffers in the page before submitting so that