linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tom Talpey <tom@talpey.com>
To: Vishal Moola <vishal.moola@gmail.com>,
	linux-fsdevel@vger.kernel.org, pc@cjr.nz
Cc: linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org,
	linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org,
	linux-cifs@vger.kernel.org, linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net, cluster-devel@redhat.com,
	linux-nilfs@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH v5 09/23] cifs: Convert wdata_alloc_and_fillpages() to use filemap_get_folios_tag()
Date: Thu, 12 Jan 2023 22:03:27 -0500	[thread overview]
Message-ID: <c2b5b3b4-d5d0-bf35-d659-b2328689073a@talpey.com> (raw)
In-Reply-To: <CAOzc2pw9WCgHyA2epbz5=HEWN4bFzD4C7zL2452J_egv7iSLrw@mail.gmail.com>

This code would be a lot more readable if it had fewer goto's.
The goto out's are ok but the again and add_more are easily
eliminated.

Two possibilities...

On 1/12/2023 12:19 PM, Vishal Moola wrote:
> On Wed, Jan 4, 2023 at 1:15 PM Vishal Moola (Oracle)
> <vishal.moola@gmail.com> wrote:
>>
>> This is in preparation for the removal of find_get_pages_range_tag(). Now also
>> supports the use of large folios.
>>
>> Since tofind might be larger than the max number of folios in a
>> folio_batch (15), we loop through filling in wdata->pages pulling more
>> batches until we either reach tofind pages or run out of folios.
>>
>> This function may not return all pages in the last found folio before
>> tofind pages are reached.
>>
>> Signed-off-by: Vishal Moola (Oracle) <vishal.moola@gmail.com>
>> ---
>>   fs/cifs/file.c | 32 +++++++++++++++++++++++++++++---
>>   1 file changed, 29 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/cifs/file.c b/fs/cifs/file.c
>> index 22dfc1f8b4f1..8cdd2f67af24 100644
>> --- a/fs/cifs/file.c
>> +++ b/fs/cifs/file.c
>> @@ -2527,14 +2527,40 @@ wdata_alloc_and_fillpages(pgoff_t tofind, struct address_space *mapping,
>>                            unsigned int *found_pages)
>>   {
>>          struct cifs_writedata *wdata;
>> -
>> +       struct folio_batch fbatch;
>> +       unsigned int i, idx, p, nr;
>>          wdata = cifs_writedata_alloc((unsigned int)tofind,
>>                                       cifs_writev_complete);
>>          if (!wdata)
>>                  return NULL;
>>
>> -       *found_pages = find_get_pages_range_tag(mapping, index, end,
>> -                               PAGECACHE_TAG_DIRTY, tofind, wdata->pages);
>> +       folio_batch_init(&fbatch);
>> +       *found_pages = 0;
>> +


This is really just the top of a while loop:

   while (nr = filemap_get_folios_tag(...)) {

>> +again:
>> +       nr = filemap_get_folios_tag(mapping, index, end,
>> +                               PAGECACHE_TAG_DIRTY, &fbatch);
>> +       if (!nr)
>> +               goto out; /* No dirty pages left in the range */
>> +
>> +       for (i = 0; i < nr; i++) {
>> +               struct folio *folio = fbatch.folios[i];
>> +
>> +               idx = 0;
>> +               p = folio_nr_pages(folio);

And this is a "do {"

>> +add_more:
>> +               wdata->pages[*found_pages] = folio_page(folio, idx);
>> +               folio_get(folio);
>> +               if (++*found_pages == tofind) {
>> +                       folio_batch_release(&fbatch);
>> +                       goto out;
>> +               }
>> +               if (++idx < p)
>> +                       goto add_more;

To here "} while (++idx < p);"

>> +       }
>> +       folio_batch_release(&fbatch);
>> +       goto again;

End while "}"

>> +out:
>>          return wdata;
>>   }
>>
>> --
>> 2.38.1
>>
> 
> Could someone review this cifs patch, please? This is one of the
> 2 remaining patches that need to be looked at in the series.

It's otherwise ok.

Tom.
> 


  reply	other threads:[~2023-01-13  3:03 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04 21:14 [PATCH v5 00/23] Convert to filemap_get_folios_tag() Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 01/23] pagemap: Add filemap_grab_folio() Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 02/23] filemap: Added filemap_get_folios_tag() Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 03/23] filemap: Convert __filemap_fdatawait_range() to use filemap_get_folios_tag() Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 04/23] page-writeback: Convert write_cache_pages() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 05/23] afs: Convert afs_writepages_region() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 06/23] btrfs: Convert btree_write_cache_pages() to use filemap_get_folio_tag() Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 07/23] btrfs: Convert extent_write_cache_pages() to use filemap_get_folios_tag() Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 08/23] ceph: Convert ceph_writepages_start() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 09/23] cifs: Convert wdata_alloc_and_fillpages() " Vishal Moola (Oracle)
2023-01-12 17:19   ` Vishal Moola
2023-01-13  3:03     ` Tom Talpey [this message]
2023-01-12 19:23   ` Paulo Alcantara
2023-01-04 21:14 ` [PATCH v5 10/23] ext4: Convert mpage_prepare_extent_to_map() " Vishal Moola (Oracle)
2023-01-12 17:16   ` Vishal Moola
2023-01-04 21:14 ` [PATCH v5 11/23] f2fs: Convert f2fs_fsync_node_pages() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 12/23] f2fs: Convert f2fs_flush_inline_data() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 13/23] f2fs: Convert f2fs_sync_node_pages() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 14/23] f2fs: Convert f2fs_write_cache_pages() " Vishal Moola (Oracle)
2023-01-12 10:17   ` [f2fs-dev] " Chao Yu
2023-01-04 21:14 ` [PATCH v5 15/23] f2fs: Convert last_fsync_dnode() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 16/23] f2fs: Convert f2fs_sync_meta_pages() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 17/23] gfs2: Convert gfs2_write_cache_jdata() " Vishal Moola (Oracle)
2023-01-06  7:57   ` [Cluster-devel] " Andreas Gruenbacher
2023-01-04 21:14 ` [PATCH v5 18/23] nilfs2: Convert nilfs_lookup_dirty_data_buffers() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 19/23] nilfs2: Convert nilfs_lookup_dirty_node_buffers() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 20/23] nilfs2: Convert nilfs_btree_lookup_dirty_buffers() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 21/23] nilfs2: Convert nilfs_copy_dirty_pages() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 22/23] nilfs2: Convert nilfs_clear_dirty_pages() " Vishal Moola (Oracle)
2023-01-04 21:14 ` [PATCH v5 23/23] filemap: Remove find_get_pages_range_tag() Vishal Moola (Oracle)
2023-02-28  1:01 ` [f2fs-dev] [PATCH v5 00/23] Convert to filemap_get_folios_tag() patchwork-bot+f2fs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c2b5b3b4-d5d0-bf35-d659-b2328689073a@talpey.com \
    --to=tom@talpey.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=cluster-devel@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=pc@cjr.nz \
    --cc=vishal.moola@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox