From patchwork Fri Jul 29 05:03:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9252089 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E25E601C0 for ; Fri, 29 Jul 2016 05:05:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8114627F46 for ; Fri, 29 Jul 2016 05:05:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7596827F96; Fri, 29 Jul 2016 05:05:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DFE827F46 for ; Fri, 29 Jul 2016 05:05:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751329AbcG2FFV (ORCPT ); Fri, 29 Jul 2016 01:05:21 -0400 Received: from mx2.suse.de ([195.135.220.15]:35135 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751055AbcG2FFU (ORCPT ); Fri, 29 Jul 2016 01:05:20 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 12160AAF2; Fri, 29 Jul 2016 05:05:19 +0000 (UTC) From: NeilBrown To: Steve Dickson Date: Fri, 29 Jul 2016 15:03:36 +1000 Subject: [PATCH 7/7] mountd: fail nfsd.export lookup for path to unmounted exportpoint Cc: "J. Bruce Fields" , Linux NFS Mailing list Message-ID: <146976861683.20186.1810009593325251793.stgit@noble> In-Reply-To: <146976807524.20186.8871903418718212567.stgit@noble> References: <146976807524.20186.8871903418718212567.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If an export point should be mounted ("mountpoint" option set) but isn't, then an attempt to mount using the MOUNT protocol for NFSv3 will fail and an attempt to access the filesystem using a pre-existing filehandle will block because nfsd_fh wont tell the kernel about it. However a lookup from the parent, as happens with an NFSv4 mount request, will pass the name to nfsd_export(), and it doesn't check the mointpoint option, and so exports the underlying (typically "/") filesystem. So change nfsd_export() to refused to export that exportpoint, but instead to explictly say that it isn't exported. This will cause an 'ls' in the parent pseudo-root directory to not show the name and will cause a "mount" attempt which walks down through the pseudo root to fail in the same way that it does with NFSv3. An access from a pre-existing NFSv4 mount will still hang until the filesystem is mounted, just like it does with NFSv3. In order to be a bit more responsive to the filesystem getting mounted, just a short timeout (1 minutes) on exports of missing "mountpoint" exportpoints. Signed-off-by: NeilBrown --- utils/mountd/cache.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/utils/mountd/cache.c b/utils/mountd/cache.c index 9cc270690d90..ca6c84f4d93d 100644 --- a/utils/mountd/cache.c +++ b/utils/mountd/cache.c @@ -1334,7 +1334,23 @@ static void nfsd_export(int f) found = lookup_export(dom, path, ai); if (found) { - if (dump_to_cache(f, buf, sizeof(buf), dom, path, &found->m_export, 0) < 0) { + char *mp = found->m_export.e_mountpoint; + + if (mp && !*mp) + mp = found->m_export.e_path; + if (mp && !is_mountpoint(mp)) + /* Exportpoint is not mounted, so tell kernel it is + * not available. + * This will cause it not to appear in the V4 Pseudo-root + * and so a "mount" of this path will fail, just like with + * V3. + * And filehandle for this mountpoint from an earlier + * mount will block in nfsd.fh lookup. + */ + dump_to_cache(f, buf, sizeof(buf), dom, path, + NULL, 60); + else if (dump_to_cache(f, buf, sizeof(buf), dom, path, + &found->m_export, 0) < 0) { xlog(L_WARNING, "Cannot export %s, possibly unsupported filesystem" " or fsid= required", path);