On Mon, 2020-09-14 at 09:26 -0400, Jeff Layton wrote:
 On Mon, 2020-09-14 at 19:32 +0800, liuwei wrote:
 > Hi,
 > I found many error info in the ganesha.log when stop nfs-ganesha.service, as
follows.
 > ganesha.log:
 > :ganesha.nfsd-1550083[Admin] mdcache_lru_clean INODE:F_DBG:Trusting op_ctx export id
2
 > :ganesha.nfsd-1550083[Admin] posix2fsal_error:FSAL:CRIT:Default case mapping
Transport endpoint is not connected (107) to ERR_FSAL_SERVERFAULT
 > :ganesha.nfsd-1550083[Admin]
 > mdcache_Iru_clean:INODE LRU:CRIT:Error closing file in cleanup:Undefined server
error
 > My version info: Ganesha-3.3+FSAL_CEPH(ceph version 14.2.10);
 >  
We should probably add a patch similar to this. I don't have the cycles
to test this at the moment. liuwei, would you be able to do so?
---------------------------8<----------------------------
FSAL_CEPH: paper over -ENOTCONN return from close when shutting down
When we're shutting down the server, we'll usually abort the connection
first. The mdcache will then try to clean up entries and issue a ->close
to each, and FSAL_CEPH ends up returning -ENOTCONN in that situation
which causes a lot of log spam.
Fix this by just ignoring -ENOTCONN errors in ceph_close_my_fd when
ganesha is shutting down.
Change-Id: If8231998a61e759be4d044f102ae6dbcebfdc975
Reported-by: liuwei <liuwei_coder(a)163.com>
Signed-off-by: Jeff Layton <jlayton(a)redhat.com>
---
 src/FSAL/FSAL_CEPH/handle.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/FSAL/FSAL_CEPH/handle.c b/src/FSAL/FSAL_CEPH/handle.c
index 464db598e6c8..c5891894bd01 100644
--- a/src/FSAL/FSAL_CEPH/handle.c
+++ b/src/FSAL/FSAL_CEPH/handle.c
@@ -45,6 +45,7 @@
 #include "nfs_exports.h"
 #include "sal_data.h"
 #include "statx_compat.h"
+#include "nfs_core.h"
 #include "linux/falloc.h"
 
 /**
@@ -863,15 +864,22 @@ static fsal_status_t ceph_open_my_fd(struct ceph_handle *myself,
 
 static fsal_status_t ceph_close_my_fd(struct ceph_fd *my_fd)
 {
-	int rc = 0;
 	fsal_status_t status = fsalstat(ERR_FSAL_NO_ERROR, 0);
 	struct ceph_export *export =
 		container_of(op_ctx->fsal_export, struct ceph_export, export);
 
 	if (my_fd->fd != NULL && my_fd->openflags != FSAL_O_CLOSED) {
-		rc = ceph_ll_close(export->cmount, my_fd->fd);
-		if (rc < 0)
+		int rc = ceph_ll_close(export->cmount, my_fd->fd);
+
+		if (rc < 0) {
+			/*
+			 * We expect -ENOTCONN errors on shutdown. Ignore
+			 * them so we don't spam the logs.
+			 */
+			if (rc == -ENOTCONN && admin_shutdown)
+				rc = 0;
 			status = ceph2fsal_error(rc);
+		}
 		my_fd->fd = NULL;
 		my_fd->openflags = FSAL_O_CLOSED;
 	}
-- 
2.26.2