Skip to content

Commit 2d0e9df

Browse files
Mark TinguelyBen Myers
authored andcommitted
xfs: fix segment in xfs_buf_item_format_segment
Not every segment in a multi-segment buffer is dirty in a transaction and they will not be outputted. The assert in xfs_buf_item_format_segment() that checks for the at least one chunk of data in the segment to be used is not necessary true for multi-segmented buffers. Signed-off-by: Mark Tinguely <tinguely@sgi.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Ben Myers <bpm@sgi.com>
1 parent 0f22f9d commit 2d0e9df

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

fs/xfs/xfs_buf_item.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,17 @@ xfs_buf_item_format_segment(
287287
*/
288288
base_size = offsetof(struct xfs_buf_log_format, blf_data_map) +
289289
(blfp->blf_map_size * sizeof(blfp->blf_data_map[0]));
290+
291+
nvecs = 0;
292+
first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
293+
if (!(bip->bli_flags & XFS_BLI_STALE) && first_bit == -1) {
294+
/*
295+
* If the map is not be dirty in the transaction, mark
296+
* the size as zero and do not advance the vector pointer.
297+
*/
298+
goto out;
299+
}
300+
290301
vecp->i_addr = blfp;
291302
vecp->i_len = base_size;
292303
vecp->i_type = XLOG_REG_TYPE_BFORMAT;
@@ -301,15 +312,13 @@ xfs_buf_item_format_segment(
301312
*/
302313
trace_xfs_buf_item_format_stale(bip);
303314
ASSERT(blfp->blf_flags & XFS_BLF_CANCEL);
304-
blfp->blf_size = nvecs;
305-
return vecp;
315+
goto out;
306316
}
307317

308318
/*
309319
* Fill in an iovec for each set of contiguous chunks.
310320
*/
311-
first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
312-
ASSERT(first_bit != -1);
321+
313322
last_bit = first_bit;
314323
nbits = 1;
315324
for (;;) {
@@ -371,7 +380,8 @@ xfs_buf_item_format_segment(
371380
nbits++;
372381
}
373382
}
374-
bip->__bli_format.blf_size = nvecs;
383+
out:
384+
blfp->blf_size = nvecs;
375385
return vecp;
376386
}
377387

0 commit comments

Comments
 (0)