linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-ext4@vger.kernel.org
Cc: tytso@mit.edu, achender@linux.vnet.ibm.com,
	Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 3/4] ext4: Do not clear EOFBLOCKS_FL too soon
Date: Tue, 20 Sep 2011 18:49:29 +0400	[thread overview]
Message-ID: <1316530170-3965-4-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1316530170-3965-1-git-send-email-dmonakhov@openvz.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 <dmonakhov@openvz.org>
---
 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);
-- 
1.7.2.3


  parent reply	other threads:[~2011-09-20 14:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-20 14:49 [PATCH 0/4] ext4: cleanup and bugfixes for grow/shrink logic Dmitry Monakhov
2011-09-20 14:49 ` [PATCH 1/4] ext4: cleanup ext4_ext_grow_indepth code Dmitry Monakhov
2011-09-20 14:49 ` [PATCH 2/4] ext4: move inode indepth shrink logic to didicated function Dmitry Monakhov
2011-09-20 14:49 ` Dmitry Monakhov [this message]
2011-09-20 14:49 ` [PATCH 4/4] ext4: fix punch_hole extend handler Dmitry Monakhov
2011-09-20 15:02 ` [PATCH 0/4] ext4: cleanup and bugfixes for grow/shrink logic Dmitry Monakhov
2011-10-19 11:47 ` [PATCH 0/4] ext4: Ping Dmitry Monakhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1316530170-3965-4-git-send-email-dmonakhov@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=achender@linux.vnet.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).