From patchwork Thu Sep 15 11:55:21 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: 9333365 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 E13316089F for ; Thu, 15 Sep 2016 12:03:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCFBD29697 for ; Thu, 15 Sep 2016 12:03:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C21972969B; Thu, 15 Sep 2016 12:03:35 +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 8E92329698 for ; Thu, 15 Sep 2016 12:03:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934886AbcIOMC3 (ORCPT ); Thu, 15 Sep 2016 08:02:29 -0400 Received: from mga03.intel.com ([134.134.136.65]:7206 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934380AbcIOLzw (ORCPT ); Thu, 15 Sep 2016 07:55:52 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 15 Sep 2016 04:55:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.30,339,1470726000"; d="scan'208";a="1050744035" Received: from black.fi.intel.com ([10.237.72.56]) by orsmga002.jf.intel.com with ESMTP; 15 Sep 2016 04:55:48 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id D36E8B9C; Thu, 15 Sep 2016 14:55:27 +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: [PATCHv3 39/41] ext4: make fallocate() operations work with huge pages Date: Thu, 15 Sep 2016 14:55:21 +0300 Message-Id: <20160915115523.29737-40-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160915115523.29737-1-kirill.shutemov@linux.intel.com> References: <20160915115523.29737-1-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 __ext4_block_zero_page_range() adjusted to calculate starting iblock correctry for huge pages. ext4_{collapse,insert}_range() requires page cache invalidation. We need the invalidation to be aligning to huge page border if huge pages are possible in page cache. Signed-off-by: Kirill A. Shutemov --- fs/ext4/extents.c | 10 ++++++++-- fs/ext4/inode.c | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index d7ccb7f51dfc..d46aeda70fb0 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -5525,7 +5525,10 @@ int ext4_collapse_range(struct inode *inode, loff_t offset, loff_t len) * Need to round down offset to be aligned with page size boundary * for page size > block size. */ - ioffset = round_down(offset, PAGE_SIZE); + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) + ioffset = round_down(offset, HPAGE_PMD_SIZE); + else + ioffset = round_down(offset, PAGE_SIZE); /* * Write tail of the last page before removed range since it will get * removed from the page cache below. @@ -5674,7 +5677,10 @@ int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len) * Need to round down to align start offset to page size boundary * for page size > block size. */ - ioffset = round_down(offset, PAGE_SIZE); + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) + ioffset = round_down(offset, HPAGE_PMD_SIZE); + else + ioffset = round_down(offset, PAGE_SIZE); /* Write out all dirty pages */ ret = filemap_write_and_wait_range(inode->i_mapping, ioffset, LLONG_MAX); diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index f2e34e340e65..645a984a15ef 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3711,7 +3711,6 @@ void ext4_set_aops(struct inode *inode) static int __ext4_block_zero_page_range(handle_t *handle, struct address_space *mapping, loff_t from, loff_t length) { - ext4_fsblk_t index = from >> PAGE_SHIFT; unsigned offset; unsigned blocksize, pos; ext4_lblk_t iblock; @@ -3730,7 +3729,7 @@ static int __ext4_block_zero_page_range(handle_t *handle, blocksize = inode->i_sb->s_blocksize; - iblock = index << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits); + iblock = page->index << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits); if (!page_has_buffers(page)) create_empty_buffers(page, blocksize, 0);