Re: [PATCH 06/12] btrfs: Convert from readpages to readahead

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 29, 2020 at 11:46:09AM +1100, Dave Chinner wrote:
> On Fri, Jan 24, 2020 at 05:35:47PM -0800, Matthew Wilcox wrote:
> > From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx>
> > 
> > Use the new readahead operation in btrfs
> > 
> > Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> > Cc: linux-btrfs@xxxxxxxxxxxxxxx
> > ---
> >  fs/btrfs/extent_io.c | 15 ++++-----------
> >  fs/btrfs/extent_io.h |  2 +-
> >  fs/btrfs/inode.c     | 18 +++++++++---------
> >  3 files changed, 14 insertions(+), 21 deletions(-)
> > 
> > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
> > index 2f4802f405a2..b1e2acbec165 100644
> > --- a/fs/btrfs/extent_io.c
> > +++ b/fs/btrfs/extent_io.c
> > @@ -4283,7 +4283,7 @@ int extent_writepages(struct address_space *mapping,
> >  	return ret;
> >  }
> >  
> > -int extent_readpages(struct address_space *mapping, struct list_head *pages,
> > +unsigned extent_readahead(struct address_space *mapping, pgoff_t start,
> >  		     unsigned nr_pages)
> >  {
> >  	struct bio *bio = NULL;
> > @@ -4294,20 +4294,13 @@ int extent_readpages(struct address_space *mapping, struct list_head *pages,
> >  	int nr = 0;
> >  	u64 prev_em_start = (u64)-1;
> >  
> > -	while (!list_empty(pages)) {
> > +	while (nr_pages) {
> >  		u64 contig_end = 0;
> >  
> > -		for (nr = 0; nr < ARRAY_SIZE(pagepool) && !list_empty(pages);) {
> > -			struct page *page = lru_to_page(pages);
> > +		for (nr = 0; nr < ARRAY_SIZE(pagepool) && nr_pages--;) {
> 
> What is stopping nr_pages from going negative here, and then looping
> forever on the outer nr_pages loop? Perhaps "while(nr_pages > 0) {"
> would be better there?

Ugh, nr_pages is unsigned, so that's no good.  Maybe make this a more
conventional loop ...

        while (nr_pages) {
                u64 contig_end = 0;

                for (nr = 0; nr < ARRAY_SIZE(pagepool); nr++) {
                        struct page *page = readahead_page(mapping, start++);

                        prefetchw(&page->flags);
                        pagepool[nr] = page;
                        contig_end = page_offset(page) + PAGE_SIZE - 1;
                        if (--nr_pages == 0)
                                break;
                }




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux