Skip to contentSkip to conversation

Btrfs: fix confusing edquot happening case

PATCH RESEND New Wang Shilong 1 participant 1 message Apr 15, 2013 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH RESEND v2 1/1 Btrfs: fix confusing edquot happening case

From: Wang Shilong <[email protected]>

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 exclusive

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

---
Changelog v1->v2:
-use s64 instead of signed long long

---
 fs/btrfs/qgroup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/qgroup.c +2 -2
index b44124d..ab364a2 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 + (s64)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 + (s64)qg->excl + num_bytes >
 		    qg->max_excl) {
 			ret = -EDQUOT;
 			goto out;
Signature · 1 line
1.7.11.7