Skip to content

Commit 415e507

Browse files
committed
orangefs_readahead: don't overflow the bufmap slot.
generic/340 showed that this caller of wait_for_direct_io was sometimes asking for more than a bufmap slot could hold. This splits the calls up if needed. Signed-off-by: Mike Marshall <hubcap@omnibond.com>
1 parent 30f5059 commit 415e507

1 file changed

Lines changed: 27 additions & 9 deletions

File tree

fs/orangefs/inode.c

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ static void orangefs_readahead(struct readahead_control *rac)
224224
loff_t new_start = readahead_pos(rac);
225225
int ret;
226226
size_t new_len = 0;
227+
size_t this_size;
228+
size_t remaining;
227229

228230
loff_t bytes_remaining = inode->i_size - readahead_pos(rac);
229231
loff_t pages_remaining = bytes_remaining / PAGE_SIZE;
@@ -239,17 +241,33 @@ static void orangefs_readahead(struct readahead_control *rac)
239241
offset = readahead_pos(rac);
240242
i_pages = &rac->mapping->i_pages;
241243

242-
iov_iter_xarray(&iter, ITER_DEST, i_pages, offset, readahead_length(rac));
244+
iov_iter_xarray(&iter, ITER_DEST, i_pages,
245+
offset, readahead_length(rac));
243246

244-
/* read in the pages. */
245-
if ((ret = wait_for_direct_io(ORANGEFS_IO_READ, inode,
246-
&offset, &iter, readahead_length(rac),
247-
inode->i_size, NULL, NULL, rac->file)) < 0)
248-
gossip_debug(GOSSIP_FILE_DEBUG,
249-
"%s: wait_for_direct_io failed. \n", __func__);
250-
else
251-
ret = 0;
247+
remaining = readahead_length(rac);
248+
while (remaining) {
249+
if (remaining > 4194304)
250+
this_size = 4194304;
251+
else
252+
this_size = remaining;
253+
254+
/* read in the pages. */
255+
if ((ret = wait_for_direct_io(ORANGEFS_IO_READ, inode,
256+
&offset, &iter, this_size,
257+
inode->i_size, NULL, NULL, rac->file)) < 0) {
258+
gossip_debug(GOSSIP_FILE_DEBUG,
259+
"%s: wait_for_direct_io failed. :%d: \n",
260+
__func__, ret);
261+
goto cleanup;
262+
} else {
263+
ret = 0;
264+
}
265+
266+
remaining -= this_size;
267+
offset += this_size;
268+
}
252269

270+
cleanup:
253271
/* clean up. */
254272
while ((folio = readahead_folio(rac))) {
255273
if (!ret)

0 commit comments

Comments
 (0)