All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ryusuke Konishi <konishi.ryusuke@gmail.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: linux-nilfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 11/35] nilfs2: Convert nilfs_page_mkwrite() to use a folio
Date: Thu, 9 Nov 2023 23:22:30 +0900	[thread overview]
Message-ID: <CAKFNMonjA2OyZRju4VRRrdKD6XvvD-cgLFH1u53M+wGKUNL2Kw@mail.gmail.com> (raw)
In-Reply-To: <ZUzgjxJoKYP9KIx0@casper.infradead.org>

On Thu, Nov 9, 2023 at 10:37 PM Matthew Wilcox wrote:
>
> On Thu, Nov 09, 2023 at 10:11:27PM +0900, Ryusuke Konishi wrote:
> > On Tue, Nov 7, 2023 at 2:39 AM Matthew Wilcox (Oracle) wrote:
> > >
> > > Using the new folio APIs saves seven hidden calls to compound_head().
> > >
> > > Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
> > > ---
> > >  fs/nilfs2/file.c | 28 +++++++++++++++-------------
> > >  1 file changed, 15 insertions(+), 13 deletions(-)
> >
> > I'm still in the middle of reviewing this series, but I had one
> > question in a relevant part outside of this patch, so I'd like to ask
> > you a question.
> >
> > In block_page_mkwrite() that nilfs_page_mkwrite() calls,
> > __block_write_begin_int() was called with the range using
> > folio_size(), as shown below:
> >
> >         end = folio_size(folio);
> >         /* folio is wholly or partially inside EOF */
> >         if (folio_pos(folio) + end > size)
> >                 end = size - folio_pos(folio);
> >
> >         ret = __block_write_begin_int(folio, 0, end, get_block, NULL);
> >         ...
> >
> > On the other hand, __block_write_begin_int() takes a folio as an
> > argument, but uses a PAGE_SIZE-based remainder calculation and BUG_ON
> > checks:
> >
> > int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len,
> >                 get_block_t *get_block, const struct iomap *iomap)
> > {
> >         unsigned from = pos & (PAGE_SIZE - 1);
> >         unsigned to = from + len;
> >         ...
> >         BUG_ON(from > PAGE_SIZE);
> >         BUG_ON(to > PAGE_SIZE);
> >         ...
> >
> > So, it looks like this function causes a kernel BUG if it's called
> > from block_page_mkwrite() and folio_size() exceeds PAGE_SIZE.
> >
> > Is this constraint intentional or temporary in folio conversions ?
>
> Good catch!
>
> At the time I converted __block_write_begin_int() to take a folio
> (over two years ago), the plan was that filesystems would convert to
> the iomap infrastructure in order to take advantage of large folios.
>
> The needs of the Large Block Size project mean that may not happen;
> filesystems want to add support for, eg, 16kB hardware block sizes
> without converting to iomap.  So we shoud fix up
> __block_write_begin_int().  I'll submit a patch along these lines:
>
> diff --git a/fs/buffer.c b/fs/buffer.c
> index cd114110b27f..24a5694f9b41 100644
> --- a/fs/buffer.c
> +++ b/fs/buffer.c
> @@ -2080,25 +2080,24 @@ iomap_to_bh(struct inode *inode, sector_t block, struct buffer_head *bh,
>  int __block_write_begin_int(struct folio *folio, loff_t pos, unsigned len,
>                 get_block_t *get_block, const struct iomap *iomap)
>  {
> -       unsigned from = pos & (PAGE_SIZE - 1);
> -       unsigned to = from + len;
> +       size_t from = offset_in_folio(folio, pos);
> +       size_t to = from + len;
>         struct inode *inode = folio->mapping->host;
> -       unsigned block_start, block_end;
> +       size_t block_start, block_end;
>         sector_t block;
>         int err = 0;
>         unsigned blocksize, bbits;
>         struct buffer_head *bh, *head, *wait[2], **wait_bh=wait;
>
>         BUG_ON(!folio_test_locked(folio));
> -       BUG_ON(from > PAGE_SIZE);
> -       BUG_ON(to > PAGE_SIZE);
> +       BUG_ON(to > folio_size(folio));
>         BUG_ON(from > to);
>
>         head = folio_create_buffers(folio, inode, 0);
>         blocksize = head->b_size;
>         bbits = block_size_bits(blocksize);
>
> -       block = (sector_t)folio->index << (PAGE_SHIFT - bbits);
> +       block = ((loff_t)folio->index * PAGE_SIZE) >> bbits;
>
>         for(bh = head, block_start = 0; bh != head || !block_start;
>             block++, block_start=block_end, bh = bh->b_this_page) {

I got it.
We may have to look at the entire function, but if this change is
applied, it seems to be fine, at least for my question.

Thank you for your prompt correction!

Regards,
Ryusuke Konishi

  reply	other threads:[~2023-11-09 14:22 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-06 17:38 [PATCH 00/35] nilfs2: Folio conversions Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 01/35] nilfs2: Add nilfs_end_folio_io() Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 02/35] nilfs2: Convert nilfs_abort_logs to use folios Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 03/35] nilfs2: Convert nilfs_segctor_complete_write " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 04/35] nilfs2: Convert nilfs_forget_buffer to use a folio Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 05/35] nilfs2: Convert to nilfs_folio_buffers_clean() Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 06/35] nilfs2: Convert nilfs_writepage() to use a folio Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 07/35] nilfs2: Convert nilfs_mdt_write_page() " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 08/35] nilfs2: Convert to nilfs_clear_folio_dirty() Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 09/35] nilfs2: Convert to __nilfs_clear_folio_dirty() Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 10/35] nilfs2: Convert nilfs_segctor_prepare_write to use folios Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 11/35] nilfs2: Convert nilfs_page_mkwrite() to use a folio Matthew Wilcox (Oracle)
2023-11-09 13:11   ` Ryusuke Konishi
2023-11-09 13:37     ` Matthew Wilcox
2023-11-09 14:22       ` Ryusuke Konishi [this message]
2023-11-06 17:38 ` [PATCH 12/35] nilfs2: Convert nilfs_mdt_create_block " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 13/35] nilfs2: Convert nilfs_mdt_submit_block " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 14/35] nilfs2: Convert nilfs_gccache_submit_read_data " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 15/35] nilfs2: Convert nilfs_btnode_create_block " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 16/35] nilfs2: Convert nilfs_btnode_submit_block " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 17/35] nilfs2: Convert nilfs_btnode_delete " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 18/35] nilfs2: Convert nilfs_btnode_prepare_change_key " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 19/35] nilfs2: Convert nilfs_btnode_commit_change_key " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 20/35] nilfs2: Convert nilfs_btnode_abort_change_key " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 21/35] nilfs2: Remove page_address() from nilfs_set_link Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 22/35] nilfs2: Remove page_address() from nilfs_add_link Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 23/35] nilfs2: Remove page_address() from nilfs_delete_entry Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 24/35] nilfs2: Return the mapped address from nilfs_get_page() Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 25/35] nilfs2: Pass the mapped address to nilfs_check_page() Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 26/35] nilfs2: Switch to kmap_local for directory handling Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 27/35] nilfs2: Add nilfs_get_folio() Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 28/35] nilfs2: Convert nilfs_readdir to use a folio Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 29/35] nilfs2: Convert nilfs_find_entry " Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 30/35] nilfs2: Convert nilfs_rename() to use folios Matthew Wilcox (Oracle)
2023-11-06 17:38 ` [PATCH 31/35] nilfs2: Convert nilfs_add_link() to use a folio Matthew Wilcox (Oracle)
2023-11-06 17:39 ` [PATCH 32/35] nilfs2: Convert nilfs_empty_dir() " Matthew Wilcox (Oracle)
2023-11-06 17:39 ` [PATCH 33/35] nilfs2: Convert nilfs_make_empty() " Matthew Wilcox (Oracle)
2023-11-06 17:39 ` [PATCH 34/35] nilfs2: Convert nilfs_prepare_chunk() and nilfs_commit_chunk() to folios Matthew Wilcox (Oracle)
2023-11-06 17:39 ` [PATCH 35/35] nilfs2: Convert nilfs_page_bug() to nilfs_folio_bug() Matthew Wilcox (Oracle)
2023-11-07  1:49 ` [PATCH 00/35] nilfs2: Folio conversions Ryusuke Konishi
2023-11-12  0:10   ` Ryusuke Konishi
2023-11-21 17:43     ` Ryusuke Konishi

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=CAKFNMonjA2OyZRju4VRRrdKD6XvvD-cgLFH1u53M+wGKUNL2Kw@mail.gmail.com \
    --to=konishi.ryusuke@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=willy@infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.