Skip to contentSkip to conversation

btrfs: qgroups: Prepare to deprecate BTRFS_QGROUP_LIMIT_RSV_RFER/EXCL flags

PATCH In review Qu Wenruo 3 participants 3 messages Nov 13, 2018 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs: qgroups: Prepare to deprecate BTRFS_QGROUP_LIMIT_RSV_RFER/EXCL flags

These two flags are only used to set btrfs_qgroup::rsv_rfer/excl number, but then are never used.

Nor these flags are really used by btrfs-progs, so it's pretty safe just to deprecate them in next kernel release.

This patch will mark these two flags deprecated and output warning messages, but still handle them.

These two flags will be completely removed in next kernel release.

---
 fs/btrfs/qgroup.c          | 16 ++++++++++------
 include/uapi/linux/btrfs.h | 12 ++++++------
 2 files changed, 16 insertions(+), 12 deletions(-)
fs/btrfs/qgroup.c +10 -6
index 9afad8c14220..d4a52dbad044 100644
@@ -1385,21 +1385,25 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,
 			qgroup->max_excl = limit->max_excl;
 		}
 	}
-	if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_RFER) {
+	if (limit->flags & __BTRFS_QGROUP_LIMIT_RSV_RFER) {
 		if (limit->rsv_rfer == CLEAR_VALUE) {
-			qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_RSV_RFER;
-			limit->flags &= ~BTRFS_QGROUP_LIMIT_RSV_RFER;
+			qgroup->lim_flags &= ~__BTRFS_QGROUP_LIMIT_RSV_RFER;
+			limit->flags &= ~__BTRFS_QGROUP_LIMIT_RSV_RFER;
 			qgroup->rsv_rfer = 0;
 		} else {
+			btrfs_warn_rl(fs_info,
+"BTRFS_QGROUP_LIMIT_RSV_RFER flag is deprecated, will not be supported in v5.1");
 			qgroup->rsv_rfer = limit->rsv_rfer;
 		}
 	}
-	if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_EXCL) {
+	if (limit->flags & __BTRFS_QGROUP_LIMIT_RSV_EXCL) {
 		if (limit->rsv_excl == CLEAR_VALUE) {
-			qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_RSV_EXCL;
-			limit->flags &= ~BTRFS_QGROUP_LIMIT_RSV_EXCL;
+			qgroup->lim_flags &= ~__BTRFS_QGROUP_LIMIT_RSV_EXCL;
+			limit->flags &= ~__BTRFS_QGROUP_LIMIT_RSV_EXCL;
 			qgroup->rsv_excl = 0;
 		} else {
+			btrfs_warn_rl(fs_info,
+"BTRFS_QGROUP_LIMIT_RSV_EXCL flag is deprecated, will not be supported in v5.1");
 			qgroup->rsv_excl = limit->rsv_excl;
 		}
 	}
include/uapi/linux/btrfs.h +6 -6
index db4c253f8011..ec79ab781ee0 100644
@@ -53,12 +53,12 @@ struct btrfs_ioctl_vol_args {
  * struct btrfs_qgroup_limit.flags
  * struct btrfs_qgroup_limit_item.flags
  */
-#define BTRFS_QGROUP_LIMIT_MAX_RFER	(1ULL << 0)
-#define BTRFS_QGROUP_LIMIT_MAX_EXCL	(1ULL << 1)
-#define BTRFS_QGROUP_LIMIT_RSV_RFER	(1ULL << 2)
-#define BTRFS_QGROUP_LIMIT_RSV_EXCL	(1ULL << 3)
-#define BTRFS_QGROUP_LIMIT_RFER_CMPR	(1ULL << 4)
-#define BTRFS_QGROUP_LIMIT_EXCL_CMPR	(1ULL << 5)
+#define BTRFS_QGROUP_LIMIT_MAX_RFER	(1ULL << 0) /* reference (rfer) limit */
+#define BTRFS_QGROUP_LIMIT_MAX_EXCL	(1ULL << 1) /* exclusive (excl) limit */
+#define __BTRFS_QGROUP_LIMIT_RSV_RFER	(1ULL << 2) /* deprecated */
+#define __BTRFS_QGROUP_LIMIT_RSV_EXCL	(1ULL << 3) /* deprecated */
+#define BTRFS_QGROUP_LIMIT_RFER_CMPR	(1ULL << 4) /* compressed rfer limit */
+#define BTRFS_QGROUP_LIMIT_EXCL_CMPR	(1ULL << 5) /* compressed excl limit */
 
 struct btrfs_qgroup_limit {
 	__u64	flags;
Signature · 1 line
2.19.1
#1 lore raw
Quoted 61 lines · Qu Wenruo

These two flags are only used to set btrfs_qgroup::rsv_rfer/excl number, but then are never used.

Nor these flags are really used by btrfs-progs, so it's pretty safe just to deprecate them in next kernel release.

This patch will mark these two flags deprecated and output warning messages, but still handle them.

These two flags will be completely removed in next kernel release.

---
 fs/btrfs/qgroup.c          | 16 ++++++++++------
 include/uapi/linux/btrfs.h | 12 ++++++------
 2 files changed, 16 insertions(+), 12 deletions(-)
fs/btrfs/qgroup.c +10 -6
index 9afad8c14220..d4a52dbad044 100644
@@ -1385,21 +1385,25 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,
 			qgroup->max_excl = limit->max_excl;
 		}
 	}
-	if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_RFER) {
+	if (limit->flags & __BTRFS_QGROUP_LIMIT_RSV_RFER) {
 		if (limit->rsv_rfer == CLEAR_VALUE) {
-			qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_RSV_RFER;
-			limit->flags &= ~BTRFS_QGROUP_LIMIT_RSV_RFER;
+			qgroup->lim_flags &= ~__BTRFS_QGROUP_LIMIT_RSV_RFER;
+			limit->flags &= ~__BTRFS_QGROUP_LIMIT_RSV_RFER;
 			qgroup->rsv_rfer = 0;
 		} else {
+			btrfs_warn_rl(fs_info,
+"BTRFS_QGROUP_LIMIT_RSV_RFER flag is deprecated, will not be supported in v5.1");
 			qgroup->rsv_rfer = limit->rsv_rfer;
 		}
 	}
-	if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_EXCL) {
+	if (limit->flags & __BTRFS_QGROUP_LIMIT_RSV_EXCL) {
 		if (limit->rsv_excl == CLEAR_VALUE) {
-			qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_RSV_EXCL;
-			limit->flags &= ~BTRFS_QGROUP_LIMIT_RSV_EXCL;
+			qgroup->lim_flags &= ~__BTRFS_QGROUP_LIMIT_RSV_EXCL;
+			limit->flags &= ~__BTRFS_QGROUP_LIMIT_RSV_EXCL;
 			qgroup->rsv_excl = 0;
 		} else {
+			btrfs_warn_rl(fs_info,
+"BTRFS_QGROUP_LIMIT_RSV_EXCL flag is deprecated, will not be supported in v5.1");
 			qgroup->rsv_excl = limit->rsv_excl;
 		}
 	}
include/uapi/linux/btrfs.h +0 -0
index db4c253f8011..ec79ab781ee0 100644
@@ -53,12 +53,12 @@ struct btrfs_ioctl_vol_args {
  * struct btrfs_qgroup_limit.flags
  * struct btrfs_qgroup_limit_item.flags
  */

include/uapi/linux/btrfs.h struct btrfs_ioctl_vol_args { · line 59

Quoted 10 lines
include/uapi/linux/btrfs.h +4 -6
-#define BTRFS_QGROUP_LIMIT_MAX_RFER	(1ULL << 0)
-#define BTRFS_QGROUP_LIMIT_MAX_EXCL	(1ULL << 1)
-#define BTRFS_QGROUP_LIMIT_RSV_RFER	(1ULL << 2)
-#define BTRFS_QGROUP_LIMIT_RSV_EXCL	(1ULL << 3)
-#define BTRFS_QGROUP_LIMIT_RFER_CMPR	(1ULL << 4)
-#define BTRFS_QGROUP_LIMIT_EXCL_CMPR	(1ULL << 5)
+#define BTRFS_QGROUP_LIMIT_MAX_RFER	(1ULL << 0) /* reference (rfer) limit */
+#define BTRFS_QGROUP_LIMIT_MAX_EXCL	(1ULL << 1) /* exclusive (excl) limit */
+#define __BTRFS_QGROUP_LIMIT_RSV_RFER	(1ULL << 2) /* deprecated */
+#define __BTRFS_QGROUP_LIMIT_RSV_EXCL	(1ULL << 3) /* deprecated */

We gain absolutely nothing by prepending the __, drop it. What's sufficient for this patch is to introduce only the warnings, nothing else.

Quoted 6 lines
include/uapi/linux/btrfs.h +2 -0
+#define BTRFS_QGROUP_LIMIT_RFER_CMPR	(1ULL << 4) /* compressed rfer limit */
+#define BTRFS_QGROUP_LIMIT_EXCL_CMPR	(1ULL << 5) /* compressed excl limit */
 
 struct btrfs_qgroup_limit {
 	__u64	flags;
#2 lore raw
Quoted 69 lines · Nikolay Borisov
Quoted 66 lines · Qu Wenruo

These two flags are only used to set btrfs_qgroup::rsv_rfer/excl number, but then are never used.

Nor these flags are really used by btrfs-progs, so it's pretty safe just to deprecate them in next kernel release.

This patch will mark these two flags deprecated and output warning messages, but still handle them.

These two flags will be completely removed in next kernel release.

---
 fs/btrfs/qgroup.c          | 16 ++++++++++------
 include/uapi/linux/btrfs.h | 12 ++++++------
 2 files changed, 16 insertions(+), 12 deletions(-)
fs/btrfs/qgroup.c +10 -6
index 9afad8c14220..d4a52dbad044 100644
@@ -1385,21 +1385,25 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,
 			qgroup->max_excl = limit->max_excl;
 		}
 	}
-	if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_RFER) {
+	if (limit->flags & __BTRFS_QGROUP_LIMIT_RSV_RFER) {
 		if (limit->rsv_rfer == CLEAR_VALUE) {
-			qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_RSV_RFER;
-			limit->flags &= ~BTRFS_QGROUP_LIMIT_RSV_RFER;
+			qgroup->lim_flags &= ~__BTRFS_QGROUP_LIMIT_RSV_RFER;
+			limit->flags &= ~__BTRFS_QGROUP_LIMIT_RSV_RFER;
 			qgroup->rsv_rfer = 0;
 		} else {
+			btrfs_warn_rl(fs_info,
+"BTRFS_QGROUP_LIMIT_RSV_RFER flag is deprecated, will not be supported in v5.1");
 			qgroup->rsv_rfer = limit->rsv_rfer;
 		}
 	}
-	if (limit->flags & BTRFS_QGROUP_LIMIT_RSV_EXCL) {
+	if (limit->flags & __BTRFS_QGROUP_LIMIT_RSV_EXCL) {
 		if (limit->rsv_excl == CLEAR_VALUE) {
-			qgroup->lim_flags &= ~BTRFS_QGROUP_LIMIT_RSV_EXCL;
-			limit->flags &= ~BTRFS_QGROUP_LIMIT_RSV_EXCL;
+			qgroup->lim_flags &= ~__BTRFS_QGROUP_LIMIT_RSV_EXCL;
+			limit->flags &= ~__BTRFS_QGROUP_LIMIT_RSV_EXCL;
 			qgroup->rsv_excl = 0;
 		} else {
+			btrfs_warn_rl(fs_info,
+"BTRFS_QGROUP_LIMIT_RSV_EXCL flag is deprecated, will not be supported in v5.1");
 			qgroup->rsv_excl = limit->rsv_excl;
 		}
 	}
include/uapi/linux/btrfs.h +0 -5
index db4c253f8011..ec79ab781ee0 100644
@@ -53,12 +53,12 @@ struct btrfs_ioctl_vol_args {
  * struct btrfs_qgroup_limit.flags
  * struct btrfs_qgroup_limit_item.flags
  */
-#define BTRFS_QGROUP_LIMIT_MAX_RFER	(1ULL << 0)
-#define BTRFS_QGROUP_LIMIT_MAX_EXCL	(1ULL << 1)
-#define BTRFS_QGROUP_LIMIT_RSV_RFER	(1ULL << 2)
-#define BTRFS_QGROUP_LIMIT_RSV_EXCL	(1ULL << 3)
-#define BTRFS_QGROUP_LIMIT_RFER_CMPR	(1ULL << 4)
Quoted 8 lines

include/uapi/linux/btrfs.h struct btrfs_ioctl_vol_args { · line 59

Quoted 5 lines
include/uapi/linux/btrfs.h +4 -1
-#define BTRFS_QGROUP_LIMIT_EXCL_CMPR	(1ULL << 5)
+#define BTRFS_QGROUP_LIMIT_MAX_RFER	(1ULL << 0) /* reference (rfer) limit */
+#define BTRFS_QGROUP_LIMIT_MAX_EXCL	(1ULL << 1) /* exclusive (excl) limit */
+#define __BTRFS_QGROUP_LIMIT_RSV_RFER	(1ULL << 2) /* deprecated */
+#define __BTRFS_QGROUP_LIMIT_RSV_EXCL	(1ULL << 3) /* deprecated */

We gain absolutely nothing by prepending the __, drop it. What's sufficient for this patch is to introduce only the warnings, nothing else.

IMHO, there are 2 problems if we don't rename it:

1) Later user can still use it without checking the header. This is particularly common for anyone using completion tool, like ctags or clang completion.
For these case, without checking the header careless user won't really know these flags are deprecated.

2) To show that there are really no existing users of these 2 flags It's much more clearly shown in the patch, than without modifying it.

3) To let us know whether there is any real user of these flags After such renaming, if we really have some users of these flags, they will mostly come and complain to the mail list. Such noise would help us to know the usage (if there is any).

So, I still prefer to rename them.
This also applies to user space counter part.

Thanks,
Qu

Quoted 7 lines
Quoted 7 lines
include/uapi/linux/btrfs.h +2 -0
+#define BTRFS_QGROUP_LIMIT_RFER_CMPR	(1ULL << 4) /* compressed rfer limit */
+#define BTRFS_QGROUP_LIMIT_EXCL_CMPR	(1ULL << 5) /* compressed excl limit */
 
 struct btrfs_qgroup_limit {
 	__u64	flags;