diff options
author | Jeff Mahoney <jeffm@suse.com> | 2016-09-20 10:05:02 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-09-26 13:37:04 -0400 |
commit | ab8d0fc48dba09e0a2b8b0dbfe144d4de9eb874f (patch) | |
tree | e6ac2c4d2f3d81a0d7b3b398db3fb48f2ed1630c | |
parent | 62e855771dacf7c4d6daf9741642a965e7066d31 (diff) |
btrfs: convert pr_* to btrfs_* where possible
For many printks, we want to know which file system issued the message.
This patch converts most pr_* calls to use the btrfs_* versions instead.
In some cases, this means adding plumbing to allow call sites access to
an fs_info pointer.
fs/btrfs/check-integrity.c is left alone for another day.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/backref.c | 43 | ||||
-rw-r--r-- | fs/btrfs/compression.c | 2 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 2 | ||||
-rw-r--r-- | fs/btrfs/delayed-ref.c | 9 | ||||
-rw-r--r-- | fs/btrfs/dev-replace.c | 2 | ||||
-rw-r--r-- | fs/btrfs/disk-io.c | 90 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 66 | ||||
-rw-r--r-- | fs/btrfs/extent_io.c | 53 | ||||
-rw-r--r-- | fs/btrfs/free-space-cache.c | 8 | ||||
-rw-r--r-- | fs/btrfs/free-space-cache.h | 6 | ||||
-rw-r--r-- | fs/btrfs/free-space-tree.c | 2 | ||||
-rw-r--r-- | fs/btrfs/inode-map.c | 31 | ||||
-rw-r--r-- | fs/btrfs/inode.c | 16 | ||||
-rw-r--r-- | fs/btrfs/qgroup.c | 11 | ||||
-rw-r--r-- | fs/btrfs/reada.c | 6 | ||||
-rw-r--r-- | fs/btrfs/super.c | 10 | ||||
-rw-r--r-- | fs/btrfs/transaction.c | 14 | ||||
-rw-r--r-- | fs/btrfs/transaction.h | 1 | ||||
-rw-r--r-- | fs/btrfs/volumes.c | 34 | ||||
-rw-r--r-- | fs/btrfs/volumes.h | 2 |
20 files changed, 231 insertions, 177 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 382e90351f14..85dc7ab8f89e 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -650,7 +650,8 @@ static int __resolve_indirect_ref(struct btrfs_fs_info *fs_info, | |||
650 | /* root node has been locked, we can release @subvol_srcu safely here */ | 650 | /* root node has been locked, we can release @subvol_srcu safely here */ |
651 | srcu_read_unlock(&fs_info->subvol_srcu, index); | 651 | srcu_read_unlock(&fs_info->subvol_srcu, index); |
652 | 652 | ||
653 | pr_debug("search slot in root %llu (level %d, ref count %d) returned %d for key (%llu %u %llu)\n", | 653 | btrfs_debug(fs_info, |
654 | "search slot in root %llu (level %d, ref count %d) returned %d for key (%llu %u %llu)", | ||
654 | ref->root_id, level, ref->count, ret, | 655 | ref->root_id, level, ref->count, ret, |
655 | ref->key_for_search.objectid, ref->key_for_search.type, | 656 | ref->key_for_search.objectid, ref->key_for_search.type, |
656 | ref->key_for_search.offset); | 657 | ref->key_for_search.offset); |
@@ -1834,7 +1835,8 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, | |||
1834 | 1835 | ||
1835 | if (found_key->objectid > logical || | 1836 | if (found_key->objectid > logical || |
1836 | found_key->objectid + size <= logical) { | 1837 | found_key->objectid + size <= logical) { |
1837 | pr_debug("logical %llu is not within any extent\n", logical); | 1838 | btrfs_debug(fs_info, |
1839 | "logical %llu is not within any extent", logical); | ||
1838 | return -ENOENT; | 1840 | return -ENOENT; |
1839 | } | 1841 | } |
1840 | 1842 | ||
@@ -1845,7 +1847,8 @@ int extent_from_logical(struct btrfs_fs_info *fs_info, u64 logical, | |||
1845 | ei = btrfs_item_ptr(eb, path->slots[0], struct btrfs_extent_item); | 1847 | ei = btrfs_item_ptr(eb, path->slots[0], struct btrfs_extent_item); |
1846 | flags = btrfs_extent_flags(eb, ei); | 1848 | flags = btrfs_extent_flags(eb, ei); |
1847 | 1849 | ||
1848 | pr_debug("logical %llu is at position %llu within the extent (%llu EXTENT_ITEM %llu) flags %#llx size %u\n", | 1850 | btrfs_debug(fs_info, |
1851 | "logical %llu is at position %llu within the extent (%llu EXTENT_ITEM %llu) flags %#llx size %u", | ||
1849 | logical, logical - found_key->objectid, found_key->objectid, | 1852 | logical, logical - found_key->objectid, found_key->objectid, |
1850 | found_key->offset, flags, item_size); | 1853 | found_key->offset, flags, item_size); |
1851 | 1854 | ||
@@ -1966,20 +1969,24 @@ int tree_backref_for_extent(unsigned long *ptr, struct extent_buffer *eb, | |||
1966 | return 0; | 1969 | return 0; |
1967 | } | 1970 | } |
1968 | 1971 | ||
1969 | static int iterate_leaf_refs(struct extent_inode_elem *inode_list, | 1972 | static int iterate_leaf_refs(struct btrfs_fs_info *fs_info, |
1970 | u64 root, u64 extent_item_objectid, | 1973 | struct extent_inode_elem *inode_list, |
1971 | iterate_extent_inodes_t *iterate, void *ctx) | 1974 | u64 root, u64 extent_item_objectid, |
1975 | iterate_extent_inodes_t *iterate, void *ctx) | ||
1972 | { | 1976 | { |
1973 | struct extent_inode_elem *eie; | 1977 | struct extent_inode_elem *eie; |
1974 | int ret = 0; | 1978 | int ret = 0; |
1975 | 1979 | ||
1976 | for (eie = inode_list; eie; eie = eie->next) { | 1980 | for (eie = inode_list; eie; eie = eie->next) { |
1977 | pr_debug("ref for %llu resolved, key (%llu EXTEND_DATA %llu), root %llu\n", extent_item_objectid, | 1981 | btrfs_debug(fs_info, |
1978 | eie->inum, eie->offset, root); | 1982 | "ref for %llu resolved, key (%llu EXTEND_DATA %llu), root %llu", |
1983 | extent_item_objectid, eie->inum, | ||
1984 | eie->offset, root); | ||
1979 | ret = iterate(eie->inum, eie->offset, root, ctx); | 1985 | ret = iterate(eie->inum, eie->offset, root, ctx); |
1980 | if (ret) { | 1986 | if (ret) { |
1981 | pr_debug("stopping iteration for %llu due to ret=%d\n", | 1987 | btrfs_debug(fs_info, |
1982 | extent_item_objectid, ret); | 1988 | "stopping iteration for %llu due to ret=%d", |
1989 | extent_item_objectid, ret); | ||
1983 | break; | 1990 | break; |
1984 | } | 1991 | } |
1985 | } | 1992 | } |
@@ -2007,7 +2014,7 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, | |||
2007 | struct ulist_iterator ref_uiter; | 2014 | struct ulist_iterator ref_uiter; |
2008 | struct ulist_iterator root_uiter; | 2015 | struct ulist_iterator root_uiter; |
2009 | 2016 | ||
2010 | pr_debug("resolving all inodes for extent %llu\n", | 2017 | btrfs_debug(fs_info, "resolving all inodes for extent %llu", |
2011 | extent_item_objectid); | 2018 | extent_item_objectid); |
2012 | 2019 | ||
2013 | if (!search_commit_root) { | 2020 | if (!search_commit_root) { |
@@ -2033,9 +2040,12 @@ int iterate_extent_inodes(struct btrfs_fs_info *fs_info, | |||
2033 | break; | 2040 | break; |
2034 | ULIST_ITER_INIT(&root_uiter); | 2041 | ULIST_ITER_INIT(&root_uiter); |
2035 | while (!ret && (root_node = ulist_next(roots, &root_uiter))) { | 2042 | while (!ret && (root_node = ulist_next(roots, &root_uiter))) { |
2036 | pr_debug("root %llu references leaf %llu, data list %#llx\n", root_node->val, ref_node->val, | 2043 | btrfs_debug(fs_info, |
2037 | ref_node->aux); | 2044 | "root %llu references leaf %llu, data list %#llx", |
2038 | ret = iterate_leaf_refs((struct extent_inode_elem *) | 2045 | root_node->val, ref_node->val, |
2046 | ref_node->aux); | ||
2047 | ret = iterate_leaf_refs(fs_info, | ||
2048 | (struct extent_inode_elem *) | ||
2039 | (uintptr_t)ref_node->aux, | 2049 | (uintptr_t)ref_node->aux, |
2040 | root_node->val, | 2050 | root_node->val, |
2041 | extent_item_objectid, | 2051 | extent_item_objectid, |
@@ -2131,8 +2141,9 @@ static int iterate_inode_refs(u64 inum, struct btrfs_root *fs_root, | |||
2131 | for (cur = 0; cur < btrfs_item_size(eb, item); cur += len) { | 2141 | for (cur = 0; cur < btrfs_item_size(eb, item); cur += len) { |
2132 | name_len = btrfs_inode_ref_name_len(eb, iref); | 2142 | name_len = btrfs_inode_ref_name_len(eb, iref); |
2133 | /* path must be released before calling iterate()! */ | 2143 | /* path must be released before calling iterate()! */ |
2134 | pr_debug("following ref at offset %u for inode %llu in tree %llu\n", cur, found_key.objectid, | 2144 | btrfs_debug(fs_root->fs_info, |
2135 | fs_root->objectid); | 2145 | "following ref at offset %u for inode %llu in tree %llu", |
2146 | cur, found_key.objectid, fs_root->objectid); | ||
2136 | ret = iterate(parent, name_len, | 2147 | ret = iterate(parent, name_len, |
2137 | (unsigned long)(iref + 1), eb, ctx); | 2148 | (unsigned long)(iref + 1), eb, ctx); |
2138 | if (ret) | 2149 | if (ret) |
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index d635d0f00f8f..ccc70d96958d 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c | |||
@@ -853,7 +853,7 @@ again: | |||
853 | /* no burst */ 1); | 853 | /* no burst */ 1); |
854 | 854 | ||
855 | if (__ratelimit(&_rs)) { | 855 | if (__ratelimit(&_rs)) { |
856 | pr_warn("no compression workspaces, low memory, retrying\n"); | 856 | pr_warn("BTRFS: no compression workspaces, low memory, retrying\n"); |
857 | } | 857 | } |
858 | } | 858 | } |
859 | goto again; | 859 | goto again; |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8937f3f8780a..9e8fd5ecef55 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -3395,7 +3395,7 @@ do { \ | |||
3395 | __cold | 3395 | __cold |
3396 | static inline void assfail(char *expr, char *file, int line) | 3396 | static inline void assfail(char *expr, char *file, int line) |
3397 | { | 3397 | { |
3398 | pr_err("BTRFS: assertion failed: %s, file: %s, line: %d", | 3398 | pr_err("assertion failed: %s, file: %s, line: %d\n", |
3399 | expr, file, line); | 3399 | expr, file, line); |
3400 | BUG(); | 3400 | BUG(); |
3401 | } | 3401 | } |
diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index a5d81f361d0b..8d93854a4b4f 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c | |||
@@ -322,10 +322,11 @@ int btrfs_check_delayed_seq(struct btrfs_fs_info *fs_info, | |||
322 | elem = list_first_entry(&fs_info->tree_mod_seq_list, | 322 | elem = list_first_entry(&fs_info->tree_mod_seq_list, |
323 | struct seq_list, list); | 323 | struct seq_list, list); |
324 | if (seq >= elem->seq) { | 324 | if (seq >= elem->seq) { |
325 | pr_debug("holding back delayed_ref %#x.%x, lowest is %#x.%x (%p)\n", | 325 | btrfs_debug(fs_info, |
326 | (u32)(seq >> 32), (u32)seq, | 326 | "holding back delayed_ref %#x.%x, lowest is %#x.%x (%p)", |
327 | (u32)(elem->seq >> 32), (u32)elem->seq, | 327 | (u32)(seq >> 32), (u32)seq, |
328 | delayed_refs); | 328 | (u32)(elem->seq >> 32), (u32)elem->seq, |
329 | delayed_refs); | ||
329 | ret = 1; | 330 | ret = 1; |
330 | } | 331 | } |
331 | } | 332 | } |
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index 26c6a770674a..05169ef30596 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c | |||
@@ -385,7 +385,7 @@ int btrfs_dev_replace_start(struct btrfs_root *root, char *tgtdev_name, | |||
385 | 385 | ||
386 | ret = btrfs_sysfs_add_device_link(tgt_device->fs_devices, tgt_device); | 386 | ret = btrfs_sysfs_add_device_link(tgt_device->fs_devices, tgt_device); |
387 | if (ret) | 387 | if (ret) |
388 | btrfs_err(fs_info, "kobj add dev failed %d\n", ret); | 388 | btrfs_err(fs_info, "kobj add dev failed %d", ret); |
389 | 389 | ||
390 | btrfs_wait_ordered_roots(root->fs_info, -1, 0, (u64)-1); | 390 | btrfs_wait_ordered_roots(root->fs_info, -1, 0, (u64)-1); |
391 | 391 | ||
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index df8c8f291831..e720d3e6ec20 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -401,7 +401,8 @@ out: | |||
401 | * Return 0 if the superblock checksum type matches the checksum value of that | 401 | * Return 0 if the superblock checksum type matches the checksum value of that |
402 | * algorithm. Pass the raw disk superblock data. | 402 | * algorithm. Pass the raw disk superblock data. |
403 | */ | 403 | */ |
404 | static int btrfs_check_super_csum(char *raw_disk_sb) | 404 | static int btrfs_check_super_csum(struct btrfs_fs_info *fs_info, |
405 | char *raw_disk_sb) | ||
405 | { | 406 | { |
406 | struct btrfs_super_block *disk_sb = | 407 | struct btrfs_super_block *disk_sb = |
407 | (struct btrfs_super_block *)raw_disk_sb; | 408 | (struct btrfs_super_block *)raw_disk_sb; |
@@ -427,7 +428,7 @@ static int btrfs_check_super_csum(char *raw_disk_sb) | |||
427 | } | 428 | } |
428 | 429 | ||
429 | if (csum_type >= ARRAY_SIZE(btrfs_csum_sizes)) { | 430 | if (csum_type >= ARRAY_SIZE(btrfs_csum_sizes)) { |
430 | pr_err("BTRFS: unsupported checksum algorithm %u\n", | 431 | btrfs_err(fs_info, "unsupported checksum algorithm %u", |
431 | csum_type); | 432 | csum_type); |
432 | ret = 1; | 433 | ret = 1; |
433 | } | 434 | } |
@@ -2780,7 +2781,7 @@ int open_ctree(struct super_block *sb, | |||
2780 | * We want to check superblock checksum, the type is stored inside. | 2781 | * We want to check superblock checksum, the type is stored inside. |
2781 | * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k). | 2782 | * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k). |
2782 | */ | 2783 | */ |
2783 | if (btrfs_check_super_csum(bh->b_data)) { | 2784 | if (btrfs_check_super_csum(fs_info, bh->b_data)) { |
2784 | btrfs_err(fs_info, "superblock checksum mismatch"); | 2785 | btrfs_err(fs_info, "superblock checksum mismatch"); |
2785 | err = -EINVAL; | 2786 | err = -EINVAL; |
2786 | brelse(bh); | 2787 | brelse(bh); |
@@ -3624,7 +3625,7 @@ int btrfs_get_num_tolerated_disk_barrier_failures(u64 flags) | |||
3624 | } | 3625 | } |
3625 | 3626 | ||
3626 | if (min_tolerated == INT_MAX) { | 3627 | if (min_tolerated == INT_MAX) { |
3627 | pr_warn("BTRFS: unknown raid flag: %llu\n", flags); | 3628 | pr_warn("BTRFS: unknown raid flag: %llu", flags); |
3628 | min_tolerated = 0; | 3629 | min_tolerated = 0; |
3629 | } | 3630 | } |
3630 | 3631 | ||
@@ -4114,24 +4115,24 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info, | |||
4114 | int ret = 0; | 4115 | int ret = 0; |
4115 | 4116 | ||
4116 | if (btrfs_super_magic(sb) != BTRFS_MAGIC) { | 4117 | if (btrfs_super_magic(sb) != BTRFS_MAGIC) { |
4117 | pr_err("BTRFS: no valid FS found\n"); | 4118 | btrfs_err(fs_info, "no valid FS found"); |
4118 | ret = -EINVAL; | 4119 | ret = -EINVAL; |
4119 | } | 4120 | } |
4120 | if (btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP) | 4121 | if (btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP) |
4121 | pr_warn("BTRFS: unrecognized super flag: %llu\n", | 4122 | btrfs_warn(fs_info, "unrecognized super flag: %llu", |
4122 | btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP); | 4123 | btrfs_super_flags(sb) & ~BTRFS_SUPER_FLAG_SUPP); |
4123 | if (btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL) { | 4124 | if (btrfs_super_root_level(sb) >= BTRFS_MAX_LEVEL) { |
4124 | pr_err("BTRFS: tree_root level too big: %d >= %d\n", | 4125 | btrfs_err(fs_info, "tree_root level too big: %d >= %d", |
4125 | btrfs_super_root_level(sb), BTRFS_MAX_LEVEL); | 4126 | btrfs_super_root_level(sb), BTRFS_MAX_LEVEL); |
4126 | ret = -EINVAL; | 4127 | ret = -EINVAL; |
4127 | } | 4128 | } |
4128 | if (btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL) { | 4129 | if (btrfs_super_chunk_root_level(sb) >= BTRFS_MAX_LEVEL) { |
4129 | pr_err("BTRFS: chunk_root level too big: %d >= %d\n", | 4130 | btrfs_err(fs_info, "chunk_root level too big: %d >= %d", |
4130 | btrfs_super_chunk_root_level(sb), BTRFS_MAX_LEVEL); | 4131 | btrfs_super_chunk_root_level(sb), BTRFS_MAX_LEVEL); |
4131 | ret = -EINVAL; | 4132 | ret = -EINVAL; |
4132 | } | 4133 | } |
4133 | if (btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL) { | 4134 | if (btrfs_super_log_root_level(sb) >= BTRFS_MAX_LEVEL) { |
4134 | pr_err("BTRFS: log_root level too big: %d >= %d\n", | 4135 | btrfs_err(fs_info, "log_root level too big: %d >= %d", |
4135 | btrfs_super_log_root_level(sb), BTRFS_MAX_LEVEL); | 4136 | btrfs_super_log_root_level(sb), BTRFS_MAX_LEVEL); |
4136 | ret = -EINVAL; | 4137 | ret = -EINVAL; |
4137 | } | 4138 | } |
@@ -4142,47 +4143,48 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info, | |||
4142 | */ | 4143 | */ |
4143 | if (!is_power_of_2(sectorsize) || sectorsize < 4096 || | 4144 | if (!is_power_of_2(sectorsize) || sectorsize < 4096 || |
4144 | sectorsize > BTRFS_MAX_METADATA_BLOCKSIZE) { | 4145 | sectorsize > BTRFS_MAX_METADATA_BLOCKSIZE) { |
4145 | pr_err("BTRFS: invalid sectorsize %llu\n", sectorsize); | 4146 | btrfs_err(fs_info, "invalid sectorsize %llu", sectorsize); |
4146 | ret = -EINVAL; | 4147 | ret = -EINVAL; |
4147 | } | 4148 | } |
4148 | /* Only PAGE SIZE is supported yet */ | 4149 | /* Only PAGE SIZE is supported yet */ |
4149 | if (sectorsize != PAGE_SIZE) { | 4150 | if (sectorsize != PAGE_SIZE) { |
4150 | pr_err("BTRFS: sectorsize %llu not supported yet, only support %lu\n", | 4151 | btrfs_err(fs_info, |
4151 | sectorsize, PAGE_SIZE); | 4152 | "sectorsize %llu not supported yet, only support %lu", |
4153 | sectorsize, PAGE_SIZE); | ||
4152 | ret = -EINVAL; | 4154 | ret = -EINVAL; |
4153 | } | 4155 | } |
4154 | if (!is_power_of_2(nodesize) || nodesize < sectorsize || | 4156 | if (!is_power_of_2(nodesize) || nodesize < sectorsize || |
4155 | nodesize > BTRFS_MAX_METADATA_BLOCKSIZE) { | 4157 | nodesize > BTRFS_MAX_METADATA_BLOCKSIZE) { |
4156 | pr_err("BTRFS: invalid nodesize %llu\n", nodesize); | 4158 | btrfs_err(fs_info, "invalid nodesize %llu", nodesize); |
4157 | ret = -EINVAL; | 4159 | ret = -EINVAL; |
4158 | } | 4160 | } |
4159 | if (nodesize != le32_to_cpu(sb->__unused_leafsize)) { | 4161 | if (nodesize != le32_to_cpu(sb->__unused_leafsize)) { |
4160 | pr_err("BTRFS: invalid leafsize %u, should be %llu\n", | 4162 | btrfs_err(fs_info, "invalid leafsize %u, should be %llu", |
4161 | le32_to_cpu(sb->__unused_leafsize), | 4163 | le32_to_cpu(sb->__unused_leafsize), nodesize); |
4162 | nodesize); | ||
4163 | ret = -EINVAL; | 4164 | ret = -EINVAL; |
4164 | } | 4165 | } |
4165 | 4166 | ||
4166 | /* Root alignment check */ | 4167 | /* Root alignment check */ |
4167 | if (!IS_ALIGNED(btrfs_super_root(sb), sectorsize)) { | 4168 | if (!IS_ALIGNED(btrfs_super_root(sb), sectorsize)) { |
4168 | pr_warn("BTRFS: tree_root block unaligned: %llu\n", | 4169 | btrfs_warn(fs_info, "tree_root block unaligned: %llu", |
4169 | btrfs_super_root(sb)); | 4170 | btrfs_super_root(sb)); |
4170 | ret = -EINVAL; | 4171 | ret = -EINVAL; |
4171 | } | 4172 | } |
4172 | if (!IS_ALIGNED(btrfs_super_chunk_root(sb), sectorsize)) { | 4173 | if (!IS_ALIGNED(btrfs_super_chunk_root(sb), sectorsize)) { |
4173 | pr_warn("BTRFS: chunk_root block unaligned: %llu\n", | 4174 | btrfs_warn(fs_info, "chunk_root block unaligned: %llu", |
4174 | btrfs_super_chunk_root(sb)); | 4175 | btrfs_super_chunk_root(sb)); |
4175 | ret = -EINVAL; | 4176 | ret = -EINVAL; |
4176 | } | 4177 | } |
4177 | if (!IS_ALIGNED(btrfs_super_log_root(sb), sectorsize)) { | 4178 | if (!IS_ALIGNED(btrfs_super_log_root(sb), sectorsize)) { |
4178 | pr_warn("BTRFS: log_root block unaligned: %llu\n", | 4179 | btrfs_warn(fs_info, "log_root block unaligned: %llu", |
4179 | btrfs_super_log_root(sb)); | 4180 | btrfs_super_log_root(sb)); |
4180 | ret = -EINVAL; | 4181 | ret = -EINVAL; |
4181 | } | 4182 | } |
4182 | 4183 | ||
4183 | if (memcmp(fs_info->fsid, sb->dev_item.fsid, BTRFS_UUID_SIZE) != 0) { | 4184 | if (memcmp(fs_info->fsid, sb->dev_item.fsid, BTRFS_UUID_SIZE) != 0) { |
4184 | pr_err("BTRFS: dev_item UUID does not match fsid: %pU != %pU\n", | 4185 | btrfs_err(fs_info, |
4185 | fs_info->fsid, sb->dev_item.fsid); | 4186 | "dev_item UUID does not match fsid: %pU != %pU", |
4187 | fs_info->fsid, sb->dev_item.fsid); | ||
4186 | ret = -EINVAL; | 4188 | ret = -EINVAL; |
4187 | } | 4189 | } |
4188 | 4190 | ||
@@ -4192,25 +4194,25 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info, | |||
4192 | */ | 4194 | */ |
4193 | if (btrfs_super_bytes_used(sb) < 6 * btrfs_super_nodesize(sb)) { | 4195 | if (btrfs_super_bytes_used(sb) < 6 * btrfs_super_nodesize(sb)) { |
4194 | btrfs_err(fs_info, "bytes_used is too small %llu", | 4196 | btrfs_err(fs_info, "bytes_used is too small %llu", |
4195 | btrfs_super_bytes_used(sb)); | 4197 | btrfs_super_bytes_used(sb)); |
4196 | ret = -EINVAL; | 4198 | ret = -EINVAL; |
4197 | } | 4199 | } |
4198 | if (!is_power_of_2(btrfs_super_stripesize(sb))) { | 4200 | if (!is_power_of_2(btrfs_super_stripesize(sb))) { |
4199 | btrfs_err(fs_info, "invalid stripesize %u", | 4201 | btrfs_err(fs_info, "invalid stripesize %u", |
4200 | btrfs_super_stripesize(sb)); | 4202 | btrfs_super_stripesize(sb)); |
4201 | ret = -EINVAL; | 4203 | ret = -EINVAL; |
4202 | } | 4204 | } |
4203 | if (btrfs_super_num_devices(sb) > (1UL << 31)) | 4205 | if (btrfs_super_num_devices(sb) > (1UL << 31)) |
4204 | pr_warn("BTRFS: suspicious number of devices: %llu\n", | 4206 | btrfs_warn(fs_info, "suspicious number of devices: %llu", |
4205 | btrfs_super_num_devices(sb)); | 4207 | btrfs_super_num_devices(sb)); |
4206 | if (btrfs_super_num_devices(sb) == 0) { | 4208 | if (btrfs_super_num_devices(sb) == 0) { |
4207 | pr_err("BTRFS: number of devices is 0\n"); | 4209 | btrfs_err(fs_info, "number of devices is 0"); |
4208 | ret = -EINVAL; | 4210 | ret = -EINVAL; |
4209 | } | 4211 | } |
4210 | 4212 | ||
4211 | if (btrfs_super_bytenr(sb) != BTRFS_SUPER_INFO_OFFSET) { | 4213 | if (btrfs_super_bytenr(sb) != BTRFS_SUPER_INFO_OFFSET) { |
4212 | pr_err("BTRFS: super offset mismatch %llu != %u\n", | 4214 | btrfs_err(fs_info, "super offset mismatch %llu != %u", |
4213 | btrfs_super_bytenr(sb), BTRFS_SUPER_INFO_OFFSET); | 4215 | btrfs_super_bytenr(sb), BTRFS_SUPER_INFO_OFFSET); |
4214 | ret = -EINVAL; | 4216 | ret = -EINVAL; |
4215 | } | 4217 | } |
4216 | 4218 | ||
@@ -4219,17 +4221,17 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info, | |||
4219 | * and one chunk | 4221 | * and one chunk |
4220 | */ | 4222 | */ |
4221 | if (btrfs_super_sys_array_size(sb) > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) { | 4223 | if (btrfs_super_sys_array_size(sb) > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE) { |
4222 | pr_err("BTRFS: system chunk array too big %u > %u\n", | 4224 | btrfs_err(fs_info, "system chunk array too big %u > %u", |
4223 | btrfs_super_sys_array_size(sb), | 4225 | btrfs_super_sys_array_size(sb), |
4224 | BTRFS_SYSTEM_CHUNK_ARRAY_SIZE); | 4226 | BTRFS_SYSTEM_CHUNK_ARRAY_SIZE); |
4225 | ret = -EINVAL; | 4227 | ret = -EINVAL; |
4226 | } | 4228 | } |
4227 | if (btrfs_super_sys_array_size(sb) < sizeof(struct btrfs_disk_key) | 4229 | if (btrfs_super_sys_array_size(sb) < sizeof(struct btrfs_disk_key) |
4228 | + sizeof(struct btrfs_chunk)) { | 4230 | + sizeof(struct btrfs_chunk)) { |
4229 | pr_err("BTRFS: system chunk array too small %u < %zu\n", | 4231 | btrfs_err(fs_info, "system chunk array too small %u < %zu", |
4230 | btrfs_super_sys_array_size(sb), | 4232 | btrfs_super_sys_array_size(sb), |
4231 | sizeof(struct btrfs_disk_key) | 4233 | sizeof(struct btrfs_disk_key) |
4232 | + sizeof(struct btrfs_chunk)); | 4234 | + sizeof(struct btrfs_chunk)); |
4233 | ret = -EINVAL; | 4235 | ret = -EINVAL; |
4234 | } | 4236 | } |
4235 | 4237 | ||
@@ -4238,12 +4240,16 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info, | |||
4238 | * but it's still possible that it's the one that's wrong. | 4240 | * but it's still possible that it's the one that's wrong. |
4239 | */ | 4241 | */ |
4240 | if (btrfs_super_generation(sb) < btrfs_super_chunk_root_generation(sb)) | 4242 | if (btrfs_super_generation(sb) < btrfs_super_chunk_root_generation(sb)) |
4241 | pr_warn("BTRFS: suspicious: generation < chunk_root_generation: %llu < %llu\n", | 4243 | btrfs_warn(fs_info, |
4242 | btrfs_super_generation(sb), btrfs_super_chunk_root_generation(sb)); | 4244 | "suspicious: generation < chunk_root_generation: %llu < %llu", |
4245 | btrfs_super_generation(sb), | ||
4246 | btrfs_super_chunk_root_generation(sb)); | ||
4243 | if (btrfs_super_generation(sb) < btrfs_super_cache_generation(sb) | 4247 | if (btrfs_super_generation(sb) < btrfs_super_cache_generation(sb) |
4244 | && btrfs_super_cache_generation(sb) != (u64)-1) | 4248 | && btrfs_super_cache_generation(sb) != (u64)-1) |
4245 | pr_warn("BTRFS: suspicious: generation < cache_generation: %llu < %llu\n", | 4249 | btrfs_warn(fs_info, |
4246 | btrfs_super_generation(sb), btrfs_super_cache_generation(sb)); | 4250 | "suspicious: generation < cache_generation: %llu < %llu", |
4251 | btrfs_super_generation(sb), | ||
4252 | btrfs_super_cache_generation(sb)); | ||
4247 | 4253 | ||
4248 | return ret; | 4254 | return ret; |
4249 | } | 4255 | } |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 4e9eeb48f76f..56d8ec21a0f4 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -87,7 +87,8 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans, | |||
87 | int force); | 87 | int force); |
88 | static int find_next_key(struct btrfs_path *path, int level, | 88 | static int find_next_key(struct btrfs_path *path, int level, |
89 | struct btrfs_key *key); | 89 | struct btrfs_key *key); |
90 | static void dump_space_info(struct btrfs_space_info *info, u64 bytes, | 90 | static void dump_space_info(struct btrfs_fs_info *fs_info, |
91 | struct btrfs_space_info *info, u64 bytes, | ||
91 | int dump_block_groups); | 92 | int dump_block_groups); |
92 | static int btrfs_add_reserved_bytes(struct btrfs_block_group_cache *cache, | 93 | static int btrfs_add_reserved_bytes(struct btrfs_block_group_cache *cache, |
93 | u64 ram_bytes, u64 num_bytes, int delalloc); | 94 | u64 ram_bytes, u64 num_bytes, int delalloc); |
@@ -266,9 +267,8 @@ static int exclude_super_stripes(struct btrfs_root *root, | |||
266 | 267 | ||
267 | for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { | 268 | for (i = 0; i < BTRFS_SUPER_MIRROR_MAX; i++) { |
268 | bytenr = btrfs_sb_offset(i); | 269 | bytenr = btrfs_sb_offset(i); |
269 | ret = btrfs_rmap_block(&root->fs_info->mapping_tree, | 270 | ret = btrfs_rmap_block(root->fs_info, cache->key.objectid, |
270 | cache->key.objectid, bytenr, | 271 | bytenr, 0, &logical, &nr, &stripe_len); |
271 | 0, &logical, &nr, &stripe_len); | ||
272 | if (ret) | 272 | if (ret) |
273 | return ret; | 273 | return ret; |
274 | 274 | ||
@@ -4432,7 +4432,7 @@ void check_system_chunk(struct btrfs_trans_handle *trans, | |||
4432 | if (left < thresh && btrfs_test_opt(root->fs_info, ENOSPC_DEBUG)) { | 4432 | if (left < thresh && btrfs_test_opt(root->fs_info, ENOSPC_DEBUG)) { |
4433 | btrfs_info(root->fs_info, "left=%llu, need=%llu, flags=%llu", | 4433 | btrfs_info(root->fs_info, "left=%llu, need=%llu, flags=%llu", |
4434 | left, thresh, type); | 4434 | left, thresh, type); |
4435 | dump_space_info(info, 0, 0); | 4435 | dump_space_info(root->fs_info, info, 0, 0); |
4436 | } | 4436 | } |
4437 | 4437 | ||
4438 | if (left < thresh) { | 4438 | if (left < thresh) { |
@@ -7907,22 +7907,24 @@ out: | |||
7907 | return ret; | 7907 | return ret; |
7908 | } | 7908 | } |
7909 | 7909 | ||
7910 | static void dump_space_info(struct btrfs_space_info *info, u64 bytes, | 7910 | static void dump_space_info(struct btrfs_fs_info *fs_info, |
7911 | struct btrfs_space_info *info, u64 bytes, | ||
7911 | int dump_block_groups) | 7912 | int dump_block_groups) |
7912 | { | 7913 | { |
7913 | struct btrfs_block_group_cache *cache; | 7914 | struct btrfs_block_group_cache *cache; |
7914 | int index = 0; | 7915 | int index = 0; |
7915 | 7916 | ||
7916 | spin_lock(&info->lock); | 7917 | spin_lock(&info->lock); |
7917 | pr_info("BTRFS: space_info %llu has %llu free, is %sfull\n", | 7918 | btrfs_info(fs_info, "space_info %llu has %llu free, is %sfull", |
7918 | info->flags, | 7919 | info->flags, |
7919 | info->total_bytes - info->bytes_used - info->bytes_pinned - | 7920 | info->total_bytes - info->bytes_used - info->bytes_pinned - |
7920 | info->bytes_reserved - info->bytes_readonly - | 7921 | info->bytes_reserved - info->bytes_readonly - |
7921 | info->bytes_may_use, (info->full) ? "" : "not "); | 7922 | info->bytes_may_use, (info->full) ? "" : "not "); |
7922 | pr_info("BTRFS: space_info total=%llu, used=%llu, pinned=%llu, reserved=%llu, may_use=%llu, readonly=%llu\n", | 7923 | btrfs_info(fs_info, |
7923 | info->total_bytes, info->bytes_used, info->bytes_pinned, | 7924 | "space_info total=%llu, used=%llu, pinned=%llu, reserved=%llu, may_use=%llu, readonly=%llu", |
7924 | info->bytes_reserved, info->bytes_may_use, | 7925 | info->total_bytes, info->bytes_used, info->bytes_pinned, |
7925 | info->bytes_readonly); | 7926 | info->bytes_reserved, info->bytes_may_use, |
7927 | info->bytes_readonly); | ||
7926 | spin_unlock(&info->lock); | 7928 | spin_unlock(&info->lock); |
7927 | 7929 | ||
7928 | if (!dump_block_groups) | 7930 | if (!dump_block_groups) |
@@ -7932,10 +7934,11 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes, | |||
7932 | again: | 7934 | again: |
7933 | list_for_each_entry(cache, &info->block_groups[index], list) { | 7935 | list_for_each_entry(cache, &info->block_groups[index], list) { |
7934 | spin_lock(&cache->lock); | 7936 | spin_lock(&cache->lock); |
7935 | pr_info("BTRFS: block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %s\n", | 7937 | btrfs_info(fs_info, |
7936 | cache->key.objectid, cache->key.offset, | 7938 | "block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %s", |
7937 | btrfs_block_group_used(&cache->item), cache->pinned, | 7939 | cache->key.objectid, cache->key.offset, |
7938 | cache->reserved, cache->ro ? "[readonly]" : ""); | 7940 | btrfs_block_group_used(&cache->item), cache->pinned, |
7941 | cache->reserved, cache->ro ? "[readonly]" : ""); | ||
7939 | btrfs_dump_free_space(cache, bytes); | 7942 | btrfs_dump_free_space(cache, bytes); |
7940 | spin_unlock(&cache->lock); | 7943 | spin_unlock(&cache->lock); |
7941 | } | 7944 | } |
@@ -7949,6 +7952,7 @@ int btrfs_reserve_extent(struct btrfs_root *root, u64 ram_bytes, | |||
7949 | u64 empty_size, u64 hint_byte, | 7952 | u64 empty_size, u64 hint_byte, |
7950 | struct btrfs_key *ins, int is_data, int delalloc) | 7953 | struct btrfs_key *ins, int is_data, int delalloc) |
7951 | { | 7954 | { |
7955 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
7952 | bool final_tried = num_bytes == min_alloc_size; | 7956 | bool final_tried = num_bytes == min_alloc_size; |
7953 | u64 flags; | 7957 | u64 flags; |
7954 | int ret; | 7958 | int ret; |
@@ -7959,8 +7963,7 @@ again: | |||
7959 | ret = find_free_extent(root, ram_bytes, num_bytes, empty_size, | 7963 | ret = find_free_extent(root, ram_bytes, num_bytes, empty_size, |
7960 | hint_byte, ins, flags, delalloc); | 7964 | hint_byte, ins, flags, delalloc); |
7961 | if (!ret && !is_data) { | 7965 | if (!ret && !is_data) { |
7962 | btrfs_dec_block_group_reservations(root->fs_info, | 7966 | btrfs_dec_block_group_reservations(fs_info, ins->objectid); |
7963 | ins->objectid); | ||
7964 | } else if (ret == -ENOSPC) { | 7967 | } else if (ret == -ENOSPC) { |
7965 | if (!final_tried && ins->offset) { | 7968 | if (!final_tried && ins->offset) { |
7966 | num_bytes = min(num_bytes >> 1, ins->offset); | 7969 | num_bytes = min(num_bytes >> 1, ins->offset); |
@@ -7970,15 +7973,15 @@ again: | |||
7970 | if (num_bytes == min_alloc_size) | 7973 | if (num_bytes == min_alloc_size) |
7971 | final_tried = true; | 7974 | final_tried = true; |
7972 | goto again; | 7975 | goto again; |
7973 | } else if (btrfs_test_opt(root->fs_info, ENOSPC_DEBUG)) { | 7976 | } else if (btrfs_test_opt(fs_info, ENOSPC_DEBUG)) { |
7974 | struct btrfs_space_info *sinfo; | 7977 | struct btrfs_space_info *sinfo; |
7975 | 7978 | ||
7976 | sinfo = __find_space_info(root->fs_info, flags); | 7979 | sinfo = __find_space_info(fs_info, flags); |
7977 | btrfs_err(root->fs_info, | 7980 | btrfs_err(root->fs_info, |
7978 | "allocation failed flags %llu, wanted %llu", | 7981 | "allocation failed flags %llu, wanted %llu", |
7979 | flags, num_bytes); | 7982 | flags, num_bytes); |
7980 | if (sinfo) | 7983 | if (sinfo) |
7981 | dump_space_info(sinfo, num_bytes, 1); | 7984 | dump_space_info(fs_info, sinfo, num_bytes, 1); |
7982 | } | 7985 | } |
7983 | } | 7986 | } |
7984 | 7987 | ||
@@ -9178,9 +9181,10 @@ int btrfs_drop_snapshot(struct btrfs_root *root, | |||
9178 | struct btrfs_block_rsv *block_rsv, int update_ref, | 9181 | struct btrfs_block_rsv *block_rsv, int update_ref, |
9179 | int for_reloc) | 9182 | int for_reloc) |
9180 | { | 9183 | { |
9184 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
9181 | struct btrfs_path *path; | 9185 | struct btrfs_path *path; |
9182 | struct btrfs_trans_handle *trans; | 9186 | struct btrfs_trans_handle *trans; |
9183 | struct btrfs_root *tree_root = root->fs_info->tree_root; | 9187 | struct btrfs_root *tree_root = fs_info->tree_root; |
9184 | struct btrfs_root_item *root_item = &root->root_item; | 9188 | struct btrfs_root_item *root_item = &root->root_item; |
9185 | struct walk_control *wc; | 9189 | struct walk_control *wc; |
9186 | struct btrfs_key key; | 9190 | struct btrfs_key key; |
@@ -9189,7 +9193,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root, | |||
9189 | int level; | 9193 | int level; |
9190 | bool root_dropped = false; | 9194 | bool root_dropped = false; |
9191 | 9195 | ||
9192 | btrfs_debug(root->fs_info, "Drop subvolume %llu", root->objectid); | 9196 | btrfs_debug(fs_info, "Drop subvolume %llu", root->objectid); |
9193 | 9197 | ||
9194 | path = btrfs_alloc_path(); | 9198 | path = btrfs_alloc_path(); |
9195 | if (!path) { | 9199 | if (!path) { |
@@ -9318,7 +9322,8 @@ int btrfs_drop_snapshot(struct btrfs_root *root, | |||
9318 | 9322 | ||
9319 | btrfs_end_transaction_throttle(trans, tree_root); | 9323 | btrfs_end_transaction_throttle(trans, tree_root); |
9320 | if (!for_reloc && btrfs_need_cleaner_sleep(root)) { | 9324 | if (!for_reloc && btrfs_need_cleaner_sleep(root)) { |
9321 | pr_debug("BTRFS: drop snapshot early exit\n"); | 9325 | btrfs_debug(fs_info, |
9326 | "drop snapshot early exit"); | ||
9322 | err = -EAGAIN; | 9327 | err = -EAGAIN; |
9323 | goto out_free; | 9328 | goto out_free; |
9324 | } | 9329 | } |
@@ -9384,7 +9389,7 @@ out: | |||
9384 | if (!for_reloc && root_dropped == false) | 9389 | if (!for_reloc && root_dropped == false) |
9385 | btrfs_add_dead_root(root); | 9390 | btrfs_add_dead_root(root); |
9386 | if (err && err != -EAGAIN) | 9391 | if (err && err != -EAGAIN) |
9387 | btrfs_handle_fs_error(root->fs_info, err, NULL); | 9392 | btrfs_handle_fs_error(fs_info, err, NULL); |
9388 | return err; | 9393 | return err; |
9389 | } | 9394 | } |
9390 | 9395 | ||
@@ -10018,7 +10023,7 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info) | |||
10018 | if (WARN_ON(space_info->bytes_pinned > 0 || | 10023 | if (WARN_ON(space_info->bytes_pinned > 0 || |
10019 | space_info->bytes_reserved > 0 || | 10024 | space_info->bytes_reserved > 0 || |
10020 | space_info->bytes_may_use > 0)) | 10025 | space_info->bytes_may_use > 0)) |
10021 | dump_space_info(space_info, 0, 0); | 10026 | dump_space_info(info, space_info, 0, 0); |
10022 | list_del(&space_info->list); | 10027 | list_del(&space_info->list); |
10023 | for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) { | 10028 | for (i = 0; i < BTRFS_NR_RAID_TYPES; i++) { |
10024 | struct kobject *kobj; | 10029 | struct kobject *kobj; |
@@ -10067,7 +10072,8 @@ static void __link_block_group(struct btrfs_space_info *space_info, | |||
10067 | 10072 | ||
10068 | return; | 10073 | return; |
10069 | out_err: | 10074 | out_err: |
10070 | pr_warn("BTRFS: failed to add kobject for block cache. ignoring.\n"); | 10075 | btrfs_warn(cache->fs_info, |
10076 | "failed to add kobject for block cache, ignoring"); | ||
10071 | } | 10077 | } |
10072 | 10078 | ||
10073 | static struct btrfs_block_group_cache * | 10079 | static struct btrfs_block_group_cache * |
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 8c4a0a09c221..0d1876c76732 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c | |||
@@ -2120,8 +2120,9 @@ int clean_io_failure(struct inode *inode, u64 start, struct page *page, | |||
2120 | 2120 | ||
2121 | if (failrec->in_validation) { | 2121 | if (failrec->in_validation) { |
2122 | /* there was no real error, just free the record */ | 2122 | /* there was no real error, just free the record */ |
2123 | pr_debug("clean_io_failure: freeing dummy error at %llu\n", | 2123 | btrfs_debug(fs_info, |
2124 | failrec->start); | 2124 | "clean_io_failure: freeing dummy error at %llu", |
2125 | failrec->start); | ||
2125 | goto out; | 2126 | goto out; |
2126 | } | 2127 | } |
2127 | if (fs_info->sb->s_flags & MS_RDONLY) | 2128 | if (fs_info->sb->s_flags & MS_RDONLY) |
@@ -2187,6 +2188,7 @@ void btrfs_free_io_failure_record(struct inode *inode, u64 start, u64 end) | |||
2187 | int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end, | 2188 | int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end, |
2188 | struct io_failure_record **failrec_ret) | 2189 | struct io_failure_record **failrec_ret) |
2189 | { | 2190 | { |
2191 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | ||
2190 | struct io_failure_record *failrec; | 2192 | struct io_failure_record *failrec; |
2191 | struct extent_map *em; | 2193 | struct extent_map *em; |
2192 | struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree; | 2194 | struct extent_io_tree *failure_tree = &BTRFS_I(inode)->io_failure_tree; |
@@ -2234,8 +2236,9 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end, | |||
2234 | em->compress_type); | 2236 | em->compress_type); |
2235 | } | 2237 | } |
2236 | 2238 | ||
2237 | pr_debug("Get IO Failure Record: (new) logical=%llu, start=%llu, len=%llu\n", | 2239 | btrfs_debug(fs_info, |
2238 | logical, start, failrec->len); | 2240 | "Get IO Failure Record: (new) logical=%llu, start=%llu, len=%llu", |
2241 | logical, start, failrec->len); | ||
2239 | 2242 | ||
2240 | failrec->logical = logical; | 2243 | failrec->logical = logical; |
2241 | free_extent_map(em); | 2244 | free_extent_map(em); |
@@ -2253,9 +2256,10 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end, | |||
2253 | return ret; | 2256 | return ret; |
2254 | } | 2257 | } |
2255 | } else { | 2258 | } else { |
2256 | pr_debug("Get IO Failure Record: (found) logical=%llu, start=%llu, len=%llu, validation=%d\n", | 2259 | btrfs_debug(fs_info, |
2257 | failrec->logical, failrec->start, failrec->len, | 2260 | "Get IO Failure Record: (found) logical=%llu, start=%llu, len=%llu, validation=%d", |
2258 | failrec->in_validation); | 2261 | failrec->logical, failrec->start, failrec->len, |
2262 | failrec->in_validation); | ||
2259 | /* | 2263 | /* |
2260 | * when data can be on disk more than twice, add to failrec here | 2264 | * when data can be on disk more than twice, add to failrec here |
2261 | * (e.g. with a list for failed_mirror) to make | 2265 | * (e.g. with a list for failed_mirror) to make |
@@ -2271,18 +2275,19 @@ int btrfs_get_io_failure_record(struct inode *inode, u64 start, u64 end, | |||
2271 | int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio, | 2275 | int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio, |
2272 | struct io_failure_record *failrec, int failed_mirror) | 2276 | struct io_failure_record *failrec, int failed_mirror) |
2273 | { | 2277 | { |
2278 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | ||
2274 | int num_copies; | 2279 | int num_copies; |
2275 | 2280 | ||
2276 | num_copies = btrfs_num_copies(BTRFS_I(inode)->root->fs_info, | 2281 | num_copies = btrfs_num_copies(fs_info, failrec->logical, failrec->len); |
2277 | failrec->logical, failrec->len); | ||
2278 | if (num_copies == 1) { | 2282 | if (num_copies == 1) { |
2279 | /* | 2283 | /* |
2280 | * we only have a single copy of the data, so don't bother with | 2284 | * we only have a single copy of the data, so don't bother with |
2281 | * all the retry and error correction code that follows. no | 2285 | * all the retry and error correction code that follows. no |
2282 | * matter what the error is, it is very likely to persist. | 2286 | * matter what the error is, it is very likely to persist. |
2283 | */ | 2287 | */ |
2284 | pr_debug("Check Repairable: cannot repair, num_copies=%d, next_mirror %d, failed_mirror %d\n", | 2288 | btrfs_debug(fs_info, |
2285 | num_copies, failrec->this_mirror, failed_mirror); | 2289 | "Check Repairable: cannot repair, num_copies=%d, next_mirror %d, failed_mirror %d", |
2290 | num_copies, failrec->this_mirror, failed_mirror); | ||
2286 | return 0; | 2291 | return 0; |
2287 | } | 2292 | } |
2288 | 2293 | ||
@@ -2321,8 +2326,9 @@ int btrfs_check_repairable(struct inode *inode, struct bio *failed_bio, | |||
2321 | } | 2326 | } |
2322 | 2327 | ||
2323 | if (failrec->this_mirror > num_copies) { | 2328 | if (failrec->this_mirror > num_copies) { |
2324 | pr_debug("Check Repairable: (fail) num_copies=%d, next_mirror %d, failed_mirror %d\n", | 2329 | btrfs_debug(fs_info, |
2325 | num_copies, failrec->this_mirror, failed_mirror); | 2330 | "Check Repairable: (fail) num_copies=%d, next_mirror %d, failed_mirror %d", |
2331 | num_copies, failrec->this_mirror, failed_mirror); | ||
2326 | return 0; | 2332 | return 0; |
2327 | } | 2333 | } |
2328 | 2334 | ||
@@ -2413,8 +2419,9 @@ static int bio_readpage_error(struct bio *failed_bio, u64 phy_offset, | |||
2413 | } | 2419 | } |
2414 | bio_set_op_attrs(bio, REQ_OP_READ, read_mode); | 2420 | bio_set_op_attrs(bio, REQ_OP_READ, read_mode); |
2415 | 2421 | ||
2416 | pr_debug("Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d\n", | 2422 | btrfs_debug(btrfs_sb(inode->i_sb), |
2417 | read_mode, failrec->this_mirror, failrec->in_validation); | 2423 | "Repair Read Error: submitting new read[%#x] to this_mirror=%d, in_validation=%d", |
2424 | read_mode, failrec->this_mirror, failrec->in_validation); | ||
2418 | 2425 | ||
2419 | ret = tree->ops->submit_bio_hook(inode, bio, failrec->this_mirror, | 2426 | ret = tree->ops->submit_bio_hook(inode, bio, failrec->this_mirror, |
2420 | failrec->bio_flags, 0); | 2427 | failrec->bio_flags, 0); |
@@ -2538,10 +2545,12 @@ static void end_bio_extent_readpage(struct bio *bio) | |||
2538 | bio_for_each_segment_all(bvec, bio, i) { | 2545 | bio_for_each_segment_all(bvec, bio, i) { |
2539 | struct page *page = bvec->bv_page; | 2546 | struct page *page = bvec->bv_page; |
2540 | struct inode *inode = page->mapping->host; | 2547 | struct inode *inode = page->mapping->host; |
2548 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | ||
2541 | 2549 | ||
2542 | pr_debug("end_bio_extent_readpage: bi_sector=%llu, err=%d, mirror=%u\n", | 2550 | btrfs_debug(fs_info, |
2543 | (u64)bio->bi_iter.bi_sector, | 2551 | "end_bio_extent_readpage: bi_sector=%llu, err=%d, mirror=%u", |
2544 | bio->bi_error, io_bio->mirror_num); | 2552 | (u64)bio->bi_iter.bi_sector, bio->bi_error, |
2553 | io_bio->mirror_num); | ||
2545 | tree = &BTRFS_I(inode)->io_tree; | 2554 | tree = &BTRFS_I(inode)->io_tree; |
2546 | 2555 | ||
2547 | /* We always issue full-page reads, but if some block | 2556 | /* We always issue full-page reads, but if some block |
@@ -2551,12 +2560,12 @@ static void end_bio_extent_readpage(struct bio *bio) | |||
2551 | * if they don't add up to a full page. */ | 2560 | * if they don't add up to a full page. */ |
2552 | if (bvec->bv_offset || bvec->bv_len != PAGE_SIZE) { | 2561 | if (bvec->bv_offset || bvec->bv_len != PAGE_SIZE) { |
2553 | if (bvec->bv_offset + bvec->bv_len != PAGE_SIZE) | 2562 | if (bvec->bv_offset + bvec->bv_len != PAGE_SIZE) |
2554 | btrfs_err(BTRFS_I(page->mapping->host)->root->fs_info, | 2563 | btrfs_err(fs_info, |
2555 | "partial page read in btrfs with offset %u and length %u", | 2564 | "partial page read in btrfs with offset %u and length %u", |
2556 | bvec->bv_offset, bvec->bv_len); | 2565 | bvec->bv_offset, bvec->bv_len); |
2557 | else | 2566 | else |
2558 | btrfs_info(BTRFS_I(page->mapping->host)->root->fs_info, | 2567 | btrfs_info(fs_info, |
2559 | "incomplete page read in btrfs with offset %u and length %u", | 2568 | "incomplete page read in btrfs with offset %u and length %u", |
2560 | bvec->bv_offset, bvec->bv_len); | 2569 | bvec->bv_offset, bvec->bv_len); |
2561 | } | 2570 | } |
2562 | 2571 | ||
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 60dedf400761..e4b48f377d3a 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -2299,7 +2299,8 @@ static void steal_from_bitmap(struct btrfs_free_space_ctl *ctl, | |||
2299 | } | 2299 | } |
2300 | } | 2300 | } |
2301 | 2301 | ||
2302 | int __btrfs_add_free_space(struct btrfs_free_space_ctl *ctl, | 2302 | int __btrfs_add_free_space(struct btrfs_fs_info *fs_info, |
2303 | struct btrfs_free_space_ctl *ctl, | ||
2303 | u64 offset, u64 bytes) | 2304 | u64 offset, u64 bytes) |
2304 | { | 2305 | { |
2305 | struct btrfs_free_space *info; | 2306 | struct btrfs_free_space *info; |
@@ -2346,7 +2347,7 @@ out: | |||
2346 | spin_unlock(&ctl->tree_lock); | 2347 | spin_unlock(&ctl->tree_lock); |
2347 | 2348 | ||
2348 | if (ret) { | 2349 | if (ret) { |
2349 | pr_crit("BTRFS: unable to add free space :%d\n", ret); | 2350 | btrfs_crit(fs_info, "unable to add free space :%d", ret); |
2350 | ASSERT(ret != -EEXIST); | 2351 | ASSERT(ret != -EEXIST); |
2351 | } | 2352 | } |
2352 | 2353 | ||
@@ -2622,7 +2623,8 @@ out: | |||
2622 | spin_unlock(&ctl->tree_lock); | 2623 | spin_unlock(&ctl->tree_lock); |
2623 | 2624 | ||
2624 | if (align_gap_len) | 2625 | if (align_gap_len) |
2625 | __btrfs_add_free_space(ctl, align_gap, align_gap_len); | 2626 | __btrfs_add_free_space(block_group->fs_info, ctl, |
2627 | align_gap, align_gap_len); | ||
2626 | return ret; | 2628 | return ret; |
2627 | } | 2629 | } |
2628 | 2630 | ||
diff --git a/fs/btrfs/free-space-cache.h b/fs/btrfs/free-space-cache.h index 3af651c2bbc7..363fdd955e5d 100644 --- a/fs/btrfs/free-space-cache.h +++ b/fs/btrfs/free-space-cache.h | |||
@@ -89,13 +89,15 @@ int btrfs_write_out_ino_cache(struct btrfs_root *root, | |||
89 | struct inode *inode); | 89 | struct inode *inode); |
90 | 90 | ||
91 | void btrfs_init_free_space_ctl(struct btrfs_block_group_cache *block_group); | 91 | void btrfs_init_free_space_ctl(struct btrfs_block_group_cache *block_group); |
92 | int __btrfs_add_free_space(struct btrfs_free_space_ctl *ctl, | 92 | int __btrfs_add_free_space(struct btrfs_fs_info *fs_info, |
93 | struct btrfs_free_space_ctl *ctl, | ||
93 | u64 bytenr, u64 size); | 94 | u64 bytenr, u64 size); |
94 | static inline int | 95 | static inline int |
95 | btrfs_add_free_space(struct btrfs_block_group_cache *block_group, | 96 | btrfs_add_free_space(struct btrfs_block_group_cache *block_group, |
96 | u64 bytenr, u64 size) | 97 | u64 bytenr, u64 size) |
97 | { | 98 | { |
98 | return __btrfs_add_free_space(block_group->free_space_ctl, | 99 | return __btrfs_add_free_space(block_group->fs_info, |
100 | block_group->free_space_ctl, | ||
99 | bytenr, size); | 101 | bytenr, size); |
100 | } | 102 | } |
101 | int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group, | 103 | int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group, |
diff --git a/fs/btrfs/free-space-tree.c b/fs/btrfs/free-space-tree.c index 1851beaa0377..e4a42a8e4f84 100644 --- a/fs/btrfs/free-space-tree.c +++ b/fs/btrfs/free-space-tree.c | |||
@@ -107,7 +107,7 @@ search_free_space_info(struct btrfs_trans_handle *trans, | |||
107 | if (ret < 0) | 107 | if (ret < 0) |
108 | return ERR_PTR(ret); | 108 | return ERR_PTR(ret); |
109 | if (ret != 0) { | 109 | if (ret != 0) { |
110 | btrfs_warn(fs_info, "missing free space info for %llu\n", | 110 | btrfs_warn(fs_info, "missing free space info for %llu", |
111 | block_group->key.objectid); | 111 | block_group->key.objectid); |
112 | ASSERT(0); | 112 | ASSERT(0); |
113 | return ERR_PTR(-ENOENT); | 113 | return ERR_PTR(-ENOENT); |
diff --git a/fs/btrfs/inode-map.c b/fs/btrfs/inode-map.c index 359ee861b5a4..d27014b8bf72 100644 --- a/fs/btrfs/inode-map.c +++ b/fs/btrfs/inode-map.c | |||
@@ -104,7 +104,7 @@ again: | |||
104 | break; | 104 | break; |
105 | 105 | ||
106 | if (last != (u64)-1 && last + 1 != key.objectid) { | 106 | if (last != (u64)-1 && last + 1 != key.objectid) { |
107 | __btrfs_add_free_space(ctl, last + 1, | 107 | __btrfs_add_free_space(fs_info, ctl, last + 1, |
108 | key.objectid - last - 1); | 108 | key.objectid - last - 1); |
109 | wake_up(&root->ino_cache_wait); | 109 | wake_up(&root->ino_cache_wait); |
110 | } | 110 | } |
@@ -115,7 +115,7 @@ next: | |||
115 | } | 115 | } |
116 | 116 | ||
117 | if (last < root->highest_objectid - 1) { | 117 | if (last < root->highest_objectid - 1) { |
118 | __btrfs_add_free_space(ctl, last + 1, | 118 | __btrfs_add_free_space(fs_info, ctl, last + 1, |
119 | root->highest_objectid - last - 1); | 119 | root->highest_objectid - last - 1); |
120 | } | 120 | } |
121 | 121 | ||
@@ -136,12 +136,13 @@ out: | |||
136 | 136 | ||
137 | static void start_caching(struct btrfs_root *root) | 137 | static void start_caching(struct btrfs_root *root) |
138 | { | 138 | { |
139 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
139 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; | 140 | struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; |
140 | struct task_struct *tsk; | 141 | struct task_struct *tsk; |
141 | int ret; | 142 | int ret; |
142 | u64 objectid; | 143 | u64 objectid; |
143 | 144 | ||
144 | if (!btrfs_test_opt(root->fs_info, INODE_MAP_CACHE)) | 145 | if (!btrfs_test_opt(fs_info, INODE_MAP_CACHE)) |
145 | return; | 146 | return; |
146 | 147 | ||
147 | spin_lock(&root->ino_cache_lock); | 148 | spin_lock(&root->ino_cache_lock); |
@@ -153,7 +154,7 @@ static void start_caching(struct btrfs_root *root) | |||
153 | root->ino_cache_state = BTRFS_CACHE_STARTED; | 154 | root->ino_cache_state = BTRFS_CACHE_STARTED; |
154 | spin_unlock(&root->ino_cache_lock); | 155 | spin_unlock(&root->ino_cache_lock); |
155 | 156 | ||
156 | ret = load_free_ino_cache(root->fs_info, root); | 157 | ret = load_free_ino_cache(fs_info, root); |
157 | if (ret == 1) { | 158 | if (ret == 1) { |
158 | spin_lock(&root->ino_cache_lock); | 159 | spin_lock(&root->ino_cache_lock); |
159 | root->ino_cache_state = BTRFS_CACHE_FINISHED; | 160 | root->ino_cache_state = BTRFS_CACHE_FINISHED; |
@@ -170,15 +171,15 @@ static void start_caching(struct btrfs_root *root) | |||
170 | */ | 171 | */ |
171 | ret = btrfs_find_free_objectid(root, &objectid); | 172 | ret = btrfs_find_free_objectid(root, &objectid); |
172 | if (!ret && objectid <= BTRFS_LAST_FREE_OBJECTID) { | 173 | if (!ret && objectid <= BTRFS_LAST_FREE_OBJECTID) { |
173 | __btrfs_add_free_space(ctl, objectid, | 174 | __btrfs_add_free_space(fs_info, ctl, objectid, |
174 | BTRFS_LAST_FREE_OBJECTID - objectid + 1); | 175 | BTRFS_LAST_FREE_OBJECTID - objectid + 1); |
175 | } | 176 | } |
176 | 177 | ||
177 | tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu", | 178 | tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu", |
178 | root->root_key.objectid); | 179 | root->root_key.objectid); |
179 | if (IS_ERR(tsk)) { | 180 | if (IS_ERR(tsk)) { |
180 | btrfs_warn(root->fs_info, "failed to start inode caching task"); | 181 | btrfs_warn(fs_info, "failed to start inode caching task"); |
181 | btrfs_clear_pending_and_info(root->fs_info, INODE_MAP_CACHE, | 182 | btrfs_clear_pending_and_info(fs_info, INODE_MAP_CACHE, |
182 | "disabling inode map caching"); | 183 | "disabling inode map caching"); |
183 | } | 184 | } |
184 | } | 185 | } |
@@ -209,28 +210,29 @@ again: | |||
209 | 210 | ||
210 | void btrfs_return_ino(struct btrfs_root *root, u64 objectid) | 211 | void btrfs_return_ino(struct btrfs_root *root, u64 objectid) |
211 | { | 212 | { |
213 | struct btrfs_fs_info *fs_info = root->fs_info; | ||
212 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; | 214 | struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; |
213 | 215 | ||
214 | if (!btrfs_test_opt(root->fs_info, INODE_MAP_CACHE)) | 216 | if (!btrfs_test_opt(fs_info, INODE_MAP_CACHE)) |
215 | return; | 217 | return; |
216 | again: | 218 | again: |
217 | if (root->ino_cache_state == BTRFS_CACHE_FINISHED) { | 219 | if (root->ino_cache_state == BTRFS_CACHE_FINISHED) { |
218 | __btrfs_add_free_space(pinned, objectid, 1); | 220 | __btrfs_add_free_space(fs_info, pinned, objectid, 1); |
219 | } else { | 221 | } else { |
220 | down_write(&root->fs_info->commit_root_sem); | 222 | down_write(&fs_info->commit_root_sem); |
221 | spin_lock(&root->ino_cache_lock); | 223 | spin_lock(&root->ino_cache_lock); |
222 | if (root->ino_cache_state == BTRFS_CACHE_FINISHED) { | 224 | if (root->ino_cache_state == BTRFS_CACHE_FINISHED) { |
223 | spin_unlock(&root->ino_cache_lock); | 225 | spin_unlock(&root->ino_cache_lock); |
224 | up_write(&root->fs_info->commit_root_sem); | 226 | up_write(&fs_info->commit_root_sem); |
225 | goto again; | 227 | goto again; |
226 | } | 228 | } |
227 | spin_unlock(&root->ino_cache_lock); | 229 | spin_unlock(&root->ino_cache_lock); |
228 | 230 | ||
229 | start_caching(root); | 231 | start_caching(root); |
230 | 232 | ||
231 | __btrfs_add_free_space(pinned, objectid, 1); | 233 | __btrfs_add_free_space(fs_info, pinned, objectid, 1); |
232 | 234 | ||
233 | up_write(&root->fs_info->commit_root_sem); | 235 | up_write(&fs_info->commit_root_sem); |
234 | } | 236 | } |
235 | } | 237 | } |
236 | 238 | ||
@@ -277,7 +279,8 @@ void btrfs_unpin_free_ino(struct btrfs_root *root) | |||
277 | rb_erase(&info->offset_index, rbroot); | 279 | rb_erase(&info->offset_index, rbroot); |
278 | spin_unlock(rbroot_lock); | 280 | spin_unlock(rbroot_lock); |
279 | if (add_to_ctl) | 281 | if (add_to_ctl) |
280 | __btrfs_add_free_space(ctl, info->offset, count); | 282 | __btrfs_add_free_space(root->fs_info, ctl, |
283 | info->offset, count); | ||
281 | kmem_cache_free(btrfs_free_space_cachep, info); | 284 | kmem_cache_free(btrfs_free_space_cachep, info); |
282 | } | 285 | } |
283 | } | 286 | } |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9323e1c25ee1..50ba4ca167e7 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -2321,7 +2321,7 @@ static noinline int record_one_backref(u64 inum, u64 offset, u64 root_id, | |||
2321 | if (PTR_ERR(root) == -ENOENT) | 2321 | if (PTR_ERR(root) == -ENOENT) |
2322 | return 0; | 2322 | return 0; |
2323 | WARN_ON(1); | 2323 | WARN_ON(1); |
2324 | pr_debug("inum=%llu, offset=%llu, root_id=%llu\n", | 2324 | btrfs_debug(fs_info, "inum=%llu, offset=%llu, root_id=%llu", |
2325 | inum, offset, root_id); | 2325 | inum, offset, root_id); |
2326 | return PTR_ERR(root); | 2326 | return PTR_ERR(root); |
2327 | } | 2327 | } |
@@ -7878,18 +7878,19 @@ static int btrfs_check_dio_repairable(struct inode *inode, | |||
7878 | struct io_failure_record *failrec, | 7878 | struct io_failure_record *failrec, |
7879 | int failed_mirror) | 7879 | int failed_mirror) |
7880 | { | 7880 | { |
7881 | struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); | ||
7881 | int num_copies; | 7882 | int num_copies; |
7882 | 7883 | ||
7883 | num_copies = btrfs_num_copies(BTRFS_I(inode)->root->fs_info, | 7884 | num_copies = btrfs_num_copies(fs_info, failrec->logical, failrec->len); |
7884 | failrec->logical, failrec->len); | ||
7885 | if (num_copies == 1) { | 7885 | if (num_copies == 1) { |
7886 | /* | 7886 | /* |
7887 | * we only have a single copy of the data, so don't bother with | 7887 | * we only have a single copy of the data, so don't bother with |
7888 | * all the retry and error correction code that follows. no | 7888 | * all the retry and error correction code that follows. no |
7889 | * matter what the error is, it is very likely to persist. | 7889 | * matter what the error is, it is very likely to persist. |
7890 | */ | 7890 | */ |
7891 | pr_debug("Check DIO Repairable: cannot repair, num_copies=%d, next_mirror %d, failed_mirror %d\n", | 7891 | btrfs_debug(fs_info, |
7892 | num_copies, failrec->this_mirror, failed_mirror); | 7892 | "Check DIO Repairable: cannot repair, num_copies=%d, next_mirror %d, failed_mirror %d", |
7893 | num_copies, failrec->this_mirror, failed_mirror); | ||
7893 | return 0; | 7894 | return 0; |
7894 | } | 7895 | } |
7895 | 7896 | ||
@@ -7899,8 +7900,9 @@ static int btrfs_check_dio_repairable(struct inode *inode, | |||
7899 | failrec->this_mirror++; | 7900 | failrec->this_mirror++; |
7900 | 7901 | ||
7901 | if (failrec->this_mirror > num_copies) { | 7902 | if (failrec->this_mirror > num_copies) { |
7902 | pr_debug("Check DIO Repairable: (fail) num_copies=%d, next_mirror %d, failed_mirror %d\n", | 7903 | btrfs_debug(fs_info, |
7903 | num_copies, failrec->this_mirror, failed_mirror); | 7904 | "Check DIO Repairable: (fail) num_copies=%d, next_mirror %d, failed_mirror %d", |
7905 | num_copies, failrec->this_mirror, failed_mirror); | ||
7904 | return 0; | 7906 | return 0; |
7905 | } | 7907 | } |
7906 | 7908 | ||
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index 0f9df5a68c54..11f4fffe503e 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c | |||
@@ -2257,10 +2257,11 @@ qgroup_rescan_leaf(struct btrfs_fs_info *fs_info, struct btrfs_path *path, | |||
2257 | &fs_info->qgroup_rescan_progress, | 2257 | &fs_info->qgroup_rescan_progress, |
2258 | path, 1, 0); | 2258 | path, 1, 0); |
2259 | 2259 | ||
2260 | pr_debug("current progress key (%llu %u %llu), search_slot ret %d\n", | 2260 | btrfs_debug(fs_info, |
2261 | fs_info->qgroup_rescan_progress.objectid, | 2261 | "current progress key (%llu %u %llu), search_slot ret %d", |
2262 | fs_info->qgroup_rescan_progress.type, | 2262 | fs_info->qgroup_rescan_progress.objectid, |
2263 | fs_info->qgroup_rescan_progress.offset, ret); | 2263 | fs_info->qgroup_rescan_progress.type, |
2264 | fs_info->qgroup_rescan_progress.offset, ret); | ||
2264 | 2265 | ||
2265 | if (ret) { | 2266 | if (ret) { |
2266 | /* | 2267 | /* |
@@ -2390,7 +2391,7 @@ out: | |||
2390 | ret = update_qgroup_status_item(trans, fs_info, fs_info->quota_root); | 2391 | ret = update_qgroup_status_item(trans, fs_info, fs_info->quota_root); |
2391 | if (ret < 0) { | 2392 | if (ret < 0) { |
2392 | err = ret; | 2393 | err = ret; |
2393 | btrfs_err(fs_info, "fail to update qgroup status: %d\n", err); | 2394 | btrfs_err(fs_info, "fail to update qgroup status: %d", err); |
2394 | } | 2395 | } |
2395 | btrfs_end_transaction(trans, fs_info->quota_root); | 2396 | btrfs_end_transaction(trans, fs_info->quota_root); |
2396 | 2397 | ||
diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c index 9e85300051cc..75bab76739be 100644 --- a/fs/btrfs/reada.c +++ b/fs/btrfs/reada.c | |||
@@ -820,7 +820,7 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) | |||
820 | 820 | ||
821 | spin_lock(&fs_info->reada_lock); | 821 | spin_lock(&fs_info->reada_lock); |
822 | list_for_each_entry(device, &fs_devices->devices, dev_list) { | 822 | list_for_each_entry(device, &fs_devices->devices, dev_list) { |
823 | pr_debug("dev %lld has %d in flight\n", device->devid, | 823 | btrfs_debug(fs_info, "dev %lld has %d in flight", device->devid, |
824 | atomic_read(&device->reada_in_flight)); | 824 | atomic_read(&device->reada_in_flight)); |
825 | index = 0; | 825 | index = 0; |
826 | while (1) { | 826 | while (1) { |
@@ -830,8 +830,8 @@ static void dump_devs(struct btrfs_fs_info *fs_info, int all) | |||
830 | if (ret == 0) | 830 | if (ret == 0) |
831 | break; | 831 | break; |
832 | pr_debug(" zone %llu-%llu elems %llu locked %d devs", | 832 | pr_debug(" zone %llu-%llu elems %llu locked %d devs", |
833 | zone->start, zone->end, zone->elems, | 833 | zone->start, zone->end, zone->elems, |
834 | zone->locked); | 834 | zone->locked); |
835 | for (j = 0; j < zone->ndevs; ++j) { | 835 | for (j = 0; j < zone->ndevs; ++j) { |
836 | pr_cont(" %lld", | 836 | pr_cont(" %lld", |
837 | zone->devs[j]->devid); | 837 | zone->devs[j]->devid); |
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 0128bc369292..74ed5aae6cea 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -1148,7 +1148,7 @@ static int btrfs_fill_super(struct super_block *sb, | |||
1148 | sb->s_iflags |= SB_I_CGROUPWB; | 1148 | sb->s_iflags |= SB_I_CGROUPWB; |
1149 | err = open_ctree(sb, fs_devices, (char *)data); | 1149 | err = open_ctree(sb, fs_devices, (char *)data); |
1150 | if (err) { | 1150 | if (err) { |
1151 | pr_err("BTRFS: open_ctree failed\n"); | 1151 | btrfs_err(fs_info, "open_ctree failed"); |
1152 | return err; | 1152 | return err; |
1153 | } | 1153 | } |
1154 | 1154 | ||
@@ -1446,12 +1446,13 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid, | |||
1446 | 1446 | ||
1447 | if (!IS_ERR(root)) { | 1447 | if (!IS_ERR(root)) { |
1448 | struct super_block *s = root->d_sb; | 1448 | struct super_block *s = root->d_sb; |
1449 | struct btrfs_fs_info *fs_info = btrfs_sb(s); | ||
1449 | struct inode *root_inode = d_inode(root); | 1450 | struct inode *root_inode = d_inode(root); |
1450 | u64 root_objectid = BTRFS_I(root_inode)->root->root_key.objectid; | 1451 | u64 root_objectid = BTRFS_I(root_inode)->root->root_key.objectid; |
1451 | 1452 | ||
1452 | ret = 0; | 1453 | ret = 0; |
1453 | if (!is_subvolume_inode(root_inode)) { | 1454 | if (!is_subvolume_inode(root_inode)) { |
1454 | pr_err("BTRFS: '%s' is not a valid subvolume\n", | 1455 | btrfs_err(fs_info, "'%s' is not a valid subvolume", |
1455 | subvol_name); | 1456 | subvol_name); |
1456 | ret = -EINVAL; | 1457 | ret = -EINVAL; |
1457 | } | 1458 | } |
@@ -1461,8 +1462,9 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid, | |||
1461 | * subvolume which was passed by ID is renamed and | 1462 | * subvolume which was passed by ID is renamed and |
1462 | * another subvolume is renamed over the old location. | 1463 | * another subvolume is renamed over the old location. |
1463 | */ | 1464 | */ |
1464 | pr_err("BTRFS: subvol '%s' does not match subvolid %llu\n", | 1465 | btrfs_err(fs_info, |
1465 | subvol_name, subvol_objectid); | 1466 | "subvol '%s' does not match subvolid %llu", |
1467 | subvol_name, subvol_objectid); | ||
1466 | ret = -EINVAL; | 1468 | ret = -EINVAL; |
1467 | } | 1469 | } |
1468 | if (ret) { | 1470 | if (ret) { |
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c index 69f7d4ccaf35..e66a18ed4588 100644 --- a/fs/btrfs/transaction.c +++ b/fs/btrfs/transaction.c | |||
@@ -65,8 +65,9 @@ void btrfs_put_transaction(struct btrfs_transaction *transaction) | |||
65 | BUG_ON(!list_empty(&transaction->list)); | 65 | BUG_ON(!list_empty(&transaction->list)); |
66 | WARN_ON(!RB_EMPTY_ROOT(&transaction->delayed_refs.href_root)); | 66 | WARN_ON(!RB_EMPTY_ROOT(&transaction->delayed_refs.href_root)); |
67 | if (transaction->delayed_refs.pending_csums) | 67 | if (transaction->delayed_refs.pending_csums) |
68 | pr_err("pending csums is %llu\n", | 68 | btrfs_err(transaction->fs_info, |
69 | transaction->delayed_refs.pending_csums); | 69 | "pending csums is %llu", |
70 | transaction->delayed_refs.pending_csums); | ||
70 | while (!list_empty(&transaction->pending_chunks)) { | 71 | while (!list_empty(&transaction->pending_chunks)) { |
71 | struct extent_map *em; | 72 | struct extent_map *em; |
72 | 73 | ||
@@ -245,6 +246,7 @@ loop: | |||
245 | return -EROFS; | 246 | return -EROFS; |
246 | } | 247 | } |
247 | 248 | ||
249 | cur_trans->fs_info = fs_info; | ||
248 | atomic_set(&cur_trans->num_writers, 1); | 250 | atomic_set(&cur_trans->num_writers, 1); |
249 | extwriter_counter_init(cur_trans, type); | 251 | extwriter_counter_init(cur_trans, type); |
250 | init_waitqueue_head(&cur_trans->writer_wait); | 252 | init_waitqueue_head(&cur_trans->writer_wait); |
@@ -1294,11 +1296,11 @@ int btrfs_defrag_root(struct btrfs_root *root) | |||
1294 | btrfs_btree_balance_dirty(info->tree_root); | 1296 | btrfs_btree_balance_dirty(info->tree_root); |
1295 | cond_resched(); | 1297 | cond_resched(); |
1296 | 1298 | ||
1297 | if (btrfs_fs_closing(root->fs_info) || ret != -EAGAIN) | 1299 | if (btrfs_fs_closing(info) || ret != -EAGAIN) |
1298 | break; | 1300 | break; |
1299 | 1301 | ||
1300 | if (btrfs_defrag_cancelled(root->fs_info)) { | 1302 | if (btrfs_defrag_cancelled(info)) { |
1301 | pr_debug("BTRFS: defrag_root cancelled\n"); | 1303 | btrfs_debug(info, "defrag_root cancelled"); |
1302 | ret = -EAGAIN; | 1304 | ret = -EAGAIN; |
1303 | break; | 1305 | break; |
1304 | } | 1306 | } |
@@ -2321,7 +2323,7 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root) | |||
2321 | list_del_init(&root->root_list); | 2323 | list_del_init(&root->root_list); |
2322 | spin_unlock(&fs_info->trans_lock); | 2324 | spin_unlock(&fs_info->trans_lock); |
2323 | 2325 | ||
2324 | pr_debug("BTRFS: cleaner removing %llu\n", root->objectid); | 2326 | btrfs_debug(fs_info, "cleaner removing %llu", root->objectid); |
2325 | 2327 | ||
2326 | btrfs_kill_all_delayed_nodes(root); | 2328 | btrfs_kill_all_delayed_nodes(root); |
2327 | 2329 | ||
diff --git a/fs/btrfs/transaction.h b/fs/btrfs/transaction.h index efb122643380..6cf0d37d4f76 100644 --- a/fs/btrfs/transaction.h +++ b/fs/btrfs/transaction.h | |||
@@ -82,6 +82,7 @@ struct btrfs_transaction { | |||
82 | spinlock_t dropped_roots_lock; | 82 | spinlock_t dropped_roots_lock; |
83 | struct btrfs_delayed_ref_root delayed_refs; | 83 | struct btrfs_delayed_ref_root delayed_refs; |
84 | int aborted; | 84 | int aborted; |
85 | struct btrfs_fs_info *fs_info; | ||
85 | }; | 86 | }; |
86 | 87 | ||
87 | #define __TRANS_FREEZABLE (1U << 0) | 88 | #define __TRANS_FREEZABLE (1U << 0) |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index eeb6733eb9f5..6500f9e23330 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -5888,10 +5888,11 @@ int btrfs_map_sblock(struct btrfs_fs_info *fs_info, int op, | |||
5888 | mirror_num, need_raid_map); | 5888 | mirror_num, need_raid_map); |
5889 | } | 5889 | } |
5890 | 5890 | ||
5891 | int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree, | 5891 | int btrfs_rmap_block(struct btrfs_fs_info *fs_info, |
5892 | u64 chunk_start, u64 physical, u64 devid, | 5892 | u64 chunk_start, u64 physical, u64 devid, |
5893 | u64 **logical, int *naddrs, int *stripe_len) | 5893 | u64 **logical, int *naddrs, int *stripe_len) |
5894 | { | 5894 | { |
5895 | struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; | ||
5895 | struct extent_map_tree *em_tree = &map_tree->map_tree; | 5896 | struct extent_map_tree *em_tree = &map_tree->map_tree; |
5896 | struct extent_map *em; | 5897 | struct extent_map *em; |
5897 | struct map_lookup *map; | 5898 | struct map_lookup *map; |
@@ -5907,13 +5908,13 @@ int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree, | |||
5907 | read_unlock(&em_tree->lock); | 5908 | read_unlock(&em_tree->lock); |
5908 | 5909 | ||
5909 | if (!em) { | 5910 | if (!em) { |
5910 | pr_err("BTRFS: couldn't find em for chunk %Lu\n", | 5911 | btrfs_err(fs_info, "couldn't find em for chunk %Lu", |
5911 | chunk_start); | 5912 | chunk_start); |
5912 | return -EIO; | 5913 | return -EIO; |
5913 | } | 5914 | } |
5914 | 5915 | ||
5915 | if (em->start != chunk_start) { | 5916 | if (em->start != chunk_start) { |
5916 | pr_err("BTRFS: bad chunk start, em=%Lu, wanted=%Lu\n", | 5917 | btrfs_err(fs_info, "bad chunk start, em=%Lu, wanted=%Lu", |
5917 | em->start, chunk_start); | 5918 | em->start, chunk_start); |
5918 | free_extent_map(em); | 5919 | free_extent_map(em); |
5919 | return -EIO; | 5920 | return -EIO; |
@@ -6118,10 +6119,12 @@ static void submit_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio, | |||
6118 | 6119 | ||
6119 | rcu_read_lock(); | 6120 | rcu_read_lock(); |
6120 | name = rcu_dereference(dev->name); | 6121 | name = rcu_dereference(dev->name); |
6121 | pr_debug("btrfs_map_bio: rw %d 0x%x, sector=%llu, dev=%lu (%s id %llu), size=%u\n", | 6122 | btrfs_debug(fs_info, |
6122 | bio_op(bio), bio->bi_opf, (u64)bio->bi_iter.bi_sector, | 6123 | "btrfs_map_bio: rw %d 0x%x, sector=%llu, dev=%lu (%s id %llu), size=%u", |
6123 | (u_long)dev->bdev->bd_dev, name->str, dev->devid, | 6124 | bio_op(bio), bio->bi_opf, |
6124 | bio->bi_iter.bi_size); | 6125 | (u64)bio->bi_iter.bi_sector, |
6126 | (u_long)dev->bdev->bd_dev, name->str, dev->devid, | ||
6127 | bio->bi_iter.bi_size); | ||
6125 | rcu_read_unlock(); | 6128 | rcu_read_unlock(); |
6126 | } | 6129 | } |
6127 | #endif | 6130 | #endif |
@@ -6644,7 +6647,8 @@ static int read_one_dev(struct btrfs_root *root, | |||
6644 | 6647 | ||
6645 | int btrfs_read_sys_array(struct btrfs_root *root) | 6648 | int btrfs_read_sys_array(struct btrfs_root *root) |
6646 | { | 6649 | { |
6647 | struct btrfs_super_block *super_copy = root->fs_info->super_copy; | 6650 | struct btrfs_fs_info *fs_info = root->fs_info; |
6651 | struct btrfs_super_block *super_copy = fs_info->super_copy; | ||
6648 | struct extent_buffer *sb; | 6652 | struct extent_buffer *sb; |
6649 | struct btrfs_disk_key *disk_key; | 6653 | struct btrfs_disk_key *disk_key; |
6650 | struct btrfs_chunk *chunk; | 6654 | struct btrfs_chunk *chunk; |
@@ -6715,7 +6719,8 @@ int btrfs_read_sys_array(struct btrfs_root *root) | |||
6715 | 6719 | ||
6716 | num_stripes = btrfs_chunk_num_stripes(sb, chunk); | 6720 | num_stripes = btrfs_chunk_num_stripes(sb, chunk); |
6717 | if (!num_stripes) { | 6721 | if (!num_stripes) { |
6718 | pr_err("BTRFS: invalid number of stripes %u in sys_array at offset %u\n", | 6722 | btrfs_err(fs_info, |
6723 | "invalid number of stripes %u in sys_array at offset %u", | ||
6719 | num_stripes, cur_offset); | 6724 | num_stripes, cur_offset); |
6720 | ret = -EIO; | 6725 | ret = -EIO; |
6721 | break; | 6726 | break; |
@@ -6723,7 +6728,7 @@ int btrfs_read_sys_array(struct btrfs_root *root) | |||
6723 | 6728 | ||
6724 | type = btrfs_chunk_type(sb, chunk); | 6729 | type = btrfs_chunk_type(sb, chunk); |
6725 | if ((type & BTRFS_BLOCK_GROUP_SYSTEM) == 0) { | 6730 | if ((type & BTRFS_BLOCK_GROUP_SYSTEM) == 0) { |
6726 | btrfs_err(root->fs_info, | 6731 | btrfs_err(fs_info, |
6727 | "invalid chunk type %llu in sys_array at offset %u", | 6732 | "invalid chunk type %llu in sys_array at offset %u", |
6728 | type, cur_offset); | 6733 | type, cur_offset); |
6729 | ret = -EIO; | 6734 | ret = -EIO; |
@@ -6738,8 +6743,9 @@ int btrfs_read_sys_array(struct btrfs_root *root) | |||
6738 | if (ret) | 6743 | if (ret) |
6739 | break; | 6744 | break; |
6740 | } else { | 6745 | } else { |
6741 | pr_err("BTRFS: unexpected item type %u in sys_array at offset %u\n", | 6746 | btrfs_err(fs_info, |
6742 | (u32)key.type, cur_offset); | 6747 | "unexpected item type %u in sys_array at offset %u", |
6748 | (u32)key.type, cur_offset); | ||
6743 | ret = -EIO; | 6749 | ret = -EIO; |
6744 | break; | 6750 | break; |
6745 | } | 6751 | } |
@@ -6752,7 +6758,7 @@ int btrfs_read_sys_array(struct btrfs_root *root) | |||
6752 | return ret; | 6758 | return ret; |
6753 | 6759 | ||
6754 | out_short_read: | 6760 | out_short_read: |
6755 | pr_err("BTRFS: sys_array too short to read %u bytes at offset %u\n", | 6761 | btrfs_err(fs_info, "sys_array too short to read %u bytes at offset %u", |
6756 | len, cur_offset); | 6762 | len, cur_offset); |
6757 | clear_extent_buffer_uptodate(sb); | 6763 | clear_extent_buffer_uptodate(sb); |
6758 | free_extent_buffer_stale(sb); | 6764 | free_extent_buffer_stale(sb); |
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 6613e6335ca2..09ed29c67848 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h | |||
@@ -382,7 +382,7 @@ int btrfs_map_sblock(struct btrfs_fs_info *fs_info, int op, | |||
382 | u64 logical, u64 *length, | 382 | u64 logical, u64 *length, |
383 | struct btrfs_bio **bbio_ret, int mirror_num, | 383 | struct btrfs_bio **bbio_ret, int mirror_num, |
384 | int need_raid_map); | 384 | int need_raid_map); |
385 | int btrfs_rmap_block(struct btrfs_mapping_tree *map_tree, | 385 | int btrfs_rmap_block(struct btrfs_fs_info *fs_info, |
386 | u64 chunk_start, u64 physical, u64 devid, | 386 | u64 chunk_start, u64 physical, u64 devid, |
387 | u64 **logical, int *naddrs, int *stripe_len); | 387 | u64 **logical, int *naddrs, int *stripe_len); |
388 | int btrfs_read_sys_array(struct btrfs_root *root); | 388 | int btrfs_read_sys_array(struct btrfs_root *root); |