Subject: Misc layerfs questions
To: None <>
From: de SAINT LEGER Rodolphe <>
List: tech-kern
Date: 02/25/2002 23:04:47

I'm actually working on a new union filesystem, using the layerfs, mainly to make it nfs exportable, and also to try to make the shadow directories created only on write operations, a find wouldn't make shadow directories (or at least it could be an option like the above/below option).

As I'm not experienced about the VFS functions (especially locking) I'm looking
in the code of the following filesystems to get informations:

nullfs, overlayfs, genfs (layerfs), and of course union

I've got the following questions :

first, I've think there is a possible bug in the layerfs code, in the layerfs_lookup routine (this is actually the first routine I'm hanging around (the vfsops are already done for the moment), At the end of the function, we got a:

error = layer_node_create(...

if this works, no problem, but in an error case, nothing more is done, we just return the error code

I think that it can cause (where the layer_node_create fails) a vnode in the lower layer to stay locked (or vref) for ever (due to possible lock flags in the cnp structure) ...

I must say that I'm not familiar with lookup lock flags and I don't think I can make a piece of code that handle unlocking myself. Also I'm perhaps making a mistake, sorry for this if it is the case.

second, I've noticed that UNION were defined in other places of the kernel, I think this is for a mount -o union stuff, but I'm not sure, any clues ???

third, I want to use at least the maximum of the layerfs, it includes layer_node_create(). layer_node_create() calls a layer_node_alloc() defined in the layer_mount structure, All the hashlist stuff is done in the layer_node_alloc(). The main reason is that in a case of the layerfs improvment, the new unionfs would be improved too.

The problem is that union handle two (lower) layers and the layer_node_alloc only takes one, wich would make me to write both layer_node_create() and layer_node_alloc().

does someone have a solution to pass union specific parameters to layer_node_alloc() throught layer_node_create() ? If not is it planned to implement such a feature ?

The last problem I encounter is for shadow directories (".." lookups). I found a trick (I have not implemented it yet) which permit without any problem to create shadow directories only if necessary (not on cwd operation but on create, delete, rename, ... ops). I haven't seen for now how it is done in the union (the real one) but the main idea is that for one layerfs vnode we have two hashes (one for the upper union layer and one for the lower layer).

Is it safe to reference twice the same layerfs vnode with two lower vnodes hash values ?

Many thanks for help