Re: [PATCH 6/8] gfs2: Convert gfs2_find_jhead() to use a folio

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

 



On Mon, Feb 10, 2025 at 2:35 PM Matthew Wilcox (Oracle)
<willy@xxxxxxxxxxxxx> wrote:
> Remove a call to grab_cache_page() by using a folio throughout
> this function.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> ---
>  fs/gfs2/lops.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
> index 09e4c5915243..30597b0f7cc3 100644
> --- a/fs/gfs2/lops.c
> +++ b/fs/gfs2/lops.c
> @@ -514,7 +514,7 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
>         struct gfs2_journal_extent *je;
>         int sz, ret = 0;
>         struct bio *bio = NULL;
> -       struct page *page = NULL;
> +       struct folio *folio = NULL;
>         bool done = false;
>         errseq_t since;
>
> @@ -527,9 +527,10 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
>                 u64 dblock = je->dblock;
>
>                 for (; block < je->lblock + je->blocks; block++, dblock++) {
> -                       if (!page) {
> -                               page = grab_cache_page(mapping, block >> shift);
> -                               if (!page) {
> +                       if (!folio) {
> +                               folio = filemap_grab_folio(mapping,
> +                                               block >> shift);
> +                               if (!folio) {
>                                         ret = -ENOMEM;
>                                         done = true;
>                                         goto out;
> @@ -541,7 +542,7 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
>                                 sector_t sector = dblock << sdp->sd_fsb2bb_shift;
>
>                                 if (bio_end_sector(bio) == sector) {
> -                                       sz = bio_add_page(bio, page, bsize, off);
> +                                       sz = bio_add_folio(bio, folio, bsize, off);

The check below needs adjusting: bio_add_folio() returns whether the
addition was successful, not how many bytes were added.

I'll fix that.

>                                         if (sz == bsize)
>                                                 goto block_added;
>                                 }
> @@ -562,12 +563,12 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header_host *head,
>                         bio = gfs2_log_alloc_bio(sdp, dblock, gfs2_end_log_read);
>                         bio->bi_opf = REQ_OP_READ;
>  add_block_to_new_bio:
> -                       sz = bio_add_page(bio, page, bsize, off);
> +                       sz = bio_add_folio(bio, folio, bsize, off);

Likewise here.

>                         BUG_ON(sz != bsize);
>  block_added:
>                         off += bsize;
> -                       if (off == PAGE_SIZE)
> -                               page = NULL;
> +                       if (off == folio_size(folio))
> +                               folio = NULL;
>                         if (blocks_submitted <= blocks_read + max_blocks) {
>                                 /* Keep at least one bio in flight */
>                                 continue;
> --
> 2.47.2
>

Thanks,
Andreas






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

  Powered by Linux