Commit Graph

2 Commits

Author SHA1 Message Date
Zach Brown
df6a8af71f scoutfs: remove name from dirent keys
Directory entries were the last items that had large variable length
keys because they stored the entry name in the key.  We'd like to have
small fixed size keys so let's store dirents with small keys.

Entries for lookup are stored at the hash of the name instead of the
full name.  The key also contains the unique readdir pos so that we
don't have to deal with collision on creation.  The lookup procedure now
does need to iterate over all the readdir positions for the hash value
and compare the names.

Entries for link backref walking are stored with the entry's position in
the parent dir instead of the entry's name.  The name is then stored in
the value.  Inode to path conversion can still walk the backref items
without having to lookup dirent items.

These changes mean that all directory entry items are now stored at a
small key with some u64s (hash, pos, parent dir, etc) and have a value
with the dirent struct and full entry name.  This lets us use the same
key and value format for the three entry key types.  We no longer have
to allocate keys, we can store them on the stack.

We store the entry's hash and pos in the dirent struct in the item value
so that any item has all the fields to reference all the other item
keys.  We store the same values in the dentry_info so that deletion
(unlink and rename) can find all the entries.

The ino_path ioctl can now much more clearly iterate over parent
directories and entry positions instead of oh so cleverly iterating over
null terminated names in the parent directories.  The ioctl interface
structs and implementation become simpler.

Signed-off-by: Zach Brown <zab@versity.com>
2018-04-04 09:15:27 -05:00
Mark Fasheh
ac09f03327 scoutfs: open by handle
This is implemented by filling in our export ops functions.
When we get those right, the VFS handles most of the details for us.

Internally, scoutfs handles are two u64's (ino and parent ino) and a
type which indicates whether the handle contains the parent ino or not.
Surpisingly enough, no existing type matches this pattern so we use our
own types to identify the handle.

Most of the export ops are self explanatory scoutfs_encode_fh() takes
an inode and an optional parent and encodes those into the smallest
handle that would fit. scoutfs_fh_to_[dentry|parent] turn an existing
file handle into a dentry.

scoutfs_get_parent() is a bit different and would be called on
directory inodes to connect a disconnected dentry path. For
scoutfs_get_parent(), we can export add_next_linkref() and use the backref
mechanism to quickly find a parent directory.

scoutfs_get_name() is almost identical to scoutfs_get_parent(). Here we're
linking an inode to a name which exists in the parent directory. We can also
use add_next_linkref, and simply copy the name from the backref.

As a result of this patch we can also now export scoutfs file systems
via NFS, however testing NFS thoroughly is outside the scope of this
work so export support should be considered experimental at best.

Signed-off-by: Mark Fasheh <mfasheh@versity.com>
[zab edited <= NAME_MAX]
2018-01-26 11:59:47 -08:00