• Ian Kent's avatar
    autofs: add per dentry expire timeout · 433f9d76
    Ian Kent authored
    Add ability to set per-dentry mount expire timeout to autofs.
    
    There are two fairly well known automounter map formats, the autofs
    format and the amd format (more or less System V and Berkley).
    
    Some time ago Linux autofs added an amd map format parser that
    implemented a fair amount of the amd functionality. This was done
    within the autofs infrastructure and some functionality wasn't
    implemented because it either didn't make sense or required extra
    kernel changes. The idea was to restrict changes to be within the
    existing autofs functionality as much as possible and leave changes
    with a wider scope to be considered later.
    
    One of these changes is implementing the amd options:
    1) "unmount", expire this mount according to a timeout (same as the
       current autofs default).
    2) "nounmount", don't expire this mount (same as setting the autofs
       timeout to 0 except only for this specific mount) .
    3) "utimeout=<seconds>", expire this mount using the specified
       timeout (again same as setting the autofs timeout but only for
       this mount).
    
    To implement these options per-dentry expire timeouts need to be
    implemented for autofs indirect mounts. This is because all map keys
    (mounts) for autofs indirect mounts use an expire timeout stored in
    the autofs mount super block info. structure and all indirect mounts
    use the same expire timeout.
    
    Now I have a request to add the "nounmount" option so I need to add
    the per-dentry expire handling to the kernel implementation to do this.
    
    The implementation uses the trailing path component to identify the
    mount (and is also used as the autofs map key) which is passed in the
    autofs_dev_ioctl structure path field. The expire timeout is passed
    in autofs_dev_ioctl timeout field (well, of the timeout union).
    
    If the passed in timeout is equal to -1 the per-dentry timeout and
    flag are cleared providing for the "unmount" option. If the timeout
    is greater than or equal to 0 the timeout is set to the value and the
    flag is also set. If the dentry timeout is 0 the dentry will not expire
    by timeout which enables the implementation of the "nounmount" option
    for the specific mount. When the dentry timeout is greater than zero it
    allows for the implementation of the "utimeout=<seconds>" option.
    Signed-off-by: default avatarIan Kent <raven@themaw.net>
    Link: https://lore.kernel.org/r/20240814090231.963520-1-raven@themaw.netSigned-off-by: default avatarChristian Brauner <brauner@kernel.org>
    433f9d76
expire.c 14.4 KB