375919f
From b58944b582722dd3c56893eb4b6c8b8a0291201d Mon Sep 17 00:00:00 2001
375919f
From: jkar8572 <jkar8572>
375919f
Date: Thu, 27 May 2010 13:12:57 +0000
375919f
Subject: [PATCH] * fix repquota to get latest quota info header (Jan Kara)
375919f
375919f
Petr Pisar: Changelog entry removed.
375919f
375919f
---
375919f
 quotaio.c    |    9 +++++++++
375919f
 quotaio_v1.c |    5 -----
375919f
 quotaio_v2.c |    5 -----
375919f
375919f
diff --git a/quotaio.c b/quotaio.c
375919f
index 533b631..ee8c48a 100644
375919f
--- a/quotaio.c
375919f
+++ b/quotaio.c
375919f
@@ -147,6 +147,15 @@ struct quota_handle *init_io(struct mntent *mnt, int type, int fmt, int flags)
375919f
 		}
375919f
 	}
375919f
 	if (!QIO_ENABLED(h) || flags & IOI_OPENFILE) {	/* Need to open file? */
375919f
+		if (QIO_ENABLED(h)) {	/* Kernel uses same file? */
375919f
+			unsigned int cmd =
375919f
+				(kernel_iface == IFACE_GENERIC) ? Q_SYNC : Q_6_5_SYNC;
375919f
+			if (quotactl(QCMD(cmd, h->qh_type), h->qh_quotadev,
375919f
+				     0, NULL) < 0) {
375919f
+				die(4, _("Cannot sync quotas on device %s: %s\n"),
375919f
+				    h->qh_quotadev, strerror(errno));
375919f
+			}
375919f
+		}
375919f
 		/* We still need to open file for operations like 'repquota' */
375919f
 		if ((fd = open(qfname, QIO_RO(h) ? O_RDONLY : O_RDWR)) < 0) {
375919f
 			errstr(_("Cannot open quotafile %s: %s\n"),
375919f
diff --git a/quotaio_v1.c b/quotaio_v1.c
375919f
index 0edbc16..1533ffc 100644
375919f
--- a/quotaio_v1.c
375919f
+++ b/quotaio_v1.c
375919f
@@ -348,11 +348,6 @@ static int v1_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct d
375919f
 	struct dquot *dquot = get_empty_dquot();
375919f
 	qid_t id = 0;
375919f
 
375919f
-	if (QIO_ENABLED(h))	/* Kernel uses same file? */
375919f
-		if (quotactl(QCMD((kernel_iface == IFACE_GENERIC) ? Q_SYNC : Q_6_5_SYNC, h->qh_type),
375919f
-			     h->qh_quotadev, 0, NULL) < 0)
375919f
-			die(4, _("Cannot sync quotas on device %s: %s\n"), h->qh_quotadev,
375919f
-			    strerror(errno));
375919f
 	memset(dquot, 0, sizeof(*dquot));
375919f
 	dquot->dq_h = h;
375919f
 	lseek(h->qh_fd, 0, SEEK_SET);
375919f
diff --git a/quotaio_v2.c b/quotaio_v2.c
375919f
index 2e3c725..38440e7 100644
375919f
--- a/quotaio_v2.c
375919f
+++ b/quotaio_v2.c
375919f
@@ -484,11 +484,6 @@ static int v2_commit_dquot(struct dquot *dquot, int flags)
375919f
 
375919f
 static int v2_scan_dquots(struct quota_handle *h, int (*process_dquot) (struct dquot *, char *))
375919f
 {
375919f
-	if (QIO_ENABLED(h))	/* Kernel uses same file? */
375919f
-		if (quotactl(QCMD((kernel_iface == IFACE_GENERIC) ? Q_SYNC : Q_6_5_SYNC, h->qh_type),
375919f
-			     h->qh_quotadev, 0, NULL) < 0)
375919f
-			die(4, _("Cannot sync quotas on device %s: %s\n"), h->qh_quotadev,
375919f
-			    strerror(errno));
375919f
 	return qtree_scan_dquots(h, process_dquot);
375919f
 }
375919f
 
375919f
-- 
375919f
1.7.4
375919f