[Top] [All Lists]

Re: Fwd: A JBD file-system (generic Journal file for ext2)

Subject: Re: Fwd: A JBD file-system generic Journal file for ext2
From: Bill Stouder-Studenmund
Date: Sun, 23 Sep 2007 06:08:27 UTC
Newsgroups: fa.netbsd.tech.kern
On Sun, Sep 23, 2007 at 03:30:32PM +1200, Avinash Malik wrote:
> Hello,
>      I have been implementing the journaling,
> I had a few questions
> 1.) Say when I am committing (which is being done on a separate lwp than 
> adding
> transactions), my current implementation first gets the transaction to be
> committed. Checks If there is enough space in the log, If there is then a copy
> of the transaction is made. This copy is then sent to the commit-func-pointer
> to be written to the journal. Fine, this is the normal case.
> 2.) When there is not enough space in log. I call the check-pointing routine
> instead of the committing routine, which flushes (not yet implemented)
> everything from log onto disk.

I think you're putting the cart before the horse. Figure out how to write 
data to the journal correctly & subsequently out to disk. Then talk about 
how to make it faster. Since you haven't written code yet, it's not clear 
that a separate thread really will help, or that it will help the most.

> Question:
> 1.) Is there a need to kick a waiting thread on mutex using condvars. Because 
> I
> have a committing function which is waiting on journal-mutex and the calling
> thread first acquires that journal-mutex, makes the transaction copies etc...
> and then exits it. Logically this should work fine since once the calling
> ufs_thread exits mutex commit-lwp should obtain it correct? So no need for me
> kicking the commit thread with condvars....

You have to wake the condvar. That's how they work. If the thread is 
waiting to lock the mutex, it may get the mutex once its released. However 
if you're waiting on a condvar, you wait until your awoken.

> 2.) A trivial question, the blkroundup macro in /sys/ufs/ext2fs.h takes the
> size,fs and gives back size out. From what I can make out, say if buf has 
> valid
> data size of 9-bytes and blocks in the fs were 2-bytes each then the returned
> size would be 10-bytes (i.e. rounded up to the block-boundary correct?)

Yes, however you should never need to use that code. Everything that gets 
sent to the journal should already be a block.

Take care,

<Prev in Thread] Current Thread [Next in Thread>