Skip to contentSkip to conversation

xfs: Initialize all quota inodes to be NULLFSINO

PATCH In review Chandra Seetharaman 3 participants 8 messages Jul 12, 2013 – Jul 18, 2013 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: Initialize all quota inodes to be NULLFSINO

mkfs doesn't initialize the quota inodes to NULLFSINO as it does for the other internal inodes. This leads to check for two values (0 and NULLFSINO) to make sure if a quota inode is valid.

Solve that problem by initializing the values to NULLFSINO if they are 0.

Note that these values are not written back to on-disk superblock unless some quota is enabled on the filesystem.

---
 fs/xfs/xfs_mount.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
fs/xfs/xfs_mount.c +12 -0
index 2b0ba35..8b95933 100644
@@ -572,6 +572,18 @@ out_unwind:
 static void
 xfs_sb_quota_from_disk(struct xfs_sb *sbp)
 {
+	/*
+	 * older mkfs doesn't initialize quota inodes to NULLFSINO,
+	 * which leads to two values for a quota inode to be invalid:
+	 * 0 and NULLFSINO. Fix it.
+	 */
+	if (sbp->sb_uquotino == 0)
+		sbp->sb_uquotino = NULLFSINO;
+	if (sbp->sb_gquotino == 0)
+		sbp->sb_gquotino = NULLFSINO;
+	if (sbp->sb_pquotino == 0)
+		sbp->sb_pquotino = NULLFSINO;
+
 	if (sbp->sb_qflags & XFS_OQUOTA_ENFD)
 		sbp->sb_qflags |= (sbp->sb_qflags & XFS_PQUOTA_ACCT) ?
 					XFS_PQUOTA_ENFD : XFS_GQUOTA_ENFD;
Signature · 8 lines
1.7.1



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

mkfs doesn't initialize the quota inodes to NULLFSINO as it does for the other internal inodes. This leads to check for two values (0 and NULLFSINO) to make sure if a quota inode is valid.

Solve that problem by initializing the values to NULLFSINO if they are 0.

Note that these values are not written back to on-disk superblock unless some quota is enabled on the filesystem.

---
 fs/xfs/xfs_mount.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
fs/xfs/xfs_mount.c +12 -0
index 2b0ba35..8b95933 100644
@@ -572,6 +572,18 @@ out_unwind:
 static void
 xfs_sb_quota_from_disk(struct xfs_sb *sbp)
 {
+	/*
+	 * older mkfs doesn't initialize quota inodes to NULLFSINO,
+	 * which leads to two values for a quota inode to be invalid:
+	 * 0 and NULLFSINO. Fix it.
+	 */
+	if (sbp->sb_uquotino == 0)
+		sbp->sb_uquotino = NULLFSINO;
+	if (sbp->sb_gquotino == 0)
+		sbp->sb_gquotino = NULLFSINO;
+	if (sbp->sb_pquotino == 0)
+		sbp->sb_pquotino = NULLFSINO;
+
 	if (sbp->sb_qflags & XFS_OQUOTA_ENFD)
 		sbp->sb_qflags |= (sbp->sb_qflags & XFS_PQUOTA_ACCT) ?
 					XFS_PQUOTA_ENFD : XFS_GQUOTA_ENFD;
Signature · 1 line
1.7.1

Hi,

in this case, wouldn't be better to make mkfs initialize the quota inodes with NULLFSINO instead of need to convert it into kernel?

Signature · 6 lines
Carlos

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw
Quoted 46 lines · Carlos Maiolino
Quoted 43 lines · Chandra Seetharaman

mkfs doesn't initialize the quota inodes to NULLFSINO as it does for the other internal inodes. This leads to check for two values (0 and NULLFSINO) to make sure if a quota inode is valid.

Solve that problem by initializing the values to NULLFSINO if they are 0.

Note that these values are not written back to on-disk superblock unless some quota is enabled on the filesystem.

---
 fs/xfs/xfs_mount.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
fs/xfs/xfs_mount.c +12 -0
index 2b0ba35..8b95933 100644
@@ -572,6 +572,18 @@ out_unwind:
 static void
 xfs_sb_quota_from_disk(struct xfs_sb *sbp)
 {
+	/*
+	 * older mkfs doesn't initialize quota inodes to NULLFSINO,
+	 * which leads to two values for a quota inode to be invalid:
+	 * 0 and NULLFSINO. Fix it.
+	 */
+	if (sbp->sb_uquotino == 0)
+		sbp->sb_uquotino = NULLFSINO;
+	if (sbp->sb_gquotino == 0)
+		sbp->sb_gquotino = NULLFSINO;
+	if (sbp->sb_pquotino == 0)
+		sbp->sb_pquotino = NULLFSINO;
+
 	if (sbp->sb_qflags & XFS_OQUOTA_ENFD)
 		sbp->sb_qflags |= (sbp->sb_qflags & XFS_PQUOTA_ACCT) ?
 					XFS_PQUOTA_ENFD : XFS_GQUOTA_ENFD;
Signature · 1 line
1.7.1

Hi,

Quoted 2 lines

in this case, wouldn't be better to make mkfs initialize the quota inodes with NULLFSINO instead of need to convert it into kernel?

Hi Carlos,

Yes. I will send a patch for mkfs also (to initialize it to NULLFSINO).

We still need the kernel fix for the already existing filessytems.

Chadnra

Quoted 1 line

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

#3 lore raw
In reply to Chandra Seetharaman
Quoted 26 lines · Chandra Seetharaman

mkfs doesn't initialize the quota inodes to NULLFSINO as it does for the other internal inodes. This leads to check for two values (0 and NULLFSINO) to make sure if a quota inode is valid.

Solve that problem by initializing the values to NULLFSINO if they are 0.

Note that these values are not written back to on-disk superblock unless some quota is enabled on the filesystem.

---
 fs/xfs/xfs_mount.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
fs/xfs/xfs_mount.c +1 -0
index 2b0ba35..8b95933 100644
@@ -572,6 +572,18 @@ out_unwind:
 static void
 xfs_sb_quota_from_disk(struct xfs_sb *sbp)
 {
+	/*

fs/xfs/xfs_mount.c out_unwind: · line 585

Quoted 10 lines
fs/xfs/xfs_mount.c +10 -0
+	 * older mkfs doesn't initialize quota inodes to NULLFSINO,
+	 * which leads to two values for a quota inode to be invalid:
+	 * 0 and NULLFSINO. Fix it.
+	 */
+	if (sbp->sb_uquotino == 0)
+		sbp->sb_uquotino = NULLFSINO;
+	if (sbp->sb_gquotino == 0)
+		sbp->sb_gquotino = NULLFSINO;
+	if (sbp->sb_pquotino == 0)
+		sbp->sb_pquotino = NULLFSINO;

There coment needs to point out that this is changing the in-memory superblock value right here, so we don't need to make changing sb_pquotino dependent on the superblock having support for this feature.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#4 lore raw
Quoted 34 lines · Dave Chinner
Quoted 33 lines · Chandra Seetharaman

mkfs doesn't initialize the quota inodes to NULLFSINO as it does for the other internal inodes. This leads to check for two values (0 and NULLFSINO) to make sure if a quota inode is valid.

Solve that problem by initializing the values to NULLFSINO if they are 0.

Note that these values are not written back to on-disk superblock unless some quota is enabled on the filesystem.

---
 fs/xfs/xfs_mount.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
fs/xfs/xfs_mount.c +8 -0
index 2b0ba35..8b95933 100644
@@ -572,6 +572,18 @@ out_unwind:
 static void
 xfs_sb_quota_from_disk(struct xfs_sb *sbp)
 {
+	/*
+	 * older mkfs doesn't initialize quota inodes to NULLFSINO,
+	 * which leads to two values for a quota inode to be invalid:
+	 * 0 and NULLFSINO. Fix it.
+	 */
+	if (sbp->sb_uquotino == 0)
+		sbp->sb_uquotino = NULLFSINO;
+	if (sbp->sb_gquotino == 0)
Quoted 8 lines

fs/xfs/xfs_mount.c out_unwind: · line 585

Quoted 3 lines
fs/xfs/xfs_mount.c +3 -0
+		sbp->sb_gquotino = NULLFSINO;
+	if (sbp->sb_pquotino == 0)
+		sbp->sb_pquotino = NULLFSINO;

There coment needs to point out that this is changing the in-memory superblock value right here, so we don't need to make changing sb_pquotino dependent on the superblock having support for this feature.

But, we are not just changing just for sb_pquotino, right ?

Since we are changing all the fields independent of superblock supporting sb_pquotino, I thought the comment should be generic.

Quoted 4 lines

Cheers,

Dave.

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

#5 lore raw
Quoted 44 lines · Chandra Seetharaman
Quoted 34 lines · Dave Chinner
Quoted 33 lines · Chandra Seetharaman

mkfs doesn't initialize the quota inodes to NULLFSINO as it does for the other internal inodes. This leads to check for two values (0 and NULLFSINO) to make sure if a quota inode is valid.

Solve that problem by initializing the values to NULLFSINO if they are 0.

Note that these values are not written back to on-disk superblock unless some quota is enabled on the filesystem.

---
 fs/xfs/xfs_mount.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
fs/xfs/xfs_mount.c +8 -0
index 2b0ba35..8b95933 100644
@@ -572,6 +572,18 @@ out_unwind:
 static void
 xfs_sb_quota_from_disk(struct xfs_sb *sbp)
 {
+	/*
+	 * older mkfs doesn't initialize quota inodes to NULLFSINO,
+	 * which leads to two values for a quota inode to be invalid:
+	 * 0 and NULLFSINO. Fix it.
+	 */
+	if (sbp->sb_uquotino == 0)
+		sbp->sb_uquotino = NULLFSINO;
+	if (sbp->sb_gquotino == 0)
Quoted 8 lines

fs/xfs/xfs_mount.c out_unwind: · line 585

Quoted 3 lines
fs/xfs/xfs_mount.c +3 -0
+		sbp->sb_gquotino = NULLFSINO;
+	if (sbp->sb_pquotino == 0)
+		sbp->sb_pquotino = NULLFSINO;

There coment needs to point out that this is changing the in-memory superblock value right here, so we don't need to make changing sb_pquotino dependent on the superblock having support for this feature.

Quoted 1 line

But, we are not just changing just for sb_pquotino, right ?

Sure, but those other two fields are always present in the superblock...

Quoted 2 lines

Since we are changing all the fields independent of superblock supporting sb_pquotino, I thought the comment should be generic.

So why is it safe to modify this when sb_pquotino isn't valid in the superblock (i.e. v4 superblock) and the only valid on-disk value for an unused section of the superblock is zero?

That's what the comment needs to explain.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#6 lore raw
Quoted 50 lines · Dave Chinner
Quoted 44 lines · Chandra Seetharaman
Quoted 34 lines · Dave Chinner
Quoted 33 lines · Chandra Seetharaman

mkfs doesn't initialize the quota inodes to NULLFSINO as it does for the other internal inodes. This leads to check for two values (0 and NULLFSINO) to make sure if a quota inode is valid.

Solve that problem by initializing the values to NULLFSINO if they are 0.

Note that these values are not written back to on-disk superblock unless some quota is enabled on the filesystem.

---
 fs/xfs/xfs_mount.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
fs/xfs/xfs_mount.c +8 -0
index 2b0ba35..8b95933 100644
@@ -572,6 +572,18 @@ out_unwind:
 static void
 xfs_sb_quota_from_disk(struct xfs_sb *sbp)
 {
+	/*
+	 * older mkfs doesn't initialize quota inodes to NULLFSINO,
+	 * which leads to two values for a quota inode to be invalid:
+	 * 0 and NULLFSINO. Fix it.
+	 */
+	if (sbp->sb_uquotino == 0)
+		sbp->sb_uquotino = NULLFSINO;
+	if (sbp->sb_gquotino == 0)
Quoted 8 lines

fs/xfs/xfs_mount.c out_unwind: · line 585

Quoted 3 lines
fs/xfs/xfs_mount.c +3 -0
+		sbp->sb_gquotino = NULLFSINO;
+	if (sbp->sb_pquotino == 0)
+		sbp->sb_pquotino = NULLFSINO;

There coment needs to point out that this is changing the in-memory superblock value right here, so we don't need to make changing sb_pquotino dependent on the superblock having support for this feature.

Quoted 1 line

But, we are not just changing just for sb_pquotino, right ?

Sure, but those other two fields are always present in the superblock...

Quoted 8 lines
Quoted 2 lines

Since we are changing all the fields independent of superblock supporting sb_pquotino, I thought the comment should be generic.

So why is it safe to modify this when sb_pquotino isn't valid in the superblock (i.e. v4 superblock) and the only valid on-disk value for an unused section of the superblock is zero?

That's what the comment needs to explain.

How about this:

/*
* older mkfs doesn't initialize quota inodes to NULLFSINO
* This leads to in-core values having two different values
* for a quota inode to be invalid: 0 and NULLFSINO.
* Change it to a single value NULLFSINO.
*
* Note that this change affect only the in-core values.
* These values are not written back to disk unless any
* quota information is written to the disk. Even in that
* case, sb_pquotino field is not written to disk unless
* the superblock supports pquotino.
*/

Quoted 3 lines

Cheers,

Dave.

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

#7 lore raw
Quoted 62 lines · Chandra Seetharaman
Quoted 50 lines · Dave Chinner
Quoted 44 lines · Chandra Seetharaman
Quoted 34 lines · Dave Chinner
Quoted 33 lines · Chandra Seetharaman

mkfs doesn't initialize the quota inodes to NULLFSINO as it does for the other internal inodes. This leads to check for two values (0 and NULLFSINO) to make sure if a quota inode is valid.

Solve that problem by initializing the values to NULLFSINO if they are 0.

Note that these values are not written back to on-disk superblock unless some quota is enabled on the filesystem.

---
 fs/xfs/xfs_mount.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
fs/xfs/xfs_mount.c +8 -0
index 2b0ba35..8b95933 100644
@@ -572,6 +572,18 @@ out_unwind:
 static void
 xfs_sb_quota_from_disk(struct xfs_sb *sbp)
 {
+	/*
+	 * older mkfs doesn't initialize quota inodes to NULLFSINO,
+	 * which leads to two values for a quota inode to be invalid:
+	 * 0 and NULLFSINO. Fix it.
+	 */
+	if (sbp->sb_uquotino == 0)
+		sbp->sb_uquotino = NULLFSINO;
+	if (sbp->sb_gquotino == 0)
Quoted 8 lines

fs/xfs/xfs_mount.c out_unwind: · line 585

Quoted 3 lines
fs/xfs/xfs_mount.c +3 -0
+		sbp->sb_gquotino = NULLFSINO;
+	if (sbp->sb_pquotino == 0)
+		sbp->sb_pquotino = NULLFSINO;

There coment needs to point out that this is changing the in-memory superblock value right here, so we don't need to make changing sb_pquotino dependent on the superblock having support for this feature.

Quoted 1 line

But, we are not just changing just for sb_pquotino, right ?

Sure, but those other two fields are always present in the superblock...

Quoted 8 lines
Quoted 2 lines

Since we are changing all the fields independent of superblock supporting sb_pquotino, I thought the comment should be generic.

So why is it safe to modify this when sb_pquotino isn't valid in the superblock (i.e. v4 superblock) and the only valid on-disk value for an unused section of the superblock is zero?

That's what the comment needs to explain.

How about this:

Quoted 12 lines

/*
* older mkfs doesn't initialize quota inodes to NULLFSINO
* This leads to in-core values having two different values
* for a quota inode to be invalid: 0 and NULLFSINO.
* Change it to a single value NULLFSINO.
*
* Note that this change affect only the in-core values.
* These values are not written back to disk unless any
* quota information is written to the disk. Even in that
* case, sb_pquotino field is not written to disk unless
* the superblock supports pquotino.
*/

Nice explanation. Expand it out to 80 columns and it's golden :)

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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