tech-kern archive

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

Re: Finding an available fss device



> On 13. Aug 2018, at 09:53, Emmanuel Dreyfus <manu%netbsd.org@localhost> wrote:
> 
> On Sun, Aug 12, 2018 at 10:16:48AM +0200, J. Hannken-Illjes wrote:
>> While creating a snapshot "/mount0" lookup "/mount0/file", it will block
>> as "/mount0" is suspended.  The lookup holds a lock on "/".
>> 
>> Now snapshot "/ "and trying to suspend "/" will block as the lookup
>> has the root vnode locked.
> 
> This scenario is not the same as the one I asked about, which
> was: performing a snapshot of filesystem mounted on /mount0 
> using /dev/fss0 and a snapshot of filesystem mounted on /mount1
> using /dev/fss1 while the first one is still active. Is there some
> deadlock in this case?

Still not sure we are talking about the same thing.

1) Create snapshot of /mount0 with fss0
1a) Open /dev/fss0
1b) Ioctl FSSIOCSET on /dev/fss0 to create the snapshot
1c) Read data from /dev/fss0
1d) Ioctl FSSIOCCLR on /dev/fss0 to delete the snapshot
1e) Close /dev/fss0

The same for a snapshot of /mount1 with fss1.

2) Create snapshot of /mount1 with fss1
2a) Open /dev/fss1
2b) Ioctl FSSIOCSET on /dev/fss1 to create the snapshot
2c) Read data from /dev/fss1
2d) Ioctl FSSIOCCLR on /dev/fss1 to delete the snapshot
2e) Close /dev/fss1

All operations are mutually exclusive, we always run exactly
one of 1), 1a) ... 2e), a second operation will block until
it gets exclusive access.

Of these operations, 1b), 1d), 2b) and 2d) may take a long time
to run if the snapshot is file system internal.

> But you also raise a deadlock scenario for which there is no
> protection in currentn code. I already experienced it in the
> past and it would be fair to return EGAIN rather than letting the
> administrator set a snapshot that will kill the system later.

This scenario is protected by mutual exclusion of fss device
operations as explained above.  Creating the snapshot of "/"
waits for the creation of the snapshot of "/mount0" to finish.

Additionally VFS_SUSPEND is always exclusive (see mutex
vfs_suspend_lock) as it gets used from mount() and unmount() too.

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



Home | Main Index | Thread Index | Old Index