lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200131021701.GB18575@dread.disaster.area>
Date:   Fri, 31 Jan 2020 13:17:01 +1100
From:   Dave Chinner <david@...morbit.com>
To:     Matthew Wilcox <willy@...radead.org>
Cc:     linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, linux-btrfs@...r.kernel.org
Subject: Re: [PATCH 06/12] btrfs: Convert from readpages to readahead

On Thu, Jan 30, 2020 at 12:09:39AM -0800, Matthew Wilcox wrote:
> 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@...radead.org>
> > > 
> > > Use the new readahead operation in btrfs
> > > 
> > > Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org>
> > > Cc: linux-btrfs@...r.kernel.org
> > > ---
> > >  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;
>                 }

Looks like it solves the problem :)

Cheers,

Dave.
-- 
Dave Chinner
david@...morbit.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ