diff options
author | Petr Písař <ppisar@redhat.com> | 2014-10-23 14:12:01 +0200 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2014-11-26 09:14:00 +0100 |
commit | bffaeb028ee716ed46e5b74a45162f2ef45b2963 (patch) | |
tree | 92a1864ad100bb5fcd626cd737b58e489fcbb743 /rquota_client.c | |
parent | 663ac451b045b4823d6d633893a5d748c09f42f2 (diff) | |
download | linuxquota-bffaeb028ee716ed46e5b74a45162f2ef45b2963.tar.gz |
Skip NFS mounts without rquotad RPC service silently
If NFS server does uses quotas, then it's high chance the RCP rquotad
service is not running at all. Then listing quotas for such NFS mount
point results into a warning about "connection refused".
This warning can be obtrusive if a host has mounted various mixture of
NFS exports with and without quotas.
This patch recognizes this special error state (after performing
a query to a client without running rquotad) and considers such
server as having quotas disabled. This silents the warning
effectively.
JK: Some coding style fixes, treat also rpc_set_quota() this way.
Signed-off-by: Petr Písař <ppisar@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'rquota_client.c')
-rw-r--r-- | rquota_client.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/rquota_client.c b/rquota_client.c index 9d4055e..a3a4ae3 100644 --- a/rquota_client.c +++ b/rquota_client.c @@ -148,6 +148,8 @@ int rpc_rquota_get(struct dquot *dquot) } args; char *fsname_tmp, *host, *pathname; struct timeval timeout = { 2, 0 }; + int rquotaprog_not_registered = 0; + int ret; /* * Initialize with NULL. @@ -206,8 +208,11 @@ int rpc_rquota_get(struct dquot *dquot) auth_destroy(clnt->cl_auth); clnt_destroy(clnt); } - else + else { result = NULL; + if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED) + rquotaprog_not_registered = 1; + } if (result == NULL || !result->status) { if (dquot->dq_h->qh_type == USRQUOTA) { @@ -244,11 +249,21 @@ int rpc_rquota_get(struct dquot *dquot) */ auth_destroy(clnt->cl_auth); clnt_destroy(clnt); + } else { + result = NULL; + if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED) + rquotaprog_not_registered = 1; } } } free(fsname_tmp); - return rquota_err(result?result->status:-1); + if (result) + ret = result->status; + else if (rquotaprog_not_registered) + ret = Q_NOQUOTA; + else + ret = -1; + return rquota_err(ret); } /* @@ -265,6 +280,8 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot) } args; char *fsname_tmp, *host, *pathname; struct timeval timeout = { 2, 0 }; + int rquotaprog_not_registered = 0; + int ret; /* RPC limits values to 32b variables. Prevent value wrapping. */ if (check_dquot_range(dquot) < 0) @@ -321,8 +338,11 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot) auth_destroy(clnt->cl_auth); clnt_destroy(clnt); } - else + else { result = NULL; + if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED) + rquotaprog_not_registered = 1; + } if (result == NULL || !result->status) { if (dquot->dq_h->qh_type == USRQUOTA) { @@ -361,11 +381,21 @@ int rpc_rquota_set(int qcmd, struct dquot *dquot) */ auth_destroy(clnt->cl_auth); clnt_destroy(clnt); + } else { + result = NULL; + if (rpc_createerr.cf_stat == RPC_PROGNOTREGISTERED) + rquotaprog_not_registered = 1; } } } free(fsname_tmp); - return rquota_err(result?result->status:-1); + if (result) + ret = result->status; + else if (rquotaprog_not_registered) + ret = Q_NOQUOTA; + else + ret = -1; + return rquota_err(ret); #endif return -1; } |