linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] Misc warning fixes
@ 2020-08-17 12:11 David Sterba
  2020-08-17 12:11 ` [PATCH 1/5] btrfs: remove const from btrfs_feature_set_name David Sterba
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: David Sterba @ 2020-08-17 12:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

Compiling with W=1 or W=2 gives warnings that seem to be worth fixing.

David Sterba (5):
  btrfs: remove const from btrfs_feature_set_name
  btrfs: compression: move declarations to header
  btrfs: remove unnecessarily shadowed variables
  btrfs: scrub: rename ratelimit state varaible to avoid shadowing
  btrfs: send: remove indirect callback parameter for changed_cb

 fs/btrfs/backref.c     |  1 -
 fs/btrfs/compression.c | 35 -----------------------------------
 fs/btrfs/compression.h | 35 +++++++++++++++++++++++++++++++++++
 fs/btrfs/inode.c       |  1 -
 fs/btrfs/scrub.c       |  8 ++++----
 fs/btrfs/send.c        | 11 ++---------
 fs/btrfs/sysfs.c       |  2 +-
 fs/btrfs/sysfs.h       |  2 +-
 8 files changed, 43 insertions(+), 52 deletions(-)

-- 
2.25.0


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

* [PATCH 1/5] btrfs: remove const from btrfs_feature_set_name
  2020-08-17 12:11 [PATCH 0/5] Misc warning fixes David Sterba
@ 2020-08-17 12:11 ` David Sterba
  2020-08-17 12:11 ` [PATCH 2/5] btrfs: compression: move declarations to header David Sterba
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2020-08-17 12:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The function btrfs_feature_set_name returns a const char pointer, the
second const is not necessary and reported as a warning:

 In file included from fs/btrfs/space-info.c:6:
 fs/btrfs/sysfs.h:16:1: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
    16 | const char * const btrfs_feature_set_name(enum btrfs_feature_set set);
       | ^~~~~

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/sysfs.c | 2 +-
 fs/btrfs/sysfs.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c
index 88fd4ce937b8..11e5f0a520d8 100644
--- a/fs/btrfs/sysfs.c
+++ b/fs/btrfs/sysfs.c
@@ -973,7 +973,7 @@ static const char * const btrfs_feature_set_names[FEAT_MAX] = {
 	[FEAT_INCOMPAT]	 = "incompat",
 };
 
-const char * const btrfs_feature_set_name(enum btrfs_feature_set set)
+const char *btrfs_feature_set_name(enum btrfs_feature_set set)
 {
 	return btrfs_feature_set_names[set];
 }
diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h
index c9efa15f96e0..4217823e255c 100644
--- a/fs/btrfs/sysfs.h
+++ b/fs/btrfs/sysfs.h
@@ -13,7 +13,7 @@ enum btrfs_feature_set {
 };
 
 char *btrfs_printable_features(enum btrfs_feature_set set, u64 flags);
-const char * const btrfs_feature_set_name(enum btrfs_feature_set set);
+const char *btrfs_feature_set_name(enum btrfs_feature_set set);
 int btrfs_sysfs_add_devices_dir(struct btrfs_fs_devices *fs_devices,
 		struct btrfs_device *one_device);
 int btrfs_sysfs_remove_devices_dir(struct btrfs_fs_devices *fs_devices,
-- 
2.25.0


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

* [PATCH 2/5] btrfs: compression: move declarations to header
  2020-08-17 12:11 [PATCH 0/5] Misc warning fixes David Sterba
  2020-08-17 12:11 ` [PATCH 1/5] btrfs: remove const from btrfs_feature_set_name David Sterba
@ 2020-08-17 12:11 ` David Sterba
  2020-08-17 12:11 ` [PATCH 3/5] btrfs: remove unnecessarily shadowed variables David Sterba
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2020-08-17 12:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

The declarations of compression algorithm callbacks are defined in the
.c file as they're used from there. Compiler warns that there are no
declarations for public functions when compiling lzo.c/zlib.c/zstd.c.
Fix that by moving the declarations to the header as it's the common
place for all of them.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/compression.c | 35 -----------------------------------
 fs/btrfs/compression.h | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 1ab56a734e70..eeface30facd 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -29,41 +29,6 @@
 #include "extent_io.h"
 #include "extent_map.h"
 
-int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
-		u64 start, struct page **pages, unsigned long *out_pages,
-		unsigned long *total_in, unsigned long *total_out);
-int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
-int zlib_decompress(struct list_head *ws, unsigned char *data_in,
-		struct page *dest_page, unsigned long start_byte, size_t srclen,
-		size_t destlen);
-struct list_head *zlib_alloc_workspace(unsigned int level);
-void zlib_free_workspace(struct list_head *ws);
-struct list_head *zlib_get_workspace(unsigned int level);
-
-int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
-		u64 start, struct page **pages, unsigned long *out_pages,
-		unsigned long *total_in, unsigned long *total_out);
-int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
-int lzo_decompress(struct list_head *ws, unsigned char *data_in,
-		struct page *dest_page, unsigned long start_byte, size_t srclen,
-		size_t destlen);
-struct list_head *lzo_alloc_workspace(unsigned int level);
-void lzo_free_workspace(struct list_head *ws);
-
-int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
-		u64 start, struct page **pages, unsigned long *out_pages,
-		unsigned long *total_in, unsigned long *total_out);
-int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
-int zstd_decompress(struct list_head *ws, unsigned char *data_in,
-		struct page *dest_page, unsigned long start_byte, size_t srclen,
-		size_t destlen);
-void zstd_init_workspace_manager(void);
-void zstd_cleanup_workspace_manager(void);
-struct list_head *zstd_alloc_workspace(unsigned int level);
-void zstd_free_workspace(struct list_head *ws);
-struct list_head *zstd_get_workspace(unsigned int level);
-void zstd_put_workspace(struct list_head *ws);
-
 static const char* const btrfs_compress_types[] = { "", "zlib", "lzo", "zstd" };
 
 const char* btrfs_compress_type2str(enum btrfs_compression_type type)
diff --git a/fs/btrfs/compression.h b/fs/btrfs/compression.h
index 9f3dbe372631..8001b700ea3a 100644
--- a/fs/btrfs/compression.h
+++ b/fs/btrfs/compression.h
@@ -144,4 +144,39 @@ bool btrfs_compress_is_valid_type(const char *str, size_t len);
 
 int btrfs_compress_heuristic(struct inode *inode, u64 start, u64 end);
 
+int zlib_compress_pages(struct list_head *ws, struct address_space *mapping,
+		u64 start, struct page **pages, unsigned long *out_pages,
+		unsigned long *total_in, unsigned long *total_out);
+int zlib_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
+int zlib_decompress(struct list_head *ws, unsigned char *data_in,
+		struct page *dest_page, unsigned long start_byte, size_t srclen,
+		size_t destlen);
+struct list_head *zlib_alloc_workspace(unsigned int level);
+void zlib_free_workspace(struct list_head *ws);
+struct list_head *zlib_get_workspace(unsigned int level);
+
+int lzo_compress_pages(struct list_head *ws, struct address_space *mapping,
+		u64 start, struct page **pages, unsigned long *out_pages,
+		unsigned long *total_in, unsigned long *total_out);
+int lzo_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
+int lzo_decompress(struct list_head *ws, unsigned char *data_in,
+		struct page *dest_page, unsigned long start_byte, size_t srclen,
+		size_t destlen);
+struct list_head *lzo_alloc_workspace(unsigned int level);
+void lzo_free_workspace(struct list_head *ws);
+
+int zstd_compress_pages(struct list_head *ws, struct address_space *mapping,
+		u64 start, struct page **pages, unsigned long *out_pages,
+		unsigned long *total_in, unsigned long *total_out);
+int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb);
+int zstd_decompress(struct list_head *ws, unsigned char *data_in,
+		struct page *dest_page, unsigned long start_byte, size_t srclen,
+		size_t destlen);
+void zstd_init_workspace_manager(void);
+void zstd_cleanup_workspace_manager(void);
+struct list_head *zstd_alloc_workspace(unsigned int level);
+void zstd_free_workspace(struct list_head *ws);
+struct list_head *zstd_get_workspace(unsigned int level);
+void zstd_put_workspace(struct list_head *ws);
+
 #endif
-- 
2.25.0


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

* [PATCH 3/5] btrfs: remove unnecessarily shadowed variables
  2020-08-17 12:11 [PATCH 0/5] Misc warning fixes David Sterba
  2020-08-17 12:11 ` [PATCH 1/5] btrfs: remove const from btrfs_feature_set_name David Sterba
  2020-08-17 12:11 ` [PATCH 2/5] btrfs: compression: move declarations to header David Sterba
@ 2020-08-17 12:11 ` David Sterba
  2020-08-17 12:11 ` [PATCH 4/5] btrfs: scrub: rename ratelimit state varaible to avoid shadowing David Sterba
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2020-08-17 12:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

In btrfs_orphan_cleanup, there's another instance of fs_info, but it's
the same as the one we already have.

In btrfs_backref_finish_upper_links, rb_node is same type and used
as temporary cursor to the tree.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/backref.c | 1 -
 fs/btrfs/inode.c   | 1 -
 2 files changed, 2 deletions(-)

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index ea1c28ccb44f..b3268f4ea5f3 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -2997,7 +2997,6 @@ int btrfs_backref_finish_upper_links(struct btrfs_backref_cache *cache,
 	while (!list_empty(&pending_edge)) {
 		struct btrfs_backref_node *upper;
 		struct btrfs_backref_node *lower;
-		struct rb_node *rb_node;
 
 		edge = list_first_entry(&pending_edge,
 				struct btrfs_backref_edge, list[UPPER]);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index dd84c4d58a56..ced88a830253 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3055,7 +3055,6 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
 
 		if (ret == -ENOENT && root == fs_info->tree_root) {
 			struct btrfs_root *dead_root;
-			struct btrfs_fs_info *fs_info = root->fs_info;
 			int is_dead_root = 0;
 
 			/*
-- 
2.25.0


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

* [PATCH 4/5] btrfs: scrub: rename ratelimit state varaible to avoid shadowing
  2020-08-17 12:11 [PATCH 0/5] Misc warning fixes David Sterba
                   ` (2 preceding siblings ...)
  2020-08-17 12:11 ` [PATCH 3/5] btrfs: remove unnecessarily shadowed variables David Sterba
@ 2020-08-17 12:11 ` David Sterba
  2020-08-17 12:11 ` [PATCH 5/5] btrfs: send: remove indirect callback parameter for changed_cb David Sterba
  2020-08-18 15:38 ` [PATCH 0/5] Misc warning fixes Josef Bacik
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2020-08-17 12:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

There's already defined _rs within ctree.h:btrfs_printk_ratelimited,
local variables should not use _ to avoid such name clashes with
macro-local variables.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/scrub.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 5a6cb9db512e..299a35bfe5c3 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -835,7 +835,7 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
 	int success;
 	bool full_stripe_locked;
 	unsigned int nofs_flag;
-	static DEFINE_RATELIMIT_STATE(_rs, DEFAULT_RATELIMIT_INTERVAL,
+	static DEFINE_RATELIMIT_STATE(rs, DEFAULT_RATELIMIT_INTERVAL,
 				      DEFAULT_RATELIMIT_BURST);
 
 	BUG_ON(sblock_to_check->page_count < 1);
@@ -969,14 +969,14 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
 		spin_lock(&sctx->stat_lock);
 		sctx->stat.read_errors++;
 		spin_unlock(&sctx->stat_lock);
-		if (__ratelimit(&_rs))
+		if (__ratelimit(&rs))
 			scrub_print_warning("i/o error", sblock_to_check);
 		btrfs_dev_stat_inc_and_print(dev, BTRFS_DEV_STAT_READ_ERRS);
 	} else if (sblock_bad->checksum_error) {
 		spin_lock(&sctx->stat_lock);
 		sctx->stat.csum_errors++;
 		spin_unlock(&sctx->stat_lock);
-		if (__ratelimit(&_rs))
+		if (__ratelimit(&rs))
 			scrub_print_warning("checksum error", sblock_to_check);
 		btrfs_dev_stat_inc_and_print(dev,
 					     BTRFS_DEV_STAT_CORRUPTION_ERRS);
@@ -984,7 +984,7 @@ static int scrub_handle_errored_block(struct scrub_block *sblock_to_check)
 		spin_lock(&sctx->stat_lock);
 		sctx->stat.verify_errors++;
 		spin_unlock(&sctx->stat_lock);
-		if (__ratelimit(&_rs))
+		if (__ratelimit(&rs))
 			scrub_print_warning("checksum/header error",
 					    sblock_to_check);
 		if (sblock_bad->generation_error)
-- 
2.25.0


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

* [PATCH 5/5] btrfs: send: remove indirect callback parameter for changed_cb
  2020-08-17 12:11 [PATCH 0/5] Misc warning fixes David Sterba
                   ` (3 preceding siblings ...)
  2020-08-17 12:11 ` [PATCH 4/5] btrfs: scrub: rename ratelimit state varaible to avoid shadowing David Sterba
@ 2020-08-17 12:11 ` David Sterba
  2020-08-18 15:38 ` [PATCH 0/5] Misc warning fixes Josef Bacik
  5 siblings, 0 replies; 7+ messages in thread
From: David Sterba @ 2020-08-17 12:11 UTC (permalink / raw)
  To: linux-btrfs; +Cc: David Sterba

There's a custom callback passed to btrfs_compare_trees which happens to
be named exactly same as the existing function implementing it. This is
confusing and the indirection is not necessary for our needs. Compiler
is clever enough to call it directly so there's effectively no change.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/send.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
index d9813a5b075a..7c7c09fc65e8 100644
--- a/fs/btrfs/send.c
+++ b/fs/btrfs/send.c
@@ -278,11 +278,6 @@ enum btrfs_compare_tree_result {
 	BTRFS_COMPARE_TREE_CHANGED,
 	BTRFS_COMPARE_TREE_SAME,
 };
-typedef int (*btrfs_changed_cb_t)(struct btrfs_path *left_path,
-				  struct btrfs_path *right_path,
-				  struct btrfs_key *key,
-				  enum btrfs_compare_tree_result result,
-				  void *ctx);
 
 __cold
 static void inconsistent_snapshot_error(struct send_ctx *sctx,
@@ -6692,8 +6687,7 @@ static int tree_compare_item(struct btrfs_path *left_path,
  * If it detects a change, it aborts immediately.
  */
 static int btrfs_compare_trees(struct btrfs_root *left_root,
-			struct btrfs_root *right_root,
-			btrfs_changed_cb_t changed_cb, void *ctx)
+			struct btrfs_root *right_root, void *ctx)
 {
 	struct btrfs_fs_info *fs_info = left_root->fs_info;
 	int ret;
@@ -6960,8 +6954,7 @@ static int send_subvol(struct send_ctx *sctx)
 		goto out;
 
 	if (sctx->parent_root) {
-		ret = btrfs_compare_trees(sctx->send_root, sctx->parent_root,
-				changed_cb, sctx);
+		ret = btrfs_compare_trees(sctx->send_root, sctx->parent_root, sctx);
 		if (ret < 0)
 			goto out;
 		ret = finish_inode_if_needed(sctx, 1);
-- 
2.25.0


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

* Re: [PATCH 0/5] Misc warning fixes
  2020-08-17 12:11 [PATCH 0/5] Misc warning fixes David Sterba
                   ` (4 preceding siblings ...)
  2020-08-17 12:11 ` [PATCH 5/5] btrfs: send: remove indirect callback parameter for changed_cb David Sterba
@ 2020-08-18 15:38 ` Josef Bacik
  5 siblings, 0 replies; 7+ messages in thread
From: Josef Bacik @ 2020-08-18 15:38 UTC (permalink / raw)
  To: David Sterba, linux-btrfs

On 8/17/20 8:11 AM, David Sterba wrote:
> Compiling with W=1 or W=2 gives warnings that seem to be worth fixing.
> 
> David Sterba (5):
>    btrfs: remove const from btrfs_feature_set_name
>    btrfs: compression: move declarations to header
>    btrfs: remove unnecessarily shadowed variables
>    btrfs: scrub: rename ratelimit state varaible to avoid shadowing
>    btrfs: send: remove indirect callback parameter for changed_cb
> 
>   fs/btrfs/backref.c     |  1 -
>   fs/btrfs/compression.c | 35 -----------------------------------
>   fs/btrfs/compression.h | 35 +++++++++++++++++++++++++++++++++++
>   fs/btrfs/inode.c       |  1 -
>   fs/btrfs/scrub.c       |  8 ++++----
>   fs/btrfs/send.c        | 11 ++---------
>   fs/btrfs/sysfs.c       |  2 +-
>   fs/btrfs/sysfs.h       |  2 +-
>   8 files changed, 43 insertions(+), 52 deletions(-)
> 

The whole series can have

Reviewed-by: Josef Bacik <josef@toxicpanda.com>

Thanks,

Josef

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

end of thread, other threads:[~2020-08-18 15:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-17 12:11 [PATCH 0/5] Misc warning fixes David Sterba
2020-08-17 12:11 ` [PATCH 1/5] btrfs: remove const from btrfs_feature_set_name David Sterba
2020-08-17 12:11 ` [PATCH 2/5] btrfs: compression: move declarations to header David Sterba
2020-08-17 12:11 ` [PATCH 3/5] btrfs: remove unnecessarily shadowed variables David Sterba
2020-08-17 12:11 ` [PATCH 4/5] btrfs: scrub: rename ratelimit state varaible to avoid shadowing David Sterba
2020-08-17 12:11 ` [PATCH 5/5] btrfs: send: remove indirect callback parameter for changed_cb David Sterba
2020-08-18 15:38 ` [PATCH 0/5] Misc warning fixes Josef Bacik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).