From: Jan Kara <jack@suse.cz>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Jan Kara <jack@suse.com>,
linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org,
"Fabio M . De Francesco" <fmdefrancesco@gmail.com>
Subject: Re: [PATCH 07/10] ext2: Handle large block size directories in ext2_delete_entry()
Date: Wed, 25 Oct 2023 20:17:50 +0200 [thread overview]
Message-ID: <20231025181750.i2ibf27imrmpkqnt@quack3> (raw)
In-Reply-To: <20230921200746.3303942-7-willy@infradead.org>
On Thu 21-09-23 21:07:44, Matthew Wilcox (Oracle) wrote:
> If the block size is > PAGE_SIZE, we need to calculate these offsets
> relative to the start of the folio, not the page.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
So I had a fresh look at the patches and I like them so I'll take them into
my tree for the merge window. Just this patch has somewhat surprising
subject and changelog - I guess it should be standard "convert to folios"
kind of thing, shouldn't it? Because a lot of dir code is not prepared for
"large block size" so it is strange to speak about it in
ext2_delete_entry(). I can fix it up on commit.
Honza
> ---
> fs/ext2/dir.c | 30 +++++++++++++++++-------------
> 1 file changed, 17 insertions(+), 13 deletions(-)
>
> diff --git a/fs/ext2/dir.c b/fs/ext2/dir.c
> index 2fc910e99234..7e75cfaa709c 100644
> --- a/fs/ext2/dir.c
> +++ b/fs/ext2/dir.c
> @@ -586,16 +586,20 @@ int ext2_add_link (struct dentry *dentry, struct inode *inode)
> */
> int ext2_delete_entry(struct ext2_dir_entry_2 *dir, struct page *page)
> {
> - struct inode *inode = page->mapping->host;
> - char *kaddr = (char *)((unsigned long)dir & PAGE_MASK);
> - unsigned from = offset_in_page(dir) & ~(ext2_chunk_size(inode)-1);
> - unsigned to = offset_in_page(dir) +
> - ext2_rec_len_from_disk(dir->rec_len);
> + struct folio *folio = page_folio(page);
> + struct inode *inode = folio->mapping->host;
> + size_t from, to;
> + char *kaddr;
> loff_t pos;
> - ext2_dirent *pde = NULL;
> - ext2_dirent *de = (ext2_dirent *)(kaddr + from);
> + ext2_dirent *de, *pde = NULL;
> int err;
>
> + from = offset_in_folio(folio, dir);
> + to = from + ext2_rec_len_from_disk(dir->rec_len);
> + kaddr = (char *)dir - from;
> + from &= ~(ext2_chunk_size(inode)-1);
> + de = (ext2_dirent *)(kaddr + from);
> +
> while ((char*)de < (char*)dir) {
> if (de->rec_len == 0) {
> ext2_error(inode->i_sb, __func__,
> @@ -606,18 +610,18 @@ int ext2_delete_entry(struct ext2_dir_entry_2 *dir, struct page *page)
> de = ext2_next_entry(de);
> }
> if (pde)
> - from = offset_in_page(pde);
> - pos = page_offset(page) + from;
> - lock_page(page);
> - err = ext2_prepare_chunk(page, pos, to - from);
> + from = offset_in_folio(folio, pde);
> + pos = folio_pos(folio) + from;
> + folio_lock(folio);
> + err = ext2_prepare_chunk(&folio->page, pos, to - from);
> if (err) {
> - unlock_page(page);
> + folio_unlock(folio);
> return err;
> }
> if (pde)
> pde->rec_len = ext2_rec_len_to_disk(to - from);
> dir->inode = 0;
> - ext2_commit_chunk(page, pos, to - from);
> + ext2_commit_chunk(&folio->page, pos, to - from);
> inode->i_mtime = inode_set_ctime_current(inode);
> EXT2_I(inode)->i_flags &= ~EXT2_BTREE_FL;
> mark_inode_dirty(inode);
> --
> 2.40.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2023-10-25 18:17 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-21 20:07 [PATCH 01/10] highmem: Add folio_release_kmap() Matthew Wilcox (Oracle)
2023-09-21 20:07 ` [PATCH 02/10] ext2: Convert ext2_check_page to ext2_check_folio Matthew Wilcox (Oracle)
2023-10-03 10:40 ` Jan Kara
2023-10-03 10:52 ` Jan Kara
2023-10-05 18:27 ` Matthew Wilcox
2023-10-03 11:02 ` Jan Kara
2023-09-21 20:07 ` [PATCH 03/10] ext2: Add ext2_get_folio() Matthew Wilcox (Oracle)
2023-09-21 20:07 ` [PATCH 04/10] ext2: Convert ext2_readdir to use a folio Matthew Wilcox (Oracle)
2023-09-21 20:07 ` [PATCH 05/10] ext2: Convert ext2_add_link() " Matthew Wilcox (Oracle)
2023-09-21 20:07 ` [PATCH 06/10] ext2: Convert ext2_empty_dir() " Matthew Wilcox (Oracle)
2023-09-21 20:07 ` [PATCH 07/10] ext2: Handle large block size directories in ext2_delete_entry() Matthew Wilcox (Oracle)
2023-10-25 18:17 ` Jan Kara [this message]
2023-09-21 20:07 ` [PATCH 08/10] ext2: Convert ext2_unlink() and ext2_rename() to use folios Matthew Wilcox (Oracle)
2023-10-25 18:20 ` Jan Kara
2023-09-21 20:07 ` [PATCH 09/10] ext2: Convert ext2_make_empty() to use a folio Matthew Wilcox (Oracle)
2023-10-03 10:41 ` [PATCH 01/10] highmem: Add folio_release_kmap() Jan Kara
2023-10-03 11:55 ` Matthew Wilcox
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=20231025181750.i2ibf27imrmpkqnt@quack3 \
--to=jack@suse.cz \
--cc=fmdefrancesco@gmail.com \
--cc=jack@suse.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox