Re: [PATCH v3 3/3] squashfs: implement readahead

From: Matthew Wilcox
Date: Tue May 31 2022 - 16:57:13 EST


On Tue, May 31, 2022 at 01:47:40PM -0700, Andrew Morton wrote:
> > + for (;;) {
> > + nr_pages = __readahead_batch(ractl, pages, max_pages);
> > + if (!nr_pages)
> > + break;
> > +
> > + if (readahead_pos(ractl) >= i_size_read(inode) ||
> > + nr_pages < max_pages)
> > + goto skip_pages;
> > +
> > + index = pages[0]->index >> shift;
> > + if ((pages[nr_pages - 1]->index >> shift) != index)
> > + goto skip_pages;
> > +
> > + expected = index == file_end ?
> > + (i_size_read(inode) & (msblk->block_size - 1)) :
> > + msblk->block_size;
> > +
> > + bsize = read_blocklist(inode, index, &block);
> > + if (bsize == 0)
> > + goto skip_pages;
> > +
> > + res = squashfs_read_data(inode->i_sb, block, bsize, NULL,
> > + actor);
> > +
> > + if (res == expected) {
> > + /* Last page may have trailing bytes not filled */
> > + bytes = res % PAGE_SIZE;
> > + if (bytes) {
> > + pageaddr = kmap_atomic(pages[nr_pages - 1]);
> > + memset(pageaddr + bytes, 0, PAGE_SIZE - bytes);
> > + kunmap_atomic(pageaddr);
> > + }
> > +
> > + for (i = 0; i < nr_pages; i++)
> > + SetPageUptodate(pages[i]);
> > + }
>
> res == -EIO is unhandled?

No it isn't ... this is readahead, which means there's nobody to care
about the error. The pages are left !Uptodate, which means that they'll
be retried with a call to ->read_folio later. At that point, somebody
actually wants the data in those pages, and they'll see the error.