[Ocfs2-tools-devel] [PATCH 5/6] fsck.ocfs2: Use the I/O cache.

Joel Becker Joel.Becker at oracle.com
Fri May 22 09:12:27 PDT 2009


On Fri, May 22, 2009 at 11:43:11AM +0800, Tao Ma wrote:
> Hi Joel,
> 	The patch set looks good to me. Just one qs.
> Joel Becker wrote:
>> +static void o2fsck_init_cache(o2fsck_state *ost, enum o2fsck_cache_hint 
>> hint)
>> +{
>> +	errcode_t ret;
>> +	uint64_t blocks_wanted;
>> +	int leave_room;
>> +	ocfs2_filesys *fs = ost->ost_fs;
>> +	int max_slots = OCFS2_RAW_SB(fs->fs_super)->s_max_slots;
>> +
>> +	switch (hint) {
>> +		case O2FSCK_CACHE_MODE_FULL:
>> +			leave_room = 1;
>> +			blocks_wanted = fs->fs_blocks;
>> +			break;
>> +		case O2FSCK_CACHE_MODE_JOURNAL:
>> +			/*
>> +			 * We need enough blocks for all the journal
>> +			 * data.  Let's guess at 256M journals.
>> +			 */
>> +			leave_room = 0;
>> +			blocks_wanted = ocfs2_blocks_in_bytes(fs,
>> +					max_slots * 1024 * 1024 * 256);
>> +			break;
>> +		case O2FSCK_CACHE_MODE_NONE:
>> +			return;
>> +		default:
>> +			assert(0);
>> +	}
> why we need max_slot * 256MB cache for the journal check?
> I just went through the code and can't see we will use these journal files 
> in the same time.
>
> o2fsck_check_journals only check the journal header(it doesn't read the 
> file content here, so the cache isn't filled) and make_journal if it is 
> corrupted(well, here we may fill the cache in write_block, but they will 
> never be used in replay since they are empty).
>
> maybe_replay_journals will iterate the journal file one by one.

	Look in o2fsck_replay_journals().  We do two loops on the slots,
calling walk_journal_func() in both loops.  The first pass doesn't
replay; it just checks to see the journal isn't crazy.  The second pass
does replay.  So in the end, it first reads all journals, then it goes
and reads and replays all journals.  A big enough cache will make the
second pass stay in RAM.

> btw, I also think of wether we can add some flag in write_block saying that 
> "don't fill in cache please. It will never be used again." For make_journal 
> case, it is very useful.

	In mkfs we're deliberately not using the cache because of this.
I may create io_read/write_block_nocache().

Joel

-- 

Life's Little Instruction Book #69

	"Whistle"

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127



More information about the Ocfs2-tools-devel mailing list