linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] ext4: Do not allow retry alloc loop under open transaction
@ 2010-02-03 18:27 Dmitry Monakhov
  2010-02-04 11:37 ` Aneesh Kumar K. V
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Monakhov @ 2010-02-03 18:27 UTC (permalink / raw)
  To: linux-ext4; +Cc: tytso


Some times we call ->write_begin() with opened journal
but write_begin() may internally call ext4_should_retry_alloc()
in case of ENOSPC, which result in deadlock.
This patch introduce new AOP_FLAG which should be tested on retry
alloc path.

Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
 fs/ext4/ext4.h        |    5 +++++
 fs/ext4/inode.c       |    6 ++++--
 fs/ext4/move_extent.c |    2 +-
 include/linux/fs.h    |    1 +
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index af7b626..0efb224 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -792,6 +792,11 @@ struct ext4_inode_info {
 #define EXT4_DFL_CHECKINTERVAL		0	/* Don't use interval check */
 
 /*
+ * Address space flags.
+ */
+#define EXT4_AOP_FLAG_NORETRY	AOP_FLAG_LAST	/* Do not allow to fail in to
+						   retry alloc loop */
+/*
  * Behaviour when detecting errors
  */
 #define EXT4_ERRORS_CONTINUE		1	/* Continue execution */
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c818972..2d3fe4d 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1593,7 +1593,8 @@ retry:
 		}
 	}
 
-	if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+	if (!(flags & EXT4_AOP_FLAG_NORETRY) && ret == -ENOSPC &&
+		ext4_should_retry_alloc(inode->i_sb, &retries))
 		goto retry;
 out:
 	return ret;
@@ -3089,7 +3090,8 @@ retry:
 			ext4_truncate_failed_write(inode);
 	}
 
-	if (ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
+	if (!(flags & EXT4_AOP_FLAG_NORETRY) &&
+		ret == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries))
 		goto retry;
 out:
 	return ret;
diff --git a/fs/ext4/move_extent.c b/fs/ext4/move_extent.c
index 82c415b..f894382 100644
--- a/fs/ext4/move_extent.c
+++ b/fs/ext4/move_extent.c
@@ -796,7 +796,7 @@ move_extent_per_page(struct file *o_filp, struct inode *donor_inode,
 	ext4_lblk_t orig_blk_offset;
 	long long offs = orig_page_offset << PAGE_CACHE_SHIFT;
 	unsigned long blocksize = orig_inode->i_sb->s_blocksize;
-	unsigned int w_flags = 0;
+	unsigned int w_flags = EXT4_AOP_FLAG_NORETRY;
 	unsigned int tmp_data_size, data_size, replaced_size;
 	void *fsdata;
 	int i, jblocks;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b1bcb27..6f68707 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -504,6 +504,7 @@ enum positive_aop_returns {
 #define AOP_FLAG_NOFS			0x0004 /* used by filesystem to direct
 						* helper code (eg buffer layer)
 						* to clear GFP_FS from alloc */
+#define AOP_FLAG_LAST			0x0008 /* First unused private flag */
 
 /*
  * oh the beauties of C type declarations.
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-02-04 12:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-03 18:27 [PATCH 1/2] ext4: Do not allow retry alloc loop under open transaction Dmitry Monakhov
2010-02-04 11:37 ` Aneesh Kumar K. V
2010-02-04 12:06   ` Dmitry Monakhov

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).