From patchwork Tue Sep 20 14:49:29 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Monakhov X-Patchwork-Id: 115561 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 A77431007D1 for ; Wed, 21 Sep 2011 00:49:17 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751413Ab1ITOtQ (ORCPT ); Tue, 20 Sep 2011 10:49:16 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:61802 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750915Ab1ITOtQ (ORCPT ); Tue, 20 Sep 2011 10:49:16 -0400 Received: by mail-bw0-f46.google.com with SMTP id zt4so535196bkb.19 for ; Tue, 20 Sep 2011 07:49:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=hfwlYqKaXJNNYxtwe5wFsa/VTqahrkuMYl0sORT5gQs=; b=aB1nINXOL5+HAmCb5AKZkp0GPlFFEI3uIAB34qzgNa1Pb24A+/8XIsQ7RFNu37uLnR jV+rYn1lvQvu/LGuPixwLbqE4n7/1qYrpMcrclqauFG7xp9DBoI1njyW6ZTJk9VO+e8O 0ESUgABTrKEbaI23JnMbBLVYPGBFZs2VkY5Wo= Received: by 10.204.135.69 with SMTP id m5mr657462bkt.78.1316530155336; Tue, 20 Sep 2011 07:49:15 -0700 (PDT) Received: from localhost.localdomain (swsoft-msk-nat.sw.ru. [195.214.232.10]) by mx.google.com with ESMTPS id z7sm1818470bkt.5.2011.09.20.07.49.13 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Sep 2011 07:49:14 -0700 (PDT) From: Dmitry Monakhov To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, achender@linux.vnet.ibm.com, Dmitry Monakhov Subject: [PATCH 3/4] ext4: Do not clear EOFBLOCKS_FL too soon Date: Tue, 20 Sep 2011 18:49:29 +0400 Message-Id: <1316530170-3965-4-git-send-email-dmonakhov@openvz.org> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1316530170-3965-1-git-send-email-dmonakhov@openvz.org> References: <1316530170-3965-1-git-send-email-dmonakhov@openvz.org> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org ext4_ext_insert_extent() may fail due to number of reasons (ENOSPC) so let's update eof flag only after extent was successfully inserted. Signed-off-by: Dmitry Monakhov --- fs/ext4/extents.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 9032214..098bf6a 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -3562,10 +3562,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, map->m_flags |= EXT4_MAP_UNINIT; } - err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len); - if (!err) - err = ext4_ext_insert_extent(handle, inode, path, - &newex, flags); + err = ext4_ext_insert_extent(handle, inode, path, &newex, flags); if (err) { int fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ? EXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0; @@ -3577,6 +3574,11 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, ext4_ext_get_actual_len(&newex), fb_flags); goto out2; } + err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len); + if (err) { + ext4_discard_preallocations(inode); + goto out2; + } /* previous routine could use block we allocated */ newblock = ext4_ext_pblock(&newex);