preferred kernel upcall method to master nfsd

John Baldwin jhb at FreeBSD.org
Thu Nov 25 15:26:55 UTC 2010


Jeremy Chadwick wrote:
> On Mon, Nov 22, 2010 at 09:01:05PM -0500, Rick Macklem wrote:
>>> nfsd is a user process. I suspect that when it receives a signal it
>>> falls out of
>>> nfssvc() with EINTR and handles saving the restart file in userland.
>>> Is that close
>>> to the process Rick or does you need to send a signal between threads
>>> that are
>>> exclusively within the kernel?
>>>
>> Yep, the kernel nfsd thread needs to tell the userland master nfsd to
>> make a backup copy of the stable restart file now.
>>
>> Doing it with signals, the kernel code would post a signal (SIGUSR2 ?)
>> to the master nfsd (which is normally in userland).
>>
>> The master nfsd would simply have a signal handler for SIGUSR2 that would
>> copy the file (it's pretty small) to a backup copy.
>>
>> At least that's how I would think I could code it. I haven't actually
>> tried it?
>>
>> My question was mostly if there was a preferred/better way for the
>> kernel code to tell the userland master nfsd to copy the file?
> 
> Could kqueue(2) be used for this?

A userland app can use kqueue(2) to check for signals already.  The real 
question is what is the easiest way for the kernel to signal an event to 
userland.  You could do something convoluted where you create a dummy 
/dev device that you mark readable when you want to post an event to 
userland, but that's a lot more work than just calling psignal() if you 
already know which process to send the signal to.

-- 
John Baldwin


More information about the freebsd-fs mailing list