Blame SOURCES/quota-4.02-Skip-NFS-mounts-without-rquotad-RPC-service-silently.patch

370c56
From bffaeb028ee716ed46e5b74a45162f2ef45b2963 Mon Sep 17 00:00:00 2001
370c56
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
370c56
Date: Thu, 23 Oct 2014 14:12:01 +0200
370c56
Subject: [PATCH] Skip NFS mounts without rquotad RPC service silently
370c56
MIME-Version: 1.0
370c56
Content-Type: text/plain; charset=UTF-8
370c56
Content-Transfer-Encoding: 8bit
370c56
370c56
If NFS server does uses quotas, then it's high chance the RCP rquotad
370c56
service is not running at all. Then listing quotas for such NFS mount
370c56
point results into a warning about "connection refused".
370c56
370c56
This warning can be obtrusive if a host has mounted various mixture of
370c56
NFS exports with and without quotas.
370c56
370c56
This patch recognizes this special error state (after performing
370c56
a query to a client without running rquotad) and considers such
370c56
server as having quotas disabled. This silents the warning
370c56
effectively.
370c56
370c56
JK: Some coding style fixes, treat also rpc_set_quota() this way.
370c56
370c56
Signed-off-by: Petr Písař <ppisar@redhat.com>
370c56
Signed-off-by: Jan Kara <jack@suse.cz>
370c56
---
370c56
 rquota_client.c | 38 ++++++++++++++++++++++++++++++++++----
370c56
 1 file changed, 34 insertions(+), 4 deletions(-)
370c56
370c56
diff --git a/rquota_client.c b/rquota_client.c
370c56
index 9d4055e..a3a4ae3 100644
370c56
--- a/rquota_client.c
370c56
+++ b/rquota_client.c
370c56
@@ -148,6 +148,8 @@ int rpc_rquota_get(struct dquot *dquot)
370c56
 	} args;
370c56
 	char *fsname_tmp, *host, *pathname;
370c56
 	struct timeval timeout = { 2, 0 };
370c56
+	int rquotaprog_not_registered = 0;
370c56
+	int ret;
370c56
 
370c56
 	/*
370c56
 	 * Initialize with NULL.
370c56
@@ -206,8 +208,11 @@ int rpc_rquota_get(struct dquot *dquot)
370c56
 		auth_destroy(clnt->cl_auth);
370c56
 		clnt_destroy(clnt);
370c56
 	}
370c56
-	else
370c56
+	else {
370c56
 		result = NULL;
370c56
+		if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED)
370c56
+			rquotaprog_not_registered = 1;
370c56
+	}
370c56
 
370c56
 	if (result == NULL || !result->status) {
370c56
 		if (dquot->dq_h->qh_type == USRQUOTA) {
370c56
@@ -244,11 +249,21 @@ int rpc_rquota_get(struct dquot *dquot)
370c56
 				 */
370c56
 				auth_destroy(clnt->cl_auth);
370c56
 				clnt_destroy(clnt);
370c56
+			} else {
370c56
+				result = NULL;
370c56
+				if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED)
370c56
+					    rquotaprog_not_registered = 1;
370c56
 			}
370c56
 		}
370c56
 	}
370c56
 	free(fsname_tmp);
370c56
-	return rquota_err(result?result->status:-1);
370c56
+	if (result)
370c56
+		ret = result->status;
370c56
+	else if (rquotaprog_not_registered)
370c56
+		ret = Q_NOQUOTA;
370c56
+	else
370c56
+		ret = -1;
370c56
+	return rquota_err(ret);
370c56
 }
370c56
 
370c56
 /*
370c56
@@ -265,6 +280,8 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot)
370c56
 	} args;
370c56
 	char *fsname_tmp, *host, *pathname;
370c56
 	struct timeval timeout = { 2, 0 };
370c56
+	int rquotaprog_not_registered = 0;
370c56
+	int ret;
370c56
 
370c56
 	/* RPC limits values to 32b variables. Prevent value wrapping. */
370c56
 	if (check_dquot_range(dquot) < 0)
370c56
@@ -321,8 +338,11 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot)
370c56
 		auth_destroy(clnt->cl_auth);
370c56
 		clnt_destroy(clnt);
370c56
 	}
370c56
-	else
370c56
+	else {
370c56
 		result = NULL;
370c56
+		if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED)
370c56
+			rquotaprog_not_registered = 1;
370c56
+	}
370c56
 
370c56
 	if (result == NULL || !result->status) {
370c56
 		if (dquot->dq_h->qh_type == USRQUOTA) {
370c56
@@ -361,11 +381,21 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot)
370c56
 				 */
370c56
 				auth_destroy(clnt->cl_auth);
370c56
 				clnt_destroy(clnt);
370c56
+			} else {
370c56
+				result = NULL;
370c56
+				if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED)
370c56
+					rquotaprog_not_registered = 1;
370c56
 			}
370c56
 		}
370c56
 	}
370c56
 	free(fsname_tmp);
370c56
-	return rquota_err(result?result->status:-1);
370c56
+	if (result)
370c56
+		ret = result->status;
370c56
+	else if (rquotaprog_not_registered)
370c56
+		ret = Q_NOQUOTA;
370c56
+	else
370c56
+		ret = -1;
370c56
+	return rquota_err(ret);
370c56
 #endif
370c56
 	return -1;
370c56
 }
370c56
-- 
370c56
1.9.3
370c56