All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ext3/4: Clear pagep after write_begin() has failed
@ 2009-02-17 19:24 Dmitri Monakhov
  2009-02-23  3:12 ` Theodore Tso
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitri Monakhov @ 2009-02-17 19:24 UTC (permalink / raw)
  To: linux-ext4; +Cc: Dmitri Monakhov

Seems there is no strict rule to for this case. In fact everybody
just ignored this variable after write_begin() has failed.
This was true until ext4_defrag_partial(). So let's follows simple
rule similar to block_write_begin().

Signed-off-by: Dmitri Monakhov <dmonakhov@openvz.org>
---
 fs/ext3/inode.c |    2 ++
 fs/ext4/inode.c |    1 +
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index 5fa453b..7aa60db 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -1170,6 +1170,7 @@ retry:
 	if (IS_ERR(handle)) {
 		unlock_page(page);
 		page_cache_release(page);
+		*pagep = NULL;
 		ret = PTR_ERR(handle);
 		goto out;
 	}
@@ -1187,6 +1188,7 @@ write_begin_failed:
 		ext3_journal_stop(handle);
 		unlock_page(page);
 		page_cache_release(page);
+		*pagep = NULL;
 		/*
 		 * block_write_begin may have instantiated a few blocks
 		 * outside i_size.  Trim these off again. Don't need
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 658c4a7..0581c48 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1388,6 +1388,7 @@ retry:
 		unlock_page(page);
 		ext4_journal_stop(handle);
 		page_cache_release(page);
+		*pagep = NULL;
 		/*
 		 * block_write_begin may have instantiated a few blocks
 		 * outside i_size.  Trim these off again. Don't need
-- 
1.5.4.3


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

* Re: [PATCH] ext3/4: Clear pagep after write_begin() has failed
  2009-02-17 19:24 [PATCH] ext3/4: Clear pagep after write_begin() has failed Dmitri Monakhov
@ 2009-02-23  3:12 ` Theodore Tso
  2009-02-24 10:11   ` Dmitri Monakhov
  0 siblings, 1 reply; 3+ messages in thread
From: Theodore Tso @ 2009-02-23  3:12 UTC (permalink / raw)
  To: Dmitri Monakhov; +Cc: linux-ext4

On Tue, Feb 17, 2009 at 10:24:19PM +0300, Dmitri Monakhov wrote:
> Seems there is no strict rule to for this case. In fact everybody
> just ignored this variable after write_begin() has failed.
> This was true until ext4_defrag_partial(). So let's follows simple
> rule similar to block_write_begin().

I've checked the latest ext4_defrag_partial, and it doesn't reference
the page variable if write_begin() failed....

						- Ted

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

* Re: [PATCH] ext3/4: Clear pagep after write_begin() has failed
  2009-02-23  3:12 ` Theodore Tso
@ 2009-02-24 10:11   ` Dmitri Monakhov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitri Monakhov @ 2009-02-24 10:11 UTC (permalink / raw)
  To: Theodore Tso; +Cc: linux-ext4

Theodore Tso <tytso@mit.edu> writes:

> On Tue, Feb 17, 2009 at 10:24:19PM +0300, Dmitri Monakhov wrote:
>> Seems there is no strict rule to for this case. In fact everybody
>> just ignored this variable after write_begin() has failed.
>> This was true until ext4_defrag_partial(). So let's follows simple
>> rule similar to block_write_begin().
>
> I've checked the latest ext4_defrag_partial, and it doesn't reference
> the page variable if write_begin() failed....
>
> 						- Ted
Latest posted defrag version 1.0 from 30 Jan, contains following code
+	up_write(&EXT4_I(org_inode)->i_data_sem);
+	ret = a_ops->write_begin(o_filp, mapping, offs, data_len, w_flags,
+								&page, &fsdata);
+	down_write(&EXT4_I(org_inode)->i_data_sem);
+
+	if (unlikely(ret < 0))
+		goto out;
.....
+out:
+	if (unlikely(page)) {
+		if (PageLocked(page))
+			unlock_page(page);
+		page_cache_release(page);
+	}
In fact the patch i'm propose is mostly a cleanup, rather then serious fix
for real issue. IMHO it is not bad idea to fold it in to some real patch.

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

end of thread, other threads:[~2009-02-24 10:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-17 19:24 [PATCH] ext3/4: Clear pagep after write_begin() has failed Dmitri Monakhov
2009-02-23  3:12 ` Theodore Tso
2009-02-24 10:11   ` Dmitri Monakhov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.