ocfs2-devel.oss.oracle.com archive mirror
 help / color / mirror / Atom feed
* [Ocfs2-devel] [patch 08/11] ocfs2: should call ocfs2_journal_access_di() before ocfs2_delete_entry() in ocfs2_orphan_del()
@ 2014-01-24 20:47 akpm at linux-foundation.org
  2014-02-06 23:28 ` Mark Fasheh
  0 siblings, 1 reply; 3+ messages in thread
From: akpm at linux-foundation.org @ 2014-01-24 20:47 UTC (permalink / raw)
  To: ocfs2-devel

From: Younger Liu <younger.liu@huawei.com>
Subject: ocfs2: should call ocfs2_journal_access_di() before ocfs2_delete_entry() in ocfs2_orphan_del()

While deleting a file into orphan dir in ocfs2_orphan_del(), it calls
ocfs2_delete_entry() before ocfs2_journal_access_di().  If
ocfs2_delete_entry() succeeded and ocfs2_journal_access_di() failed, there
would be a inconsistency: the file is deleted from orphan dir, but orphan
dir dinode is not updated.

So we need to call ocfs2_journal_access_di() before ocfs2_orphan_del().

Signed-off-by: Younger Liu <younger.liu@huawei.com>
Reviewed-by: Jensen <shencanquan@huawei.com>
Cc: Jie Liu <jeff.liu@oracle.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Mark Fasheh <mfasheh@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/ocfs2/namei.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff -puN fs/ocfs2/namei.c~ocfs2-should-call-ocfs2_journal_access_di-before-ocfs2_delete_entry-in-ocfs2_orphan_del fs/ocfs2/namei.c
--- a/fs/ocfs2/namei.c~ocfs2-should-call-ocfs2_journal_access_di-before-ocfs2_delete_entry-in-ocfs2_orphan_del
+++ a/fs/ocfs2/namei.c
@@ -2207,17 +2207,17 @@ int ocfs2_orphan_del(struct ocfs2_super
 		goto leave;
 	}
 
-	/* remove it from the orphan directory */
-	status = ocfs2_delete_entry(handle, orphan_dir_inode, &lookup);
+	status = ocfs2_journal_access_di(handle,
+					 INODE_CACHE(orphan_dir_inode),
+					 orphan_dir_bh,
+					 OCFS2_JOURNAL_ACCESS_WRITE);
 	if (status < 0) {
 		mlog_errno(status);
 		goto leave;
 	}
 
-	status = ocfs2_journal_access_di(handle,
-					 INODE_CACHE(orphan_dir_inode),
-					 orphan_dir_bh,
-					 OCFS2_JOURNAL_ACCESS_WRITE);
+	/* remove it from the orphan directory */
+	status = ocfs2_delete_entry(handle, orphan_dir_inode, &lookup);
 	if (status < 0) {
 		mlog_errno(status);
 		goto leave;
_

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

* [Ocfs2-devel] [patch 08/11] ocfs2: should call ocfs2_journal_access_di() before ocfs2_delete_entry() in ocfs2_orphan_del()
  2014-01-24 20:47 [Ocfs2-devel] [patch 08/11] ocfs2: should call ocfs2_journal_access_di() before ocfs2_delete_entry() in ocfs2_orphan_del() akpm at linux-foundation.org
@ 2014-02-06 23:28 ` Mark Fasheh
  2014-03-07  6:13   ` Younger Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Fasheh @ 2014-02-06 23:28 UTC (permalink / raw)
  To: ocfs2-devel

On Fri, Jan 24, 2014 at 12:47:07PM -0800, akpm at linux-foundation.org wrote:
> From: Younger Liu <younger.liu@huawei.com>
> Subject: ocfs2: should call ocfs2_journal_access_di() before ocfs2_delete_entry() in ocfs2_orphan_del()
> 
> While deleting a file into orphan dir in ocfs2_orphan_del(), it calls
> ocfs2_delete_entry() before ocfs2_journal_access_di().  If
> ocfs2_delete_entry() succeeded and ocfs2_journal_access_di() failed, there
> would be a inconsistency: the file is deleted from orphan dir, but orphan
> dir dinode is not updated.
> 
> So we need to call ocfs2_journal_access_di() before ocfs2_orphan_del().

I am confused by this. Re-reading the code in fs/ocfs2/dir.c,
__ocfs2_delete_entry() takes great pains to mark the buffer head as part of
the journal:

	ocfs2_journal_access_func access = ocfs2_journal_access_db;

	if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
		access = ocfs2_journal_access_di;

<snip>

			status = access(handle, INODE_CACHE(dir), bh,
					OCFS2_JOURNAL_ACCESS_WRITE);


Am I missing something here?
	--Mark

--
Mark Fasheh

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

* [Ocfs2-devel] [patch 08/11] ocfs2: should call ocfs2_journal_access_di() before ocfs2_delete_entry() in ocfs2_orphan_del()
  2014-02-06 23:28 ` Mark Fasheh
@ 2014-03-07  6:13   ` Younger Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Younger Liu @ 2014-03-07  6:13 UTC (permalink / raw)
  To: ocfs2-devel

On 2014/2/7 7:28, Mark Fasheh wrote:
> On Fri, Jan 24, 2014 at 12:47:07PM -0800, akpm at linux-foundation.org wrote:
>> From: Younger Liu <younger.liu@huawei.com>
>> Subject: ocfs2: should call ocfs2_journal_access_di() before ocfs2_delete_entry() in ocfs2_orphan_del()
>>
>> While deleting a file into orphan dir in ocfs2_orphan_del(), it calls
>> ocfs2_delete_entry() before ocfs2_journal_access_di().  If
>> ocfs2_delete_entry() succeeded and ocfs2_journal_access_di() failed, there
>> would be a inconsistency: the file is deleted from orphan dir, but orphan
>> dir dinode is not updated.
>>
>> So we need to call ocfs2_journal_access_di() before ocfs2_orphan_del().
> 
> I am confused by this. Re-reading the code in fs/ocfs2/dir.c,
> __ocfs2_delete_entry() takes great pains to mark the buffer head as part of
> the journal:
> 
> 	ocfs2_journal_access_func access = ocfs2_journal_access_db;
> 
> 	if (OCFS2_I(dir)->ip_dyn_features & OCFS2_INLINE_DATA_FL)
> 		access = ocfs2_journal_access_di;
> 
> <snip>
> 
> 			status = access(handle, INODE_CACHE(dir), bh,
> 					OCFS2_JOURNAL_ACCESS_WRITE);
> 
> 
> Am I missing something here?
> 	--Mark
Hi Mark
   I am sorry to reply so late.
   I can understand your meaning, But if OCFS2_I(dir) is not inline
data, access = ocfs2_journal_access_db.
   Moreover, logically speaking, ocfs2_journal_access_di() should not
been called after ocfs2_delete_entry(). Otherwise, there is a potential
risk for inconsistency.

     --Younger
> 
> --
> Mark Fasheh
> 
> _______________________________________________
> Ocfs2-devel mailing list
> Ocfs2-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/ocfs2-devel
> 

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

end of thread, other threads:[~2014-03-07  6:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-24 20:47 [Ocfs2-devel] [patch 08/11] ocfs2: should call ocfs2_journal_access_di() before ocfs2_delete_entry() in ocfs2_orphan_del() akpm at linux-foundation.org
2014-02-06 23:28 ` Mark Fasheh
2014-03-07  6:13   ` Younger Liu

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