5eda098
From e6decbfe6c44935584954ab01c8be2f5d02acf1b Mon Sep 17 00:00:00 2001
5eda098
From: Jan Kara <jack@suse.cz>
5eda098
Date: Fri, 24 May 2019 12:21:46 +0200
5eda098
Subject: [PATCH 2/4] quotaops: Do not return partial list from getprivs()
5eda098
MIME-Version: 1.0
5eda098
Content-Type: text/plain; charset=UTF-8
5eda098
Content-Transfer-Encoding: 8bit
5eda098
5eda098
When we failed to get some dquots from NFS server, we just reported
5eda098
error, didn't include the dquot in the list built in getprivs() but
5eda098
otherwise continued operation. Fail getprivs() in case of error instead
5eda098
so that the failure propagates properly to the caller.
5eda098
5eda098
Signed-off-by: Jan Kara <jack@suse.cz>
5eda098
Signed-off-by: Petr Písař <ppisar@redhat.com>
5eda098
---
5eda098
 quotaops.c | 19 +++++++++++--------
5eda098
 1 file changed, 11 insertions(+), 8 deletions(-)
5eda098
5eda098
diff --git a/quotaops.c b/quotaops.c
5eda098
index ad29fd9..3d65490 100644
5eda098
--- a/quotaops.c
5eda098
+++ b/quotaops.c
5eda098
@@ -61,7 +61,7 @@ void update_grace_times(struct dquot *q)
5eda098
 /*
5eda098
  * Collect the requested quota information.
5eda098
  */
5eda098
-struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet)
5eda098
+struct dquot *getprivs(qid_t id, struct quota_handle **handles, int ignore_noquota)
5eda098
 {
5eda098
 	struct dquot *q, *qtail = NULL, *qhead = NULL;
5eda098
 	int i;
5eda098
@@ -124,15 +124,18 @@ struct dquot *getprivs(qid_t id, struct quota_handle **handles, int quiet)
5eda098
 #endif
5eda098
 
5eda098
 		if (!(q = handles[i]->qh_ops->read_dquot(handles[i], id))) {
5eda098
+			int olderrno = errno;
5eda098
+
5eda098
 			/* If rpc.rquotad is not running filesystem might be just without quotas... */
5eda098
-			if (!quiet || (errno != ENOENT && errno != ECONNREFUSED)) {
5eda098
-				int olderrno = errno;
5eda098
+			if (ignore_noquota &&
5eda098
+			    (errno == ENOENT || errno == ECONNREFUSED))
5eda098
+				continue;
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
-			}
5eda098
-			continue;
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
+			freeprivs(qhead);
5eda098
+			return NULL;
5eda098
 		}
5eda098
 		if (qhead == NULL)
5eda098
 			qhead = q;
5eda098
-- 
5eda098
2.20.1
5eda098