Blob Blame History Raw
From e6decbfe6c44935584954ab01c8be2f5d02acf1b Mon Sep 17 00:00:00 2001
From: Jan Kara <jack@suse.cz>
Date: Fri, 24 May 2019 12:21:46 +0200
Subject: [PATCH 2/4] quotaops: Do not return partial list from getprivs()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When we failed to get some dquots from NFS server, we just reported
error, didn't include the dquot in the list built in getprivs() but
otherwise continued operation. Fail getprivs() in case of error instead
so that the failure propagates properly to the caller.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 quotaops.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/quotaops.c b/quotaops.c
index ad29fd9..3d65490 100644
--- a/quotaops.c
+++ b/quotaops.c
@@ -61,7 +61,7 @@ void update_grace_times(struct dquot *q)
 /*
  * Collect the requested quota information.
  */
-struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet)
+struct dquot *getprivs(qid_t id, struct quota_handle **handles, int ignore_noquota)
 {
 	struct dquot *q, *qtail = NULL, *qhead = NULL;
 	int i;
@@ -124,15 +124,18 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet)
 #endif
 
 		if (!(q = handles[i]->qh_ops->read_dquot(handles[i], id))) {
+			int olderrno = errno;
+
 			/* If rpc.rquotad is not running filesystem might be just without quotas... */
-			if (!quiet || (errno != ENOENT && errno != ECONNREFUSED)) {
-				int olderrno = errno;
+			if (ignore_noquota &&
+			    (errno == ENOENT || errno == ECONNREFUSED))
+				continue;
 
-				id2name(id, handles[i]->qh_type, name);
-				errstr(_("error while getting quota from %s for %s (id %u): %s\n"),
-					handles[i]->qh_quotadev, name, id, strerror(olderrno));
-			}
-			continue;
+			id2name(id, handles[i]->qh_type, name);
+			errstr(_("error while getting quota from %s for %s (id %u): %s\n"),
+				handles[i]->qh_quotadev, name, id, strerror(olderrno));
+			freeprivs(qhead);
+			return NULL;
 		}
 		if (qhead == NULL)
 			qhead = q;
-- 
2.20.1