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

Pull btrfs fix from David Sterba:
"One regression fix to TRIM ioctl.

The range cannot be used as its meaning can be confusing regarding
physical and logical addresses. This confusion in code led to
potential corruptions when the range overlapped data.

The original patch made it to several stable kernels and was promptly
reverted, the version for master branch is different due to additional
changes but the change is effectively the same"

* tag 'for-5.2-rc4-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
btrfs: Always trim all unallocated space in btrfs_trim_free_extents

+3 -25
+3 -25
fs/btrfs/extent-tree.c
··· 11137 11137 * it while performing the free space search since we have already 11138 11138 * held back allocations. 11139 11139 */ 11140 - static int btrfs_trim_free_extents(struct btrfs_device *device, 11141 - struct fstrim_range *range, u64 *trimmed) 11140 + static int btrfs_trim_free_extents(struct btrfs_device *device, u64 *trimmed) 11142 11141 { 11143 - u64 start, len = 0, end = 0; 11142 + u64 start = SZ_1M, len = 0, end = 0; 11144 11143 int ret; 11145 11144 11146 - start = max_t(u64, range->start, SZ_1M); 11147 11145 *trimmed = 0; 11148 11146 11149 11147 /* Discard not supported = nothing to do. */ ··· 11184 11186 break; 11185 11187 } 11186 11188 11187 - /* Keep going until we satisfy minlen or reach end of space */ 11188 - if (len < range->minlen) { 11189 - mutex_unlock(&fs_info->chunk_mutex); 11190 - start += len; 11191 - continue; 11192 - } 11193 - 11194 - /* If we are out of the passed range break */ 11195 - if (start > range->start + range->len - 1) { 11196 - mutex_unlock(&fs_info->chunk_mutex); 11197 - break; 11198 - } 11199 - 11200 - start = max(range->start, start); 11201 - len = min(range->len, len); 11202 - 11203 11189 ret = btrfs_issue_discard(device->bdev, start, len, 11204 11190 &bytes); 11205 11191 if (!ret) ··· 11197 11215 11198 11216 start += len; 11199 11217 *trimmed += bytes; 11200 - 11201 - /* We've trimmed enough */ 11202 - if (*trimmed >= range->len) 11203 - break; 11204 11218 11205 11219 if (fatal_signal_pending(current)) { 11206 11220 ret = -ERESTARTSYS; ··· 11281 11303 mutex_lock(&fs_info->fs_devices->device_list_mutex); 11282 11304 devices = &fs_info->fs_devices->devices; 11283 11305 list_for_each_entry(device, devices, dev_list) { 11284 - ret = btrfs_trim_free_extents(device, range, &group_trimmed); 11306 + ret = btrfs_trim_free_extents(device, &group_trimmed); 11285 11307 if (ret) { 11286 11308 dev_failed++; 11287 11309 dev_ret = ret;