Skip to contentSkip to conversation

Btrfs: fix confusing edquot happening case

RFC PATCH In review Wang Shilong 3 participants 4 messages Apr 15, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Btrfs: fix confusing edquot happening case

Step to reproduce:
mkfs.btrfs <disk>
mount <disk> <mnt>
dd if=/dev/zero of=/<mnt>/data bs=1M count=10 sync
btrfs quota enable <mnt>
btrfs qgroup create 0/5 <mnt>
btrfs qgroup limit 5M 0/5 <mnt>
rm -f /<mnt>/data
sync
btrfs qgroup show <mnt>
dd if=/dev/zero of=data bs=1M count=1

Quoted 1 line

From the perspective of users, qgroup's referenced or referenced

is negative,But user can not continue to write data! a workaround way is to cast u64 to int64 when doing qgroup reservation.

---
This confusing edquot may also happen after Jan's qgroup rescan has been implemented.

---
 fs/btrfs/qgroup.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/qgroup.c +2 -2
index b44124d..0178223 100644
@@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes)
 		qg = (struct btrfs_qgroup *)(uintptr_t)unode->aux;
 
 		if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) &&
-		    qg->reserved + qg->rfer + num_bytes >
+		    qg->reserved + (signed long long)qg->rfer + num_bytes >
 		    qg->max_rfer) {
 			ret = -EDQUOT;
 			goto out;
 		}
 
 		if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) &&
-		    qg->reserved + qg->excl + num_bytes >
+		    qg->reserved + (signed long long)qg->excl + num_bytes >
 		    qg->max_excl) {
 			ret = -EDQUOT;
 			goto out;
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 31 lines · Wang Shilong

Step to reproduce:
mkfs.btrfs <disk>
mount <disk> <mnt>
dd if=/dev/zero of=/<mnt>/data bs=1M count=10 sync
btrfs quota enable <mnt>
btrfs qgroup create 0/5 <mnt>
btrfs qgroup limit 5M 0/5 <mnt>
rm -f /<mnt>/data
sync
btrfs qgroup show <mnt>
dd if=/dev/zero of=data bs=1M count=1

From the perspective of users, qgroup's referenced or referenced

is negative,But user can not continue to write data! a workaround way is to cast u64 to int64 when doing qgroup reservation.

---
This confusing edquot may also happen after Jan's qgroup rescan has been implemented.

---
 fs/btrfs/qgroup.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/qgroup.c +0 -0
index b44124d..0178223 100644

fs/btrfs/qgroup.c int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) · line 1526

Quoted 5 lines
fs/btrfs/qgroup.c +1 -1
@@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes)
 		qg = (struct btrfs_qgroup *)(uintptr_t)unode->aux;
 
 		if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) &&
-		    qg->reserved + qg->rfer + num_bytes >
+		    qg->reserved + (signed long long)qg->rfer + num_bytes >

why not use s64 instead of signed long long? Otherwise this is the right way to solve this.

Thanks,
Arne

Quoted 11 lines
fs/btrfs/qgroup.c +1 -1
 		    qg->max_rfer) {
 			ret = -EDQUOT;
 			goto out;
 		}
 
 		if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) &&
-		    qg->reserved + qg->excl + num_bytes >
+		    qg->reserved + (signed long long)qg->excl + num_bytes >
 		    qg->max_excl) {
 			ret = -EDQUOT;
 			goto out;
#2 lore raw

Hello Arne,

Quoted 34 lines · Wang Shilong
Quoted 33 lines

Step to reproduce:
mkfs.btrfs <disk>
mount <disk> <mnt>
dd if=/dev/zero of=/<mnt>/data bs=1M count=10 sync
btrfs quota enable <mnt>
btrfs qgroup create 0/5 <mnt>
btrfs qgroup limit 5M 0/5 <mnt>
rm -f /<mnt>/data
sync
btrfs qgroup show <mnt>
dd if=/dev/zero of=data bs=1M count=1

From the perspective of users, qgroup's referenced or referenced

is negative,But user can not continue to write data! a workaround way is to cast u64 to int64 when doing qgroup reservation.

---
This confusing edquot may also happen after Jan's qgroup rescan has been implemented.
---
fs/btrfs/qgroup.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/qgroup.c +0 -0
index b44124d..0178223 100644
@@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes)
 		qg = (struct btrfs_qgroup *)(uintptr_t)unode->aux;
 
Quoted 6 lines

fs/btrfs/qgroup.c int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) · line 1526

Quoted 3 lines
fs/btrfs/qgroup.c +1 -1
 		if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) &&
-		    qg->reserved + qg->rfer + num_bytes >
+		    qg->reserved + (signed long long)qg->rfer + num_bytes >

why not use s64 instead of signed long long? Otherwise this is the right way to solve this.

Yeah,V2 is coming. By the way, do you mind that i add Acked-by: Arne Jasen <[email protected]>?

Thanks,
Wang

Quoted 20 lines

Thanks,
Arne

fs/btrfs/qgroup.c int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) · line 1536

Quoted 11 lines
fs/btrfs/qgroup.c +1 -1
 		    qg->max_rfer) {
 			ret = -EDQUOT;
 			goto out;
 		}
 
 		if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) &&
-		    qg->reserved + qg->excl + num_bytes >
+		    qg->reserved + (signed long long)qg->excl + num_bytes >
 		    qg->max_excl) {
 			ret = -EDQUOT;
 			goto out;

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
Quoted 36 lines · Wang Shilong

Hello Arne,

Quoted 34 lines · Wang Shilong
Quoted 33 lines

Step to reproduce:
mkfs.btrfs <disk>
mount <disk> <mnt>
dd if=/dev/zero of=/<mnt>/data bs=1M count=10 sync
btrfs quota enable <mnt>
btrfs qgroup create 0/5 <mnt>
btrfs qgroup limit 5M 0/5 <mnt>
rm -f /<mnt>/data
sync
btrfs qgroup show <mnt>
dd if=/dev/zero of=data bs=1M count=1

From the perspective of users, qgroup's referenced or referenced

is negative,But user can not continue to write data! a workaround way is to cast u64 to int64 when doing qgroup reservation.

---
This confusing edquot may also happen after Jan's qgroup rescan has been implemented.
---
fs/btrfs/qgroup.c | 4 ++--

1 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/qgroup.c +0 -0
index b44124d..0178223 100644
@@ -1523,14 +1523,14 @@ int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes)
 		qg = (struct btrfs_qgroup *)(uintptr_t)unode->aux;
 
Quoted 8 lines
Quoted 6 lines

fs/btrfs/qgroup.c int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) · line 1526

Quoted 3 lines
fs/btrfs/qgroup.c +1 -1
 		if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_RFER) &&
-		    qg->reserved + qg->rfer + num_bytes >
+		    qg->reserved + (signed long long)qg->rfer + num_bytes >

why not use s64 instead of signed long long? Otherwise this is the right way to solve this.

Yeah,V2 is coming. By the way, do you mind that i add Acked-by: Arne Jasen <[email protected]>?

You can add a Reviewed-by: Arne Jansen <[email protected]>

Thanks,
Arne

Quoted 28 lines

Thanks,
Wang

Quoted 9 lines

Thanks,
Arne

Quoted 5 lines
fs/btrfs/qgroup.c +0 -0
 		    qg->max_rfer) {
 			ret = -EDQUOT;
 			goto out;
 		}
 
Quoted 11 lines

fs/btrfs/qgroup.c int btrfs_qgroup_reserve(struct btrfs_root *root, u64 num_bytes) · line 1536

Quoted 6 lines
fs/btrfs/qgroup.c +1 -1
 		if ((qg->lim_flags & BTRFS_QGROUP_LIMIT_MAX_EXCL) &&
-		    qg->reserved + qg->excl + num_bytes >
+		    qg->reserved + (signed long long)qg->excl + num_bytes >
 		    qg->max_excl) {
 			ret = -EDQUOT;
 			goto out;

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html