Re: [PATCH] [Request for inclusion] Filesystem in Userspace

Miklos Szeredi
2004-11-25T09:53:20Z

> > Why not? I can set bdi->memory_backed to 1 just like ramfs, implement
> > my own writeback thread, and voila, no deadlock.
>
> Yes, you can. Just you have to take care never to occupy too much
> memory.

Yes, this is the hard part IMO, because it should be done in a way
that when FUSE wants a new writable page and it's over the limit, it
should block until it goes under the limit. Not trivial at all.

> > Of course I believe, that it's probably easier to tweak the page cache
> > to teach it that fuse pages _can_ be written back, but not reliably
> > like a disk filesystem. And there's the small problem of limiting the
> > number of writable pages allocated to FUSE.
>
> It's not that easy. How do you tell when the page is no longer likely to
> get cleaned?

Tell the page cache it's never going to get cleaned, but call the
writepage() anyway. It's sort of splitting the bdi->memory_backed
flag into two: dont_count_as_dirty and dont_writeback. Ramfs, etc
would set both, FUSE would set only dont_count_as_dirty. See what I'm
thinking of?

> The file backing would be easier, but to be really easy, the interface
> would be a bit different (and actualy simpler, since it would need no
> data channel, just a control one).

That's not a problem.

> The trick is, that the coda file-granularity interface is not that hard
> to extend to page-granularity. Several filesystems allow "files with
> holes". So the fuse process could just touch a file and truncate it to
> desired length on open. Then kernel would tell it which pages it wants
> and the process would acknowledge when they are actualy filled. For
> write, kernel would just notify the process of dirty ranges and what --
> and when -- the process does with that is not kernel's business.

Yes, this would be a nice interface. How would you solve the problem
of freeing the space which is no longer needed?

Imagine that you have a 4G virtual file on a FUSE filesystem, and some
process is reading that file sequentially. But there's only 10MByte
of free space on the local disk. With the above method you'd never be
able to read the whole file. Do you see the problem?

Miklos