From patchwork Wed Mar 6 14:17:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zheng Liu X-Patchwork-Id: 225502 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 5029A2C03BB for ; Thu, 7 Mar 2013 01:02:27 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757341Ab3CFOC0 (ORCPT ); Wed, 6 Mar 2013 09:02:26 -0500 Received: from mail-pb0-f41.google.com ([209.85.160.41]:60241 "EHLO mail-pb0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757237Ab3CFOC0 (ORCPT ); Wed, 6 Mar 2013 09:02:26 -0500 Received: by mail-pb0-f41.google.com with SMTP id um15so6070528pbc.0 for ; Wed, 06 Mar 2013 06:02:25 -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=46gGIUj3ap8PsXuUk9+0B1TbAzMJ1uqqdCWjEfylNdU=; b=cHL5GJ16NfTstYDy+O+4o2WOdL8liaS67OFHF31s0bDkGywwd4+GlKB/KRTY8I7GJ+ 2CI51WAMGmEMvzX+XXECSUeFUEIcPKz5THoavaXPWqhMs/7jjDpRCqpqw4i3584isA1h jMeKZa6DTDgpFNN3C6s4MN6VVqHOGjjugQDu19ayyC78cAMJfja1bx0xmwID3RgDa2so zPip3WfIjVg9lFrfvecDgxYGHmWC6/6uZTwHSfTnuO+aO3y17vtd09wMYScakCFZpBNv G/lsqVykzVAmK2j5bffKvticppy4yTLUp7+VKuI60tT6i/+tVGIerTjHIo85TJ+y8AVy n/uA== X-Received: by 10.68.212.197 with SMTP id nm5mr45864925pbc.179.1362578545445; Wed, 06 Mar 2013 06:02:25 -0800 (PST) Received: from lz-desktop.taobao.ali.com ([182.92.247.2]) by mx.google.com with ESMTPS id iv3sm31421931pbc.40.2013.03.06.06.02.20 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 06 Mar 2013 06:02:24 -0800 (PST) From: Zheng Liu To: linux-ext4@vger.kernel.org Cc: Zheng Liu , "Theodore Ts'o" , Dmitry Monakhov Subject: [PATCH v2 3/5] ext4: fix wrong m_len value after unwritten extent conversion Date: Wed, 6 Mar 2013 22:17:13 +0800 Message-Id: <1362579435-6333-4-git-send-email-wenqing.lz@taobao.com> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: <1362579435-6333-1-git-send-email-wenqing.lz@taobao.com> References: <1362579435-6333-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 We always assume that the return value of ext4_ext_map_blocks is equal to map->m_len but when we try to convert an unwritten extent 'm_len' value will break this assumption. It is harmless until we use status tree as a extent cache because we need to update status tree according to 'm_len' value. Meanwhile this commit marks EXT4_MAP_MAPPED flag after unwritten extent conversion. It shouldn't cause a bug because we update status tree according to checking EXT4_MAP_UNWRITTEN flag. But it should be fixed. After applied this commit, the following error message from self-testing infrastructure disappears. ... kernel: ES len assertation failed for inode: 230 retval 1 != map->m_len 3 in ext4_map_blocks (allocation) ... Signed-off-by: Zheng Liu Cc: "Theodore Ts'o" Cc: Dmitry Monakhov --- fs/ext4/extents.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 25c86aa..110e85a 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3650,6 +3650,10 @@ ext4_ext_handle_uninitialized_extents(handle_t *handle, struct inode *inode, path, map->m_len); } else err = ret; + map->m_flags |= EXT4_MAP_MAPPED; + if (allocated > map->m_len) + allocated = map->m_len; + map->m_len = allocated; goto out2; } /* buffered IO case */