lkml.org 
[lkml]   [2008]   [Aug]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC] readdir mess


On Wed, 13 Aug 2008, Al Viro wrote:
>
> What _can_ a common helper do, anyway, when we are busy parsing an arseload of
> possibly corrupt data in whatever weird format fs insists upon?

Well, the parsing has to be done by the low-level filesystem code, yes.

However, the whole thing with races with "f_pos" and all the locking -
that's only because we see the filesystem "readdir" code as being the
primary source of data.

Quite frankly, if we had a "readdir page cache", the low-level filesystem
would still have to parse the insane low-level data with corruption
issues, but we could make it totally independent of f_pos (because we
would never use in the _real_ file->f_pos - we would just populate the
cache), and the locking issues would be only a cold-cache issue, with the
hot-cache hopefully needing little locking at all.

For an exmple of that: you did a good job with all the "seq_file" helpers,
which meant that the low-level "filesystem" ops didn't need to know
_anything_ about partial results etc, and it automatically did the right
thing wrt f_pos updates and lseek etc.

I'm not saying that readdir() would use the _same_ model, but I do suspect
that a common format in between the disk format and the eventual readdir()
output, that also could be cached, might mitigate a lot of the problems.

As to the issues with lookup() - yes, a lookup would need to get the lock
for writing, but only for the last entry, and only if O_CREAT is set.
There's nothing wrogn with concurrent read-only lookups, I think (apart
from having to protect the dentries from being duplicated, of course, but
that would be a per-dentry lock flag, not a directory lock, methinks).

I dunno.

That said, I think you are right that we could also just improve on the
current non-caching version with soem higher-level semantics. Including
flags like "yes, we've seen the end", so that we don't need to always call
into the low-level filesystem one extra time to see that final zero
return.

So yes, instead of separate "filldir_t" and "void *data" things, having a
"struct filldir_t" with several fields in common might be worth it.

Linus


\
 
 \ /
  Last update: 2008-08-13 03:55    [W:0.048 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site