From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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> In-Reply-To: <20160915115523.29737-1-kirill.shutemov@linux.intel.com> References: <20160915115523.29737-1-kirill.shutemov@linux.intel.com> Sender: linux-block-owner@vger.kernel.org List-Id: linux-block@vger.kernel.org __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); -- 2.9.3 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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> In-Reply-To: <20160915115523.29737-1-kirill.shutemov@linux.intel.com> References: <20160915115523.29737-1-kirill.shutemov@linux.intel.com> Sender: owner-linux-mm@kvack.org List-ID: __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); -- 2.9.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