Bug 1961523

Summary: autofs: amd map hosts mount failing
Product: Red Hat Enterprise Linux 8 Reporter: Ian Kent <ikent>
Component: autofsAssignee: Ian Kent <ikent>
Status: CLOSED DUPLICATE QA Contact: Kun Wang <kunwan>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.5CC: xzhou
Target Milestone: betaKeywords: Regression, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-19 00:59:25 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ian Kent 2021-05-18 07:39:18 UTC
Description of problem:
As a result of the changes for bug 1912106 I have found a couple more regressions, this is the last one I'm aware of.

This is due to an amd mounted mount entry not being added for certain hosts of an amd hosts mount.

Version-Release number of selected component (if applicable):
autofs-5.1.4-68.el8

How reproducible:
Always for certain amd hosts mount type maps.

Steps to Reproduce:
Steps to Reproduce:
1. Setup an NFS server with out of order exports.

Note: the server name I use below is f28 and it is define
in /etc/hosts with an FQDN of f28.long.domain.name.themaw.net.

mkdir /autofs
mkdir /exports
mkdir /exports/data/tmp
mkdir /exports/data/lib

Create /etc/exports as:
/autofs         *(rw,sync,no_subtree_check)
/exports                *(insecure,rw,sync,no_subtree_check)
/exports/data/tmp       *(insecure,rw,sync,no_subtree_check)
/exports/data/lib       *(insecure,rw,sync,no_subtree_check)

Check order of exports returned:
showmount -e
Export list for f28:
/exports/data/lib *
/exports/data/tmp *
/exports          *
/autofs           *

2. Add an amd entry to /etc/auto.master
/test/redhat    file,amd:/etc/amd.redhat

Where /etc/amd.redhat contains, say:
exports   fs:=${map};pref:=${key}
exports/* hostd==${/key}.long.domain.name.themaw.net;type:=link;fs:=/ \
          hostd!=${/key}.long.domain.name.themaw.net; \
            type:=host; rhost:=${/key}.long.domain.name.themaw.net;\
            opts:=rw,hard,intr,nosuid,retrans=9,timeo=45;\
            fs:=${autodir}/redhat/${key}

You might need to get rid of the line continueations following the
hostd!=...

3. Start autofs and try to mount /test/redhat/exports/f28/exports/data/tmp     
   and observe that the offset (and the NFS mount) for export /exports/data/tmp
   has not been mounted:
service autofs start
ls /test/redhat/exports/f28/exports/data/tmp
ls: cannot access '/test/redhat/exports/f28/exports/data/tmp': No such file or directory
cat /proc/mounts|grep \/exports\/data\tmp

4. stop autofs and observe that shutdown has not succeeded
   cleanly, as it should in this case.
service stop autofs
cat /proc/mounts|grep \/test\/redhat
/etc/amd.redhat /test/redhat autofs rw,relatime,fd=-1,pgrp=23146,timeout=60,minproto=5,maxproto=5,indirect,pipe_ino=-1 0 0
/etc/amd.redhat /test/redhat/exports autofs rw,relatime,fd=-1,pgrp=23146,timeout=60,minproto=5,maxproto=5,indirect,pipe_ino=-1 0 0
/etc/amd.redhat /test/redhat/exports/f28.long.domain.name.themaw.net/exports autofs rw,relatime,fd=21,pgrp=23146,timeout=60,minproto=5,maxproto=5,offset,pipe_ino=129608 0 0

5. Cleanup
umount /test/redhat/exports/f28.long.domain.name.themaw.net/exports /test/redhat/exports /test/redhat

Actual results:
The mount above fails and following the mount attempt autofs is not able to shutdown cleanly.

Expected results:
The mount succeeds and autofs is able to shutdown cleanly.