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 tag 'for-5.15-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux

Pull btrfs fixes from David Sterba:

- fix max_inline mount option limit on 64k page system

- lockdep fixes:
- update bdev time in a safer way
- move bdev put outside of sb write section when removing device
- fix possible deadlock when mounting seed/sprout filesystem

- zoned mode: fix split extent accounting

- minor include fixup

* tag 'for-5.15-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
btrfs: zoned: fix double counting of split ordered extent
btrfs: fix lockdep warning while mounting sprout fs
btrfs: delay blkdev_put until after the device remove
btrfs: update the bdev time directly when closing
btrfs: use correct header for div_u64 in misc.h
btrfs: fix upper limit for max_inline for page size 64K

+77 -47
+24 -24
fs/btrfs/disk-io.c
··· 3314 3314 */ 3315 3315 fs_info->compress_type = BTRFS_COMPRESS_ZLIB; 3316 3316 3317 + /* 3318 + * Flag our filesystem as having big metadata blocks if they are bigger 3319 + * than the page size. 3320 + */ 3321 + if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) { 3322 + if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA)) 3323 + btrfs_info(fs_info, 3324 + "flagging fs with big metadata feature"); 3325 + features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA; 3326 + } 3327 + 3328 + /* Set up fs_info before parsing mount options */ 3329 + nodesize = btrfs_super_nodesize(disk_super); 3330 + sectorsize = btrfs_super_sectorsize(disk_super); 3331 + stripesize = sectorsize; 3332 + fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids)); 3333 + fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids)); 3334 + 3335 + fs_info->nodesize = nodesize; 3336 + fs_info->sectorsize = sectorsize; 3337 + fs_info->sectorsize_bits = ilog2(sectorsize); 3338 + fs_info->csums_per_leaf = BTRFS_MAX_ITEM_SIZE(fs_info) / fs_info->csum_size; 3339 + fs_info->stripesize = stripesize; 3340 + 3317 3341 ret = btrfs_parse_options(fs_info, options, sb->s_flags); 3318 3342 if (ret) { 3319 3343 err = ret; ··· 3363 3339 3364 3340 if (features & BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA) 3365 3341 btrfs_info(fs_info, "has skinny extents"); 3366 - 3367 - /* 3368 - * flag our filesystem as having big metadata blocks if 3369 - * they are bigger than the page size 3370 - */ 3371 - if (btrfs_super_nodesize(disk_super) > PAGE_SIZE) { 3372 - if (!(features & BTRFS_FEATURE_INCOMPAT_BIG_METADATA)) 3373 - btrfs_info(fs_info, 3374 - "flagging fs with big metadata feature"); 3375 - features |= BTRFS_FEATURE_INCOMPAT_BIG_METADATA; 3376 - } 3377 - 3378 - nodesize = btrfs_super_nodesize(disk_super); 3379 - sectorsize = btrfs_super_sectorsize(disk_super); 3380 - stripesize = sectorsize; 3381 - fs_info->dirty_metadata_batch = nodesize * (1 + ilog2(nr_cpu_ids)); 3382 - fs_info->delalloc_batch = sectorsize * 512 * (1 + ilog2(nr_cpu_ids)); 3383 - 3384 - /* Cache block sizes */ 3385 - fs_info->nodesize = nodesize; 3386 - fs_info->sectorsize = sectorsize; 3387 - fs_info->sectorsize_bits = ilog2(sectorsize); 3388 - fs_info->csums_per_leaf = BTRFS_MAX_ITEM_SIZE(fs_info) / fs_info->csum_size; 3389 - fs_info->stripesize = stripesize; 3390 3342 3391 3343 /* 3392 3344 * mixed block groups end up with duplicate but slightly offset
+11 -4
fs/btrfs/ioctl.c
··· 3223 3223 struct inode *inode = file_inode(file); 3224 3224 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 3225 3225 struct btrfs_ioctl_vol_args_v2 *vol_args; 3226 + struct block_device *bdev = NULL; 3227 + fmode_t mode; 3226 3228 int ret; 3227 3229 bool cancel = false; 3228 3230 ··· 3257 3255 /* Exclusive operation is now claimed */ 3258 3256 3259 3257 if (vol_args->flags & BTRFS_DEVICE_SPEC_BY_ID) 3260 - ret = btrfs_rm_device(fs_info, NULL, vol_args->devid); 3258 + ret = btrfs_rm_device(fs_info, NULL, vol_args->devid, &bdev, &mode); 3261 3259 else 3262 - ret = btrfs_rm_device(fs_info, vol_args->name, 0); 3260 + ret = btrfs_rm_device(fs_info, vol_args->name, 0, &bdev, &mode); 3263 3261 3264 3262 btrfs_exclop_finish(fs_info); 3265 3263 ··· 3275 3273 kfree(vol_args); 3276 3274 err_drop: 3277 3275 mnt_drop_write_file(file); 3276 + if (bdev) 3277 + blkdev_put(bdev, mode); 3278 3278 return ret; 3279 3279 } 3280 3280 ··· 3285 3281 struct inode *inode = file_inode(file); 3286 3282 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); 3287 3283 struct btrfs_ioctl_vol_args *vol_args; 3284 + struct block_device *bdev = NULL; 3285 + fmode_t mode; 3288 3286 int ret; 3289 3287 bool cancel; 3290 3288 ··· 3308 3302 ret = exclop_start_or_cancel_reloc(fs_info, BTRFS_EXCLOP_DEV_REMOVE, 3309 3303 cancel); 3310 3304 if (ret == 0) { 3311 - ret = btrfs_rm_device(fs_info, vol_args->name, 0); 3305 + ret = btrfs_rm_device(fs_info, vol_args->name, 0, &bdev, &mode); 3312 3306 if (!ret) 3313 3307 btrfs_info(fs_info, "disk deleted %s", vol_args->name); 3314 3308 btrfs_exclop_finish(fs_info); ··· 3317 3311 kfree(vol_args); 3318 3312 out_drop_write: 3319 3313 mnt_drop_write_file(file); 3320 - 3314 + if (bdev) 3315 + blkdev_put(bdev, mode); 3321 3316 return ret; 3322 3317 } 3323 3318
+1 -1
fs/btrfs/misc.h
··· 5 5 6 6 #include <linux/sched.h> 7 7 #include <linux/wait.h> 8 - #include <asm/div64.h> 8 + #include <linux/math64.h> 9 9 #include <linux/rbtree.h> 10 10 11 11 #define in_range(b, first, len) ((b) >= (first) && (b) < (first) + (len))
+8
fs/btrfs/ordered-data.c
··· 1049 1049 u64 len) 1050 1050 { 1051 1051 struct inode *inode = ordered->inode; 1052 + struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info; 1052 1053 u64 file_offset = ordered->file_offset + pos; 1053 1054 u64 disk_bytenr = ordered->disk_bytenr + pos; 1054 1055 u64 num_bytes = len; ··· 1067 1066 else 1068 1067 type = __ffs(flags_masked); 1069 1068 1069 + /* 1070 + * The splitting extent is already counted and will be added again 1071 + * in btrfs_add_ordered_extent_*(). Subtract num_bytes to avoid 1072 + * double counting. 1073 + */ 1074 + percpu_counter_add_batch(&fs_info->ordered_bytes, -num_bytes, 1075 + fs_info->delalloc_batch); 1070 1076 if (test_bit(BTRFS_ORDERED_COMPRESSED, &ordered->flags)) { 1071 1077 WARN_ON_ONCE(1); 1072 1078 ret = btrfs_add_ordered_extent_compress(BTRFS_I(inode),
+31 -17
fs/btrfs/volumes.c
··· 558 558 struct btrfs_device *device, *tmp_device; 559 559 int ret = 0; 560 560 561 + lockdep_assert_held(&uuid_mutex); 562 + 561 563 if (path) 562 564 ret = -ENOENT; 563 565 ··· 990 988 struct btrfs_device *orig_dev; 991 989 int ret = 0; 992 990 991 + lockdep_assert_held(&uuid_mutex); 992 + 993 993 fs_devices = alloc_fs_devices(orig->fsid, NULL); 994 994 if (IS_ERR(fs_devices)) 995 995 return fs_devices; 996 996 997 - mutex_lock(&orig->device_list_mutex); 998 997 fs_devices->total_devices = orig->total_devices; 999 998 1000 999 list_for_each_entry(orig_dev, &orig->devices, dev_list) { ··· 1027 1024 device->fs_devices = fs_devices; 1028 1025 fs_devices->num_devices++; 1029 1026 } 1030 - mutex_unlock(&orig->device_list_mutex); 1031 1027 return fs_devices; 1032 1028 error: 1033 - mutex_unlock(&orig->device_list_mutex); 1034 1029 free_fs_devices(fs_devices); 1035 1030 return ERR_PTR(ret); 1036 1031 } ··· 1870 1869 * Function to update ctime/mtime for a given device path. 1871 1870 * Mainly used for ctime/mtime based probe like libblkid. 1872 1871 */ 1873 - static void update_dev_time(const char *path_name) 1872 + static void update_dev_time(struct block_device *bdev) 1874 1873 { 1875 - struct file *filp; 1874 + struct inode *inode = bdev->bd_inode; 1875 + struct timespec64 now; 1876 1876 1877 - filp = filp_open(path_name, O_RDWR, 0); 1878 - if (IS_ERR(filp)) 1877 + /* Shouldn't happen but just in case. */ 1878 + if (!inode) 1879 1879 return; 1880 - file_update_time(filp); 1881 - filp_close(filp, NULL); 1880 + 1881 + now = current_time(inode); 1882 + generic_update_time(inode, &now, S_MTIME | S_CTIME); 1882 1883 } 1883 1884 1884 1885 static int btrfs_rm_dev_item(struct btrfs_device *device) ··· 2056 2053 btrfs_kobject_uevent(bdev, KOBJ_CHANGE); 2057 2054 2058 2055 /* Update ctime/mtime for device path for libblkid */ 2059 - update_dev_time(device_path); 2056 + update_dev_time(bdev); 2060 2057 } 2061 2058 2062 2059 int btrfs_rm_device(struct btrfs_fs_info *fs_info, const char *device_path, 2063 - u64 devid) 2060 + u64 devid, struct block_device **bdev, fmode_t *mode) 2064 2061 { 2065 2062 struct btrfs_device *device; 2066 2063 struct btrfs_fs_devices *cur_devices; ··· 2174 2171 mutex_unlock(&fs_devices->device_list_mutex); 2175 2172 2176 2173 /* 2177 - * at this point, the device is zero sized and detached from 2178 - * the devices list. All that's left is to zero out the old 2179 - * supers and free the device. 2174 + * At this point, the device is zero sized and detached from the 2175 + * devices list. All that's left is to zero out the old supers and 2176 + * free the device. 2177 + * 2178 + * We cannot call btrfs_close_bdev() here because we're holding the sb 2179 + * write lock, and blkdev_put() will pull in the ->open_mutex on the 2180 + * block device and it's dependencies. Instead just flush the device 2181 + * and let the caller do the final blkdev_put. 2180 2182 */ 2181 - if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) 2183 + if (test_bit(BTRFS_DEV_STATE_WRITEABLE, &device->dev_state)) { 2182 2184 btrfs_scratch_superblocks(fs_info, device->bdev, 2183 2185 device->name->str); 2186 + if (device->bdev) { 2187 + sync_blockdev(device->bdev); 2188 + invalidate_bdev(device->bdev); 2189 + } 2190 + } 2184 2191 2185 - btrfs_close_bdev(device); 2192 + *bdev = device->bdev; 2193 + *mode = device->mode; 2186 2194 synchronize_rcu(); 2187 2195 btrfs_free_device(device); 2188 2196 ··· 2720 2706 btrfs_forget_devices(device_path); 2721 2707 2722 2708 /* Update ctime/mtime for blkid or udev */ 2723 - update_dev_time(device_path); 2709 + update_dev_time(bdev); 2724 2710 2725 2711 return ret; 2726 2712
+2 -1
fs/btrfs/volumes.h
··· 472 472 const u8 *uuid); 473 473 void btrfs_free_device(struct btrfs_device *device); 474 474 int btrfs_rm_device(struct btrfs_fs_info *fs_info, 475 - const char *device_path, u64 devid); 475 + const char *device_path, u64 devid, 476 + struct block_device **bdev, fmode_t *mode); 476 477 void __exit btrfs_cleanup_fs_uuids(void); 477 478 int btrfs_num_copies(struct btrfs_fs_info *fs_info, u64 logical, u64 len); 478 479 int btrfs_grow_device(struct btrfs_trans_handle *trans,