• Anton Altaparmakov's avatar
    NTFS: 2.0.8 release. Major updates for dcache aliasing issues wrt short/long file names. · ccc55c48
    Anton Altaparmakov authored
    In order to handle the case insensitivity issues of NTFS with regards to the
    dcache and the dcache requiring only one dentry per directory, we deal with
    dentry aliases that only differ in case in ->ntfs_lookup() while maintining
    a case sensitive dcache. This means that we get the full benefit of dcache
    speed when the file/directory is looked up with the same case as returned by
    ->ntfs_readdir() but that a lookup for any other case (or for the short file
    name) will not find anything in dcache and will enter ->ntfs_lookup()
    instead, where we search the directory for a fully matching file name
    (including case) and if that is not found, we search for a file name that
    matches with different case and if that has non-POSIX semantics we return
    that. We actually do only one search (case sensitive) and keep tabs on
    whether we have found a case insensitive match in the process.
    
    To simplify matters for us, we do not treat the short vs long filenames as
    two hard links but instead if the lookup matches a short filename, we
    return the dentry for the corresponding long filename instead.
    
    In ->ntfs_lookup() we distinguish three cases:
    
    1) @dent perfectly matches (i.e. including case) a directory entry with a
       file name in the WIN32 or POSIX namespaces. In this case
       ntfs_lookup_inode_by_name() will return with name set to NULL and we
       just d_add() @dent.
    2) @dent matches (not including case) a directory entry with a file name in
       the WIN32 namespace. In this case ntfs_lookup_inode_by_name() will return
       with name set to point to a kmalloc()ed ntfs_name structure containing
       the properly cased little endian Unicode name. We convert the name to the
       current NLS code page, search if a dentry with this name already exists
       and if so return that instead of @dent. The VFS will then destroy the old
       @dent and use the one we returned. If a dentry is not found, we allocate
       a new one, d_add() it, and return it as above.
    3) @dent matches either perfectly or not (i.e. we don't care about case) a
       directory entry with a file name in the DOS namespace. In this case
       ntfs_lookup_inode_by_name() will return with name set to point to a
       kmalloc()ed ntfs_name structure containing the mft reference (cpu endian)
       of the inode. We use the mft reference to read the inode and to find the
       file name in the WIN32 namespace corresponding to the matched short file
       name. We then convert the name to the current NLS code page, and proceed
       searching for a dentry with this name, etc, as in case 2), above.
    ccc55c48
namei.c 10.2 KB