2009-08-20 04:31:04

by 홍신 shin hong

[permalink] [raw]
Subject: jbd: a question on __log_wait_for_space()

Hi. I have a question on __log_wait_for_space() in jbd/checkpoint.c
while I read jbd code of Linux 2.6.30.4

In __log_wait_for_space(), it releases and re-takes journal->j_state_lock
in while loop (at line 139).

After the retaking the lock, it checks 'space_left < nblocks'. It seems that
it considers that the journal might be written during the lock
releasing and re-taking.

Then, is it necessary to check 'journal->j_flags & JFS_ABORT' again too?
I found that journal_t's j_flags is synchronized via j_state_lock. So, is there
any possiblity that j_flags value can be changed during the lock
releasing and re-taking?

Thank you

Sincerely
Shin Hong


2009-08-21 13:53:04

by Jan Kara

[permalink] [raw]
Subject: Re: jbd: a question on __log_wait_for_space()

Hello,

> Hi. I have a question on __log_wait_for_space() in jbd/checkpoint.c
> while I read jbd code of Linux 2.6.30.4
>
> In __log_wait_for_space(), it releases and re-takes journal->j_state_lock
> in while loop (at line 139).
>
> After the retaking the lock, it checks 'space_left < nblocks'. It seems that
> it considers that the journal might be written during the lock
> releasing and re-taking.
>
> Then, is it necessary to check 'journal->j_flags & JFS_ABORT' again too?
> I found that journal_t's j_flags is synchronized via j_state_lock. So, is there
> any possiblity that j_flags value can be changed during the lock
> releasing and re-taking?
Well, it may happen that JFS_ABORT has been set while we didn't hold
j_state_lock but I don't see a problem in it. We just call a few other
functions and then reiterate the while loop and we exit the loop either
because there is enough space in the journal or becauce we notice the
JFS_ABORT flag.
The point of JFS_ABORT check is that we didn't loop indefinitely when
the journal gets aborted and no blocks can be freed.

Honza
--
Jan Kara <[email protected]>
SuSE CR Labs