Skip to contentSkip to conversation

Change printk to btrfs_* where applicable

PATCH Superseded Frank Holton 2 participants 5 messages Nov 13, 2013 – Nov 14, 2013 Btrfs file system

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover Change printk to btrfs_* where applicable

I've replaced pr_ and printk statments by btrfs_ output macros where I could find a fs_info structure. There may be a few remaining cases where a fs_info structure could be obtained from one of the inputs but I wasn't sure how. For all the of the remaining pr_ and printk statements I've made sure that the btrfs: prefix is present and correct.

The second patch is needed because of the way pr_debug is handled by the kernel. When DEBUG is not defined pr_debug is removed and does not cause any output. This patch defines btrfs_debug as noprintk when DEBUG is not defined which matches the way pr_debug is handled.

Thanks

Frank Holton (2):
Btrfs: convert printk and pr_ to btrfs_* and fix btrfs: prefix
Btrfs: make btrfs_debug match pr_debug handling related to DEBUG

 fs/btrfs/backref.c               |   21 ++++----
 fs/btrfs/compression.c           |   11 ++--
 fs/btrfs/ctree.c                 |   14 ++---
 fs/btrfs/ctree.h                 |   10 +++-
 fs/btrfs/delayed-inode.c         |   10 ++--
 fs/btrfs/delayed-ref.c           |    3 +-
 fs/btrfs/dev-replace.c           |   28 +++++-----
 fs/btrfs/dir-item.c              |    6 +--
 fs/btrfs/disk-io.c               |   45 ++++++++--------
 fs/btrfs/extent-tree.c           |   12 ++---
 fs/btrfs/extent_io.c             |   83 ++++++++++++++++++------------
 fs/btrfs/file-item.c             |    4 +-
 fs/btrfs/free-space-cache.c      |   14 ++---
 fs/btrfs/inode.c                 |   12 ++---
 fs/btrfs/ioctl.c                 |   28 +++++-----
 fs/btrfs/lzo.c                   |    6 +--
 fs/btrfs/ordered-data.c          |    9 ++--
 fs/btrfs/qgroup.c                |   29 ++++++-----
 fs/btrfs/reada.c                 |   14 ++---
 fs/btrfs/relocation.c            |    4 +-
 fs/btrfs/root-tree.c             |    3 +-
 fs/btrfs/scrub.c                 |   27 +++++-----
 fs/btrfs/super.c                 |  105 ++++++++++++++++++--------------------
 fs/btrfs/tests/extent-io-tests.c |    3 +-
 fs/btrfs/transaction.c           |    4 +-
 fs/btrfs/uuid-tree.c             |   12 ++---
 fs/btrfs/volumes.c               |   70 ++++++++++++-------------
 27 files changed, 307 insertions(+), 280 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v2 1/2 Btrfs: convert printk and pr_ to btrfs_* and fix btrfs: prefix

Convert all applicable cases of printk and pr_ macros to the btrfs_* macro. Fix btrfs: prefix in remaining cases.

---
v2: changed pr_ and printk to btrfs_ output macro

 fs/btrfs/backref.c               |   21 ++++----
 fs/btrfs/compression.c           |   11 ++--
 fs/btrfs/ctree.c                 |   14 ++---
 fs/btrfs/ctree.h                 |    4 +-
 fs/btrfs/delayed-inode.c         |   10 ++--
 fs/btrfs/delayed-ref.c           |    3 +-
 fs/btrfs/dev-replace.c           |   28 +++++-----
 fs/btrfs/dir-item.c              |    6 +--
 fs/btrfs/disk-io.c               |   45 ++++++++--------
 fs/btrfs/extent-tree.c           |   12 ++---
 fs/btrfs/extent_io.c             |   83 ++++++++++++++++++------------
 fs/btrfs/file-item.c             |    4 +-
 fs/btrfs/free-space-cache.c      |   14 ++---
 fs/btrfs/inode.c                 |   12 ++---
 fs/btrfs/ioctl.c                 |   28 +++++-----
 fs/btrfs/lzo.c                   |    6 +--
 fs/btrfs/ordered-data.c          |    9 ++--
 fs/btrfs/qgroup.c                |   29 ++++++-----
 fs/btrfs/reada.c                 |   14 ++---
 fs/btrfs/relocation.c            |    4 +-
 fs/btrfs/root-tree.c             |    3 +-
 fs/btrfs/scrub.c                 |   27 +++++-----
 fs/btrfs/super.c                 |  105 ++++++++++++++++++--------------------
 fs/btrfs/tests/extent-io-tests.c |    3 +-
 fs/btrfs/transaction.c           |    4 +-
 fs/btrfs/uuid-tree.c             |   12 ++---
 fs/btrfs/volumes.c               |   70 ++++++++++++-------------
 27 files changed, 301 insertions(+), 280 deletions(-)
fs/btrfs/backref.c +11 -10
index 3775947..0bab8a9 100644
@@ -316,8 +316,8 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
 
 	path->lowest_level = level;
 	ret = btrfs_search_old_slot(root, &ref->key_for_search, path, time_seq);
-	pr_debug("search slot in root %llu (level %d, ref count %d) returned "
-		 "%d for key (%llu %u %llu)\n",
+	btrfs_debug(fs_info, "search slot in root %llu (level %d, ref count %d) "
+		 "returned %d for key (%llu %u %llu)",
 		 ref->root_id, level, ref->count, ret,
 		 ref->key_for_search.objectid, ref->key_for_search.type,
 		 ref->key_for_search.offset);
@@ -1350,7 +1350,8 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
 	     found_key->type != BTRFS_METADATA_ITEM_KEY) ||
 	    found_key->objectid > logical ||
 	    found_key->objectid + size <= logical) {
-		pr_debug("logical %llu is not within any extent\n", logical);
+		btrfs_debug(fs_info, "logical %llu is not within any extent",
+				logical);
 		return -ENOENT;
 	}
 
@@ -1361,8 +1362,8 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical,
 	ei = btrfs_item_ptr(eb, path->slots[0], struct btrfs_extent_item);
 	flags = btrfs_extent_flags(eb, ei);
 
-	pr_debug("logical %llu is at position %llu within the extent (%llu "
-		 "EXTENT_ITEM %llu) flags %#llx size %u\n",
+	btrfs_debug(fs_info, "logical %llu is at position %llu within the extent"
+		 "(%llu EXTENT_ITEM %llu) flags %#llx size %u",
 		 logical, logical - found_key->objectid, found_key->objectid,
 		 found_key->offset, flags, item_size);
 
@@ -1510,7 +1511,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
 	struct ulist_iterator ref_uiter;
 	struct ulist_iterator root_uiter;
 
-	pr_debug("resolving all inodes for extent %llu\n",
+	btrfs_debug(fs_info, "resolving all inodes for extent %llu",
 			extent_item_objectid);
 
 	if (!search_commit_root) {
@@ -1534,8 +1535,8 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info,
 			break;
 		ULIST_ITER_INIT(&root_uiter);
 		while (!ret && (root_node = ulist_next(roots, &root_uiter))) {
-			pr_debug("root %llu references leaf %llu, data list "
-				 "%#llx\n", root_node->val, ref_node->val,
+			btrfs_debug(fs_info, "root %llu references leaf %llu, data list "
+				 "%#llx", root_node->val, ref_node->val,
 				 ref_node->aux);
 			ret = iterate_leaf_refs((struct extent_inode_elem *)
 						(uintptr_t)ref_node->aux,
@@ -1627,8 +1628,8 @@ static int iterate_inode_refs(u64 inum, struct btrfs_root *fs_root,
 		for (cur = 0; cur < btrfs_item_size(eb, item); cur += len) {
 			name_len = btrfs_inode_ref_name_len(eb, iref);
 			/* path must be released before calling iterate()! */
-			pr_debug("following ref at offset %u for inode %llu in "
-				 "tree %llu\n", cur, found_key.objectid,
+			btrfs_debug(fs_root->fs_info, "following ref at offset %u for "
+				 "inode %llu in tree %llu", cur, found_key.objectid,
 				 fs_root->objectid);
 			ret = iterate(parent, name_len,
 				      (unsigned long)(iref + 1), eb, ctx);
fs/btrfs/compression.c +6 -5
index 1499b27..452e94a 100644
@@ -128,10 +128,10 @@ static int check_compressed_csum(struct inode *inode,
 		kunmap_atomic(kaddr);
 
 		if (csum != *cb_sum) {
-			printk(KERN_INFO "btrfs csum failed ino %llu "
-			       "extent %llu csum %u "
-			       "wanted %u mirror %d\n",
-			       btrfs_ino(inode), disk_start, csum, *cb_sum,
+			btrfs_info(BTRFS_I(inode)->root->fs_info, "csum failed "
+				   "ino %llu extent %llu csum %u "
+				   "wanted %u mirror %d",
+				   btrfs_ino(inode), disk_start, csum, *cb_sum,
 			       cb->mirror_num);
 			ret = -EIO;
 			goto fail;
@@ -412,7 +412,8 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
 			bio_add_page(bio, page, PAGE_CACHE_SIZE, 0);
 		}
 		if (bytes_left < PAGE_CACHE_SIZE) {
-			printk("bytes left %lu compress len %lu nr %lu\n",
+			btrfs_info(BTRFS_I(inode)->root->fs_info, "bytes left %lu compress"
+				   "len %lu nr %lu",
 			       bytes_left, cb->compressed_len, cb->nr_pages);
 		}
 		bytes_left -= PAGE_CACHE_SIZE;
fs/btrfs/ctree.c +7 -7
index 316136b..fe1dc0e 100644
@@ -1287,8 +1287,8 @@ get_old_root(struct btrfs_root *root, u64 time_seq)
 		old = read_tree_block(root, logical, blocksize, 0);
 		if (WARN_ON(!old || !extent_buffer_uptodate(old))) {
 			free_extent_buffer(old);
-			pr_warn("btrfs: failed to read tree block %llu from get_old_root\n",
-				logical);
+			btrfs_warn(root->fs_info, "failed to read tree block %llu from "
+				 "get_old_root", logical);
 		} else {
 			eb = btrfs_clone_extent_buffer(old);
 			free_extent_buffer(old);
@@ -3362,8 +3362,8 @@ noinline int btrfs_leaf_free_space(struct btrfs_root *root,
 	int ret;
 	ret = BTRFS_LEAF_DATA_SIZE(root) - leaf_space_used(leaf, 0, nritems);
 	if (ret < 0) {
-		printk(KERN_CRIT "leaf free space ret %d, leaf data size %lu, "
-		       "used %d nritems %d\n",
+		btrfs_crit(root->fs_info, "leaf free space ret %d, leaf data size %lu, "
+			   "used %d nritems %d",
 		       ret, (unsigned long) BTRFS_LEAF_DATA_SIZE(root),
 		       leaf_space_used(leaf, 0, nritems), nritems);
 	}
@@ -4432,7 +4432,7 @@ void btrfs_extend_item(struct btrfs_root *root, struct btrfs_path *path,
 	BUG_ON(slot < 0);
 	if (slot >= nritems) {
 		btrfs_print_leaf(root, leaf);
-		printk(KERN_CRIT "slot %d too large, nritems %d\n",
+		btrfs_crit(root->fs_info, "slot %d too large, nritems %d",
 		       slot, nritems);
 		BUG_ON(1);
 	}
@@ -4495,7 +4495,7 @@ void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path,
 
 	if (btrfs_leaf_free_space(root, leaf) < total_size) {
 		btrfs_print_leaf(root, leaf);
-		printk(KERN_CRIT "not enough freespace need %u have %d\n",
+		btrfs_crit(root->fs_info, "not enough freespace need %u have %d",
 		       total_size, btrfs_leaf_free_space(root, leaf));
 		BUG();
 	}
@@ -4505,7 +4505,7 @@ void setup_items_for_insert(struct btrfs_root *root, struct btrfs_path *path,
 
 		if (old_data < data_end) {
 			btrfs_print_leaf(root, leaf);
-			printk(KERN_CRIT "slot %d old_data %d data_end %d\n",
+			btrfs_crit(root->fs_info, "slot %d old_data %d data_end %d",
 			       slot, old_data, data_end);
 			BUG_ON(1);
 		}
fs/btrfs/ctree.h +2 -2
index f013a31..e319d25 100644
@@ -3816,7 +3816,7 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
 
 static inline void assfail(char *expr, char *file, int line)
 {
-	printk(KERN_ERR "BTRFS assertion failed: %s, file: %s, line: %d",
+	pr_err("btrfs: assertion failed: %s, file: %s, line: %d",
 	       expr, file, line);
 	BUG();
 }
@@ -3854,7 +3854,7 @@ static inline void __btrfs_set_fs_incompat(struct btrfs_fs_info *fs_info,
 		if (!(features & flag)) {
 			features |= flag;
 			btrfs_set_super_incompat_flags(disk_super, features);
-			printk(KERN_INFO "btrfs: setting %llu feature flag\n",
+			btrfs_info(fs_info, "setting %llu feature flag",
 					 flag);
 		}
 		spin_unlock(&fs_info->super_lock);
fs/btrfs/delayed-inode.c +5 -5
index 8d292fb..cea715f 100644
@@ -1472,9 +1472,9 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,
 	mutex_lock(&delayed_node->mutex);
 	ret = __btrfs_add_delayed_insertion_item(delayed_node, delayed_item);
 	if (unlikely(ret)) {
-		printk(KERN_ERR "err add delayed dir index item(name: %.*s) "
+		btrfs_err(root->fs_info, "err add delayed dir index item(name: %.*s) "
 				"into the insertion tree of the delayed node"
-				"(root id: %llu, inode id: %llu, errno: %d)\n",
+				"(root id: %llu, inode id: %llu, errno: %d)",
 				name_len, name, delayed_node->root->objectid,
 				delayed_node->inode_id, ret);
 		BUG();
@@ -1544,9 +1544,9 @@ int btrfs_delete_delayed_dir_index(struct btrfs_trans_handle *trans,
 	mutex_lock(&node->mutex);
 	ret = __btrfs_add_delayed_deletion_item(node, item);
 	if (unlikely(ret)) {
-		printk(KERN_ERR "err add delayed dir index item(index: %llu) "
-				"into the deletion tree of the delayed node"
-				"(root id: %llu, inode id: %llu, errno: %d)\n",
+		btrfs_crit(root->fs_info, "err add delayed dir index item(index: %llu)"
+				" into the deletion tree of the delayed node"
+				"(root id: %llu, inode id: %llu, errno: %d)",
 				index, node->root->objectid, node->inode_id,
 				ret);
 		BUG();
fs/btrfs/delayed-ref.c +2 -1
index e4d467b..fd26823 100644
@@ -361,7 +361,8 @@ int btrfs_check_delayed_seq(struct btrfs_fs_info *fs_info,
 		elem = list_first_entry(&fs_info->tree_mod_seq_list,
 					struct seq_list, list);
 		if (seq >= elem->seq) {
-			pr_debug("holding back delayed_ref %#x.%x, lowest is %#x.%x (%p)\n",
+			btrfs_debug(fs_info, "holding back delayed_ref %#x.%x, "
+				 "lowest is %#x.%x (%p)",
 				 (u32)(seq >> 32), (u32)seq,
 				 (u32)(elem->seq >> 32), (u32)elem->seq,
 				 delayed_refs);
fs/btrfs/dev-replace.c +16 -12
index 3e41097..f6f50d2 100644
@@ -102,7 +102,7 @@ no_valid_dev_replace_entry_found:
 	ptr = btrfs_item_ptr(eb, slot, struct btrfs_dev_replace_item);
 
 	if (item_size != sizeof(struct btrfs_dev_replace_item)) {
-		pr_warn("btrfs: dev_replace entry found has unexpected size, ignore entry\n");
+		btrfs_warn(fs_info, "dev_replace entry found has unexpected size, ignore entry");
 		goto no_valid_dev_replace_entry_found;
 	}
 
@@ -145,13 +145,17 @@ no_valid_dev_replace_entry_found:
 		if (!dev_replace->srcdev &&
 		    !btrfs_test_opt(dev_root, DEGRADED)) {
 			ret = -EIO;
-			pr_warn("btrfs: cannot mount because device replace operation is ongoing and\n" "srcdev (devid %llu) is missing, need to run 'btrfs dev scan'?\n",
+			btrfs_warn(fs_info, "cannot mount because device replace operation"
+				 " is ongoing and\n" "srcdev (devid %llu) is missing, need to "
+				 "run 'btrfs dev scan'?",
 				src_devid);
 		}
 		if (!dev_replace->tgtdev &&
 		    !btrfs_test_opt(dev_root, DEGRADED)) {
 			ret = -EIO;
-			pr_warn("btrfs: cannot mount because device replace operation is ongoing and\n" "tgtdev (devid %llu) is missing, need to run btrfs dev scan?\n",
+			btrfs_warn(fs_info, "cannot mount because device replace operation "
+				 "is ongoing and\n" "tgtdev (devid %llu) is missing, need to "
+				 "run btrfs dev scan?",
 				BTRFS_DEV_REPLACE_DEVID);
 		}
 		if (dev_replace->tgtdev) {
@@ -210,7 +214,7 @@ int btrfs_run_dev_replace(struct btrfs_trans_handle *trans,
 	}
 	ret = btrfs_search_slot(trans, dev_root, &key, path, -1, 1);
 	if (ret < 0) {
-		pr_warn("btrfs: error %d while searching for dev_replace item!\n",
+		btrfs_warn(fs_info, "error %d while searching for dev_replace item!",
 			ret);
 		goto out;
 	}
@@ -230,7 +234,7 @@ int btrfs_run_dev_replace(struct btrfs_trans_handle *trans,
 		 */
 		ret = btrfs_del_item(trans, dev_root, path);
 		if (ret != 0) {
-			pr_warn("btrfs: delete too small dev_replace item failed %d!\n",
+			btrfs_warn(fs_info, "delete too small dev_replace item failed %d!",
 				ret);
 			goto out;
 		}
@@ -243,7 +247,7 @@ int btrfs_run_dev_replace(struct btrfs_trans_handle *trans,
 		ret = btrfs_insert_empty_item(trans, dev_root, path,
 					      &key, sizeof(*ptr));
 		if (ret < 0) {
-			pr_warn("btrfs: insert dev_replace item failed %d!\n",
+			btrfs_warn(fs_info, "insert dev_replace item failed %d!",
 				ret);
 			goto out;
 		}
@@ -305,7 +309,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
 	struct btrfs_device *src_device = NULL;
 
 	if (btrfs_fs_incompat(fs_info, RAID56)) {
-		pr_warn("btrfs: dev_replace cannot yet handle RAID5/RAID6\n");
+		btrfs_warn(fs_info, "dev_replace cannot yet handle RAID5/RAID6");
 		return -EINVAL;
 	}
 
@@ -325,7 +329,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
 	ret = btrfs_init_dev_replace_tgtdev(root, args->start.tgtdev_name,
 					    &tgt_device);
 	if (ret) {
-		pr_err("btrfs: target device %s is invalid!\n",
+		btrfs_err(fs_info, "target device %s is invalid!",
 		       args->start.tgtdev_name);
 		mutex_unlock(&fs_info->volume_mutex);
 		return -EINVAL;
@@ -341,7 +345,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root,
 	}
 
 	if (tgt_device->total_bytes < src_device->total_bytes) {
-		pr_err("btrfs: target device is smaller than source device!\n");
+		btrfs_err(fs_info, "target device is smaller than source device!");
 		ret = -EINVAL;
 		goto leave_no_lock;
 	}
@@ -699,7 +703,7 @@ void btrfs_dev_replace_suspend_for_unmount(struct btrfs_fs_info *fs_info)
 			BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED;
 		dev_replace->time_stopped = get_seconds();
 		dev_replace->item_needs_writeback = 1;
-		pr_info("btrfs: suspending dev_replace for unmount\n");
+		btrfs_info(fs_info, "suspending dev_replace for unmount");
 		break;
 	}
 
@@ -728,8 +732,8 @@ int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info)
 		break;
 	}
 	if (!dev_replace->tgtdev || !dev_replace->tgtdev->bdev) {
-		pr_info("btrfs: cannot continue dev_replace, tgtdev is missing\n"
-			"btrfs: you may cancel the operation after 'mount -o degraded'\n");
+		btrfs_info(fs_info, "cannot continue dev_replace, tgtdev is missing"
+			"btrfs: you may cancel the operation after 'mount -o degraded'");
 		btrfs_dev_replace_unlock(dev_replace);
 		return 0;
 	}
fs/btrfs/dir-item.c +3 -3
index c031ea3..9cc2be0 100644
@@ -459,7 +459,7 @@ int verify_dir_item(struct btrfs_root *root,
 	u8 type = btrfs_dir_type(leaf, dir_item);
 
 	if (type >= BTRFS_FT_MAX) {
-		printk(KERN_CRIT "btrfs: invalid dir item type: %d\n",
+		btrfs_crit(root->fs_info, "invalid dir item type: %d",
 		       (int)type);
 		return 1;
 	}
@@ -468,7 +468,7 @@ int verify_dir_item(struct btrfs_root *root,
 		namelen = XATTR_NAME_MAX;
 
 	if (btrfs_dir_name_len(leaf, dir_item) > namelen) {
-		printk(KERN_CRIT "btrfs: invalid dir item name len: %u\n",
+		btrfs_crit(root->fs_info, "invalid dir item name len: %u",
 		       (unsigned)btrfs_dir_data_len(leaf, dir_item));
 		return 1;
 	}
@@ -476,7 +476,7 @@ int verify_dir_item(struct btrfs_root *root,
 	/* BTRFS_MAX_XATTR_SIZE is the same for all dir items */
 	if ((btrfs_dir_data_len(leaf, dir_item) +
 	     btrfs_dir_name_len(leaf, dir_item)) > BTRFS_MAX_XATTR_SIZE(root)) {
-		printk(KERN_CRIT "btrfs: invalid dir item name + data len: %u + %u\n",
+		btrfs_crit(root->fs_info, "invalid dir item name + data len: %u + %u",
 		       (unsigned)btrfs_dir_name_len(leaf, dir_item),
 		       (unsigned)btrfs_dir_data_len(leaf, dir_item));
 		return 1;
fs/btrfs/disk-io.c +23 -22

164 lines not on this page · raw message

fs/btrfs/extent-tree.c +6 -6
index 42f1c8e..1efda46 100644
@@ -5840,8 +5840,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
 
 	refs = btrfs_extent_refs(leaf, ei);
 	if (refs < refs_to_drop) {
-		btrfs_err(info, "trying to drop %d refs but we only have %Lu "
-			  "for bytenr %Lu\n", refs_to_drop, refs, bytenr);
+		btrfs_err(info, "trying to drop %d refs but we only have %llu "
+			  "for bytenr %llu", refs_to_drop, refs, bytenr);
 		ret = -EINVAL;
 		btrfs_abort_transaction(trans, extent_root, ret);
 		goto out;
@@ -6591,12 +6591,12 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes,
 	int index = 0;
 
 	spin_lock(&info->lock);
-	printk(KERN_INFO "space_info %llu has %llu free, is %sfull\n",
+	printk(KERN_INFO "btrfs: space_info %llu has %llu free, is %sfull\n",
 	       info->flags,
 	       info->total_bytes - info->bytes_used - info->bytes_pinned -
 	       info->bytes_reserved - info->bytes_readonly,
 	       (info->full) ? "" : "not ");
-	printk(KERN_INFO "space_info total=%llu, used=%llu, pinned=%llu, "
+	printk(KERN_INFO "btrfs: space_info total=%llu, used=%llu, pinned=%llu, "
 	       "reserved=%llu, may_use=%llu, readonly=%llu\n",
 	       info->total_bytes, info->bytes_used, info->bytes_pinned,
 	       info->bytes_reserved, info->bytes_may_use,
@@ -6610,7 +6610,7 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes,
 again:
 	list_for_each_entry(cache, &info->block_groups[index], list) {
 		spin_lock(&cache->lock);
-		printk(KERN_INFO "block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %s\n",
+		printk(KERN_INFO "btrfs: block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %s\n",
 		       cache->key.objectid, cache->key.offset,
 		       btrfs_block_group_used(&cache->item), cache->pinned,
 		       cache->reserved, cache->ro ? "[readonly]" : "");
@@ -7721,7 +7721,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
 
 			btrfs_end_transaction_throttle(trans, tree_root);
 			if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
-				pr_debug("btrfs: drop snapshot early exit\n");
+				btrfs_debug(root->fs_info, "drop snapshot early exit");
 				err = -EAGAIN;
 				goto out_free;
 			}
fs/btrfs/extent_io.c +49 -34

193 lines not on this page · raw message

fs/btrfs/file-item.c +2 -2
index 6f38488..b3a2b4d 100644
@@ -246,8 +246,8 @@ static int __btrfs_lookup_bio_sums(struct btrfs_root *root,
 						offset + bvec->bv_len - 1,
 						EXTENT_NODATASUM, GFP_NOFS);
 				} else {
-					printk(KERN_INFO "btrfs no csum found "
-					       "for inode %llu start %llu\n",
+					btrfs_info(BTRFS_I(inode)->root->fs_info, "no csum found "
+						   "for inode %llu start %llu",
 					       btrfs_ino(inode), offset);
 				}
 				item = NULL;
fs/btrfs/free-space-cache.c +7 -7
index 7008868..0f13a6e 100644
@@ -349,8 +349,8 @@ static int io_ctl_prepare_pages(struct io_ctl *io_ctl, struct inode *inode,
 			btrfs_readpage(NULL, page);
 			lock_page(page);
 			if (!PageUptodate(page)) {
-				printk(KERN_ERR "btrfs: error reading free "
-				       "space cache\n");
+				btrfs_err(BTRFS_I(inode)->root->fs_info, "error reading free "
+					   "space cache");
 				io_ctl_drop_pages(io_ctl);
 				return -EIO;
 			}
@@ -2013,14 +2013,14 @@ void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group,
 		info = rb_entry(n, struct btrfs_free_space, offset_index);
 		if (info->bytes >= bytes && !block_group->ro)
 			count++;
-		printk(KERN_CRIT "entry offset %llu, bytes %llu, bitmap %s\n",
-		       info->offset, info->bytes,
+		btrfs_crit(block_group->fs_info, "entry offset %llu, bytes %llu, "
+			   "bitmap %s", info->offset, info->bytes,
 		       (info->bitmap) ? "yes" : "no");
 	}
-	printk(KERN_INFO "block group has cluster?: %s\n",
+	btrfs_info(block_group->fs_info, "block group has cluster?: %s",
 	       list_empty(&block_group->cluster_list) ? "no" : "yes");
-	printk(KERN_INFO "%d blocks of free space at or bigger than bytes is"
-	       "\n", count);
+	btrfs_info(block_group->fs_info, "%d blocks of free space at or bigger "
+		   "than bytes is", count);
 }
 
 void btrfs_init_free_space_ctl(struct btrfs_block_group_cache *block_group)
fs/btrfs/inode.c +6 -6
index f167ced..d9e55c3 100644
@@ -2026,7 +2026,7 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id,
 		if (PTR_ERR(root) == -ENOENT)
 			return 0;
 		WARN_ON(1);
-		pr_debug("inum=%llu, offset=%llu, root_id=%llu\n",
+		btrfs_debug(fs_info, "inum=%llu, offset=%llu, root_id=%llu",
 			 inum, offset, root_id);
 		return PTR_ERR(root);
 	}
@@ -6912,8 +6912,8 @@ static void btrfs_end_dio_bio(struct bio *bio, int err)
 	struct btrfs_dio_private *dip = bio->bi_private;
 
 	if (err) {
-		printk(KERN_ERR "btrfs direct IO failed ino %llu rw %lu "
-		      "sector %#Lx len %u err no %d\n",
+		btrfs_err(BTRFS_I(dip->inode)->root->fs_info, "direct IO failed "
+				  "ino %llu rw %lu sector %#Lx len %u err no %d",
 		      btrfs_ino(dip->inode), bio->bi_rw,
 		      (unsigned long long)bio->bi_sector, bio->bi_size, err);
 		dip->errors = 1;
@@ -8070,9 +8070,9 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	 */
 	trans = btrfs_start_transaction(root, 11);
 	if (IS_ERR(trans)) {
-                ret = PTR_ERR(trans);
-                goto out_notrans;
-        }
+				ret = PTR_ERR(trans);
+				goto out_notrans;
+		}
 
 	if (dest != root)
 		btrfs_record_root_in_trans(trans, dest);
fs/btrfs/ioctl.c +14 -14
index 1d04b55..c384809 100644
@@ -1249,7 +1249,7 @@ int btrfs_defrag_file(struct inode *inode, struct file *file,
 			break;
 
 		if (btrfs_defrag_cancelled(root->fs_info)) {
-			printk(KERN_DEBUG "btrfs: defrag_file cancelled\n");
+			btrfs_debug(root->fs_info, "defrag_file cancelled");
 			ret = -EAGAIN;
 			break;
 		}
@@ -1411,20 +1411,20 @@ static noinline int btrfs_ioctl_resize(struct file *file,
 			ret = -EINVAL;
 			goto out_free;
 		}
-		printk(KERN_INFO "btrfs: resizing devid %llu\n", devid);
+		btrfs_info(root->fs_info, "resizing devid %llu", devid);
 	}
 
 	device = btrfs_find_device(root->fs_info, devid, NULL, NULL);
 	if (!device) {
-		printk(KERN_INFO "btrfs: resizer unable to find device %llu\n",
+		btrfs_info(root->fs_info, "resizer unable to find device %llu",
 		       devid);
 		ret = -ENODEV;
 		goto out_free;
 	}
 
 	if (!device->writeable) {
-		printk(KERN_INFO "btrfs: resizer unable to apply on "
-		       "readonly device %llu\n",
+		btrfs_info(root->fs_info, "resizer unable to apply on "
+			   "readonly device %llu",
 		       devid);
 		ret = -EPERM;
 		goto out_free;
@@ -1537,8 +1537,8 @@ static noinline int btrfs_ioctl_snap_create_transid(struct file *file,
 
 		src_inode = file_inode(src.file);
 		if (src_inode->i_sb != file_inode(file)->i_sb) {
-			printk(KERN_INFO "btrfs: Snapshot src from "
-			       "another FS\n");
+			btrfs_info(BTRFS_I(src_inode)->root->fs_info, "Snapshot src from "
+				   "another FS");
 			ret = -EINVAL;
 		} else {
 			ret = btrfs_mksubvol(&file->f_path, name, namelen,
@@ -1905,7 +1905,7 @@ static noinline int search_ioctl(struct inode *inode,
 		key.offset = (u64)-1;
 		root = btrfs_read_fs_root_no_name(info, &key);
 		if (IS_ERR(root)) {
-			printk(KERN_ERR "could not find root %llu\n",
+			printk(KERN_ERR "btrfs: could not find root %llu\n",
 			       sk->tree_id);
 			btrfs_free_path(path);
 			return -ENOENT;
@@ -1995,7 +1995,7 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_fs_info *info,
 	key.offset = (u64)-1;
 	root = btrfs_read_fs_root_no_name(info, &key);
 	if (IS_ERR(root)) {
-		printk(KERN_ERR "could not find root %llu\n", tree_id);
+		printk(KERN_ERR "btrfs: could not find root %llu\n", tree_id);
 		ret = -ENOENT;
 		goto out;
 	}
@@ -3337,8 +3337,8 @@ static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp)
 	if (IS_ERR_OR_NULL(di)) {
 		btrfs_free_path(path);
 		btrfs_end_transaction(trans, root);
-		printk(KERN_ERR "Umm, you don't have the default dir item, "
-		       "this isn't going to work\n");
+		btrfs_err(new_root->fs_info, "Umm, you don't have the default dir"
+			   "item, this isn't going to work");
 		ret = -ENOENT;
 		goto out;
 	}
@@ -4425,8 +4425,8 @@ static int btrfs_ioctl_get_fslabel(struct file *file, void __user *arg)
 	len = strnlen(label, BTRFS_LABEL_SIZE);
 
 	if (len == BTRFS_LABEL_SIZE) {
-		pr_warn("btrfs: label is too long, return the first %zu bytes\n",
-			--len);
+		btrfs_warn(root->fs_info, "label is too long, return the first %zu "
+			"bytes", --len);
 	}
 
 	ret = copy_to_user(arg, label, len);
@@ -4449,7 +4449,7 @@ static int btrfs_ioctl_set_fslabel(struct file *file, void __user *arg)
 		return -EFAULT;
 
 	if (strnlen(label, BTRFS_LABEL_SIZE) == BTRFS_LABEL_SIZE) {
-		pr_err("btrfs: unable to set label with more than %d bytes\n",
+		btrfs_err(root->fs_info, "unable to set label with more than %d bytes",
 		       BTRFS_LABEL_SIZE - 1);
 		return -EINVAL;
 	}
fs/btrfs/lzo.c +3 -3
index b6a6f07..6596b0a 100644
@@ -141,7 +141,7 @@ static int lzo_compress_pages(struct list_head *ws,
 		ret = lzo1x_1_compress(data_in, in_len, workspace->cbuf,
 				       &out_len, workspace->mem);
 		if (ret != LZO_E_OK) {
-			printk(KERN_DEBUG "btrfs deflate in loop returned %d\n",
+			printk(KERN_DEBUG "btrfs: deflate in loop returned %d\n",
 			       ret);
 			ret = -1;
 			goto out;
@@ -357,7 +357,7 @@ cont:
 		if (need_unmap)
 			kunmap(pages_in[page_in_index - 1]);
 		if (ret != LZO_E_OK) {
-			printk(KERN_WARNING "btrfs decompress failed\n");
+			printk(KERN_WARNING "btrfs: decompress failed\n");
 			ret = -1;
 			break;
 		}
@@ -401,7 +401,7 @@ static int lzo_decompress(struct list_head *ws, unsigned char *data_in,
 	out_len = PAGE_CACHE_SIZE;
 	ret = lzo1x_decompress_safe(data_in, in_len, workspace->buf, &out_len);
 	if (ret != LZO_E_OK) {
-		printk(KERN_WARNING "btrfs decompress failed!\n");
+		printk(KERN_WARNING "btrfs: decompress failed!\n");
 		ret = -1;
 		goto out;
 	}
fs/btrfs/ordered-data.c +5 -4
index 25a8f38..5613186 100644
@@ -336,12 +336,13 @@ int btrfs_dec_test_first_ordered_pending(struct inode *inode,
 		      entry->len);
 	*file_offset = dec_end;
 	if (dec_start > dec_end) {
-		printk(KERN_CRIT "bad ordering dec_start %llu end %llu\n",
-		       dec_start, dec_end);
+		btrfs_crit(BTRFS_I(inode)->root->fs_info, "bad ordering dec_start %llu"
+			   "end %llu", dec_start, dec_end);
 	}
 	to_dec = dec_end - dec_start;
 	if (to_dec > entry->bytes_left) {
-		printk(KERN_CRIT "bad ordered accounting left %llu size %llu\n",
+		btrfs_crit(BTRFS_I(inode)->root->fs_info, "bad ordered accounting "
+			   "left %llu size %llu",
 		       entry->bytes_left, to_dec);
 	}
 	entry->bytes_left -= to_dec;
@@ -401,7 +402,7 @@ have_entry:
 	}
 
 	if (io_size > entry->bytes_left) {
-		printk(KERN_CRIT "bad ordered accounting left %llu size %llu\n",
+		btrfs_crit(BTRFS_I(inode)->root->fs_info, "bad ordered accounting left %llu size %llu",
 		       entry->bytes_left, io_size);
 	}
 	entry->bytes_left -= io_size;
fs/btrfs/qgroup.c +15 -14
index 4e6ef49..8093103 100644
@@ -301,16 +301,16 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
 
 			if (btrfs_qgroup_status_version(l, ptr) !=
 			    BTRFS_QGROUP_STATUS_VERSION) {
-				printk(KERN_ERR
-				 "btrfs: old qgroup version, quota disabled\n");
+				btrfs_err(fs_info,
+				 "old qgroup version, quota disabled");
 				goto out;
 			}
 			if (btrfs_qgroup_status_generation(l, ptr) !=
 			    fs_info->generation) {
 				flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT;
-				printk(KERN_ERR
-					"btrfs: qgroup generation mismatch, "
-					"marked as inconsistent\n");
+				btrfs_err(fs_info,
+					"qgroup generation mismatch, "
+					"marked as inconsistent");
 			}
 			fs_info->qgroup_flags = btrfs_qgroup_status_flags(l,
 									  ptr);
@@ -325,7 +325,7 @@ int btrfs_read_qgroup_config(struct btrfs_fs_info *fs_info)
 		qgroup = find_qgroup_rb(fs_info, found_key.offset);
 		if ((qgroup && found_key.type == BTRFS_QGROUP_INFO_KEY) ||
 		    (!qgroup && found_key.type == BTRFS_QGROUP_LIMIT_KEY)) {
-			printk(KERN_ERR "btrfs: inconsitent qgroup config\n");
+			btrfs_err(fs_info, "inconsitent qgroup config");
 			flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT;
 		}
 		if (!qgroup) {
@@ -396,8 +396,8 @@ next1:
 		ret = add_relation_rb(fs_info, found_key.objectid,
 				      found_key.offset);
 		if (ret == -ENOENT) {
-			printk(KERN_WARNING
-				"btrfs: orphan qgroup relation 0x%llx->0x%llx\n",
+			btrfs_warn(fs_info,
+				"orphan qgroup relation 0x%llx->0x%llx",
 				found_key.objectid, found_key.offset);
 			ret = 0;	/* ignore the error */
 		}
@@ -1161,7 +1161,7 @@ int btrfs_limit_qgroup(struct btrfs_trans_handle *trans,
 				       limit->rsv_excl);
 	if (ret) {
 		fs_info->qgroup_flags |= BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT;
-		printk(KERN_INFO "unable to update quota limit for %llu\n",
+		btrfs_info(fs_info, "unable to update quota limit for %llu",
 		       qgroupid);
 	}
 
@@ -1840,7 +1840,8 @@ void assert_qgroups_uptodate(struct btrfs_trans_handle *trans)
 {
 	if (list_empty(&trans->qgroup_ref_list) && !trans->delayed_ref_elem.seq)
 		return;
-	pr_err("btrfs: qgroups not uptodate in trans handle %p: list is%s empty, seq is %#x.%x\n",
+	btrfs_err(trans->root->fs_info, "qgroups not uptodate in trans handle %p:"
+		" list is%s empty, seq is %#x.%x",
 		trans, list_empty(&trans->qgroup_ref_list) ? "" : " not",
 		(u32)(trans->delayed_ref_elem.seq >> 32),
 		(u32)trans->delayed_ref_elem.seq);
@@ -1871,7 +1872,7 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path,
 					 &fs_info->qgroup_rescan_progress,
 					 path, 1, 0);
 
-	pr_debug("current progress key (%llu %u %llu), search_slot ret %d\n",
+	btrfs_debug(fs_info, "current progress key (%llu %u %llu), search_slot ret %d",
 		 fs_info->qgroup_rescan_progress.objectid,
 		 fs_info->qgroup_rescan_progress.type,
 		 fs_info->qgroup_rescan_progress.offset, ret);
@@ -2037,10 +2038,10 @@ out:
 	mutex_unlock(&fs_info->qgroup_rescan_lock);
 
 	if (err >= 0) {
-		pr_info("btrfs: qgroup scan completed%s\n",
+		btrfs_info(fs_info, "qgroup scan completed%s",
 			err == 2 ? " (inconsistency flag cleared)" : "");
 	} else {
-		pr_err("btrfs: qgroup scan failed with %d\n", err);
+		btrfs_err(fs_info, "qgroup scan failed with %d", err);
 	}
 
 	complete_all(&fs_info->qgroup_rescan_completion);
@@ -2096,7 +2097,7 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
 
 	if (ret) {
 err:
-		pr_info("btrfs: qgroup_rescan_init failed with %d\n", ret);
+		btrfs_info(fs_info, "qgroup_rescan_init failed with %d", ret);
 		return ret;
 	}
 
fs/btrfs/reada.c +7 -7
index 1031b69..da72999 100644
@@ -189,8 +189,8 @@ static int __readahead_hook(struct btrfs_root *root, struct extent_buffer *eb,
 			 */
 #ifdef DEBUG
 			if (rec->generation != generation) {
-				printk(KERN_DEBUG "generation mismatch for "
-						"(%llu,%d,%llu) %llu != %llu\n",
+				btrfs_debug(root->fs_info "generation mismatch for "
+						"(%llu,%d,%llu) %llu != %llu",
 				       key.objectid, key.type, key.offset,
 				       rec->generation, generation);
 			}
@@ -365,7 +365,7 @@ static struct reada_extent *reada_find_extent(struct btrfs_root *root,
 		goto error;
 
 	if (bbio->num_stripes > BTRFS_MAX_MIRRORS) {
-		printk(KERN_ERR "btrfs readahead: more than %d copies not "
+		btrfs_err(root->fs_info, "btrfs readahead: more than %d copies not "
 				"supported", BTRFS_MAX_MIRRORS);
 		goto error;
 	}
@@ -811,7 +811,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
 
 	spin_lock(&fs_info->reada_lock);
 	list_for_each_entry(device, &fs_devices->devices, dev_list) {
-		printk(KERN_DEBUG "dev %lld has %d in flight\n", device->devid,
+		btrfs_debug(fsinfo, "dev %lld has %d in flight", device->devid,
 			atomic_read(&device->reada_in_flight));
 		index = 0;
 		while (1) {
@@ -820,7 +820,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
 						     (void **)&zone, index, 1);
 			if (ret == 0)
 				break;
-			printk(KERN_DEBUG "  zone %llu-%llu elems %llu locked "
+			btrfs_debug(fsinfo, "  zone %llu-%llu elems %llu locked "
 				"%d devs", zone->start, zone->end, zone->elems,
 				zone->locked);
 			for (j = 0; j < zone->ndevs; ++j) {
@@ -842,7 +842,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
 						     (void **)&re, index, 1);
 			if (ret == 0)
 				break;
-			printk(KERN_DEBUG
+			btrfs_debug(fsinfo,
 				"  re: logical %llu size %u empty %d for %lld",
 				re->logical, re->blocksize,
 				list_empty(&re->extctl), re->scheduled_for ?
@@ -877,7 +877,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all)
 			index = (re->logical >> PAGE_CACHE_SHIFT) + 1;
 			continue;
 		}
-		printk(KERN_DEBUG
+		btrfs_debug(fsinfo,
 			"re: logical %llu size %u list empty %d for %lld",
 			re->logical, re->blocksize, list_empty(&re->extctl),
 			re->scheduled_for ? re->scheduled_for->devid : -1);
fs/btrfs/relocation.c +2 -2
index ce459a7..c1de9a4 100644
@@ -4219,7 +4219,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
 		goto out;
 	}
 
-	printk(KERN_INFO "btrfs: relocating block group %llu flags %llu\n",
+	btrfs_debug(extent_root->fs_info, "relocating block group %llu flags %llu",
 	       rc->block_group->key.objectid, rc->block_group->flags);
 
 	ret = btrfs_start_delalloc_roots(fs_info, 0);
@@ -4241,7 +4241,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
 		if (rc->extents_found == 0)
 			break;
 
-		printk(KERN_INFO "btrfs: found %llu extents\n",
+		btrfs_info(extent_root->fs_info, "found %llu extents",
 			rc->extents_found);
 
 		if (rc->stage == MOVE_DATA_EXTENTS && rc->found_file_extent) {
fs/btrfs/root-tree.c +1 -2
index ec71ea4..79d5b0f 100644
@@ -35,7 +35,6 @@ static void btrfs_read_root_item(struct extent_buffer *eb, int slot,
 	uuid_le uuid;
 	int len;
 	int need_reset = 0;
-
 	len = btrfs_item_size_nr(eb, slot);
 	read_extent_buffer(eb, item, btrfs_item_ptr_offset(eb, slot),
 			min_t(int, len, (int)sizeof(*item)));
@@ -154,7 +153,7 @@ int btrfs_update_root(struct btrfs_trans_handle *trans, struct btrfs_root
 
 	if (ret != 0) {
 		btrfs_print_leaf(root, path->nodes[0]);
-		printk(KERN_CRIT "unable to update root key %llu %u %llu\n",
+		btrfs_crit(root->fs_info, "unable to update root key %llu %u %llu",
 		       key->objectid, key->type, key->offset);
 		BUG_ON(1);
 	}
fs/btrfs/scrub.c +15 -12
index 2544805..ed8bb82 100644
@@ -2457,9 +2457,9 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
 
 			if (key.objectid < logical &&
 			    (flags & BTRFS_EXTENT_FLAG_TREE_BLOCK)) {
-				printk(KERN_ERR
-				       "btrfs scrub: tree block %llu spanning "
-				       "stripes, ignored. logical=%llu\n",
+				btrfs_err(fs_info,
+					   "scrub: tree block %llu spanning "
+					   "stripes, ignored. logical=%llu",
 				       key.objectid, logical);
 				goto next;
 			}
@@ -2841,8 +2841,8 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
 	 * check some assumptions
 	 */
 	if (fs_info->chunk_root->nodesize != fs_info->chunk_root->leafsize) {
-		printk(KERN_ERR
-		       "btrfs_scrub: size assumption nodesize == leafsize (%d == %d) fails\n",
+		btrfs_err(fs_info,
+			   "scrub: size assumption nodesize == leafsize (%d == %d) fails",
 		       fs_info->chunk_root->nodesize,
 		       fs_info->chunk_root->leafsize);
 		return -EINVAL;
@@ -2854,16 +2854,17 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
 		 * the way scrub is implemented. Do not handle this
 		 * situation at all because it won't ever happen.
 		 */
-		printk(KERN_ERR
-		       "btrfs_scrub: size assumption nodesize <= BTRFS_STRIPE_LEN (%d <= %d) fails\n",
+		btrfs_err(fs_info,
+			   "scrub: size assumption nodesize <= BTRFS_STRIPE_LEN (%d <= %d) fails",
 		       fs_info->chunk_root->nodesize, BTRFS_STRIPE_LEN);
 		return -EINVAL;
 	}
 
 	if (fs_info->chunk_root->sectorsize != PAGE_SIZE) {
 		/* not supported for data w/o checksums */
-		printk(KERN_ERR
-		       "btrfs_scrub: size assumption sectorsize != PAGE_SIZE (%d != %lu) fails\n",
+		btrfs_err(fs_info,
+			   "scrub: size assumption sectorsize != PAGE_SIZE "
+			   "(%d != %lu) fails",
 		       fs_info->chunk_root->sectorsize, PAGE_SIZE);
 		return -EINVAL;
 	}
@@ -2876,7 +2877,8 @@ int btrfs_scrub_dev(struct btrfs_fs_info *fs_info, u64 devid, u64 start,
 		 * would exhaust the array bounds of pagev member in
 		 * struct scrub_block
 		 */
-		pr_err("btrfs_scrub: size assumption nodesize and sectorsize <= SCRUB_MAX_PAGES_PER_BLOCK (%d <= %d && %d <= %d) fails\n",
+		btrfs_err(fs_info, "scrub: size assumption nodesize and sectorsize "
+			   "<= SCRUB_MAX_PAGES_PER_BLOCK (%d <= %d && %d <= %d) fails",
 		       fs_info->chunk_root->nodesize,
 		       SCRUB_MAX_PAGES_PER_BLOCK,
 		       fs_info->chunk_root->sectorsize,
@@ -3185,7 +3187,8 @@ static void copy_nocow_pages_worker(struct btrfs_work *work)
 	ret = iterate_inodes_from_logical(logical, fs_info, path,
 					  record_inode_for_nocow, nocow_ctx);
 	if (ret != 0 && ret != -ENOENT) {
-		pr_warn("iterate_inodes_from_logical() failed: log %llu, phys %llu, len %llu, mir %u, ret %d\n",
+		btrfs_warn(fs_info, "iterate_inodes_from_logical() failed: log %llu, "
+			"phys %llu, len %llu, mir %u, ret %d",
 			logical, physical_for_dev_replace, len, mirror_num,
 			ret);
 		not_written = 1;
@@ -3307,7 +3310,7 @@ static int copy_nocow_pages_for_inode(u64 inum, u64 offset, u64 root,
 again:
 		page = find_or_create_page(inode->i_mapping, index, GFP_NOFS);
 		if (!page) {
-			pr_err("find_or_create_page() failed\n");
+			btrfs_err(fs_info, "find_or_create_page() failed");
 			ret = -ENOMEM;
 			goto out;
 		}
fs/btrfs/super.c +50 -55

308 lines not on this page · raw message

fs/btrfs/tests/extent-io-tests.c +2 -1
index 7e99c2f..a228973 100644
@@ -56,7 +56,8 @@ static noinline int process_page_range(struct inode *inode, u64 start, u64 end,
 		cond_resched();
 		loops++;
 		if (loops > 100000) {
-			printk(KERN_ERR "stuck in a loop, start %Lu, end %Lu, nr_pages %lu, ret %d\n", start, end, nr_pages, ret);
+			btrfs_err(BTRFS_I(inode)->root->fs_info, "stuck in a loop, "
+				"start %llu, end %llu, nr_pages %lu, ret %d", start, end, nr_pages, ret);
 			break;
 		}
 	}
fs/btrfs/transaction.c +2 -2
index 57c16b4..0ffcc05 100644
@@ -1105,7 +1105,7 @@ int btrfs_defrag_root(struct btrfs_root *root)
 			break;
 
 		if (btrfs_defrag_cancelled(root->fs_info)) {
-			printk(KERN_DEBUG "btrfs: defrag_root cancelled\n");
+			btrfs_debug(root->fs_info, "defrag_root cancelled");
 			ret = -EAGAIN;
 			break;
 		}
@@ -1978,7 +1978,7 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
 	list_del_init(&root->root_list);
 	spin_unlock(&fs_info->trans_lock);
 
-	pr_debug("btrfs: cleaner removing %llu\n", root->objectid);
+	btrfs_debug(root->fs_info, "cleaner removing %llu", root->objectid);
 
 	btrfs_kill_all_delayed_nodes(root);
 
fs/btrfs/uuid-tree.c +6 -6
index fbda900..34bf72e 100644
@@ -69,7 +69,7 @@ static int btrfs_uuid_tree_lookup(struct btrfs_root *uuid_root, u8 *uuid,
 	ret = -ENOENT;
 
 	if (!IS_ALIGNED(item_size, sizeof(u64))) {
-		pr_warn("btrfs: uuid item with illegal size %lu!\n",
+		btrfs_warn(uuid_root->fs_info, "uuid item with illegal size %lu!",
 			(unsigned long)item_size);
 		goto out;
 	}
@@ -137,7 +137,7 @@ int btrfs_uuid_tree_add(struct btrfs_trans_handle *trans,
 		offset = btrfs_item_ptr_offset(eb, slot);
 		offset += btrfs_item_size_nr(eb, slot) - sizeof(subid_le);
 	} else if (ret < 0) {
-		pr_warn("btrfs: insert uuid item failed %d (0x%016llx, 0x%016llx) type %u!\n",
+		btrfs_warn(uuid_root->fs_info, "insert uuid item failed %d (0x%016llx, 0x%016llx) type %u!",
 			ret, (unsigned long long)key.objectid,
 			(unsigned long long)key.offset, type);
 		goto out;
@@ -183,7 +183,7 @@ int btrfs_uuid_tree_rem(struct btrfs_trans_handle *trans,
 
 	ret = btrfs_search_slot(trans, uuid_root, &key, path, -1, 1);
 	if (ret < 0) {
-		pr_warn("btrfs: error %d while searching for uuid item!\n",
+		btrfs_warn(uuid_root->fs_info, "error %d while searching for uuid item!",
 			ret);
 		goto out;
 	}
@@ -197,7 +197,7 @@ int btrfs_uuid_tree_rem(struct btrfs_trans_handle *trans,
 	offset = btrfs_item_ptr_offset(eb, slot);
 	item_size = btrfs_item_size_nr(eb, slot);
 	if (!IS_ALIGNED(item_size, sizeof(u64))) {
-		pr_warn("btrfs: uuid item with illegal size %lu!\n",
+		btrfs_warn(uuid_root->fs_info, "uuid item with illegal size %lu!",
 			(unsigned long)item_size);
 		ret = -ENOENT;
 		goto out;
@@ -299,7 +299,7 @@ again_search_slot:
 		offset = btrfs_item_ptr_offset(leaf, slot);
 		item_size = btrfs_item_size_nr(leaf, slot);
 		if (!IS_ALIGNED(item_size, sizeof(u64))) {
-			pr_warn("btrfs: uuid item with illegal size %lu!\n",
+			btrfs_warn(fs_info, "uuid item with illegal size %lu!",
 				(unsigned long)item_size);
 			goto skip;
 		}
@@ -349,6 +349,6 @@ skip:
 out:
 	btrfs_free_path(path);
 	if (ret)
-		pr_warn("btrfs: btrfs_uuid_tree_iterate failed %d\n", ret);
+		btrfs_warn(fs_info, "btrfs_uuid_tree_iterate failed %d", ret);
 	return 0;
 }
fs/btrfs/volumes.c +34 -36

210 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH v2 1/2] Btrfs: convert printk and pr_ to btrfs_* and fix btrfs: prefix

Hi,

I've found a few types of issues that appear throughout the patch, commented the at the first occurance. It will be some work to fix them all, but the transition to btrfs_wrr/... (and fixing the typos) is desired and number of patches doing that should be minimal.

fs/btrfs/backref.c static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, · line 320

Quoted 10 lines · Frank Holton
fs/btrfs/backref.c +2 -2
@@ -316,8 +316,8 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
 
 	path->lowest_level = level;
 	ret = btrfs_search_old_slot(root, &ref->key_for_search, path, time_seq);
-	pr_debug("search slot in root %llu (level %d, ref count %d) returned "
-		 "%d for key (%llu %u %llu)\n",
+	btrfs_debug(fs_info, "search slot in root %llu (level %d, ref count %d) "
+		 "returned %d for key (%llu %u %llu)",

pr_debug is special, first it's only a debugging print, not meant for normal use.

pr_debug can be enabled/disabled dynamically trhough sysfs, but btrfs_debug is printk(KERN_DEBUG...) which is not equivalent to pr_debug in the end.

I suggest to keep them untouched.

Quoted 4 lines
fs/btrfs/compression.c +0 -0
@@ -128,10 +128,10 @@ static int check_compressed_csum(struct inode *inode,
 		kunmap_atomic(kaddr);

fs/btrfs/compression.c static int check_compressed_csum(struct inode *inode, · line 134

Quoted 10 lines
fs/btrfs/compression.c +4 -4
 
 		if (csum != *cb_sum) {
-			printk(KERN_INFO "btrfs csum failed ino %llu "
-			       "extent %llu csum %u "
-			       "wanted %u mirror %d\n",
-			       btrfs_ino(inode), disk_start, csum, *cb_sum,
+			btrfs_info(BTRFS_I(inode)->root->fs_info, "csum failed "
+				   "ino %llu extent %llu csum %u "
+				   "wanted %u mirror %d",
+				   btrfs_ino(inode), disk_start, csum, *cb_sum,

An example of the right conversion, but then I'd also want to see the printed string on one line, because it will be grepped for when resolving problems. In case the string exceeds 80 columns, it could be shifted to the left.

fs/btrfs/delayed-inode.c int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans, · line 1477

Quoted 11 lines
fs/btrfs/delayed-inode.c +2 -2
@@ -1472,9 +1472,9 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,
 	mutex_lock(&delayed_node->mutex);
 	ret = __btrfs_add_delayed_insertion_item(delayed_node, delayed_item);
 	if (unlikely(ret)) {
-		printk(KERN_ERR "err add delayed dir index item(name: %.*s) "
+		btrfs_err(root->fs_info, "err add delayed dir index item(name: %.*s) "
 				"into the insertion tree of the delayed node"
-				"(root id: %llu, inode id: %llu, errno: %d)\n",
+				"(root id: %llu, inode id: %llu, errno: %d)",

This is a long string, the original split could work, and it's followed by a BUG, so locating it in the sources is easy. Although it's an exception to the string-on-one-line recommendation, it follows a common sense.

Quoted 10 lines
fs/btrfs/delayed-inode.c +1 -1
 				name_len, name, delayed_node->root->objectid,
 				delayed_node->inode_id, ret);
 		BUG();
 
-		pr_info("btrfs: suspending dev_replace for unmount\n");
+		btrfs_info(fs_info, "suspending dev_replace for unmount");
 		break;
 	}

fs/btrfs/delayed-inode.c int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info) · line 735

Quoted 6 lines
fs/btrfs/delayed-inode.c +1 -2
@@ -728,8 +732,8 @@ int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info)
 		break;
 	}
 	if (!dev_replace->tgtdev || !dev_replace->tgtdev->bdev) {
-		pr_info("btrfs: cannot continue dev_replace, tgtdev is missing\n"
-			"btrfs: you may cancel the operation after 'mount -o degraded'\n");
+		btrfs_info(fs_info, "cannot continue dev_replace, tgtdev is missing"

In the original code, there's a newline between the strings, missing in the new code. This looks like it should be split to two btrfs_info calls instead.

Quoted 8 lines
fs/btrfs/delayed-inode.c +1 -0
+			"btrfs: you may cancel the operation after 'mount -o degraded'");
 		btrfs_dev_replace_unlock(dev_replace);
 		return 0;
 	}

fs/btrfs/disk-io.c static int check_tree_block_fsid(struct btrfs_root *root, · line 503

Quoted 6 lines
fs/btrfs/disk-io.c +1 -2
@@ -500,8 +500,8 @@ static int check_tree_block_fsid(struct btrfs_root *root,
 }
 
 #define CORRUPT(reason, eb, root, slot)				\
-	printk(KERN_CRIT "btrfs: corrupt leaf, %s: block=%llu,"	\
-	       "root=%llu, slot=%d\n", reason,			\
+	btrfs_crit(root->fs_info, "btrfs: corrupt leaf, %s: block=%llu,"	\

Extra "btrfs: "

fs/btrfs/disk-io.c static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, · line 603

Quoted 10 lines
fs/btrfs/disk-io.c +2 -1
+		   "root=%llu, slot=%d", reason,			\
 	       btrfs_header_bytenr(eb),	root->objectid, slot)
 
 static noinline int check_leaf(struct btrfs_root *root,
@@ -600,21 +600,21 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
 
 	found_start = btrfs_header_bytenr(eb);
 	if (found_start != eb->start) {
-		printk_ratelimited(KERN_INFO "btrfs bad tree block start "
+		printk_ratelimited(KERN_INFO "btrfs: bad tree block start "

The _ratelimited variants could make sense for the btrfs_* variants, but it's for a separate patch. The fix you do here is ok for now I think.

fs/btrfs/disk-io.c static void btree_invalidatepage(struct page *page, unsigned int offset, · line 1013

Quoted 12 lines
fs/btrfs/disk-io.c +1 -2
 			       "%llu %llu\n",
 			       found_start, eb->start);
 		ret = -EIO;
 		goto err;
 	}
@@ -1010,8 +1010,9 @@ static void btree_invalidatepage(struct page *page, unsigned int offset,
 	extent_invalidatepage(tree, page, offset);
 	btree_releasepage(page, GFP_NOFS);
 	if (PagePrivate(page)) {
-		printk(KERN_WARNING "btrfs warning page private not zero "
-		       "on page %llu\n", (unsigned long long)page_offset(page));
+		btrfs_warn(BTRFS_I(page->mapping->host)->root->fs_info, "btrfs warning"

"btrfs warning" can be dropped here

fs/btrfs/disk-io.c int open_ctree(struct super_block *sb, · line 2395

Quoted 11 lines
fs/btrfs/disk-io.c +3 -1
+			   " page private not zero "
+			   "on page %llu", (unsigned long long)page_offset(page));
 		ClearPagePrivate(page);
 		set_page_private(page, 0);
 		page_cache_release(page);
@@ -2391,7 +2392,7 @@ int open_ctree(struct super_block *sb,
 	features = btrfs_super_incompat_flags(disk_super) &
 		~BTRFS_FEATURE_INCOMPAT_SUPP;
 	if (features) {
-		printk(KERN_ERR "BTRFS: couldn't mount because of "
+		printk(KERN_ERR "btrfs: couldn't mount because of "

I think the preferred spelling in the longterm is BTRFS, other filesystems use upper case as well.

fs/btrfs/disk-io.c static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate) · line 3004

Quoted 10 lines
fs/btrfs/disk-io.c +1 -1
 		       "unsupported optional features (%Lx).\n",
 		       features);
 		err = -EINVAL;
@@ -3000,7 +3001,7 @@ static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)
 		struct btrfs_device *device = (struct btrfs_device *)
 			bh->b_private;
 
-		printk_ratelimited_in_rcu(KERN_WARNING "lost page write due to "
+		printk_ratelimited_in_rcu(KERN_WARNING "btrfs: lost page write due to "

Hm another variant for btrfs_*, now it starts to look heavy. I'm ok with adding the prefix.

fs/btrfs/extent-tree.c static int __btrfs_free_extent(struct btrfs_trans_handle *trans, · line 5844

Quoted 13 lines
fs/btrfs/disk-io.c +0 -0
 					  "I/O error on %s\n",
 					  rcu_str_deref(device->name));
 		/* note, we dont' set_buffer_write_io_error because we have
fs/btrfs/extent-tree.c +2 -2
@@ -5840,8 +5840,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
 
 	refs = btrfs_extent_refs(leaf, ei);
 	if (refs < refs_to_drop) {
-		btrfs_err(info, "trying to drop %d refs but we only have %Lu "
-			  "for bytenr %Lu\n", refs_to_drop, refs, bytenr);
+		btrfs_err(info, "trying to drop %d refs but we only have %llu "
+			  "for bytenr %llu", refs_to_drop, refs, bytenr);

%Lu is a valid format, no need to change that

Quoted 7 lines
fs/btrfs/extent-tree.c +0 -0
 		ret = -EINVAL;
 		btrfs_abort_transaction(trans, extent_root, ret);
 		goto out;
fs/btrfs/extent-tree.c +0 -0
 		      btrfs_ino(dip->inode), bio->bi_rw,
 		      (unsigned long long)bio->bi_sector, bio->bi_size, err);
 		dip->errors = 1;

fs/btrfs/extent-tree.c static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, · line 8075

Quoted 9 lines
fs/btrfs/extent-tree.c +3 -3
@@ -8070,9 +8070,9 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
 	 */
 	trans = btrfs_start_transaction(root, 11);
 	if (IS_ERR(trans)) {
-                ret = PTR_ERR(trans);
-                goto out_notrans;
-        }
+				ret = PTR_ERR(trans);
+				goto out_notrans;
+		}

Wrong indentation

fs/btrfs/relocation.c int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start) · line 4222

Quoted 8 lines
fs/btrfs/relocation.c +1 -1
@@ -4219,7 +4219,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
 		goto out;
 	}
 
-	printk(KERN_INFO "btrfs: relocating block group %llu flags %llu\n",
+	btrfs_debug(extent_root->fs_info, "relocating block group %llu flags %llu",

Message level changed?

fs/btrfs/root-tree.c static void btrfs_read_root_item(struct extent_buffer *eb, int slot, · line 38

Quoted 11 lines
fs/btrfs/relocation.c +0 -0
 	       rc->block_group->key.objectid, rc->block_group->flags);
 
 	ret = btrfs_start_delalloc_roots(fs_info, 0);

@@ -4241,7 +4241,7

fs/btrfs/root-tree.c +0 -1
@@ -35,7 +35,6 @@ static void btrfs_read_root_item(struct extent_buffer *eb, int slot,
 	uuid_le uuid;
 	int len;
 	int need_reset = 0;
-

Unrelated change

fs/btrfs/super.c void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, · line 144

Quoted 11 lines
fs/btrfs/root-tree.c +0 -0
 	len = btrfs_item_size_nr(eb, slot);
 	read_extent_buffer(eb, item, btrfs_item_ptr_offset(eb, slot),
 			min_t(int, len, (int)sizeof(*item)));
fs/btrfs/super.c +1 -1
@@ -141,7 +141,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
 	 * under MS_RDONLY, then it is safe here.
 	 */
 	if (errno == -EROFS && (sb->s_flags & MS_RDONLY))
-  		return;
+		return;

Unrelated change

fs/btrfs/super.c static void btrfs_interface_exit(void) · line 1777

Quoted 9 lines
fs/btrfs/super.c +1 -1
 	errstr = btrfs_decode_error(errno);
 	if (fmt) {
@@ -1779,7 +1774,7 @@ static void btrfs_interface_exit(void)
 
 static void btrfs_print_info(void)
 {
-	printk(KERN_INFO "Btrfs loaded"
+	printk(KERN_INFO "btrfs: loaded"

This is a message that the module has been loaded, different from the other messages, I'd keep this one untouched.

#3 lore raw

Re: [PATCH v2 1/2] Btrfs: convert printk and pr_ to btrfs_* and fix btrfs: prefix

Hi,

Thanks for your comments, I've got a few comments/questions that I've written below.

Quoted 22 lines · David Sterba

Hi,

I've found a few types of issues that appear throughout the patch, commented the at the first occurance. It will be some work to fix them all, but the transition to btrfs_wrr/... (and fixing the typos) is desired and number of patches doing that should be minimal.

fs/btrfs/backref.c static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, · line 320

Quoted 10 lines · Frank Holton
fs/btrfs/backref.c +2 -2
@@ -316,8 +316,8 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info,
 
      path->lowest_level = level;
      ret = btrfs_search_old_slot(root, &ref->key_for_search, path, time_seq);
-     pr_debug("search slot in root %llu (level %d, ref count %d) returned "
-              "%d for key (%llu %u %llu)\n",
+     btrfs_debug(fs_info, "search slot in root %llu (level %d, ref count %d) "
+              "returned %d for key (%llu %u %llu)",

pr_debug is special, first it's only a debugging print, not meant for normal use.

Quoted 5 lines

pr_debug can be enabled/disabled dynamically trhough sysfs, but btrfs_debug is printk(KERN_DEBUG...) which is not equivalent to pr_debug in the end.

I suggest to keep them untouched.

Yeah I noticed the special handling of pr_debug as soon as I loaded the updated module.
The other patch submitted with this set handled some of that difference. It would not take much to
handle the dynamically enabled version of pr_debug. How do you feel about another function like btrfs_debug_printk
that calls pr_debug and allows us to use all of the debug information that btrfs_printk would normally print out.
btrfs_debug would then be dependent on CONFIG_DYNAMIC_DEBUG and DEBUG being defined same as pr_debug.

So it would be
CONFIG_DYNAMIC_DEBUG => #define btrfs_debug btrfs_debug_printk CONFIG_DEBUG => #define btrfs_debug btrfs_printk ELSE => #define btrfs_debug /*does nothing */

It seems weird having btrfs_debug if it behaves so different than pr_debug.

Quoted 6 lines
Quoted 6 lines
fs/btrfs/compression.c +0 -0
@@ -128,10 +128,10 @@ static int check_compressed_csum(struct inode *inode,
              kunmap_atomic(kaddr);
 
Quoted 14 lines

fs/btrfs/compression.c static int check_compressed_csum(struct inode *inode, · line 134

Quoted 9 lines
fs/btrfs/compression.c +4 -4
              if (csum != *cb_sum) {
-                     printk(KERN_INFO "btrfs csum failed ino %llu "
-                            "extent %llu csum %u "
-                            "wanted %u mirror %d\n",
-                            btrfs_ino(inode), disk_start, csum, *cb_sum,
+                     btrfs_info(BTRFS_I(inode)->root->fs_info, "csum failed "
+                                "ino %llu extent %llu csum %u "
+                                "wanted %u mirror %d",
+                                btrfs_ino(inode), disk_start, csum, *cb_sum,

An example of the right conversion, but then I'd also want to see the printed string on one line, because it will be grepped for when resolving problems. In case the string exceeds 80 columns, it could be shifted to the left.

Clarification needed, keep the existing line breaks? Like this
btrfs_info(BTRFS_I(inode)->root->fs_info,
"btrfs csum failed ino %llu "
"wanted %u mirror %d\n",

Quoted 85 lines

fs/btrfs/delayed-inode.c int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans, · line 1477

Quoted 12 lines
fs/btrfs/delayed-inode.c +2 -2
@@ -1472,9 +1472,9 @@ int btrfs_insert_delayed_dir_index(struct btrfs_trans_handle *trans,
      mutex_lock(&delayed_node->mutex);
      ret = __btrfs_add_delayed_insertion_item(delayed_node, delayed_item);
      if (unlikely(ret)) {
-             printk(KERN_ERR "err add delayed dir index item(name: %.*s) "
+             btrfs_err(root->fs_info, "err add delayed dir index item(name: %.*s) "
                              "into the insertion tree of the delayed node"
-                             "(root id: %llu, inode id: %llu, errno: %d)\n",
+                             "(root id: %llu, inode id: %llu, errno: %d)",

This is a long string, the original split could work, and it's followed by a BUG, so locating it in the sources is easy. Although it's an exception to the string-on-one-line recommendation, it follows a common sense.

Quoted 10 lines
fs/btrfs/delayed-inode.c +1 -1
                              name_len, name, delayed_node->root->objectid,
                              delayed_node->inode_id, ret);
              BUG();
 
-             pr_info("btrfs: suspending dev_replace for unmount\n");
+             btrfs_info(fs_info, "suspending dev_replace for unmount");
              break;
      }

fs/btrfs/delayed-inode.c int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info) · line 735

Quoted 6 lines
fs/btrfs/delayed-inode.c +1 -2
@@ -728,8 +732,8 @@ int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info)
              break;
      }
      if (!dev_replace->tgtdev || !dev_replace->tgtdev->bdev) {
-             pr_info("btrfs: cannot continue dev_replace, tgtdev is missing\n"
-                     "btrfs: you may cancel the operation after 'mount -o degraded'\n");
+             btrfs_info(fs_info, "cannot continue dev_replace, tgtdev is missing"

In the original code, there's a newline between the strings, missing in the new code. This looks like it should be split to two btrfs_info calls instead.

Quoted 8 lines
fs/btrfs/delayed-inode.c +1 -0
+                     "btrfs: you may cancel the operation after 'mount -o degraded'");
              btrfs_dev_replace_unlock(dev_replace);
              return 0;
      }

fs/btrfs/disk-io.c static int check_tree_block_fsid(struct btrfs_root *root, · line 503

Quoted 6 lines
fs/btrfs/disk-io.c +1 -2
@@ -500,8 +500,8 @@ static int check_tree_block_fsid(struct btrfs_root *root,
 }
 
 #define CORRUPT(reason, eb, root, slot)                              \
-     printk(KERN_CRIT "btrfs: corrupt leaf, %s: block=%llu," \
-            "root=%llu, slot=%d\n", reason,                  \
+     btrfs_crit(root->fs_info, "btrfs: corrupt leaf, %s: block=%llu,"        \

Extra "btrfs: "

fs/btrfs/disk-io.c static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio, · line 603

Quoted 10 lines
fs/btrfs/disk-io.c +2 -1
+                "root=%llu, slot=%d", reason,                        \
             btrfs_header_bytenr(eb), root->objectid, slot)
 
 static noinline int check_leaf(struct btrfs_root *root,
@@ -600,21 +600,21 @@ static int btree_readpage_end_io_hook(struct btrfs_io_bio *io_bio,
 
      found_start = btrfs_header_bytenr(eb);
      if (found_start != eb->start) {
-             printk_ratelimited(KERN_INFO "btrfs bad tree block start "
+             printk_ratelimited(KERN_INFO "btrfs: bad tree block start "

The _ratelimited variants could make sense for the btrfs_* variants, but it's for a separate patch. The fix you do here is ok for now I think.

fs/btrfs/disk-io.c static void btree_invalidatepage(struct page *page, unsigned int offset, · line 1013

Quoted 12 lines
fs/btrfs/disk-io.c +1 -2
                             "%llu %llu\n",
                             found_start, eb->start);
              ret = -EIO;
              goto err;
      }
@@ -1010,8 +1010,9 @@ static void btree_invalidatepage(struct page *page, unsigned int offset,
      extent_invalidatepage(tree, page, offset);
      btree_releasepage(page, GFP_NOFS);
      if (PagePrivate(page)) {
-             printk(KERN_WARNING "btrfs warning page private not zero "
-                    "on page %llu\n", (unsigned long long)page_offset(page));
+             btrfs_warn(BTRFS_I(page->mapping->host)->root->fs_info, "btrfs warning"

"btrfs warning" can be dropped here

Quoted 14 lines

fs/btrfs/disk-io.c int open_ctree(struct super_block *sb, · line 2395

Quoted 11 lines
fs/btrfs/disk-io.c +3 -1
+                        " page private not zero "
+                        "on page %llu", (unsigned long long)page_offset(page));
              ClearPagePrivate(page);
              set_page_private(page, 0);
              page_cache_release(page);
@@ -2391,7 +2392,7 @@ int open_ctree(struct super_block *sb,
      features = btrfs_super_incompat_flags(disk_super) &
              ~BTRFS_FEATURE_INCOMPAT_SUPP;
      if (features) {
-             printk(KERN_ERR "BTRFS: couldn't mount because of "
+             printk(KERN_ERR "btrfs: couldn't mount because of "

I think the preferred spelling in the longterm is BTRFS, other filesystems use upper case as well.

Since the point of this patch set is to try and get the syslog output to be as consistent as possible would you suggest changing it to BTRFS throughout the rest of the code and would that have a colon after it ie BTRFS:

This is how ext4 is printed
EXT4-fs (sde1):
Btrfs currently
BTRFS: [error_level] (device sda):

Quoted 22 lines

fs/btrfs/disk-io.c static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate) · line 3004

Quoted 11 lines
fs/btrfs/disk-io.c +1 -1
                     "unsupported optional features (%Lx).\n",
                     features);
              err = -EINVAL;
@@ -3000,7 +3001,7 @@ static void btrfs_end_buffer_write_sync(struct buffer_head *bh, int uptodate)
              struct btrfs_device *device = (struct btrfs_device *)
                      bh->b_private;
 
-             printk_ratelimited_in_rcu(KERN_WARNING "lost page write due to "
+             printk_ratelimited_in_rcu(KERN_WARNING "btrfs: lost page write due to "

Hm another variant for btrfs_*, now it starts to look heavy. I'm ok with adding the prefix.

Quoted 7 lines
fs/btrfs/disk-io.c +0 -0
                                        "I/O error on %s\n",
                                        rcu_str_deref(device->name));
              /* note, we dont' set_buffer_write_io_error because we have
fs/btrfs/extent-tree.c +0 -0
@@ -5840,8 +5840,8 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
 
Quoted 8 lines

fs/btrfs/extent-tree.c static int __btrfs_free_extent(struct btrfs_trans_handle *trans, · line 5844

Quoted 6 lines
fs/btrfs/extent-tree.c +2 -2
      refs = btrfs_extent_refs(leaf, ei);
      if (refs < refs_to_drop) {
-             btrfs_err(info, "trying to drop %d refs but we only have %Lu "
-                       "for bytenr %Lu\n", refs_to_drop, refs, bytenr);
+             btrfs_err(info, "trying to drop %d refs but we only have %llu "
+                       "for bytenr %llu", refs_to_drop, refs, bytenr);

%Lu is a valid format, no need to change that

Sorry about that check_patch was complaining about it will revert.

Quoted 64 lines
Quoted 8 lines
fs/btrfs/extent-tree.c +0 -0
              ret = -EINVAL;
              btrfs_abort_transaction(trans, extent_root, ret);
              goto out;
                    btrfs_ino(dip->inode), bio->bi_rw,
                    (unsigned long long)bio->bi_sector, bio->bi_size, err);
              dip->errors = 1;

fs/btrfs/extent-tree.c static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, · line 8075

Quoted 9 lines
fs/btrfs/extent-tree.c +3 -3
@@ -8070,9 +8070,9 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
       */
      trans = btrfs_start_transaction(root, 11);
      if (IS_ERR(trans)) {
-                ret = PTR_ERR(trans);
-                goto out_notrans;
-        }
+                             ret = PTR_ERR(trans);
+                             goto out_notrans;
+             }

Wrong indentation

fs/btrfs/relocation.c int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start) · line 4222

Quoted 8 lines
fs/btrfs/relocation.c +1 -1
@@ -4219,7 +4219,7 @@ int btrfs_relocate_block_group(struct btrfs_root *extent_root, u64 group_start)
              goto out;
      }
 
-     printk(KERN_INFO "btrfs: relocating block group %llu flags %llu\n",
+     btrfs_debug(extent_root->fs_info, "relocating block group %llu flags %llu",

Message level changed?

fs/btrfs/root-tree.c static void btrfs_read_root_item(struct extent_buffer *eb, int slot, · line 38

Quoted 11 lines
fs/btrfs/relocation.c +0 -0
             rc->block_group->key.objectid, rc->block_group->flags);
 
      ret = btrfs_start_delalloc_roots(fs_info, 0);

@@ -4241,7 +4241,7

fs/btrfs/root-tree.c +0 -1
@@ -35,7 +35,6 @@ static void btrfs_read_root_item(struct extent_buffer *eb, int slot,
      uuid_le uuid;
      int len;
      int need_reset = 0;
-

Unrelated change

fs/btrfs/super.c void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, · line 144

Quoted 11 lines
fs/btrfs/root-tree.c +0 -0
      len = btrfs_item_size_nr(eb, slot);
      read_extent_buffer(eb, item, btrfs_item_ptr_offset(eb, slot),
                      min_t(int, len, (int)sizeof(*item)));
fs/btrfs/super.c +1 -1
@@ -141,7 +141,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
       * under MS_RDONLY, then it is safe here.
       */
      if (errno == -EROFS && (sb->s_flags & MS_RDONLY))
-             return;
+             return;

Unrelated change

Quoted 5 lines
fs/btrfs/super.c +0 -0
      errstr = btrfs_decode_error(errno);
      if (fmt) {
@@ -1779,7 +1774,7 @@ static void btrfs_interface_exit(void)
 
Quoted 7 lines

fs/btrfs/super.c static void btrfs_interface_exit(void) · line 1777

Quoted 4 lines
fs/btrfs/super.c +1 -1
 static void btrfs_print_info(void)
 {
-     printk(KERN_INFO "Btrfs loaded"
+     printk(KERN_INFO "btrfs: loaded"

This is a message that the module has been loaded, different from the other messages, I'd keep this one untouched.

Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo

#4 lore raw

PATCH v2 2/2 Btrfs: make btrfs_debug match pr_debug handling related to DEBUG

In reply to Frank Holton

The kernel macro pr_debug is defined as a empty statement when DEBUG is not defined. Make btrfs_debug match pr_debug to avoid spamming the kernel log with debug messages

---
 fs/btrfs/ctree.h |    6 ++++++
 1 file changed, 6 insertions(+)
fs/btrfs/ctree.h +6 -0
index e319d25..3969133 100644
@@ -3809,8 +3809,14 @@ void btrfs_printk(const struct btrfs_fs_info *fs_info, const char *fmt, ...)
 	btrfs_printk(fs_info, KERN_NOTICE fmt, ##args)
 #define btrfs_info(fs_info, fmt, args...) \
 	btrfs_printk(fs_info, KERN_INFO fmt, ##args)
+
+#ifdef DEBUG
 #define btrfs_debug(fs_info, fmt, args...) \
 	btrfs_printk(fs_info, KERN_DEBUG fmt, ##args)
+#else
+#define btrfs_debug(fs_info, fmt, args...) \
+    no_printk(KERN_DEBUG fmt, ##args)
+#endif
 
 #ifdef CONFIG_BTRFS_ASSERT
 
Signature · 1 line
1.7.9.5