Skip to contentSkip to conversation

Reconsidering exportable UBIFS

DISCUSSION Richard Weinberger 4 participants 7 messages Apr 4, 2016 – May 11, 2016

Subsystems (4)
lore
Share & tools
lore

Richard Weinberger

author maintainer
#0 lore raw

Hi!

Currently UBIFS is not exportable.
I'm not sure whether it is completely impossible or if I just miss a detail. So I've some questions.

Documentation/filesystems/nfs/Exporting states that the only required function is fh_to_dentry().
This function should on UBIFS be implementable using generic_fh_to_dentry(). While UBIFS reuses in theory inode numbers we can ignore i_generation as the flash chip is long dead before we start reusing inodes. Same as for JFFS2. But the same document states also that fh_to_parent() and get_parent() are optional but strongly recommended.
What does this mean? Will NFS work but puppies die and turn into zombies?

Implementing get_parent() is a little unpleasant. UBIFS's on-flash layout does not support querying the parent. We could change UBIFS's struct ubifs_ino_node, but I'd change the on-flash layout only as last resort.

The biggest problem I see is that UBIFS does not really support telldir() and seekdir().
Directory offsets in UBIFS are plain hash values, so telldir()/seekdir() won't correctly work if UBIFS faces hash collisions.
Currently UBIFS implements a hack which stores the UBIFS dent object into file->private_data such that consecutive readdir()s are guaranteed to work. A comment on UBIFS's readdir states:
* This means that UBIFS cannot support NFS which requires full
* 'seekdir()'/'telldir()' support.

Is this still true? Maybe we can have NFS even if it is not perfect in terms of performance.

Artem, did I miss another show stopper? :-)

Thanks,
//richard

#1 lore raw
Quoted 5 lines · Richard Weinberger

The biggest problem I see is that UBIFS does not really support telldir()
and seekdir().
Directory offsets in UBIFS are plain hash values, so telldir()/seekdir() won't

Quoted 8 lines

correctly work if UBIFS faces hash collisions.
Currently UBIFS implements a hack which stores the UBIFS dent object into
file->private_data such that consecutive readdir()s are guaranteed to work.
A comment on UBIFS's readdir states:
 * This means that UBIFS cannot support NFS which requires full
 * 'seekdir()'/'telldir()' support.

Richard, I do not remember much about NFS support. I can only say that I never really put efforts into this, unfortunately.
Here is an old discussion which could give you some more hints:

http://marc.info/?l=linux-nfsv4&m=126480082613293&w=2

Artem.

#2 lore raw
In reply to Richard Weinberger

(added [email protected])

Quoted 6 lines · Richard Weinberger

Hi!

Currently UBIFS is not exportable.
I'm not sure whether it is completely impossible or if I just miss a detail. So I've some questions.

Quoted 9 lines

Documentation/filesystems/nfs/Exporting states that the only required function is fh_to_dentry().
This function should on UBIFS be implementable using generic_fh_to_dentry(). While UBIFS reuses in theory inode numbers we can ignore i_generation as the flash chip is long dead before we start reusing inodes. Same as for JFFS2. But the same document states also that fh_to_parent() and get_parent() are optional but strongly recommended.
What does this mean? Will NFS work but puppies die and turn into zombies?

Not puppies, just kittens.

If you don't provide these functions, then exporting with "subtree_check" won't work. That is no great loss except that people might find the failure confusing.

Quoted 16 lines

Implementing get_parent() is a little unpleasant. UBIFS's on-flash layout does not support querying the parent. We could change UBIFS's struct ubifs_ino_node, but I'd change the on-flash layout only as last resort.

The biggest problem I see is that UBIFS does not really support telldir() and seekdir().
Directory offsets in UBIFS are plain hash values, so telldir()/seekdir() won't correctly work if UBIFS faces hash collisions.
Currently UBIFS implements a hack which stores the UBIFS dent object into file->private_data such that consecutive readdir()s are guaranteed to work. A comment on UBIFS's readdir states:
* This means that UBIFS cannot support NFS which requires full
* 'seekdir()'/'telldir()' support.

Quoted 2 lines

Is this still true? Maybe we can have NFS even if it is not perfect in terms of performance.

How big are your hashes?
ext3 messed up their readdir/telldir design too so they don't have guaranteed unique keys.
When using 32bit hashes you can definitely get problems with collisions. I have not heard of problems with 64bit hashes.

I may have the details slightly wrong, but as I recall non-uniqueness of cookies only causes a problem when the last cookie returned in a READDIR reply matches the first cookie returned in reply to the next readdir. So non-uniqueness is only a problem when it aligns badly.

NeilBrown

Quoted 9 lines

Artem, did I miss another show stopper? :-)

Thanks,
//richard
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#3 lore raw
Quoted 5 lines · NeilBrown

Not puppies, just kittens.

If you don't provide these functions, then exporting with "subtree_check" won't work. That is no great loss except that people might find the failure confusing.

OK, a client sends you a RENAME. With fhandles of both parents +
old and new names in those. Your task, should you choose to accept it, is to figure out whether we should fail with nfserr_inval due to an attempt to make a directory its own descendent. Without being able to locate all ancestors of a directory.

You are fond of complaining about the checks that could've been left
to server not getting skipped on the client. Now you want to skip them on the server side as well? Can't have it both ways...

Seriously, it really doesn't work. You can't do directory
modifications without having found the chain of ancestors. No ->get_parent() is OK _only_ for something like tmpfs, where we have the full chains of ancestors towards root all the time. For UBIFS it's obviously not true. Not unless you suck the entire directory tree in memory at the mount time.

#4 lore raw
Quoted 8 lines · Al Viro
Quoted 5 lines · NeilBrown

Not puppies, just kittens.

If you don't provide these functions, then exporting with "subtree_check" won't work. That is no great loss except that people might find the failure confusing.

Quoted 5 lines

OK, a client sends you a RENAME. With fhandles of both parents +
old and new names in those. Your task, should you choose to accept it, is to figure out whether we should fail with nfserr_inval due to an attempt to make a directory its own descendent. Without being able to locate all ancestors of a directory.

You are right, sorry. I was thinking that get_parent() was for finding the parent of a non-directory, but it is for directories. It does the equivalent of lookup(".."). So if you have a ".." link or something like it, it should be easy. If you don't, it won't be easy at all.

Thanks,
NeilBrown

Quoted 10 lines

You are fond of complaining about the checks that could've been left
to server not getting skipped on the client. Now you want to skip them on the server side as well? Can't have it both ways...

Seriously, it really doesn't work. You can't do directory
modifications without having found the chain of ancestors. No ->get_parent() is OK _only_ for something like tmpfs, where we have the full chains of ancestors towards root all the time. For UBIFS it's obviously not true. Not unless you suck the entire directory tree in memory at the mount time.

author maintainer
#5 lore raw

Am 09.05.2016 um 07:03 schrieb NeilBrown:

Quoted 16 lines · Al Viro
Quoted 9 lines · NeilBrown
Quoted 6 lines

Not puppies, just kittens.

If you don't provide these functions, then exporting with "subtree_check" won't work. That is no great loss except that people might find the failure confusing.

Quoted 5 lines

OK, a client sends you a RENAME. With fhandles of both parents +
old and new names in those. Your task, should you choose to accept it, is to figure out whether we should fail with nfserr_inval due to an attempt to make a directory its own descendent. Without being able to locate all ancestors of a directory.

Quoted 4 lines

You are right, sorry. I was thinking that get_parent() was for finding the parent of a non-directory, but it is for directories. It does the equivalent of lookup(".."). So if you have a ".." link or something like it, it should be easy. If you don't, it won't be easy at all.

Thanks for the detailed explanation.
UBIFS does not have ".." links in the on-flash layout. So, we'd have to change this.

Thanks,
//richard

author maintainer
#6 lore raw
In reply to NeilBrown

Am 09.05.2016 um 00:18 schrieb NeilBrown:

Quoted 19 lines
Quoted 10 lines

The biggest problem I see is that UBIFS does not really support telldir() and seekdir().
Directory offsets in UBIFS are plain hash values, so telldir()/seekdir() won't correctly work if UBIFS faces hash collisions.
Currently UBIFS implements a hack which stores the UBIFS dent object into file->private_data such that consecutive readdir()s are guaranteed to work. A comment on UBIFS's readdir states:
* This means that UBIFS cannot support NFS which requires full
* 'seekdir()'/'telldir()' support.

Quoted 2 lines

Is this still true? Maybe we can have NFS even if it is not perfect in terms of performance.

How big are your hashes?
ext3 messed up their readdir/telldir design too so they don't have guaranteed unique keys.
When using 32bit hashes you can definitely get problems with collisions. I have not heard of problems with 64bit hashes.

Quoted 4 lines

I may have the details slightly wrong, but as I recall non-uniqueness of cookies only causes a problem when the last cookie returned in a READDIR reply matches the first cookie returned in reply to the next readdir. So non-uniqueness is only a problem when it aligns badly.

UBIFS is using 32bit hashes, r5 hash from reiserfs. ;-\

Thanks,
//richard