Skip to contentSkip to conversation

xfs: send warning of project quota to userspace via netlink

PATCH Superseded Masatake YAMATO 2 participants 8 messages Nov 25, 2015 – Dec 17, 2015 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: send warning of project quota to userspace via netlink

Linux's quota subsystem has an ability to handle project quota. This commit just utilizes the ability from xfs side.

---
 fs/xfs/xfs_trans_dquot.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
fs/xfs/xfs_trans_dquot.c +9 -4
index ce78534..1a46544 100644
@@ -572,12 +572,17 @@ xfs_quota_warn(
 	struct xfs_dquot	*dqp,
 	int			type)
 {
-	/* no warnings for project quotas - we just return ENOSPC later */
+	enum quota_type t;
+
 	if (dqp->dq_flags & XFS_DQ_PROJ)
-		return;
+		t = PRJQUOTA;
+	else if (dqp->dq_flags & XFS_DQ_USER)
+		t = USRQUOTA;
+	else
+		t = GRPQUOTA;
+
 	quota_send_warning(make_kqid(&init_user_ns,
-				     (dqp->dq_flags & XFS_DQ_USER) ?
-				     USRQUOTA : GRPQUOTA,
+				     t,
 				     be32_to_cpu(dqp->q_core.d_id)),
 			   mp->m_super->s_dev, type);
 }
Signature · 6 lines
2.5.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 6 lines · Masatake YAMATO

Linux's quota subsystem has an ability to handle project quota. This commit just utilizes the ability from xfs side.

---

Seems reasonable to me. A couple questions... how has this been tested? The original commit a210c1aa7 ("xfs: implement quota warnings via netlink") mentions that the xfstests quota tests with something listening for events was sufficient.

Also, is the userspace support for this new? If so, what is the behavior if somebody runs a new kernel with this event and an old userspace?

Other than that, just a couple aesthetic things..

Quoted 8 lines
 fs/xfs/xfs_trans_dquot.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
fs/xfs/xfs_trans_dquot.c +0 -0
index ce78534..1a46544 100644

fs/xfs/xfs_trans_dquot.c xfs_quota_warn( · line 576

Quoted 6 lines
fs/xfs/xfs_trans_dquot.c +2 -1
@@ -572,12 +572,17 @@ xfs_quota_warn(
 	struct xfs_dquot	*dqp,
 	int			type)
 {
-	/* no warnings for project quotas - we just return ENOSPC later */
+	enum quota_type t;
+

The variable name should be lined up with the function parameter names. I'd prefer a more descriptive variable name as well (e.g., 'qtype'?).

fs/xfs/xfs_trans_dquot.c xfs_quota_warn( · line 585

Quoted 12 lines
fs/xfs/xfs_trans_dquot.c +7 -3
 	if (dqp->dq_flags & XFS_DQ_PROJ)
-		return;
+		t = PRJQUOTA;
+	else if (dqp->dq_flags & XFS_DQ_USER)
+		t = USRQUOTA;
+	else
+		t = GRPQUOTA;
+
 	quota_send_warning(make_kqid(&init_user_ns,
-				     (dqp->dq_flags & XFS_DQ_USER) ?
-				     USRQUOTA : GRPQUOTA,
+				     t,

This could probably get moved to the end of the previous line rather than it's own separate line now that the conditional is removed. We generally just want to keep lines within 80 columns.

Brian

Quoted 10 lines
fs/xfs/xfs_trans_dquot.c +0 -0
 				     be32_to_cpu(dqp->q_core.d_id)),
 			   mp->m_super->s_dev, type);
 }
Signature · 6 lines
2.5.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw

PATCH v2 1/1 xfs: send warning of project quota to userspace via netlink

Linux's quota subsystem has an ability to handle project quota. This commit just utilizes the ability from xfs side.

dbus-monitor and quota_nld shipped as part of quota-tools can be used for testing.

The testing environment and condition:

    # cat /etc/projects
    10:/root/Q/a
    # grep Q /proc/mounts
    /dev/loop0 /root/Q xfs rw,relatime,attr2,inode64,prjquota 0 0
    # ls -l /dev/loop0
    brw-rw---- 1 root disk 7, 0 Nov 26 10:46 /dev/loop0

3 terminals are used for each commands: dd, quota_nld, and dbus-monitor.

Start quota_nld with terminal 1:

	[1]# quota_nld -F

Start dbus-monitor with terminal 2:

        [2]# dbus-monitor --system

Start dd to generate a large file for hitting the quota limit:

        [3]# dd if=/dev/sda of=/root/Q/a/X

At the terminal 1, you will see warning messages like:

quota_nld: Failed to open tty /dev/tty1 of user 0 to report warning.

Let's ignore them. These meaningless messages
are suppressed by a patch available at
https://sourceforge.net/p/linuxquota/patches/43/.

At the terminal 2, you will see following traffic about disk quota (newlines are inserted):

    signal time=1448502680.741715 sender=:1.35 -> \
	   destination=(null destination) serial=4 path=/; \
	   interface=com.system.quota.warning; member=warning
       uint32 2
       uint64 10
       uint32 6
       uint32 7
       uint32 0
       uint64 0
    signal time=1448502680.742518 sender=:1.35 -> \
	   destination=(null destination) serial=5 path=/; \
	   interface=com.system.quota.warning; member=warning
       uint32 2
       uint64 10
       uint32 4
       uint32 7
       uint32 0
       uint64 0

The 1st "2" means the type of quota: project quota. The 2nd "10" means the project id.
The 3rd "4" and "6" mean "Block hardlimit reached" and "Block softlimit reached".
The 4th "7" means the major number of loop0. The 5th "0" means the minor number of loop0.

Changes in v2:

a couple aesthetic things suggested by Brian Foster <[email protected]>.
* rename local vairable for aligning the parameter names,
* move a short line to the end of its previous line.

---
 fs/xfs/xfs_trans_dquot.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
fs/xfs/xfs_trans_dquot.c +9 -5
index ce78534..9951701 100644
@@ -572,12 +572,16 @@ xfs_quota_warn(
 	struct xfs_dquot	*dqp,
 	int			type)
 {
-	/* no warnings for project quotas - we just return ENOSPC later */
+	enum quota_type qtype;
+
 	if (dqp->dq_flags & XFS_DQ_PROJ)
-		return;
-	quota_send_warning(make_kqid(&init_user_ns,
-				     (dqp->dq_flags & XFS_DQ_USER) ?
-				     USRQUOTA : GRPQUOTA,
+		qtype = PRJQUOTA;
+	else if (dqp->dq_flags & XFS_DQ_USER)
+		qtype = USRQUOTA;
+	else
+		qtype = GRPQUOTA;
+
+	quota_send_warning(make_kqid(&init_user_ns, qtype,
 				     be32_to_cpu(dqp->q_core.d_id)),
 			   mp->m_super->s_dev, type);
 }
Signature · 6 lines
2.5.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#5 lore raw

PATCH v2 1/1 xfs: send warning of project quota to userspace via netlink

In reply to Brian Foster

Linux's quota subsystem has an ability to handle project quota. This commit just utilizes the ability from xfs side.

dbus-monitor and quota_nld shipped as part of quota-tools can be used for testing.

The testing environment and condition:

    # cat /etc/projects
    10:/root/Q/a
    # grep Q /proc/mounts
    /dev/loop0 /root/Q xfs rw,relatime,attr2,inode64,prjquota 0 0
    # ls -l /dev/loop0
    brw-rw---- 1 root disk 7, 0 Nov 26 10:46 /dev/loop0

3 terminals are used for each commands: dd, quota_nld, and dbus-monitor.

Start quota_nld with terminal 1:

	[1]# quota_nld -F

Start dbus-monitor with terminal 2:

        [2]# dbus-monitor --system

Start dd to generate a large file for hitting the quota limit:

        [3]# dd if=/dev/sda of=/root/Q/a/X

At the terminal 1, you will see warning messages like:

quota_nld: Failed to open tty /dev/tty1 of user 0 to report warning.

Let's ignore them. These meaningless messages
are suppressed by a patch available at
https://sourceforge.net/p/linuxquota/patches/43/.

At the terminal 2, you will see following traffic about disk quota (newlines are inserted):

    signal time=1448502680.741715 sender=:1.35 -> \
	   destination=(null destination) serial=4 path=/; \
	   interface=com.system.quota.warning; member=warning
       uint32 2
       uint64 10
       uint32 6
       uint32 7
       uint32 0
       uint64 0
    signal time=1448502680.742518 sender=:1.35 -> \
	   destination=(null destination) serial=5 path=/; \
	   interface=com.system.quota.warning; member=warning
       uint32 2
       uint64 10
       uint32 4
       uint32 7
       uint32 0
       uint64 0

The 1st "2" means the type of quota: project quota. The 2nd "10" means the project id.
The 3rd "4" and "6" mean "Block hardlimit reached" and "Block softlimit reached".
The 4th "7" means the major number of loop0. The 5th "0" means the minor number of loop0.

Changes in v2:

a couple aesthetic things suggested by Brian Foster <[email protected]>.
* rename local vairable for aligning the parameter names,
* move a short line to the end of its previous line.

---
 fs/xfs/xfs_trans_dquot.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
fs/xfs/xfs_trans_dquot.c +9 -5
index ce78534..9951701 100644
@@ -572,12 +572,16 @@ xfs_quota_warn(
 	struct xfs_dquot	*dqp,
 	int			type)
 {
-	/* no warnings for project quotas - we just return ENOSPC later */
+	enum quota_type qtype;
+
 	if (dqp->dq_flags & XFS_DQ_PROJ)
-		return;
-	quota_send_warning(make_kqid(&init_user_ns,
-				     (dqp->dq_flags & XFS_DQ_USER) ?
-				     USRQUOTA : GRPQUOTA,
+		qtype = PRJQUOTA;
+	else if (dqp->dq_flags & XFS_DQ_USER)
+		qtype = USRQUOTA;
+	else
+		qtype = GRPQUOTA;
+
+	quota_send_warning(make_kqid(&init_user_ns, qtype,
 				     be32_to_cpu(dqp->q_core.d_id)),
 			   mp->m_super->s_dev, type);
 }
Signature · 6 lines
2.5.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#6 lore raw

PATCH v2 1/1 xfs: send warning of project quota to userspace via netlink

Linux's quota subsystem has an ability to handle project quota. This commit just utilizes the ability from xfs side.

dbus-monitor and quota_nld shipped as part of quota-tools can be used for testing.

The testing environment and condition:

    # cat /etc/projects
    10:/root/Q/a
    # grep Q /proc/mounts
    /dev/loop0 /root/Q xfs rw,relatime,attr2,inode64,prjquota 0 0
    # ls -l /dev/loop0
    brw-rw---- 1 root disk 7, 0 Nov 26 10:46 /dev/loop0

3 terminals are used for each commands: dd, quota_nld, and dbus-monitor.

Start quota_nld with terminal 1:

	[1]# quota_nld -F

Start dbus-monitor with terminal 2:

        [2]# dbus-monitor --system

Start dd to generate a large file for hitting the quota limit:

        [3]# dd if=/dev/sda of=/root/Q/a/X

At the terminal 1, you will see warning messages like:

quota_nld: Failed to open tty /dev/tty1 of user 0 to report warning.

Let's ignore them. These meaningless messages
are suppressed by a patch available at
https://sourceforge.net/p/linuxquota/patches/43/.

At the terminal 2, you will see following traffic about disk quota (newlines are inserted):

    signal time=1448502680.741715 sender=:1.35 -> \
	   destination=(null destination) serial=4 path=/; \
	   interface=com.system.quota.warning; member=warning
       uint32 2
       uint64 10
       uint32 6
       uint32 7
       uint32 0
       uint64 0
    signal time=1448502680.742518 sender=:1.35 -> \
	   destination=(null destination) serial=5 path=/; \
	   interface=com.system.quota.warning; member=warning
       uint32 2
       uint64 10
       uint32 4
       uint32 7
       uint32 0
       uint64 0

The 1st "2" means the type of quota: project quota. The 2nd "10" means the project id.
The 3rd "4" and "6" mean "Block hardlimit reached" and "Block softlimit reached".
The 4th "7" means the major number of loop0. The 5th "0" means the minor number of loop0.

Changes in v2:

a couple aesthetic things suggested by Brian Foster <[email protected]>.
* rename local vairable for aligning the parameter names,
* move a short line to the end of its previous line.

---
 fs/xfs/xfs_trans_dquot.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
fs/xfs/xfs_trans_dquot.c +9 -5
index ce78534..9951701 100644
@@ -572,12 +572,16 @@ xfs_quota_warn(
 	struct xfs_dquot	*dqp,
 	int			type)
 {
-	/* no warnings for project quotas - we just return ENOSPC later */
+	enum quota_type qtype;
+
 	if (dqp->dq_flags & XFS_DQ_PROJ)
-		return;
-	quota_send_warning(make_kqid(&init_user_ns,
-				     (dqp->dq_flags & XFS_DQ_USER) ?
-				     USRQUOTA : GRPQUOTA,
+		qtype = PRJQUOTA;
+	else if (dqp->dq_flags & XFS_DQ_USER)
+		qtype = USRQUOTA;
+	else
+		qtype = GRPQUOTA;
+
+	quota_send_warning(make_kqid(&init_user_ns, qtype,
 				     be32_to_cpu(dqp->q_core.d_id)),
 			   mp->m_super->s_dev, type);
 }
Signature · 6 lines
2.5.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#7 lore raw

I'm sorry, mistakenly I sent the same message multiple times. All the same. so please, review the any one of them.

Masatake YAMATO

Quoted 107 lines

Linux's quota subsystem has an ability to handle project quota. This commit just utilizes the ability from xfs side.

dbus-monitor and quota_nld shipped as part of quota-tools can be used for testing.

The testing environment and condition:

    # cat /etc/projects
    10:/root/Q/a
    # grep Q /proc/mounts
    /dev/loop0 /root/Q xfs rw,relatime,attr2,inode64,prjquota 0 0
    # ls -l /dev/loop0
    brw-rw---- 1 root disk 7, 0 Nov 26 10:46 /dev/loop0

3 terminals are used for each commands: dd, quota_nld, and dbus-monitor.

Start quota_nld with terminal 1:

	[1]# quota_nld -F

Start dbus-monitor with terminal 2:

        [2]# dbus-monitor --system

Start dd to generate a large file for hitting the quota limit:

        [3]# dd if=/dev/sda of=/root/Q/a/X

At the terminal 1, you will see warning messages like:

quota_nld: Failed to open tty /dev/tty1 of user 0 to report warning.

Let's ignore them. These meaningless messages
are suppressed by a patch available at
https://sourceforge.net/p/linuxquota/patches/43/.

At the terminal 2, you will see following traffic about disk quota (newlines are inserted):

    signal time=1448502680.741715 sender=:1.35 -> \
	   destination=(null destination) serial=4 path=/; \
	   interface=com.system.quota.warning; member=warning
       uint32 2
       uint64 10
       uint32 6
       uint32 7
       uint32 0
       uint64 0
    signal time=1448502680.742518 sender=:1.35 -> \
	   destination=(null destination) serial=5 path=/; \
	   interface=com.system.quota.warning; member=warning
       uint32 2
       uint64 10
       uint32 4
       uint32 7
       uint32 0
       uint64 0

The 1st "2" means the type of quota: project quota. The 2nd "10" means the project id.
The 3rd "4" and "6" mean "Block hardlimit reached" and "Block softlimit reached".
The 4th "7" means the major number of loop0. The 5th "0" means the minor number of loop0.

Changes in v2:

a couple aesthetic things suggested by Brian Foster <[email protected]>.
* rename local vairable for aligning the parameter names,
* move a short line to the end of its previous line.

---
 fs/xfs/xfs_trans_dquot.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
fs/xfs/xfs_trans_dquot.c +9 -5
index ce78534..9951701 100644
@@ -572,12 +572,16 @@ xfs_quota_warn(
 	struct xfs_dquot	*dqp,
 	int			type)
 {
-	/* no warnings for project quotas - we just return ENOSPC later */
+	enum quota_type qtype;
+
 	if (dqp->dq_flags & XFS_DQ_PROJ)
-		return;
-	quota_send_warning(make_kqid(&init_user_ns,
-				     (dqp->dq_flags & XFS_DQ_USER) ?
-				     USRQUOTA : GRPQUOTA,
+		qtype = PRJQUOTA;
+	else if (dqp->dq_flags & XFS_DQ_USER)
+		qtype = USRQUOTA;
+	else
+		qtype = GRPQUOTA;
+
+	quota_send_warning(make_kqid(&init_user_ns, qtype,
 				     be32_to_cpu(dqp->q_core.d_id)),
 			   mp->m_super->s_dev, type);
 }
Signature · 1 line
2.5.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v2 1/1
#3 lore raw
In reply to Masatake YAMATO
Quoted 4 lines · Masatake YAMATO

Linux's quota subsystem has an ability to handle project quota. This commit just utilizes the ability from xfs side.

...

Quoted 8 lines

Changes in v2:

a couple aesthetic things suggested by Brian Foster <[email protected]>.
* rename local vairable for aligning the parameter names,
* move a short line to the end of its previous line.

---

Thanks for all of the test information. Now you have a really long commit log description rather than a short one. ;) Maybe Dave can truncate it. Regardless, looks fine to me:

Quoted 36 lines
 fs/xfs/xfs_trans_dquot.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
fs/xfs/xfs_trans_dquot.c +9 -5
index ce78534..9951701 100644
@@ -572,12 +572,16 @@ xfs_quota_warn(
 	struct xfs_dquot	*dqp,
 	int			type)
 {
-	/* no warnings for project quotas - we just return ENOSPC later */
+	enum quota_type qtype;
+
 	if (dqp->dq_flags & XFS_DQ_PROJ)
-		return;
-	quota_send_warning(make_kqid(&init_user_ns,
-				     (dqp->dq_flags & XFS_DQ_USER) ?
-				     USRQUOTA : GRPQUOTA,
+		qtype = PRJQUOTA;
+	else if (dqp->dq_flags & XFS_DQ_USER)
+		qtype = USRQUOTA;
+	else
+		qtype = GRPQUOTA;
+
+	quota_send_warning(make_kqid(&init_user_ns, qtype,
 				     be32_to_cpu(dqp->q_core.d_id)),
 			   mp->m_super->s_dev, type);
 }
Signature · 6 lines
2.5.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw
Quoted 12 lines · Brian Foster
Quoted 4 lines · Masatake YAMATO

Linux's quota subsystem has an ability to handle project quota. This commit just utilizes the ability from xfs side.

...

Quoted 6 lines

Changes in v2:

a couple aesthetic things suggested by Brian Foster <[email protected]>.
* rename local vairable for aligning the parameter names,
* move a short line to the end of its previous line.

Quoted 8 lines
Quoted 2 lines

---

Thanks for all of the test information. Now you have a really long commit log description rather than a short one. ;) Maybe Dave can truncate it. Regardless, looks fine to me:

Any progress?

The patch for userland is merged today:
https://sourceforge.net/p/linuxquota/patches/43/

Masatake YAMATO

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs