@@ -1137,6 +1137,35 @@ static void scrub_write_endio(struct btrfs_bio *bbio)
1137
1137
wake_up (& stripe -> io_wait );
1138
1138
}
1139
1139
1140
+ static void scrub_submit_write_bio (struct scrub_ctx * sctx ,
1141
+ struct scrub_stripe * stripe ,
1142
+ struct btrfs_bio * bbio , bool dev_replace )
1143
+ {
1144
+ struct btrfs_fs_info * fs_info = sctx -> fs_info ;
1145
+ u32 bio_len = bbio -> bio .bi_iter .bi_size ;
1146
+ u32 bio_off = (bbio -> bio .bi_iter .bi_sector << SECTOR_SHIFT ) -
1147
+ stripe -> logical ;
1148
+
1149
+ fill_writer_pointer_gap (sctx , stripe -> physical + bio_off );
1150
+ atomic_inc (& stripe -> pending_io );
1151
+ btrfs_submit_repair_write (bbio , stripe -> mirror_num , dev_replace );
1152
+ if (!btrfs_is_zoned (fs_info ))
1153
+ return ;
1154
+ /*
1155
+ * For zoned writeback, queue depth must be 1, thus we must wait for
1156
+ * the write to finish before the next write.
1157
+ */
1158
+ wait_scrub_stripe_io (stripe );
1159
+
1160
+ /*
1161
+ * And also need to update the write pointer if write finished
1162
+ * successfully.
1163
+ */
1164
+ if (!test_bit (bio_off >> fs_info -> sectorsize_bits ,
1165
+ & stripe -> write_error_bitmap ))
1166
+ sctx -> write_pointer += bio_len ;
1167
+ }
1168
+
1140
1169
/*
1141
1170
* Submit the write bio(s) for the sectors specified by @write_bitmap.
1142
1171
*
@@ -1155,7 +1184,6 @@ static void scrub_write_sectors(struct scrub_ctx *sctx, struct scrub_stripe *str
1155
1184
{
1156
1185
struct btrfs_fs_info * fs_info = stripe -> bg -> fs_info ;
1157
1186
struct btrfs_bio * bbio = NULL ;
1158
- const bool zoned = btrfs_is_zoned (fs_info );
1159
1187
int sector_nr ;
1160
1188
1161
1189
for_each_set_bit (sector_nr , & write_bitmap , stripe -> nr_sectors ) {
@@ -1168,13 +1196,7 @@ static void scrub_write_sectors(struct scrub_ctx *sctx, struct scrub_stripe *str
1168
1196
1169
1197
/* Cannot merge with previous sector, submit the current one. */
1170
1198
if (bbio && sector_nr && !test_bit (sector_nr - 1 , & write_bitmap )) {
1171
- fill_writer_pointer_gap (sctx , stripe -> physical +
1172
- (sector_nr << fs_info -> sectorsize_bits ));
1173
- atomic_inc (& stripe -> pending_io );
1174
- btrfs_submit_repair_write (bbio , stripe -> mirror_num , dev_replace );
1175
- /* For zoned writeback, queue depth must be 1. */
1176
- if (zoned )
1177
- wait_scrub_stripe_io (stripe );
1199
+ scrub_submit_write_bio (sctx , stripe , bbio , dev_replace );
1178
1200
bbio = NULL ;
1179
1201
}
1180
1202
if (!bbio ) {
@@ -1187,14 +1209,8 @@ static void scrub_write_sectors(struct scrub_ctx *sctx, struct scrub_stripe *str
1187
1209
ret = bio_add_page (& bbio -> bio , page , fs_info -> sectorsize , pgoff );
1188
1210
ASSERT (ret == fs_info -> sectorsize );
1189
1211
}
1190
- if (bbio ) {
1191
- fill_writer_pointer_gap (sctx , bbio -> bio .bi_iter .bi_sector <<
1192
- SECTOR_SHIFT );
1193
- atomic_inc (& stripe -> pending_io );
1194
- btrfs_submit_repair_write (bbio , stripe -> mirror_num , dev_replace );
1195
- if (zoned )
1196
- wait_scrub_stripe_io (stripe );
1197
- }
1212
+ if (bbio )
1213
+ scrub_submit_write_bio (sctx , stripe , bbio , dev_replace );
1198
1214
}
1199
1215
1200
1216
/*
0 commit comments