Skip to content

Commit fd87851

Browse files
Dave Chinnercmaiolino
authored andcommitted
xfs: buffer items don't straddle pages anymore
Unmapped buffers don't exist anymore, so the page straddling detection and slow path code can go away now. Signed-off-by: Dave Chinner <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Carlos Maiolino <[email protected]>
1 parent a2f790b commit fd87851

File tree

1 file changed

+0
-124
lines changed

1 file changed

+0
-124
lines changed

fs/xfs/xfs_buf_item.c

Lines changed: 0 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -57,31 +57,6 @@ xfs_buf_log_format_size(
5757
(blfp->blf_map_size * sizeof(blfp->blf_data_map[0]));
5858
}
5959

60-
/*
61-
* We only have to worry about discontiguous buffer range straddling on unmapped
62-
* buffers. Everything else will have a contiguous data region we can copy from.
63-
*/
64-
static inline bool
65-
xfs_buf_item_straddle(
66-
struct xfs_buf *bp,
67-
uint offset,
68-
int first_bit,
69-
int nbits)
70-
{
71-
void *first, *last;
72-
73-
if (bp->b_page_count == 1)
74-
return false;
75-
76-
first = xfs_buf_offset(bp, offset + (first_bit << XFS_BLF_SHIFT));
77-
last = xfs_buf_offset(bp,
78-
offset + ((first_bit + nbits) << XFS_BLF_SHIFT));
79-
80-
if (last - first != nbits * XFS_BLF_CHUNK)
81-
return true;
82-
return false;
83-
}
84-
8560
/*
8661
* Return the number of log iovecs and space needed to log the given buf log
8762
* item segment.
@@ -98,11 +73,8 @@ xfs_buf_item_size_segment(
9873
int *nvecs,
9974
int *nbytes)
10075
{
101-
struct xfs_buf *bp = bip->bli_buf;
10276
int first_bit;
10377
int nbits;
104-
int next_bit;
105-
int last_bit;
10678

10779
first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
10880
if (first_bit == -1)
@@ -115,15 +87,6 @@ xfs_buf_item_size_segment(
11587
nbits = xfs_contig_bits(blfp->blf_data_map,
11688
blfp->blf_map_size, first_bit);
11789
ASSERT(nbits > 0);
118-
119-
/*
120-
* Straddling a page is rare because we don't log contiguous
121-
* chunks of unmapped buffers anywhere.
122-
*/
123-
if (nbits > 1 &&
124-
xfs_buf_item_straddle(bp, offset, first_bit, nbits))
125-
goto slow_scan;
126-
12790
(*nvecs)++;
12891
*nbytes += nbits * XFS_BLF_CHUNK;
12992

@@ -138,43 +101,6 @@ xfs_buf_item_size_segment(
138101
} while (first_bit != -1);
139102

140103
return;
141-
142-
slow_scan:
143-
ASSERT(bp->b_addr == NULL);
144-
last_bit = first_bit;
145-
nbits = 1;
146-
while (last_bit != -1) {
147-
148-
*nbytes += XFS_BLF_CHUNK;
149-
150-
/*
151-
* This takes the bit number to start looking from and
152-
* returns the next set bit from there. It returns -1
153-
* if there are no more bits set or the start bit is
154-
* beyond the end of the bitmap.
155-
*/
156-
next_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size,
157-
last_bit + 1);
158-
/*
159-
* If we run out of bits, leave the loop,
160-
* else if we find a new set of bits bump the number of vecs,
161-
* else keep scanning the current set of bits.
162-
*/
163-
if (next_bit == -1) {
164-
if (first_bit != last_bit)
165-
(*nvecs)++;
166-
break;
167-
} else if (next_bit != last_bit + 1 ||
168-
xfs_buf_item_straddle(bp, offset, first_bit, nbits)) {
169-
last_bit = next_bit;
170-
first_bit = next_bit;
171-
(*nvecs)++;
172-
nbits = 1;
173-
} else {
174-
last_bit++;
175-
nbits++;
176-
}
177-
}
178104
}
179105

180106
/*
@@ -287,8 +213,6 @@ xfs_buf_item_format_segment(
287213
struct xfs_buf *bp = bip->bli_buf;
288214
uint base_size;
289215
int first_bit;
290-
int last_bit;
291-
int next_bit;
292216
uint nbits;
293217

294218
/* copy the flags across from the base format item */
@@ -333,15 +257,6 @@ xfs_buf_item_format_segment(
333257
nbits = xfs_contig_bits(blfp->blf_data_map,
334258
blfp->blf_map_size, first_bit);
335259
ASSERT(nbits > 0);
336-
337-
/*
338-
* Straddling a page is rare because we don't log contiguous
339-
* chunks of unmapped buffers anywhere.
340-
*/
341-
if (nbits > 1 &&
342-
xfs_buf_item_straddle(bp, offset, first_bit, nbits))
343-
goto slow_scan;
344-
345260
xfs_buf_item_copy_iovec(lv, vecp, bp, offset,
346261
first_bit, nbits);
347262
blfp->blf_size++;
@@ -357,45 +272,6 @@ xfs_buf_item_format_segment(
357272
} while (first_bit != -1);
358273

359274
return;
360-
361-
slow_scan:
362-
ASSERT(bp->b_addr == NULL);
363-
last_bit = first_bit;
364-
nbits = 1;
365-
for (;;) {
366-
/*
367-
* This takes the bit number to start looking from and
368-
* returns the next set bit from there. It returns -1
369-
* if there are no more bits set or the start bit is
370-
* beyond the end of the bitmap.
371-
*/
372-
next_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size,
373-
(uint)last_bit + 1);
374-
/*
375-
* If we run out of bits fill in the last iovec and get out of
376-
* the loop. Else if we start a new set of bits then fill in
377-
* the iovec for the series we were looking at and start
378-
* counting the bits in the new one. Else we're still in the
379-
* same set of bits so just keep counting and scanning.
380-
*/
381-
if (next_bit == -1) {
382-
xfs_buf_item_copy_iovec(lv, vecp, bp, offset,
383-
first_bit, nbits);
384-
blfp->blf_size++;
385-
break;
386-
} else if (next_bit != last_bit + 1 ||
387-
xfs_buf_item_straddle(bp, offset, first_bit, nbits)) {
388-
xfs_buf_item_copy_iovec(lv, vecp, bp, offset,
389-
first_bit, nbits);
390-
blfp->blf_size++;
391-
first_bit = next_bit;
392-
last_bit = next_bit;
393-
nbits = 1;
394-
} else {
395-
last_bit++;
396-
nbits++;
397-
}
398-
}
399275
}
400276

401277
/*

0 commit comments

Comments
 (0)