On Tue, Nov 17, 2020 at 10:16:49AM -0800, Eric Biggers wrote: > > Here's a suggestion which I think explains it a lot better. It's still possible > I'm misunderstanding something, though, so please check it carefully: > > /** > * generic_set_encrypted_ci_d_ops - helper for setting d_ops for given dentry > * @dentry: dentry to set ops on > * > * Casefolded directories need d_hash and d_compare set, so that the dentries > * contained in them are handled case-insensitively. Note that these operations > * are needed on the parent directory rather than on the dentries in it, and the > * casefolding flag can be enabled on an empty directory later but the > * dentry_operations can't be changed later. As a result, if the filesystem has > * casefolding support enabled at all, we have to give all dentries the > * casefolding operations even if their inode doesn't have the casefolding flag > * currently (and thus the casefolding ops would be no-ops for now). > * > * Encryption works differently in that the only dentry operation it needs is > * d_revalidate, which it only needs on dentries that have the no-key name flag. > * The no-key flag can't be set "later", so we don't have to worry about that. > * > * Finally, to maximize compatibility with overlayfs (which isn't compatible > * with certain dentry operations) and to avoid taking an unnecessary > * performance hit, we use custom dentry_operations for each possible > * combination rather always installing all operations. > */ Last line in my suggestion has a typo: "rather" => "rather than". - Eric