From: Steve Dickson <steved@redhat.com>
To: Richard Weinberger <richard@nod.at>
Cc: trond.myklebust@hammerspace.com, linux-nfs@vger.kernel.org,
chris.chilvers@appsbroker.com
Subject: Re: [PATCH] export: Fix rootdir corner case in next_mnt()
Date: Wed, 5 Apr 2023 12:29:57 -0400 [thread overview]
Message-ID: <ed63ab9d-e863-5596-1259-7d7efca2cf79@redhat.com> (raw)
In-Reply-To: <20230324121608.16808-1-richard@nod.at>
On 3/24/23 8:16 AM, Richard Weinberger wrote:
> Currently the following setup causes failure:
>
> 1. /etc/exports:
> / *(rw,crossmnt,no_subtree_check,fsid=root)
>
> 2. /etc/nfs.conf:
> [exports]
> rootdir=/nfs_srv
>
> 3. Mounts:
> /root/fs1.ext4 on /nfs_srv type ext4 (rw,relatime)
> /root/fs2.ext4 on /nfs_srv/fs2 type ext4 (rw,relatime)
>
> 4. On the client:
> $ ls /nfs_client/fs2
> ls: cannot open directory '/nfs_client/fs2': Stale file handle
>
> The problem is that next_mnt() misses the corner case that
> every mount is a sub-mount of "/".
> So it fails to see that /nfs_srv/fs2 is a mountpoint when the
> client asks for fs2 it and as consequence the crossmnt mechanism
> fails.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
Committed... (tag: nfs-utils-2-6-3-rc7)
steved.
> ---
> support/export/cache.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/support/export/cache.c b/support/export/cache.c
> index 2497d4f48df3..1c526277d3c6 100644
> --- a/support/export/cache.c
> +++ b/support/export/cache.c
> @@ -410,12 +410,16 @@ static char *next_mnt(void **v, char *p)
> *v = f;
> } else
> f = *v;
> - while ((me = getmntent(f)) != NULL && l > 1) {
> + while ((me = getmntent(f)) != NULL && l >= 1) {
> char *mnt_dir = nfsd_path_strip_root(me->mnt_dir);
>
> if (!mnt_dir)
> continue;
>
> + /* Everything below "/" is a proper sub-mount */
> + if (strcmp(p, "/") == 0)
> + return mnt_dir;
> +
> if (strncmp(mnt_dir, p, l) == 0 && mnt_dir[l] == '/')
> return mnt_dir;
> }
prev parent reply other threads:[~2023-04-05 16:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-24 12:16 [PATCH] export: Fix rootdir corner case in next_mnt() Richard Weinberger
2023-04-05 16:29 ` Steve Dickson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ed63ab9d-e863-5596-1259-7d7efca2cf79@redhat.com \
--to=steved@redhat.com \
--cc=chris.chilvers@appsbroker.com \
--cc=linux-nfs@vger.kernel.org \
--cc=richard@nod.at \
--cc=trond.myklebust@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox