From patchwork Fri Jan 11 10:53:42 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 211296 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 0FD3E2C022F for ; Fri, 11 Jan 2013 21:40:22 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753530Ab3AKKkV (ORCPT ); Fri, 11 Jan 2013 05:40:21 -0500 Received: from mail-da0-f53.google.com ([209.85.210.53]:51304 "EHLO mail-da0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753219Ab3AKKkU (ORCPT ); Fri, 11 Jan 2013 05:40:20 -0500 Received: by mail-da0-f53.google.com with SMTP id x6so716819dac.26 for ; Fri, 11 Jan 2013 02:40:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=/bIXQaIws/ulL1Z4iPX3yV3gYDMr4xTu0sw/dQYl23U=; b=S2WFigeuOUNwb3HeqGCD4/Ui5BCQtVq5k4cEzz2UK1JsZzMcszp7ca0EtzNlPwLglK 6G8gtM7qn0eCje9IafPgIAInl5CH2xndsQAWwUKAOcw0SX/hjwRNAdK8Rwm0b9pmgmEl W7pSDu5cYggp3zTCjr3V+y0kqqSdvz/WwIMLSkMeIUHELyLGvphpXsWrA/HCayE4RpDO Na0PsFucueD0py9HDyLU2jYg9BTZ5dnOWqp9MCzZaQaD5gv9JzQwvAf6YjnRWpl21wrO KUrX35DZF+hQPnIxxLtChZlCfBcEgSjAV32gfo1wcJPOMGuns9UY7LUIEM4dxzkGxmXo /FWQ== X-Received: by 10.66.84.195 with SMTP id b3mr206603467paz.30.1357900819956; Fri, 11 Jan 2013 02:40:19 -0800 (PST) Received: from lz-desktop.taobao.ali.com ([182.92.247.2]) by mx.google.com with ESMTPS id uk9sm2576791pbc.63.2013.01.11.02.40.14 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 11 Jan 2013 02:40:19 -0800 (PST) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: Jan kara , "Theodore Ts'o" , Zheng Liu Subject: [PATCH 2/7 v2] ext4: remove EXT4_MAP_FROM_CLUSTER flag Date: Fri, 11 Jan 2013 18:53:42 +0800 Message-Id: <1357901627-3068-3-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: <1357901627-3068-1-git-send-email-wenqing.lz@taobao.com> References: <1357901627-3068-1-git-send-email-wenqing.lz@taobao.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Zheng Liu EXT4_MAP_FROM_CLUSTER flag is only used in ext4_da_map_blocks() and ext4_ext_map_blocks() to indicate whether a cluster has been reserved or not. But in ext4_da_map_blocks() we can check it directly. Meanwhile this flag couldn't appear on the buffer head. So it can be replaced with a local variable. CC: Jan kara CC: "Theodore Ts'o" Signed-off-by: Zheng Liu --- fs/ext4/ext4.h | 15 +-------------- fs/ext4/extents.c | 18 ++++-------------- fs/ext4/inode.c | 11 ++--------- 3 files changed, 7 insertions(+), 37 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 8462eb3..36145ef1 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -155,17 +155,9 @@ struct ext4_allocation_request { #define EXT4_MAP_UNWRITTEN (1 << BH_Unwritten) #define EXT4_MAP_BOUNDARY (1 << BH_Boundary) #define EXT4_MAP_UNINIT (1 << BH_Uninit) -/* Sometimes (in the bigalloc case, from ext4_da_get_block_prep) the caller of - * ext4_map_blocks wants to know whether or not the underlying cluster has - * already been accounted for. EXT4_MAP_FROM_CLUSTER conveys to the caller that - * the requested mapping was from previously mapped (or delayed allocated) - * cluster. We use BH_AllocFromCluster only for this flag. BH_AllocFromCluster - * should never appear on buffer_head's state flags. - */ -#define EXT4_MAP_FROM_CLUSTER (1 << BH_AllocFromCluster) #define EXT4_MAP_FLAGS (EXT4_MAP_NEW | EXT4_MAP_MAPPED |\ EXT4_MAP_UNWRITTEN | EXT4_MAP_BOUNDARY |\ - EXT4_MAP_UNINIT | EXT4_MAP_FROM_CLUSTER) + EXT4_MAP_UNINIT) struct ext4_map_blocks { ext4_fsblk_t m_pblk; @@ -2553,11 +2545,6 @@ extern int ext4_mmp_csum_verify(struct super_block *sb, enum ext4_state_bits { BH_Uninit /* blocks are allocated but uninitialized on disk */ = BH_JBDPrivateStart, - BH_AllocFromCluster, /* allocated blocks were part of already - * allocated cluster. Note that this flag will - * never, ever appear in a buffer_head's state - * flag. See EXT4_MAP_FROM_CLUSTER to see where - * this is used. */ }; BUFFER_FNS(Uninit, uninit) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index f7bf616..aa9a6d2 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3894,6 +3894,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, ext4_io_end_t *io = ext4_inode_aio(inode); ext4_lblk_t cluster_offset; int set_unwritten = 0; + int from_cluster = 0; ext_debug("blocks %u/%u requested for inode %lu\n", map->m_lblk, map->m_len, inode->i_ino); @@ -3902,10 +3903,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, /* check in cache */ if (ext4_ext_in_cache(inode, map->m_lblk, &newex)) { if (!newex.ee_start_lo && !newex.ee_start_hi) { - if ((sbi->s_cluster_ratio > 1) && - ext4_find_delalloc_cluster(inode, map->m_lblk)) - map->m_flags |= EXT4_MAP_FROM_CLUSTER; - if ((flags & EXT4_GET_BLOCKS_CREATE) == 0) { /* * block isn't allocated yet and @@ -3916,8 +3913,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, /* we should allocate requested block */ } else { /* block is already allocated */ - if (sbi->s_cluster_ratio > 1) - map->m_flags |= EXT4_MAP_FROM_CLUSTER; newblock = map->m_lblk - le32_to_cpu(newex.ee_block) + ext4_ext_pblock(&newex); @@ -3990,10 +3985,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, } } - if ((sbi->s_cluster_ratio > 1) && - ext4_find_delalloc_cluster(inode, map->m_lblk)) - map->m_flags |= EXT4_MAP_FROM_CLUSTER; - /* * requested block isn't allocated yet; * we couldn't try to create block if create flag is zero @@ -4010,7 +4001,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, /* * Okay, we need to do block allocation. */ - map->m_flags &= ~EXT4_MAP_FROM_CLUSTER; newex.ee_block = cpu_to_le32(map->m_lblk); cluster_offset = map->m_lblk & (sbi->s_cluster_ratio-1); @@ -4022,7 +4012,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, get_implied_cluster_alloc(inode->i_sb, map, ex, path)) { ar.len = allocated = map->m_len; newblock = map->m_pblk; - map->m_flags |= EXT4_MAP_FROM_CLUSTER; + from_cluster = 1; goto got_allocated_blocks; } @@ -4043,7 +4033,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) { ar.len = allocated = map->m_len; newblock = map->m_pblk; - map->m_flags |= EXT4_MAP_FROM_CLUSTER; + from_cluster = 1; goto got_allocated_blocks; } @@ -4168,7 +4158,7 @@ got_allocated_blocks: */ reserved_clusters = get_reserved_cluster_alloc(inode, map->m_lblk, allocated); - if (map->m_flags & EXT4_MAP_FROM_CLUSTER) { + if (from_cluster) { if (reserved_clusters) { /* * We have clusters reserved for this range. diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index cbfe13b..4d066f3 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -1798,9 +1798,6 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, * of mapping from cluster so that the reserved space * is calculated properly. */ - if ((EXT4_SB(inode->i_sb)->s_cluster_ratio > 1) && - ext4_find_delalloc_cluster(inode, map->m_lblk)) - map->m_flags |= EXT4_MAP_FROM_CLUSTER; retval = 0; } else if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)) retval = ext4_ext_map_blocks(NULL, inode, map, 0); @@ -1814,7 +1811,8 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, */ /* If the block was allocated from previously allocated cluster, * then we dont need to reserve it again. */ - if (!(map->m_flags & EXT4_MAP_FROM_CLUSTER)) { + if ((EXT4_SB(inode->i_sb)->s_cluster_ratio == 1) || + !ext4_find_delalloc_cluster(inode, map->m_lblk)) { retval = ext4_da_reserve_space(inode, iblock); if (retval) /* not enough space to reserve */ @@ -1825,11 +1823,6 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, if (retval) goto out_unlock; - /* Clear EXT4_MAP_FROM_CLUSTER flag since its purpose is served - * and it should not appear on the bh->b_state. - */ - map->m_flags &= ~EXT4_MAP_FROM_CLUSTER; - map_bh(bh, inode->i_sb, invalid_block); set_buffer_new(bh); set_buffer_delay(bh);