Skip to content

Commit e88c4cf

Browse files
committed
Merge tag 'for-6.9-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux
Pull btrfs fixes from David Sterba: - fix information leak by the buffer returned from LOGICAL_INO ioctl - fix flipped condition in scrub when tracking sectors in zoned mode - fix calculation when dropping extent range - reinstate fallback to write uncompressed data in case of fragmented space that could not store the entire compressed chunk - minor fix to message formatting style to make it conforming to the commonly used style * tag 'for-6.9-rc5-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux: btrfs: fix wrong block_start calculation for btrfs_drop_extent_map_range() btrfs: fix information leak in btrfs_ioctl_logical_to_ino() btrfs: fallback if compressed IO fails for ENOSPC btrfs: scrub: run relocation repair when/only needed btrfs: remove colon from messages with state
2 parents 9d1ddab + fe1c6c7 commit e88c4cf

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

fs/btrfs/backref.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,20 +2776,14 @@ struct btrfs_data_container *init_data_container(u32 total_bytes)
27762776
size_t alloc_bytes;
27772777

27782778
alloc_bytes = max_t(size_t, total_bytes, sizeof(*data));
2779-
data = kvmalloc(alloc_bytes, GFP_KERNEL);
2779+
data = kvzalloc(alloc_bytes, GFP_KERNEL);
27802780
if (!data)
27812781
return ERR_PTR(-ENOMEM);
27822782

2783-
if (total_bytes >= sizeof(*data)) {
2783+
if (total_bytes >= sizeof(*data))
27842784
data->bytes_left = total_bytes - sizeof(*data);
2785-
data->bytes_missing = 0;
2786-
} else {
2785+
else
27872786
data->bytes_missing = sizeof(*data) - total_bytes;
2788-
data->bytes_left = 0;
2789-
}
2790-
2791-
data->elem_cnt = 0;
2792-
data->elem_missed = 0;
27932787

27942788
return data;
27952789
}

fs/btrfs/extent_map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end,
817817
split->block_len = em->block_len;
818818
split->orig_start = em->orig_start;
819819
} else {
820-
const u64 diff = start + len - em->start;
820+
const u64 diff = end - em->start;
821821

822822
split->block_len = split->len;
823823
split->block_start += diff;

fs/btrfs/inode.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,13 +1145,13 @@ static void submit_one_async_extent(struct async_chunk *async_chunk,
11451145
0, *alloc_hint, &ins, 1, 1);
11461146
if (ret) {
11471147
/*
1148-
* Here we used to try again by going back to non-compressed
1149-
* path for ENOSPC. But we can't reserve space even for
1150-
* compressed size, how could it work for uncompressed size
1151-
* which requires larger size? So here we directly go error
1152-
* path.
1148+
* We can't reserve contiguous space for the compressed size.
1149+
* Unlikely, but it's possible that we could have enough
1150+
* non-contiguous space for the uncompressed size instead. So
1151+
* fall back to uncompressed.
11531152
*/
1154-
goto out_free;
1153+
submit_uncompressed_range(inode, async_extent, locked_page);
1154+
goto done;
11551155
}
11561156

11571157
/* Here we're doing allocation and writeback of the compressed pages */
@@ -1203,7 +1203,6 @@ static void submit_one_async_extent(struct async_chunk *async_chunk,
12031203
out_free_reserve:
12041204
btrfs_dec_block_group_reservations(fs_info, ins.objectid);
12051205
btrfs_free_reserved_extent(fs_info, ins.objectid, ins.offset, 1);
1206-
out_free:
12071206
mapping_set_error(inode->vfs_inode.i_mapping, -EIO);
12081207
extent_clear_unlock_delalloc(inode, start, end,
12091208
NULL, EXTENT_LOCKED | EXTENT_DELALLOC |

fs/btrfs/messages.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
#ifdef CONFIG_PRINTK
99

10-
#define STATE_STRING_PREFACE ": state "
10+
#define STATE_STRING_PREFACE " state "
1111
#define STATE_STRING_BUF_LEN (sizeof(STATE_STRING_PREFACE) + BTRFS_FS_STATE_COUNT + 1)
1212

1313
/*

fs/btrfs/scrub.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,7 @@ static void scrub_stripe_read_repair_worker(struct work_struct *work)
10121012
struct btrfs_fs_info *fs_info = sctx->fs_info;
10131013
int num_copies = btrfs_num_copies(fs_info, stripe->bg->start,
10141014
stripe->bg->length);
1015+
unsigned long repaired;
10151016
int mirror;
10161017
int i;
10171018

@@ -1078,16 +1079,15 @@ static void scrub_stripe_read_repair_worker(struct work_struct *work)
10781079
* Submit the repaired sectors. For zoned case, we cannot do repair
10791080
* in-place, but queue the bg to be relocated.
10801081
*/
1081-
if (btrfs_is_zoned(fs_info)) {
1082-
if (!bitmap_empty(&stripe->error_bitmap, stripe->nr_sectors))
1082+
bitmap_andnot(&repaired, &stripe->init_error_bitmap, &stripe->error_bitmap,
1083+
stripe->nr_sectors);
1084+
if (!sctx->readonly && !bitmap_empty(&repaired, stripe->nr_sectors)) {
1085+
if (btrfs_is_zoned(fs_info)) {
10831086
btrfs_repair_one_zone(fs_info, sctx->stripes[0].bg->start);
1084-
} else if (!sctx->readonly) {
1085-
unsigned long repaired;
1086-
1087-
bitmap_andnot(&repaired, &stripe->init_error_bitmap,
1088-
&stripe->error_bitmap, stripe->nr_sectors);
1089-
scrub_write_sectors(sctx, stripe, repaired, false);
1090-
wait_scrub_stripe_io(stripe);
1087+
} else {
1088+
scrub_write_sectors(sctx, stripe, repaired, false);
1089+
wait_scrub_stripe_io(stripe);
1090+
}
10911091
}
10921092

10931093
scrub_stripe_report_errors(sctx, stripe);

fs/btrfs/tests/extent-map-tests.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,11 @@ static int test_case_7(struct btrfs_fs_info *fs_info)
847847
goto out;
848848
}
849849

850+
if (em->block_start != SZ_32K + SZ_4K) {
851+
test_err("em->block_start is %llu, expected 36K", em->block_start);
852+
goto out;
853+
}
854+
850855
free_extent_map(em);
851856

852857
read_lock(&em_tree->lock);

0 commit comments

Comments
 (0)