Add support for directories

When creating a new directory of file, the directory entry should be
added to the KHO inode so it can be restored after KHO. This is done via
shmem_kho_mknod(). It currently co-exists simple_offset, though it might
not be strictly needed. The insertion of a dirent is simple: just add it
to the end of the list of dirents in a KHO inode. Before the first KHO
kexec, this is all that should be needed since all dirents will exist in
the dcache.

After kexec, the dcache is initialized lazily. When a dirent is looked
up, it is initialized and added to the dcache. To achieve this lazy
initialization, a lookup callback is needed. This is done via
shmem_lookup(). For non-KHO mounts, it behaves same as before by calling
simple_lookup(). Otherwise, it loops through the dirents in the KHO
inode, looks for one with a matching name, and splices it dentry in.

Since we do lazy lookup, simple_offset also doesn't work directly
anymore. So shmem_kho_readdir() is added to allow listing directory
entries. This is only used after kexec.

On the unlink side, the dirent is removed, and other dirents shifted up
to fill the blank slot.

NOTE: As with every patch is this series, the code here is very hacky
and quickly put together to get a proof-of-concept. So the code is full
of bugs and problems, and will be significantly improved before the
first round of patches on the list.

Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
1 file changed