Skip to contentSkip to conversation

More quota fixes

PATCH New Abhi Das 2 participants 4 messages Jun 1, 2015 – Jun 2, 2015 GFS2 file system

lore
Share & tools
lore

Abhi Das

author
#0 lore raw

v2 cover More quota fixes

This is a follow-up set of patches to fix the issues discovered during testing of my previous set that reworked significant portions of the quota code. Also addresses some of the fixes Bob suggested earlier.

Abhi Das (2):
gfs2: fix quota updates on block boundaries
gfs2: limit quota log messages

 fs/gfs2/incore.h |   1 +
 fs/gfs2/inode.c  |   2 +-
 fs/gfs2/quota.c  | 212 +++++++++++++++++++++++++++++++++----------------------
 3 files changed, 131 insertions(+), 84 deletions(-)
Signature · 1 line
1.8.1.4
author
#1 lore raw

PATCH v2 1/2 gfs2: fix quota updates on block boundaries

For smaller block sizes (512B, 1K, 2K), some quotas straddle block boundaries such that the usage value is on one block and the rest of the quota is on the previous block. In such cases, the value does not get updated correctly. This patch fixes that by addressing the boundary conditions correctly.

This patch also adds a (s64) cast that was missing in a call to gfs2_quota_change() in inode.c

Resolves: rhbz#1174295

---
 fs/gfs2/inode.c |   2 +-
 fs/gfs2/quota.c | 197 +++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 119 insertions(+), 80 deletions(-)
fs/gfs2/inode.c +1 -1
index 4d809eb..a088e54 100644
@@ -1889,7 +1889,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
 
 	if (!uid_eq(ouid, NO_UID_QUOTA_CHANGE) ||
 	    !gid_eq(ogid, NO_GID_QUOTA_CHANGE)) {
-		gfs2_quota_change(ip, -ap.target, ouid, ogid);
+		gfs2_quota_change(ip, -(s64)ap.target, ouid, ogid);
 		gfs2_quota_change(ip, ap.target, nuid, ngid);
 	}
 
fs/gfs2/quota.c +118 -79

226 lines not on this page · raw message

Signature · 1 line
1.8.1.4
author
#2 lore raw

PATCH v2 2/2 gfs2: limit quota log messages

In reply to Abhi Das

This patch makes the quota subsystem only report once that a particular user/group has exceeded their allotted quota.

Previously, it was possible for a program to continuously try exceeding quota (despite receiving EDQUOT) and in turn trigger gfs2 to issue a kernel log message about quota exceed. In theory, this could get out of hand and flood the log and the filesystem hosting the log files.

Resolves: rhbz#1174295

---
 fs/gfs2/incore.h |  1 +
 fs/gfs2/quota.c  | 15 +++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)
fs/gfs2/incore.h +1 -0
index 58b75ab..304a223 100644
@@ -432,6 +432,7 @@ enum {
 	QDF_CHANGE		= 1,
 	QDF_LOCKED		= 2,
 	QDF_REFRESH		= 3,
+	QDF_QMSG_QUIET          = 4,
 };
 
 struct gfs2_quota_data {
fs/gfs2/quota.c +11 -4
index 7c20031..dcd598a 100644
@@ -649,6 +649,8 @@ static void do_qc(struct gfs2_quota_data *qd, s64 change)
 		slot_hold(qd);
 	}
 
+	if (change < 0) /* Reset quiet flag if we freed some blocks */
+		clear_bit(QDF_QMSG_QUIET, &qd->qd_flags);
 	mutex_unlock(&sdp->sd_quota_mutex);
 }
 
@@ -1187,10 +1189,13 @@ int gfs2_quota_check(struct gfs2_inode *ip, kuid_t uid, kgid_t gid,
 			/* If no min_target specified or we don't meet
 			 * min_target, return -EDQUOT */
 			if (!ap->min_target || ap->min_target > ap->allowed) {
-				print_message(qd, "exceeded");
-				quota_send_warning(qd->qd_id,
-						   sdp->sd_vfs->s_dev,
-						   QUOTA_NL_BHARDWARN);
+				if (!test_and_set_bit(QDF_QMSG_QUIET,
+						      &qd->qd_flags)) {
+					print_message(qd, "exceeded");
+					quota_send_warning(qd->qd_id,
+							   sdp->sd_vfs->s_dev,
+							   QUOTA_NL_BHARDWARN);
+				}
 				error = -EDQUOT;
 				break;
 			}
@@ -1685,6 +1690,8 @@ static int gfs2_set_dqblk(struct super_block *sb, struct kqid qid,
 
 	/* Apply changes */
 	error = gfs2_adjust_quota(ip, offset, 0, qd, fdq);
+	if (!error)
+		clear_bit(QDF_QMSG_QUIET, &qd->qd_flags);
 
 	gfs2_trans_end(sdp);
 out_release:
Signature · 1 line
1.8.1.4
#3 lore raw

v2 cover More quota fixes

In reply to Abhi Das

----- Original Message -----

Quoted 8 lines

This is a follow-up set of patches to fix the issues discovered during testing of my previous set that reworked significant portions of the quota code. Also addresses some of the fixes Bob suggested earlier.

Abhi Das (2):
gfs2: fix quota updates on block boundaries
gfs2: limit quota log messages

Quoted 10 lines
 fs/gfs2/incore.h |   1 +
 fs/gfs2/inode.c  |   2 +-
 fs/gfs2/quota.c  | 212
 +++++++++++++++++++++++++++++++++----------------------
 3 files changed, 131 insertions(+), 84 deletions(-)

--
1.8.1.4

Hi,

Thanks. These two patches are now in the for-next branch of the linux-gfs2 tree at these locations:

https://git.kernel.org/cgit/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next&id=39a725803beeffeb319261df1ab145ef3c1ea0a1
https://git.kernel.org/cgit/linux/kernel/git/gfs2/linux-gfs2.git/commit/fs/gfs2?h=for-next&id=9cde2898d04595c3bf24828822b3ea7acff181dd

Regards,

Bob Peterson
Red Hat File Systems