From patchwork Sat Oct 20 14:53:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 10650557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D12B81750 for ; Sat, 20 Oct 2018 14:53:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF2B62861E for ; Sat, 20 Oct 2018 14:53:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C5D02863B; Sat, 20 Oct 2018 14:53:52 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 012252861E for ; Sat, 20 Oct 2018 14:53:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727397AbeJTXEe (ORCPT ); Sat, 20 Oct 2018 19:04:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45800 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727353AbeJTXEe (ORCPT ); Sat, 20 Oct 2018 19:04:34 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 269FD81DE5 for ; Sat, 20 Oct 2018 14:53:49 +0000 (UTC) Received: from steved.boston.devel.redhat.com (ovpn-120-63.rdu2.redhat.com [10.10.120.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC9A170465 for ; Sat, 20 Oct 2018 14:53:48 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH] mount.nfs: Only ignore EBUSY when a filesystem is already mount Date: Sat, 20 Oct 2018 10:53:47 -0400 Message-Id: <20181020145347.134233-1-steved@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Sat, 20 Oct 2018 14:53:49 +0000 (UTC) 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 EBUSY errors can be caused by using the -o sharecache flag and different context= values. So make sure the filesytem is mounted before ignoring the EBUSY error. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1629705 Found-by: Jianhong.Yin Signed-off-by: Steve Dickson --- utils/mount/Makefile.am | 1 + utils/mount/stropts.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/utils/mount/Makefile.am b/utils/mount/Makefile.am index 7b97c31..ad0be93 100644 --- a/utils/mount/Makefile.am +++ b/utils/mount/Makefile.am @@ -27,6 +27,7 @@ endif mount_nfs_LDADD = ../../support/nfs/libnfs.la \ ../../support/export/libexport.a \ + ../../support/misc/libmisc.a \ $(LIBTIRPC) mount_nfs_SOURCES = $(mount_common) diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c index 4d2e37e..eed0356 100644 --- a/utils/mount/stropts.c +++ b/utils/mount/stropts.c @@ -48,6 +48,7 @@ #include "version.h" #include "parse_dev.h" #include "conffile.h" +#include "misc.h" #ifndef NFS_PROGRAM #define NFS_PROGRAM (100003) @@ -1078,12 +1079,15 @@ static int nfsmount_fg(struct nfsmount_info *mi) if (nfs_try_mount(mi)) return EX_SUCCESS; - if (errno == EBUSY) - /* The only cause of EBUSY is if exactly the desired - * filesystem is already mounted. That can arguably - * be seen as success. "mount -a" tries to optimise - * out this case but sometimes fails. Help it out - * by pretending everything is rosy +#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers" + if (errno == EBUSY && is_mountpoint(mi->node)) +#pragma GCC diagnostic warning "-Wdiscarded-qualifiers" + /* + * EBUSY can happen when mounting a filesystem that + * is already mounted or when the context= are + * different when using the -o sharecache + * + * Only error out in the latter case. */ return EX_SUCCESS;