mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-05 01:54:09 +08:00
btrfs: Change qgroup_meta_rsv to 64bit
Using an int value is causing qg->reserved to become negative and exclusive -EDQUOT to be reached prematurely. This affects exclusive qgroups only. TEST CASE: DEVICE=/dev/vdb MOUNTPOINT=/mnt SUBVOL=$MOUNTPOINT/tmp umount $SUBVOL umount $MOUNTPOINT mkfs.btrfs -f $DEVICE mount /dev/vdb $MOUNTPOINT btrfs quota enable $MOUNTPOINT btrfs subvol create $SUBVOL umount $MOUNTPOINT mount /dev/vdb $MOUNTPOINT mount -o subvol=tmp $DEVICE $SUBVOL btrfs qgroup limit -e 3G $SUBVOL btrfs quota rescan /mnt -w for i in `seq 1 44000`; do dd if=/dev/zero of=/mnt/tmp/test_$i bs=10k count=1 if [[ $? > 0 ]]; then btrfs qgroup show -pcref $SUBVOL exit 1 fi done Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com> [ add reproducer to changelog ] Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
9d0d1c8b1c
commit
ce0dcee626
@ -1258,7 +1258,7 @@ struct btrfs_root {
|
||||
atomic_t will_be_snapshoted;
|
||||
|
||||
/* For qgroup metadata space reserve */
|
||||
atomic_t qgroup_meta_rsv;
|
||||
atomic64_t qgroup_meta_rsv;
|
||||
};
|
||||
static inline u32 btrfs_inode_sectorsize(const struct inode *inode)
|
||||
{
|
||||
|
@ -1342,7 +1342,7 @@ static void __setup_root(struct btrfs_root *root, struct btrfs_fs_info *fs_info,
|
||||
atomic_set(&root->orphan_inodes, 0);
|
||||
atomic_set(&root->refs, 1);
|
||||
atomic_set(&root->will_be_snapshoted, 0);
|
||||
atomic_set(&root->qgroup_meta_rsv, 0);
|
||||
atomic64_set(&root->qgroup_meta_rsv, 0);
|
||||
root->log_transid = 0;
|
||||
root->log_transid_committed = -1;
|
||||
root->last_log_commit = 0;
|
||||
|
@ -2948,20 +2948,20 @@ int btrfs_qgroup_reserve_meta(struct btrfs_root *root, int num_bytes,
|
||||
ret = qgroup_reserve(root, num_bytes, enforce);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
atomic_add(num_bytes, &root->qgroup_meta_rsv);
|
||||
atomic64_add(num_bytes, &root->qgroup_meta_rsv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void btrfs_qgroup_free_meta_all(struct btrfs_root *root)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = root->fs_info;
|
||||
int reserved;
|
||||
u64 reserved;
|
||||
|
||||
if (!test_bit(BTRFS_FS_QUOTA_ENABLED, &fs_info->flags) ||
|
||||
!is_fstree(root->objectid))
|
||||
return;
|
||||
|
||||
reserved = atomic_xchg(&root->qgroup_meta_rsv, 0);
|
||||
reserved = atomic64_xchg(&root->qgroup_meta_rsv, 0);
|
||||
if (reserved == 0)
|
||||
return;
|
||||
btrfs_qgroup_free_refroot(fs_info, root->objectid, reserved);
|
||||
@ -2976,8 +2976,8 @@ void btrfs_qgroup_free_meta(struct btrfs_root *root, int num_bytes)
|
||||
return;
|
||||
|
||||
BUG_ON(num_bytes != round_down(num_bytes, fs_info->nodesize));
|
||||
WARN_ON(atomic_read(&root->qgroup_meta_rsv) < num_bytes);
|
||||
atomic_sub(num_bytes, &root->qgroup_meta_rsv);
|
||||
WARN_ON(atomic64_read(&root->qgroup_meta_rsv) < num_bytes);
|
||||
atomic64_sub(num_bytes, &root->qgroup_meta_rsv);
|
||||
btrfs_qgroup_free_refroot(fs_info, root->objectid, num_bytes);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user