|
|
5eda098 |
From 4cd287f3fa3838a31eb6636366f8ce26ee6e1425 Mon Sep 17 00:00:00 2001
|
|
|
5eda098 |
From: Jan Kara <jack@suse.cz>
|
|
|
5eda098 |
Date: Tue, 28 May 2019 10:52:49 +0200
|
|
|
5eda098 |
Subject: [PATCH] rpc: Clarify error message when cannot connect to rpc.rquotad
|
|
|
5eda098 |
MIME-Version: 1.0
|
|
|
5eda098 |
Content-Type: text/plain; charset=UTF-8
|
|
|
5eda098 |
Content-Transfer-Encoding: 8bit
|
|
|
5eda098 |
|
|
|
5eda098 |
Currently when RPC rquota service is not registered, we report somewhat
|
|
|
5eda098 |
confusing "No such file of directory" error. For other errors when
|
|
|
5eda098 |
creating rquota request we report "Connection refused". There's no big
|
|
|
5eda098 |
difference for user between these errors and neither of them tells what
|
|
|
5eda098 |
really happened. So just unify handling of these errors and report more
|
|
|
5eda098 |
general error telling the user where the problem is.
|
|
|
5eda098 |
|
|
|
5eda098 |
Signed-off-by: Jan Kara <jack@suse.cz>
|
|
|
5eda098 |
Signed-off-by: Petr Písař <ppisar@redhat.com>
|
|
|
5eda098 |
---
|
|
|
5eda098 |
quotaops.c | 14 +++++++++-----
|
|
|
5eda098 |
rquota_client.c | 14 --------------
|
|
|
5eda098 |
2 files changed, 9 insertions(+), 19 deletions(-)
|
|
|
5eda098 |
|
|
|
5eda098 |
diff --git a/quotaops.c b/quotaops.c
|
|
|
5eda098 |
index e067d29..16475e8 100644
|
|
|
5eda098 |
--- a/quotaops.c
|
|
|
5eda098 |
+++ b/quotaops.c
|
|
|
5eda098 |
@@ -124,16 +124,20 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int ignore_noquo
|
|
|
5eda098 |
#endif
|
|
|
5eda098 |
|
|
|
5eda098 |
if (!(q = handles[i]->qh_ops->read_dquot(handles[i], id))) {
|
|
|
5eda098 |
- int olderrno = errno;
|
|
|
5eda098 |
+ char *estr;
|
|
|
5eda098 |
|
|
|
5eda098 |
- /* If rpc.rquotad is not running filesystem might be just without quotas... */
|
|
|
5eda098 |
- if (ignore_noquota &&
|
|
|
5eda098 |
- (errno == ENOENT || errno == ECONNREFUSED))
|
|
|
5eda098 |
+ /* If rpc.rquotad is not running, filesystem might be just without quotas... */
|
|
|
5eda098 |
+ if (ignore_noquota && errno == ECONNREFUSED)
|
|
|
5eda098 |
continue;
|
|
|
5eda098 |
|
|
|
5eda098 |
+ if (errno == ECONNREFUSED) {
|
|
|
5eda098 |
+ estr = "Cannot connect to RPC quota service";
|
|
|
5eda098 |
+ } else {
|
|
|
5eda098 |
+ estr = strerror(errno);
|
|
|
5eda098 |
+ }
|
|
|
5eda098 |
id2name(id, handles[i]->qh_type, name);
|
|
|
5eda098 |
errstr(_("error while getting quota from %s for %s (id %u): %s\n"),
|
|
|
5eda098 |
- handles[i]->qh_quotadev, name, id, strerror(olderrno));
|
|
|
5eda098 |
+ handles[i]->qh_quotadev, name, id, estr);
|
|
|
5eda098 |
out_err:
|
|
|
5eda098 |
freeprivs(qhead);
|
|
|
5eda098 |
return NULL;
|
|
|
5eda098 |
diff --git a/rquota_client.c b/rquota_client.c
|
|
|
5eda098 |
index a3a4ae3..7f8e821 100644
|
|
|
5eda098 |
--- a/rquota_client.c
|
|
|
5eda098 |
+++ b/rquota_client.c
|
|
|
5eda098 |
@@ -148,7 +148,6 @@ int rpc_rquota_get(struct dquot *dquot)
|
|
|
5eda098 |
} args;
|
|
|
5eda098 |
char *fsname_tmp, *host, *pathname;
|
|
|
5eda098 |
struct timeval timeout = { 2, 0 };
|
|
|
5eda098 |
- int rquotaprog_not_registered = 0;
|
|
|
5eda098 |
int ret;
|
|
|
5eda098 |
|
|
|
5eda098 |
/*
|
|
|
5eda098 |
@@ -210,8 +209,6 @@ int rpc_rquota_get(struct dquot *dquot)
|
|
|
5eda098 |
}
|
|
|
5eda098 |
else {
|
|
|
5eda098 |
result = NULL;
|
|
|
5eda098 |
- if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED)
|
|
|
5eda098 |
- rquotaprog_not_registered = 1;
|
|
|
5eda098 |
}
|
|
|
5eda098 |
|
|
|
5eda098 |
if (result == NULL || !result->status) {
|
|
|
5eda098 |
@@ -251,16 +248,12 @@ int rpc_rquota_get(struct dquot *dquot)
|
|
|
5eda098 |
clnt_destroy(clnt);
|
|
|
5eda098 |
} else {
|
|
|
5eda098 |
result = NULL;
|
|
|
5eda098 |
- if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED)
|
|
|
5eda098 |
- rquotaprog_not_registered = 1;
|
|
|
5eda098 |
}
|
|
|
5eda098 |
}
|
|
|
5eda098 |
}
|
|
|
5eda098 |
free(fsname_tmp);
|
|
|
5eda098 |
if (result)
|
|
|
5eda098 |
ret = result->status;
|
|
|
5eda098 |
- else if (rquotaprog_not_registered)
|
|
|
5eda098 |
- ret = Q_NOQUOTA;
|
|
|
5eda098 |
else
|
|
|
5eda098 |
ret = -1;
|
|
|
5eda098 |
return rquota_err(ret);
|
|
|
5eda098 |
@@ -280,7 +273,6 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot)
|
|
|
5eda098 |
} args;
|
|
|
5eda098 |
char *fsname_tmp, *host, *pathname;
|
|
|
5eda098 |
struct timeval timeout = { 2, 0 };
|
|
|
5eda098 |
- int rquotaprog_not_registered = 0;
|
|
|
5eda098 |
int ret;
|
|
|
5eda098 |
|
|
|
5eda098 |
/* RPC limits values to 32b variables. Prevent value wrapping. */
|
|
|
5eda098 |
@@ -340,8 +332,6 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot)
|
|
|
5eda098 |
}
|
|
|
5eda098 |
else {
|
|
|
5eda098 |
result = NULL;
|
|
|
5eda098 |
- if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED)
|
|
|
5eda098 |
- rquotaprog_not_registered = 1;
|
|
|
5eda098 |
}
|
|
|
5eda098 |
|
|
|
5eda098 |
if (result == NULL || !result->status) {
|
|
|
5eda098 |
@@ -383,16 +373,12 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot)
|
|
|
5eda098 |
clnt_destroy(clnt);
|
|
|
5eda098 |
} else {
|
|
|
5eda098 |
result = NULL;
|
|
|
5eda098 |
- if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED)
|
|
|
5eda098 |
- rquotaprog_not_registered = 1;
|
|
|
5eda098 |
}
|
|
|
5eda098 |
}
|
|
|
5eda098 |
}
|
|
|
5eda098 |
free(fsname_tmp);
|
|
|
5eda098 |
if (result)
|
|
|
5eda098 |
ret = result->status;
|
|
|
5eda098 |
- else if (rquotaprog_not_registered)
|
|
|
5eda098 |
- ret = Q_NOQUOTA;
|
|
|
5eda098 |
else
|
|
|
5eda098 |
ret = -1;
|
|
|
5eda098 |
return rquota_err(ret);
|
|
|
5eda098 |
--
|
|
|
5eda098 |
2.20.1
|
|
|
5eda098 |
|