All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tao Ma <tao.ma@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 2/3] ocfs2/xattr: Merge xattr set transaction.
Date: Fri, 24 Oct 2008 09:17:40 +0800	[thread overview]
Message-ID: <49012234.7050807@oracle.com> (raw)
In-Reply-To: <20081024010912.GG12751@mail.oracle.com>



Joel Becker wrote:
> On Fri, Oct 24, 2008 at 08:44:25AM +0800, Tao Ma wrote:
>> Joel Becker wrote:
>>>>  fs/ocfs2/xattr.c |  889 +++++++++++++++++++++++++++++++-----------------------
>>>>  1 files changed, 514 insertions(+), 375 deletions(-)
>>> 	I'm trying to think of a way you could break this patch up.
>>> It's huge.
>> Actually, most of the modification are just changing ocfs2_start_trans  
>> to ocfs2_extend_trans and passing 'handle_t *' to the function. So  
>> although the patch is a little large, but I think it is easy to review,  
>> does it? ;)
> 
> 	No, I found it incredibly hard to wade through, because I'd get
> to a point where I'd lost track of where I was, and I would look and see
> I'd only viewed 44% of the patch :-)
> 	There's a lot going on in here.  You're moving the transaction
> calculations around, moving locks, reorganizing the calls to the various
> set handlers, and that's just for starters.
OK, I will try to separate it into small ones.
> 
>>>>   static int ocfs2_xattr_set_entry_index_block(struct inode *inode,
>>>> +					     handle_t *handle,
>>>>  					     struct ocfs2_xattr_info *xi,
>>>> -					     struct ocfs2_xattr_search *xs);
>>>> +					     struct ocfs2_xattr_search *xs,
>>>> +					     struct ocfs2_xattr_set_ctxt *ctxt);
>>> 	You pass 'handle' and 'ctxt' to all the same functions.  Why not
>>> put the handle on the ctxt?
>> Most functions doesn't need 'ctxt' actually, only the functions which  
>> use cluster/metadata allocation/free use it. So I'd like to separate 
>> them.
> 
> 	Almost every function I saw that took 'handle' also took 'ctxt'.
> But that's not such a big deal.
> 
>>>> +			clusters_to_add) + handle->h_buffer_credits;
>>>> +	status = ocfs2_extend_trans(handle, credits);
>>> 	Um, you just made 'credits' be double the existing transaction +
>>> the result of ocfs2_calc_extend_credits().  Did you mean that?
>>> ocfs2_extend_trans() takes the additional credits, not the total.  Later
>>> you do an eocfs2_extend_trans() with merely the new credits, so I wonder
>>> if you meant this here?
>> Yes, I do this intentionally. Because ocfs2_extend_trans sometimes  
>> doesn't work like its name. ;) If the first extension fails, it will  
>> commit the dirty blocks and then extend it, that make the credits which  
>> isn't used lost. In some cases it is OK(see some of my following  
>> modification), while in other cases when some metadata will be updated  
>> after this function, it will fails because of no credits. I have once  
>> meet with a bug for this. And actually tree operation do the same thing  
>> as I do. See  ocfs2_extend_rotate_transaction.
> 
> 	Ok, so the basic thought is that we're going to need
> h_buffer_credits after we return from this function in other places -
> we're not done with them just because we commit inside
> ocfs2_extend_trans().
> 	The big concern here is that:
> 
> 1) ocfs2_extend_trans() commits the half-completed work so it can
>    free up some space in the journal.
> 2) The system crashes.
> 3) jbd2 replays the half-completed work.
> 4) We mount again, and our code can't handle the half-completed work.
> 
> 	The alloc.c code is written to handle this half-completed state
> of our trees.  Actually, our trees almost never end up in half-completed
> states.  They are always valid trees at the point we might extend/commit
> a transaction.   I'm not worried about the xattr trees (index or value)
> in this regard.  I'm worried about any fields we've updated that get
> written due to these unexpected commits.
> 	For example, when setting an xattr you try ibody_set() first.
> If that succeeds, you then go ahead and clear the same xattr out of the
> external block/tree.  So if there is an extend_trans() somewhere in
> there, and it commits a change, you could crash and have the xattr in
> both the ibody and the external block/tree.  The same with the reverse
> (set in external, commit, clear in ibody, crash).  We need to make sure
> we either don't actually have these cases happen or handle them
> gracefully.
yeah, you may be right. As my previous e-mail said, I will try to 
calculate all the credits in the beginning. Let's see how it works.

Regards,
Tao

  reply	other threads:[~2008-10-24  1:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-17  4:40 [Ocfs2-devel] [PATCH 0/3] ocfs2/xattr: xattr improvement Tao Ma
2008-10-17  4:44 ` [Ocfs2-devel] [PATCH 1/3] ocfs2/xattr: Remove unused restore_extent_block Tao Ma
2008-10-17  4:44 ` [Ocfs2-devel] [PATCH 2/3] ocfs2/xattr: Merge xattr set transaction Tao Ma
2008-10-23 21:40   ` Joel Becker
2008-10-24  0:44     ` Tao Ma
2008-10-24  1:09       ` Joel Becker
2008-10-24  1:17         ` Tao Ma [this message]
2008-10-24  5:59           ` Joel Becker
2008-10-17  4:44 ` [Ocfs2-devel] [PATCH 3/3] ocfs2/xattr: Proper hash collision handle in bucket division Tao Ma
2008-10-17  0:54   ` [Ocfs2-devel] [PATCH 3/3] ocfs2/xattr: Proper hash collision handle in bucket division.v2 Tao Ma
2008-10-23 23:20     ` Joel Becker
2008-10-24  0:52       ` Tao Ma
2008-10-24  1:14         ` Joel Becker
2008-10-24  1:28           ` Tao Ma
2008-10-24  6:02             ` Joel Becker
2008-10-24  6:15               ` Tao Ma
2008-10-24  7:43                 ` Joel Becker
2008-10-24  8:47                   ` Joel Becker
2008-10-24  9:02                     ` Tao Ma
2008-10-24  9:15                       ` Joel Becker
2008-10-24  9:29                         ` Tao Ma

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=49012234.7050807@oracle.com \
    --to=tao.ma@oracle.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /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 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.