From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753527AbdAZL7Q (ORCPT ); Thu, 26 Jan 2017 06:59:16 -0500 Received: from mga11.intel.com ([192.55.52.93]:43461 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753478AbdAZL7N (ORCPT ); Thu, 26 Jan 2017 06:59:13 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,289,1477983600"; d="scan'208";a="1118089815" 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: [PATCHv6 27/37] ext4: handle huge pages in __ext4_block_zero_page_range() Date: Thu, 26 Jan 2017 14:58:09 +0300 Message-Id: <20170126115819.58875-28-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170126115819.58875-1-kirill.shutemov@linux.intel.com> References: <20170126115819.58875-1-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the function handles zeroing range only within one block, the required changes are trivial, just remove assuption on page size. Signed-off-by: Kirill A. Shutemov --- fs/ext4/inode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index a25be1cf4506..7e65a5b78cf1 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3785,7 +3785,7 @@ 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 = from & (PAGE_SIZE-1); + unsigned offset; unsigned blocksize, pos; ext4_lblk_t iblock; struct inode *inode = mapping->host; @@ -3798,6 +3798,9 @@ static int __ext4_block_zero_page_range(handle_t *handle, if (!page) return -ENOMEM; + page = compound_head(page); + offset = from & ~hpage_mask(page); + blocksize = inode->i_sb->s_blocksize; iblock = index << (PAGE_SHIFT - inode->i_sb->s_blocksize_bits); @@ -3853,7 +3856,7 @@ static int __ext4_block_zero_page_range(handle_t *handle, if (err) goto unlock; } - zero_user(page, offset, length); + zero_user(page + offset / PAGE_SIZE, offset % PAGE_SIZE, length); BUFFER_TRACE(bh, "zeroed end of block"); if (ext4_should_journal_data(inode)) { -- 2.11.0