Prefaulting for i/o buffers

mdf at FreeBSD.org mdf at FreeBSD.org
Sat Feb 25 16:34:07 UTC 2012


On Sat, Feb 25, 2012 at 7:13 AM, Pawel Jakub Dawidek <pjd at freebsd.org> wrote:
> On Sat, Feb 25, 2012 at 01:01:32PM +0000, Attilio Rao wrote:
>> Il 03 febbraio 2012 19:37, Konstantin Belousov <kostikbel at gmail.com> ha scritto:
>> > FreeBSD I/O infrastructure has well known issue with deadlock caused
>> > by vnode lock order reversal when buffers supplied to read(2) or
>> > write(2) syscalls are backed by mmaped file.
>> >
>> > I previously published the patches to convert i/o path to use VMIO,
>> > based on the Jeff Roberson proposal, see
>> > http://wiki.freebsd.org/VM6. As a side effect, the VM6 fixed the
>> > deadlock. Since that work is very intrusive and did not got any
>> > follow-up, it get stalled.
>> >
>> > Below is very lightweight patch which only goal is to fix deadlock in
>> > the least intrusive way. This is possible after FreeBSD got the
>> > vm_fault_quick_hold_pages(9) and vm_fault_disable_pagefaults(9) KPIs.
>> > http://people.freebsd.org/~kib/misc/vm1.3.patch
>>
>> Hi,
>> I was reviewing:
>> http://people.freebsd.org/~kib/misc/vm1.11.patch
>>
>> and I think it is great. It is simple enough and I don't have further
>> comments on it.
>>
>> However, as a side note, I was thinking if we could get one day at the
>> point to integrate rangelocks into vnodes lockmgr directly.
>> It would be a huge patch, rewrtiting the locking of several members of
>> vnodes likely, but I think it would be worth it in terms of cleaness
>> of the interface and less overhead. Also, it would be interesting to
>> consider merging rangelock implementation in ZFS' one, at some point.
>
> I personal opinion about rangelocks and many other VFS features we
> currently have is that it is good idea in theory, but in practise it
> tends to overcomplicate VFS.
>
> I'm in opinion that we should move as much stuff as we can to individual
> file systems. We try to implement everything in VFS itself in hope that
> this will simplify file systems we have. It then turns out only one file
> system is really using this stuff (most of the time it is UFS) and this
> is PITA for all the other file systems as well as maintaining VFS. VFS
> became so complicated over the years that there are maybe few people
> that can understand it, and every single change to VFS is a huge risk of
> potentially breaking some unrelated parts.
>
> File systems most of the time know much better how they work and what
> should be done to make them optimal. For example ZFS had range locking
> from day one, but we can't take advantage of this, because our VFS "knows
> better" how ZFS locking should be done. There plenty of examples:
> - range vnode locking,
> - shared vnode locking,
> - quota (which I believe is still part of UFS, but I remember ideas of
>  moving it to VFS),
> - suspend/resume fs,
> - buffer cache,
> - vnodes reclamation.
> I'm sure there are other examples.
>
> In my opinion we should do whatever we can to simplify VFS. Having
> complex VFS makes it harder, _not_ easier to develop file systems for
> and port file systems to FreeBSD. Interaction with VFS was definiately
> the hardest part of my work to port ZFS to FreeBSD.

It's also a large hassle when maintaining a custom VFS for a commercial product.

When we implemented multi-writer (either multiple nodes or multiple
threads on a node writing to a file) we had to add a new lockmgr(9)
lock type and implement range locks on the file data.  But the details
of my file system's range locking needs are not the same as yours.
And maybe your filesystem will never allow multi-writer since it
doesn't have the same performance concerns.

But then we need a bunch of new VOPs to attempt a DELTA locked
operation, and fail back to a SHARED or EXCLUSIVE when the filesystem
doesn't support it.  This becomes a large patch on vfs_* files to
maintain, making it harder to stay in sync with other FreeBSD changes.

So it's not just ZFS, that's just the most accessible example.

Cheers,
matthew


More information about the freebsd-arch mailing list