Hi, I would like to know if there is more comment on this? On Tue, Mar 8, 2011 at 19:40, Zhang Huan <zhhuan@xxxxxxxxx> wrote: > Hi all, > > There is potential memory leak of journal head in function > jbd2_journal_commit_transaction. The problem is that JBD2 will not > reclaim the journal head of commit record if error occurs or journal is > abotred. > > I use the following script to reproduce this issue, on a RHEL6 system. I > found it very easy to reproduce with async commit enabled. > > mount /dev/sdb /mnt -o journal_checksum,journal_async_commit > touch /mnt/xxx > echo offline > /sys/block/sdb/device/state > sync > umount /mnt > rmmod ext4 > rmmod jbd2 > > Removal of the jbd2 module will make slab complaining that > "cache `jbd2_journal_head': can't free all objects". > > > Here is my fix for this issue. The commit record should be reclaimed no > matter error occurs or not. > > diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c > index f3ad159..37a973a 100644 > --- a/fs/jbd2/commit.c > +++ b/fs/jbd2/commit.c > @@ -105,6 +105,8 @@ static int journal_submit_commit_record(journal_t *journal, > Â Â Â Âint ret; > Â Â Â Âstruct timespec now = current_kernel_time(); > > + Â Â Â *cbh = NULL; > + > Â Â Â Âif (is_journal_aborted(journal)) > Â Â Â Â Â Â Â Âreturn 0; > > @@ -808,7 +810,7 @@ wait_for_iobuf: > Â Â Â Â Â Â Â Âif (err) > Â Â Â Â Â Â Â Â Â Â Â Â__jbd2_journal_abort_hard(journal); > Â Â Â Â} > - Â Â Â if (!err && !is_journal_aborted(journal)) > + Â Â Â if (cbh) > Â Â Â Â Â Â Â Âerr = journal_wait_on_commit_record(journal, cbh); > Â Â Â Âif (JBD2_HAS_INCOMPAT_FEATURE(journal, > Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂJBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) && > > > > PS: Just out of curiosity, why would journal_submit_commit_record return a > value of 1 instead of an error number if get descriptor buffer is failed. > > > Zhang Huan > Zhang Huan -- To unsubscribe from this list: send the line "unsubscribe linux-ext4" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html