tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: vnd locking



On 22 May 2015, at 14:09, Patrick Welche <prlw1%cam.ac.uk@localhost> wrote:

> There are a load of locking PRs involving vnd. I thought I would have a
> stab at converting vnd to use condvars and mutexes (mutices?) as a first
> step. I cobbled something together which allows me to
> 
>  vnconfig vnd0 /tmp/foo.img
>  disklabel -r -w vnd0 vndtest
>  newfs /dev/vnd0b
>  mount /dev/vnd0b /mnt
>  cd /mnt
>  echo hello > foo
>  cat foo
>  df -h .
>  umount /mnt
> 
> with a LOCKDEBUG kernel, so I may have guessed right, but I haven't found
> any documentation on The Right Way, so please review carefully, assume
> the worst, and tell me how to do it better!
> 
> Things to ponder:
> - there was some sort of start kernel thread, thread sets variable,
>  meanwhile loop waiting for variable to be set. I removed that. On
>  the other hand I added a MUSTJOIN for the kernel thread exiting
>  side of things.
> - given that vnd is a pseudo-device, do I need an extra lock to care
>  of device creation/destruction? (What am I protecting against?

One thread creating a device while it gets unconfigured by other thread?

- make sure all accesses to sc_flags etc. are protected by mutex.

- locking is no longer interruptible (no PCATCH / cv_wait_sig), not
  sure if this is a problem.

- keep the first blank line for functions without locals.

- do the white space change with a separate commit.

Otherwise looks like a good starting point.

--
J. Hannken-Illjes - hannken%eis.cs.tu-bs.de@localhost - TU Braunschweig (Germany)



Home | Main Index | Thread Index | Old Index