From patchwork Tue Oct 25 00:13:38 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: 9393647 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 6EC6260762 for ; Tue, 25 Oct 2016 00:18:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5ECD628F00 for ; Tue, 25 Oct 2016 00:18:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52BF2290B3; Tue, 25 Oct 2016 00:18:42 +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=ham 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 DD8BC28F00 for ; Tue, 25 Oct 2016 00:18:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S941341AbcJYASj (ORCPT ); Mon, 24 Oct 2016 20:18:39 -0400 Received: from mga03.intel.com ([134.134.136.65]:63386 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933586AbcJYAO2 (ORCPT ); Mon, 24 Oct 2016 20:14:28 -0400 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP; 24 Oct 2016 17:14:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,543,1473145200"; d="scan'208";a="777123301" Received: from black.fi.intel.com ([10.237.72.28]) by FMSMGA003.fm.intel.com with ESMTP; 24 Oct 2016 17:14:22 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 4358FD0A; Tue, 25 Oct 2016 03:13:47 +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: [PATCHv4 39/43] ext4: make EXT4_IOC_MOVE_EXT work with huge pages Date: Tue, 25 Oct 2016 03:13:38 +0300 Message-Id: <20161025001342.76126-40-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161025001342.76126-1-kirill.shutemov@linux.intel.com> References: <20161025001342.76126-1-kirill.shutemov@linux.intel.com> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Adjust how we find relevant block within page and how we clear the required part of the page. Signed-off-by: Kirill A. Shutemov --- fs/ext4/move_extent.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c index 6fc14def0c70..2efa9deb47a9 100644 --- a/fs/ext4/move_extent.c +++ b/fs/ext4/move_extent.c @@ -210,7 +210,9 @@ mext_page_mkuptodate(struct page *page, unsigned from, unsigned to) return err; } if (!buffer_mapped(bh)) { - zero_user(page, block_start, blocksize); + zero_user(page + block_start / PAGE_SIZE, + block_start % PAGE_SIZE, + blocksize); set_buffer_uptodate(bh); continue; } @@ -267,10 +269,11 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, unsigned int tmp_data_size, data_size, replaced_size; int i, err2, jblocks, retries = 0; int replaced_count = 0; - int from = data_offset_in_page << orig_inode->i_blkbits; + int from; int blocks_per_page = PAGE_SIZE >> orig_inode->i_blkbits; struct super_block *sb = orig_inode->i_sb; struct buffer_head *bh = NULL; + int diff; /* * It needs twice the amount of ordinary journal buffers because @@ -355,6 +358,9 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, goto unlock_pages; } data_copy: + diff = (pagep[0] - compound_head(pagep[0])) * blocks_per_page; + from = (data_offset_in_page + diff) << orig_inode->i_blkbits; + pagep[0] = compound_head(pagep[0]); *err = mext_page_mkuptodate(pagep[0], from, from + replaced_size); if (*err) goto unlock_pages; @@ -384,7 +390,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode, if (!page_has_buffers(pagep[0])) create_empty_buffers(pagep[0], 1 << orig_inode->i_blkbits, 0); bh = page_buffers(pagep[0]); - for (i = 0; i < data_offset_in_page; i++) + for (i = 0; i < data_offset_in_page + diff; i++) bh = bh->b_this_page; for (i = 0; i < block_len_in_page; i++) { *err = ext4_get_block(orig_inode, orig_blk_offset + i, bh, 0);