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
| ||
|
Message-ID: <CAHc6FU6JasO3-8VaOm3MieLEn599OTKPnZC5BwkNUMqNoJ+meA@mail.gmail.com> Date: Wed, 20 Sep 2023 00:34:41 +0200 From: Andreas Gruenbacher <agruenba@...hat.com> To: "Matthew Wilcox (Oracle)" <willy@...radead.org> Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-fsdevel@...r.kernel.org, gfs2@...ts.linux.dev, linux-nilfs@...r.kernel.org, linux-ntfs-dev@...ts.sourceforge.net, ntfs3@...ts.linux.dev, ocfs2-devel@...ts.linux.dev, reiserfs-devel@...r.kernel.org, linux-ext4@...r.kernel.org, Pankaj Raghav <p.raghav@...sung.com> Subject: Re: [PATCH 06/26] gfs2: Convert gfs2_getbuf() to folios On Tue, Sep 19, 2023 at 7:00 AM Matthew Wilcox (Oracle) <willy@...radead.org> wrote: > Remove several folio->page->folio conversions. Also use __GFP_NOFAIL > instead of calling yield() and the new get_nth_bh(). > > Signed-off-by: Matthew Wilcox (Oracle) <willy@...radead.org> > --- > fs/gfs2/meta_io.c | 39 +++++++++++++++++---------------------- > 1 file changed, 17 insertions(+), 22 deletions(-) > > diff --git a/fs/gfs2/meta_io.c b/fs/gfs2/meta_io.c > index 924361fa510b..f1fac1b45059 100644 > --- a/fs/gfs2/meta_io.c > +++ b/fs/gfs2/meta_io.c > @@ -115,7 +115,7 @@ struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno, int create) > { > struct address_space *mapping = gfs2_glock2aspace(gl); > struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; > - struct page *page; > + struct folio *folio; > struct buffer_head *bh; > unsigned int shift; > unsigned long index; > @@ -129,36 +129,31 @@ struct buffer_head *gfs2_getbuf(struct gfs2_glock *gl, u64 blkno, int create) > bufnum = blkno - (index << shift); /* block buf index within page */ > > if (create) { > - for (;;) { > - page = grab_cache_page(mapping, index); > - if (page) > - break; > - yield(); > - } > - if (!page_has_buffers(page)) > - create_empty_buffers(page, sdp->sd_sb.sb_bsize, 0); > + folio = __filemap_get_folio(mapping, index, > + FGP_LOCK | FGP_ACCESSED | FGP_CREAT, > + mapping_gfp_mask(mapping) | __GFP_NOFAIL); > + bh = folio_buffers(folio); > + if (!bh) > + bh = folio_create_empty_buffers(folio, > + sdp->sd_sb.sb_bsize, 0); > } else { > - page = find_get_page_flags(mapping, index, > - FGP_LOCK|FGP_ACCESSED); > - if (!page) > + folio = __filemap_get_folio(mapping, index, > + FGP_LOCK | FGP_ACCESSED, 0); > + if (IS_ERR(folio)) > return NULL; > - if (!page_has_buffers(page)) { > - bh = NULL; > - goto out_unlock; > - } > + bh = folio_buffers(folio); > } > > - /* Locate header for our buffer within our page */ > - for (bh = page_buffers(page); bufnum--; bh = bh->b_this_page) > - /* Do nothing */; > - get_bh(bh); > + if (!bh) > + goto out_unlock; > > + bh = get_nth_bh(bh, bufnum); > if (!buffer_mapped(bh)) > map_bh(bh, sdp->sd_vfs, blkno); > > out_unlock: > - unlock_page(page); > - put_page(page); > + folio_unlock(folio); > + folio_put(folio); > > return bh; > } > -- > 2.40.1 > Reviewed-by: Andreas Gruenbacher <agruenba@...hat.com> Thanks, Andreas
Powered by blists - more mailing lists