All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] btrfs: Change qgroup_meta_rsv to 64bit
@ 2017-03-14 10:25 Goldwyn Rodrigues
  2017-03-14 12:30 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Goldwyn Rodrigues @ 2017-03-14 10:25 UTC (permalink / raw)
  To: linux-btrfs; +Cc: dsterba, Goldwyn Rodrigues

From: Goldwyn Rodrigues <rgoldwyn@suse.com>

Using an int value is causing qg->reserved to become negative and
exclusive -EDQUOT to be reached prematurely.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
---

Changes since v1:
 - changed reserved from long to u64

 fs/btrfs/ctree.h   |  2 +-
 fs/btrfs/disk-io.c |  2 +-
 fs/btrfs/qgroup.c  | 10 +++++-----
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 29b7fc2..c411590 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1259,7 +1259,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)
 {
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 08b74da..eb1ee7b 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -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;
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 6215264..3757902 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -2963,20 +2963,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);
@@ -2991,8 +2991,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);
 }
 
-- 
2.10.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] btrfs: Change qgroup_meta_rsv to 64bit
  2017-03-14 10:25 [PATCH v2] btrfs: Change qgroup_meta_rsv to 64bit Goldwyn Rodrigues
@ 2017-03-14 12:30 ` David Sterba
  2017-03-14 13:31   ` Goldwyn Rodrigues
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2017-03-14 12:30 UTC (permalink / raw)
  To: Goldwyn Rodrigues; +Cc: linux-btrfs, dsterba, Goldwyn Rodrigues

On Tue, Mar 14, 2017 at 05:25:09AM -0500, Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> 
> Using an int value is causing qg->reserved to become negative and
> exclusive -EDQUOT to be reached prematurely.

V1 had a reproducer, I think it's fine to keep it here so I'll copy it.

Reviewed-by: David Sterba <dsterba@suse.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] btrfs: Change qgroup_meta_rsv to 64bit
  2017-03-14 12:30 ` David Sterba
@ 2017-03-14 13:31   ` Goldwyn Rodrigues
  2017-03-14 14:04     ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: Goldwyn Rodrigues @ 2017-03-14 13:31 UTC (permalink / raw)
  To: dsterba, linux-btrfs



On 03/14/2017 07:30 AM, David Sterba wrote:
> On Tue, Mar 14, 2017 at 05:25:09AM -0500, Goldwyn Rodrigues wrote:
>> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
>>
>> Using an int value is causing qg->reserved to become negative and
>> exclusive -EDQUOT to be reached prematurely.
> 
> V1 had a reproducer, I think it's fine to keep it here so I'll copy it.
> 
> Reviewed-by: David Sterba <dsterba@suse.com>
> 

I am adding a testcase in (x)fstests which covers both qgroup issues for
which I have sent the patches. I am fine either ways.

-- 
Goldwyn

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] btrfs: Change qgroup_meta_rsv to 64bit
  2017-03-14 13:31   ` Goldwyn Rodrigues
@ 2017-03-14 14:04     ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2017-03-14 14:04 UTC (permalink / raw)
  To: Goldwyn Rodrigues; +Cc: dsterba, linux-btrfs

On Tue, Mar 14, 2017 at 08:31:26AM -0500, Goldwyn Rodrigues wrote:
> 
> 
> On 03/14/2017 07:30 AM, David Sterba wrote:
> > On Tue, Mar 14, 2017 at 05:25:09AM -0500, Goldwyn Rodrigues wrote:
> >> From: Goldwyn Rodrigues <rgoldwyn@suse.com>
> >>
> >> Using an int value is causing qg->reserved to become negative and
> >> exclusive -EDQUOT to be reached prematurely.
> > 
> > V1 had a reproducer, I think it's fine to keep it here so I'll copy it.
> > 
> > Reviewed-by: David Sterba <dsterba@suse.com>
> > 
> 
> I am adding a testcase in (x)fstests which covers both qgroup issues for
> which I have sent the patches. I am fine either ways.

The fstests testcase is orthogonal to the changelog describing the steps
to reproduce the bug (it could just roughly describe the idea), as it
helps to understand what's the patch going to fix.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-14 14:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-14 10:25 [PATCH v2] btrfs: Change qgroup_meta_rsv to 64bit Goldwyn Rodrigues
2017-03-14 12:30 ` David Sterba
2017-03-14 13:31   ` Goldwyn Rodrigues
2017-03-14 14:04     ` David Sterba

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.