Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs

Pull btrfs fixes from Chris Mason.

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mason/linux-btrfs:
Btrfs: limit the path size in send to PATH_MAX
Btrfs: correctly set profile flags on seqlock retry
Btrfs: use correct key when repeating search for extent item
Btrfs: fix inode caching vs tree log
Btrfs: fix possible memory leaks in open_ctree()
Btrfs: avoid triggering bug_on() when we fail to start inode caching task
Btrfs: move btrfs_{set,clear}_and_info() to ctree.h
btrfs: replace error code from btrfs_drop_extents
btrfs: Change the hole range to a more accurate value.
btrfs: fix use-after-free in mount_subvol()

+48 -45
+14
fs/btrfs/ctree.h
··· 2058 2058 #define btrfs_raw_test_opt(o, opt) ((o) & BTRFS_MOUNT_##opt) 2059 2059 #define btrfs_test_opt(root, opt) ((root)->fs_info->mount_opt & \ 2060 2060 BTRFS_MOUNT_##opt) 2061 + #define btrfs_set_and_info(root, opt, fmt, args...) \ 2062 + { \ 2063 + if (!btrfs_test_opt(root, opt)) \ 2064 + btrfs_info(root->fs_info, fmt, ##args); \ 2065 + btrfs_set_opt(root->fs_info->mount_opt, opt); \ 2066 + } 2067 + 2068 + #define btrfs_clear_and_info(root, opt, fmt, args...) \ 2069 + { \ 2070 + if (btrfs_test_opt(root, opt)) \ 2071 + btrfs_info(root->fs_info, fmt, ##args); \ 2072 + btrfs_clear_opt(root->fs_info->mount_opt, opt); \ 2073 + } 2074 + 2061 2075 /* 2062 2076 * Inode flags 2063 2077 */
+5 -5
fs/btrfs/disk-io.c
··· 2861 2861 printk(KERN_ERR "BTRFS: failed to read log tree\n"); 2862 2862 free_extent_buffer(log_tree_root->node); 2863 2863 kfree(log_tree_root); 2864 - goto fail_trans_kthread; 2864 + goto fail_qgroup; 2865 2865 } 2866 2866 /* returns with log_tree_root freed on success */ 2867 2867 ret = btrfs_recover_log_trees(log_tree_root); ··· 2870 2870 "Failed to recover log tree"); 2871 2871 free_extent_buffer(log_tree_root->node); 2872 2872 kfree(log_tree_root); 2873 - goto fail_trans_kthread; 2873 + goto fail_qgroup; 2874 2874 } 2875 2875 2876 2876 if (sb->s_flags & MS_RDONLY) { 2877 2877 ret = btrfs_commit_super(tree_root); 2878 2878 if (ret) 2879 - goto fail_trans_kthread; 2879 + goto fail_qgroup; 2880 2880 } 2881 2881 } 2882 2882 2883 2883 ret = btrfs_find_orphan_roots(tree_root); 2884 2884 if (ret) 2885 - goto fail_trans_kthread; 2885 + goto fail_qgroup; 2886 2886 2887 2887 if (!(sb->s_flags & MS_RDONLY)) { 2888 2888 ret = btrfs_cleanup_fs_roots(fs_info); 2889 2889 if (ret) 2890 - goto fail_trans_kthread; 2890 + goto fail_qgroup; 2891 2891 2892 2892 ret = btrfs_recover_relocation(tree_root); 2893 2893 if (ret < 0) {
+5 -1
fs/btrfs/extent-tree.c
··· 1542 1542 ret = 0; 1543 1543 } 1544 1544 if (ret) { 1545 + key.objectid = bytenr; 1545 1546 key.type = BTRFS_EXTENT_ITEM_KEY; 1546 1547 key.offset = num_bytes; 1547 1548 btrfs_release_path(path); ··· 3543 3542 return extended_to_chunk(flags | tmp); 3544 3543 } 3545 3544 3546 - static u64 get_alloc_profile(struct btrfs_root *root, u64 flags) 3545 + static u64 get_alloc_profile(struct btrfs_root *root, u64 orig_flags) 3547 3546 { 3548 3547 unsigned seq; 3548 + u64 flags; 3549 3549 3550 3550 do { 3551 + flags = orig_flags; 3551 3552 seq = read_seqbegin(&root->fs_info->profiles_lock); 3552 3553 3553 3554 if (flags & BTRFS_BLOCK_GROUP_DATA) ··· 5722 5719 5723 5720 if (ret > 0 && skinny_metadata) { 5724 5721 skinny_metadata = false; 5722 + key.objectid = bytenr; 5725 5723 key.type = BTRFS_EXTENT_ITEM_KEY; 5726 5724 key.offset = num_bytes; 5727 5725 btrfs_release_path(path);
+4 -4
fs/btrfs/file.c
··· 800 800 if (start > key.offset && end < extent_end) { 801 801 BUG_ON(del_nr > 0); 802 802 if (extent_type == BTRFS_FILE_EXTENT_INLINE) { 803 - ret = -EINVAL; 803 + ret = -EOPNOTSUPP; 804 804 break; 805 805 } 806 806 ··· 846 846 */ 847 847 if (start <= key.offset && end < extent_end) { 848 848 if (extent_type == BTRFS_FILE_EXTENT_INLINE) { 849 - ret = -EINVAL; 849 + ret = -EOPNOTSUPP; 850 850 break; 851 851 } 852 852 ··· 872 872 if (start > key.offset && end >= extent_end) { 873 873 BUG_ON(del_nr > 0); 874 874 if (extent_type == BTRFS_FILE_EXTENT_INLINE) { 875 - ret = -EINVAL; 875 + ret = -EOPNOTSUPP; 876 876 break; 877 877 } 878 878 ··· 1777 1777 start_pos = round_down(pos, root->sectorsize); 1778 1778 if (start_pos > i_size_read(inode)) { 1779 1779 /* Expand hole size to cover write data, preventing empty gap */ 1780 - end_pos = round_up(pos + iov->iov_len, root->sectorsize); 1780 + end_pos = round_up(pos + count, root->sectorsize); 1781 1781 err = btrfs_cont_expand(inode, i_size_read(inode), end_pos); 1782 1782 if (err) { 1783 1783 mutex_unlock(&inode->i_mutex);
+7 -17
fs/btrfs/inode-map.c
··· 176 176 177 177 tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu\n", 178 178 root->root_key.objectid); 179 - BUG_ON(IS_ERR(tsk)); /* -ENOMEM */ 179 + if (IS_ERR(tsk)) { 180 + btrfs_warn(root->fs_info, "failed to start inode caching task"); 181 + btrfs_clear_and_info(root, CHANGE_INODE_CACHE, 182 + "disabling inode map caching"); 183 + } 180 184 } 181 185 182 186 int btrfs_find_free_ino(struct btrfs_root *root, u64 *objectid) ··· 209 205 210 206 void btrfs_return_ino(struct btrfs_root *root, u64 objectid) 211 207 { 212 - struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; 213 208 struct btrfs_free_space_ctl *pinned = root->free_ino_pinned; 214 209 215 210 if (!btrfs_test_opt(root, INODE_MAP_CACHE)) 216 211 return; 217 - 218 212 again: 219 213 if (root->cached == BTRFS_CACHE_FINISHED) { 220 - __btrfs_add_free_space(ctl, objectid, 1); 214 + __btrfs_add_free_space(pinned, objectid, 1); 221 215 } else { 222 - /* 223 - * If we are in the process of caching free ino chunks, 224 - * to avoid adding the same inode number to the free_ino 225 - * tree twice due to cross transaction, we'll leave it 226 - * in the pinned tree until a transaction is committed 227 - * or the caching work is done. 228 - */ 229 - 230 216 down_write(&root->fs_info->commit_root_sem); 231 217 spin_lock(&root->cache_lock); 232 218 if (root->cached == BTRFS_CACHE_FINISHED) { ··· 228 234 229 235 start_caching(root); 230 236 231 - if (objectid <= root->cache_progress || 232 - objectid >= root->highest_objectid) 233 - __btrfs_add_free_space(ctl, objectid, 1); 234 - else 235 - __btrfs_add_free_space(pinned, objectid, 1); 237 + __btrfs_add_free_space(pinned, objectid, 1); 236 238 237 239 up_write(&root->fs_info->commit_root_sem); 238 240 }
+2 -2
fs/btrfs/ioctl.c
··· 3066 3066 new_key.offset + datal, 3067 3067 1); 3068 3068 if (ret) { 3069 - if (ret != -EINVAL) 3069 + if (ret != -EOPNOTSUPP) 3070 3070 btrfs_abort_transaction(trans, 3071 3071 root, ret); 3072 3072 btrfs_end_transaction(trans, root); ··· 3141 3141 new_key.offset + datal, 3142 3142 1); 3143 3143 if (ret) { 3144 - if (ret != -EINVAL) 3144 + if (ret != -EOPNOTSUPP) 3145 3145 btrfs_abort_transaction(trans, 3146 3146 root, ret); 3147 3147 btrfs_end_transaction(trans, root);
+5
fs/btrfs/send.c
··· 349 349 if (p->buf_len >= len) 350 350 return 0; 351 351 352 + if (len > PATH_MAX) { 353 + WARN_ON(1); 354 + return -ENOMEM; 355 + } 356 + 352 357 path_len = p->end - p->start; 353 358 old_buf_len = p->buf_len; 354 359
+6 -16
fs/btrfs/super.c
··· 385 385 {Opt_err, NULL}, 386 386 }; 387 387 388 - #define btrfs_set_and_info(root, opt, fmt, args...) \ 389 - { \ 390 - if (!btrfs_test_opt(root, opt)) \ 391 - btrfs_info(root->fs_info, fmt, ##args); \ 392 - btrfs_set_opt(root->fs_info->mount_opt, opt); \ 393 - } 394 - 395 - #define btrfs_clear_and_info(root, opt, fmt, args...) \ 396 - { \ 397 - if (btrfs_test_opt(root, opt)) \ 398 - btrfs_info(root->fs_info, fmt, ##args); \ 399 - btrfs_clear_opt(root->fs_info->mount_opt, opt); \ 400 - } 401 - 402 388 /* 403 389 * Regular mount options parser. Everything that is needed only when 404 390 * reading in a new superblock is parsed here. ··· 1172 1186 return ERR_PTR(-ENOMEM); 1173 1187 mnt = vfs_kern_mount(&btrfs_fs_type, flags, device_name, 1174 1188 newargs); 1175 - kfree(newargs); 1176 1189 1177 1190 if (PTR_RET(mnt) == -EBUSY) { 1178 1191 if (flags & MS_RDONLY) { ··· 1181 1196 int r; 1182 1197 mnt = vfs_kern_mount(&btrfs_fs_type, flags | MS_RDONLY, device_name, 1183 1198 newargs); 1184 - if (IS_ERR(mnt)) 1199 + if (IS_ERR(mnt)) { 1200 + kfree(newargs); 1185 1201 return ERR_CAST(mnt); 1202 + } 1186 1203 1187 1204 r = btrfs_remount(mnt->mnt_sb, &flags, NULL); 1188 1205 if (r < 0) { 1189 1206 /* FIXME: release vfsmount mnt ??*/ 1207 + kfree(newargs); 1190 1208 return ERR_PTR(r); 1191 1209 } 1192 1210 } 1193 1211 } 1212 + 1213 + kfree(newargs); 1194 1214 1195 1215 if (IS_ERR(mnt)) 1196 1216 return ERR_CAST(mnt);