On Sun, Sep 23, 2007 at 03:30:32PM +1200, Avinash Malik wrote:
> 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
> 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.
> 1.) Is there a need to kick a waiting thread on mutex using condvars. Because
> 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
> 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.