Lawrence Stewart <[EMAIL PROTECTED]> writes:
> Dag-Erling Smørgrav <[EMAIL PROTECTED]> writes:
> > Since you are writing kernel code, I assume you have KDB/DDB in your
> > kernel and know how to use it.
> I don't know how to use them really. Thus far I haven't had a need for
> really low level debugging tools... seems that may have changed
> though! Any good tutorials/pointers on how to get started with kernel
> debugging?

The handbook and FAQ have information on debugging panics.  Greg Lehey
(grog@) does a tutorial on kernel debugging, you can probably find
slides online (or just ask him)

> > kio_write probably blocks waiting for the write to complete.  You can't
> > do that while holding a non-sleepable lock.
> So this is where my knowledge/understanding gets very hazy...
>
> When a thread blocks waiting for some operation to complete or event
> to happen, the thread effectively goes to sleep, correct?

It depends on the type of lock used, but mostly, yes.

> Looking at the kio_write code in subr_kernio.c, I'm guessing the lock
> that is causing the trouble is related to the "vn_lock" function call?

What matters is that kio_write() may sleep and therefore can't be called
while holding a non-sleepable lock.

> I don't understand though why the vnode lock would be set up in such a
> way that when the write blocks whilst waiting for the underlying
> filesystem to signal everything is ok, it causes the kernel to panic!

You cannot sleep while holding a non-sleepable lock.  You need to find
out which locks are held at the point where you call kio_write(), and
figure out a way to delay the kio_write() call until those locks are
released.

> How do I make the lock "sleepable" or make sure the thread doesn't try
> go to sleep whilst holding the lock?

You can't make an unsleepable lock sleepable.  You might be able to
replace it with a sleepable lock, but you would have to go through every
part of the kernel that uses the lock and make sure that it works
correctly with a sleepable lock.  Most likely, it won't.

DES
-- 
Dag-Erling Smørgrav - [EMAIL PROTECTED]
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to