From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
akpm <akpm@linux-foundation.org>
Cc: Mark Tinguely <mark.tinguely@oracle.com>, ocfs2-devel@lists.linux.dev
Subject: Re: [PATCH 03/23] ocfs2: Convert w_target_page to w_target_folio
Date: Sat, 14 Dec 2024 20:29:03 +0800 [thread overview]
Message-ID: <d2c052eb-d78b-4e47-b85b-a59d724315ce@linux.alibaba.com> (raw)
In-Reply-To: <20241205171653.3179945-4-willy@infradead.org>
On 2024/12/6 01:16, Matthew Wilcox (Oracle) wrote:
> From: Mark Tinguely <mark.tinguely@oracle.com>
>
> Pass a folio around instead of a page. Saves a few hidden calls to
> compound_head() and removes a call to kmap_atomic().
>
> Signed-off-by: Mark Tinguely <mark.tinguely@oracle.com>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Looks good.
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
> ---
> fs/ocfs2/aops.c | 63 ++++++++++++++++++++++++-------------------------
> 1 file changed, 31 insertions(+), 32 deletions(-)
>
> diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
> index db72b3e924b3..5f7a33335385 100644
> --- a/fs/ocfs2/aops.c
> +++ b/fs/ocfs2/aops.c
> @@ -731,22 +731,22 @@ struct ocfs2_write_ctxt {
> /*
> * Pages involved in this write.
> *
> - * w_target_page is the page being written to by the user.
> + * w_target_folio is the folio being written to by the user.
> *
> * w_pages is an array of pages which always contains
> - * w_target_page, and in the case of an allocating write with
> + * w_target_folio, and in the case of an allocating write with
> * page_size < cluster size, it will contain zero'd and mapped
> - * pages adjacent to w_target_page which need to be written
> + * pages adjacent to w_target_folio which need to be written
> * out in so that future reads from that region will get
> * zero's.
> */
> unsigned int w_num_pages;
> struct page *w_pages[OCFS2_MAX_CTXT_PAGES];
> - struct page *w_target_page;
> + struct folio *w_target_folio;
>
> /*
> * w_target_locked is used for page_mkwrite path indicating no unlocking
> - * against w_target_page in ocfs2_write_end_nolock.
> + * against w_target_folio in ocfs2_write_end_nolock.
> */
> unsigned int w_target_locked:1;
>
> @@ -791,18 +791,18 @@ static void ocfs2_unlock_pages(struct ocfs2_write_ctxt *wc)
> /*
> * w_target_locked is only set to true in the page_mkwrite() case.
> * The intent is to allow us to lock the target page from write_begin()
> - * to write_end(). The caller must hold a ref on w_target_page.
> + * to write_end(). The caller must hold a ref on w_target_folio.
> */
> if (wc->w_target_locked) {
> - BUG_ON(!wc->w_target_page);
> + BUG_ON(!wc->w_target_folio);
> for (i = 0; i < wc->w_num_pages; i++) {
> - if (wc->w_target_page == wc->w_pages[i]) {
> + if (&wc->w_target_folio->page == wc->w_pages[i]) {
> wc->w_pages[i] = NULL;
> break;
> }
> }
> - mark_page_accessed(wc->w_target_page);
> - put_page(wc->w_target_page);
> + folio_mark_accessed(wc->w_target_folio);
> + folio_put(wc->w_target_folio);
> }
> ocfs2_unlock_and_free_pages(wc->w_pages, wc->w_num_pages);
> }
> @@ -869,8 +869,9 @@ static int ocfs2_alloc_write_ctxt(struct ocfs2_write_ctxt **wcp,
> * and dirty so they'll be written out (in order to prevent uninitialised
> * block data from leaking). And clear the new bit.
> */
> -static void ocfs2_zero_new_buffers(struct page *page, unsigned from, unsigned to)
> +static void ocfs2_zero_new_buffers(struct folio *folio, unsigned from, unsigned to)
> {
> + struct page *page = &folio->page;
> unsigned int block_start, block_end;
> struct buffer_head *head, *bh;
>
> @@ -918,8 +919,8 @@ static void ocfs2_write_failure(struct inode *inode,
> to = user_pos + user_len;
> struct page *tmppage;
>
> - if (wc->w_target_page)
> - ocfs2_zero_new_buffers(wc->w_target_page, from, to);
> + if (wc->w_target_folio)
> + ocfs2_zero_new_buffers(wc->w_target_folio, from, to);
>
> for(i = 0; i < wc->w_num_pages; i++) {
> tmppage = wc->w_pages[i];
> @@ -954,7 +955,7 @@ static int ocfs2_prepare_page_for_write(struct inode *inode, u64 *p_blkno,
> new = new | ((i_size_read(inode) <= page_offset(page)) &&
> (page_offset(page) <= user_pos));
>
> - if (page == wc->w_target_page) {
> + if (page == &wc->w_target_folio->page) {
> map_from = user_pos & (PAGE_SIZE - 1);
> map_to = map_from + user_len;
>
> @@ -1097,7 +1098,7 @@ static int ocfs2_grab_pages_for_write(struct address_space *mapping,
> wait_for_stable_page(wc->w_pages[i]);
>
> if (index == target_index)
> - wc->w_target_page = wc->w_pages[i];
> + wc->w_target_folio = page_folio(wc->w_pages[i]);
> }
> out:
> if (ret)
> @@ -1494,7 +1495,8 @@ static int ocfs2_write_begin_inline(struct address_space *mapping,
> * If we don't set w_num_pages then this page won't get unlocked
> * and freed on cleanup of the write context.
> */
> - wc->w_pages[0] = wc->w_target_page = page;
> + wc->w_target_folio = page_folio(page);
> + wc->w_pages[0] = page;
> wc->w_num_pages = 1;
>
> ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), wc->w_di_bh,
> @@ -1803,7 +1805,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
> * the operation.
> */
> if (type == OCFS2_WRITE_MMAP && ret == -EAGAIN) {
> - BUG_ON(wc->w_target_page);
> + BUG_ON(wc->w_target_folio);
> ret = 0;
> goto out_quota;
> }
> @@ -1826,7 +1828,7 @@ int ocfs2_write_begin_nolock(struct address_space *mapping,
>
> success:
> if (foliop)
> - *foliop = page_folio(wc->w_target_page);
> + *foliop = wc->w_target_folio;
> *fsdata = wc;
> return 0;
> out_quota:
> @@ -1924,18 +1926,15 @@ static void ocfs2_write_end_inline(struct inode *inode, loff_t pos,
> struct ocfs2_dinode *di,
> struct ocfs2_write_ctxt *wc)
> {
> - void *kaddr;
> -
> if (unlikely(*copied < len)) {
> - if (!PageUptodate(wc->w_target_page)) {
> + if (!folio_test_uptodate(wc->w_target_folio)) {
> *copied = 0;
> return;
> }
> }
>
> - kaddr = kmap_atomic(wc->w_target_page);
> - memcpy(di->id2.i_data.id_data + pos, kaddr + pos, *copied);
> - kunmap_atomic(kaddr);
> + memcpy_from_folio(di->id2.i_data.id_data + pos, wc->w_target_folio,
> + pos, *copied);
>
> trace_ocfs2_write_end_inline(
> (unsigned long long)OCFS2_I(inode)->ip_blkno,
> @@ -1973,15 +1972,15 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
> goto out_write_size;
> }
>
> - if (unlikely(copied < len) && wc->w_target_page) {
> + if (unlikely(copied < len) && wc->w_target_folio) {
> loff_t new_isize;
>
> - if (!PageUptodate(wc->w_target_page))
> + if (!folio_test_uptodate(wc->w_target_folio))
> copied = 0;
>
> new_isize = max_t(loff_t, i_size_read(inode), pos + copied);
> - if (new_isize > page_offset(wc->w_target_page))
> - ocfs2_zero_new_buffers(wc->w_target_page, start+copied,
> + if (new_isize > folio_pos(wc->w_target_folio))
> + ocfs2_zero_new_buffers(wc->w_target_folio, start+copied,
> start+len);
> else {
> /*
> @@ -1991,12 +1990,12 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
> * put page & buffer dirty bits into inconsistent
> * state.
> */
> - block_invalidate_folio(page_folio(wc->w_target_page),
> + block_invalidate_folio(wc->w_target_folio,
> 0, PAGE_SIZE);
> }
> }
> - if (wc->w_target_page)
> - flush_dcache_page(wc->w_target_page);
> + if (wc->w_target_folio)
> + flush_dcache_folio(wc->w_target_folio);
>
> for(i = 0; i < wc->w_num_pages; i++) {
> tmppage = wc->w_pages[i];
> @@ -2005,7 +2004,7 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
> if (tmppage == NULL)
> continue;
>
> - if (tmppage == wc->w_target_page) {
> + if (tmppage == &wc->w_target_folio->page) {
> from = wc->w_target_from;
> to = wc->w_target_to;
>
next prev parent reply other threads:[~2024-12-14 12:29 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-05 17:16 [PATCH 00/23] Convert ocfs2 to use folios Matthew Wilcox (Oracle)
2024-12-05 17:16 ` [PATCH 01/23] ocfs2: Handle a symlink read error correctly Matthew Wilcox (Oracle)
2024-12-14 12:03 ` Joseph Qi
2024-12-14 15:20 ` Matthew Wilcox
2024-12-14 15:45 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 02/23] ocfs2: Convert ocfs2_page_mkwrite() to use a folio Matthew Wilcox (Oracle)
2024-12-14 12:20 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 03/23] ocfs2: Convert w_target_page to w_target_folio Matthew Wilcox (Oracle)
2024-12-14 12:29 ` Joseph Qi [this message]
2024-12-05 17:16 ` [PATCH 04/23] ocfs2: Use a folio in ocfs2_zero_new_buffers() Matthew Wilcox (Oracle)
2024-12-14 14:01 ` Joseph Qi
2024-12-14 15:32 ` Matthew Wilcox
2024-12-14 15:46 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 05/23] ocfs2: Use a folio in ocfs2_write_begin_inline() Matthew Wilcox (Oracle)
2024-12-14 14:04 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 06/23] ocfs2: Pass mmap_folio around instead of mmap_page Matthew Wilcox (Oracle)
2024-12-14 14:08 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 07/23] ocfs2: Convert ocfs2_readpage_inline() to take a folio Matthew Wilcox (Oracle)
2024-12-14 14:08 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 08/23] ocfs2: Convert ocfs2_inode_lock_with_page() to ocfs2_inode_lock_with_folio() Matthew Wilcox (Oracle)
2024-12-14 14:10 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 09/23] ocfs2: Convert w_pages to w_folios Matthew Wilcox (Oracle)
2024-12-14 14:15 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 10/23] ocfs2: Convert ocfs2_write_failure() to use a folio Matthew Wilcox (Oracle)
2024-12-14 14:16 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 11/23] ocfs2: Use a folio in ocfs2_write_end_nolock() Matthew Wilcox (Oracle)
2024-12-14 14:18 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 12/23] ocfs2: Use a folio in ocfs2_prepare_page_for_write() Matthew Wilcox (Oracle)
2024-12-14 14:26 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 13/23] ocfs2: Use a folio in ocfs2_map_and_dirty_page() Matthew Wilcox (Oracle)
2024-12-14 14:27 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 14/23] ocfs2: Convert ocfs2_map_page_blocks() to ocfs2_map_folio_blocks() Matthew Wilcox (Oracle)
2024-12-14 14:28 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 15/23] ocfs2: Convert ocfs2_clear_page_regions() to ocfs2_clear_folio_regions() Matthew Wilcox (Oracle)
2024-12-14 14:29 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 16/23] ocfs2: Use an array of folios instead of an array of pages Matthew Wilcox (Oracle)
2024-12-14 14:34 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 17/23] ocfs2: Convert ocfs2_duplicate_clusters_by_page() to use a folio Matthew Wilcox (Oracle)
2024-12-14 14:36 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 18/23] ocfs2: Convert ocfs2_map_and_dirty_page() to ocfs2_map_and_dirty_folio() Matthew Wilcox (Oracle)
2024-12-14 14:36 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 19/23] ocfs2: Convert ocfs2_read_inline_data() to take a folio Matthew Wilcox (Oracle)
2024-12-14 14:39 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 20/23] ocfs2: Use a folio in ocfs2_fast_symlink_read_folio() Matthew Wilcox (Oracle)
2024-12-14 14:43 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 21/23] ocfs2: Remove ocfs2_start_walk_page_trans() prototype Matthew Wilcox (Oracle)
2024-12-14 14:44 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 22/23] ocfs2: Support large folios in ocfs2_zero_cluster_folios() Matthew Wilcox (Oracle)
2024-12-14 14:50 ` Joseph Qi
2024-12-05 17:16 ` [PATCH 23/23] ocfs2: Support large folios in ocfs2_write_zero_page() Matthew Wilcox (Oracle)
2024-12-14 14:51 ` Joseph Qi
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=d2c052eb-d78b-4e47-b85b-a59d724315ce@linux.alibaba.com \
--to=joseph.qi@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=mark.tinguely@oracle.com \
--cc=ocfs2-devel@lists.linux.dev \
--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.