From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Ilya Dryomov <idryomov@gmail.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
ceph-devel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
David Howells <dhowells@redhat.com>
Subject: [PATCH v2 7/7] ceph: Use a folio in ceph_writepages_start()
Date: Fri, 14 Feb 2025 15:57:09 +0000 [thread overview]
Message-ID: <20250214155710.2790505-8-willy@infradead.org> (raw)
In-Reply-To: <20250214155710.2790505-1-willy@infradead.org>
We currently convert the folio returned from filemap_get_folios_tag()
to a page and operate on that page. Remove this and operate on the
folio. Removes a lot of calls to obsolete functions and references
to page->index and page->mapping.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ceph/addr.c | 63 +++++++++++++++++++++++++-------------------------
1 file changed, 31 insertions(+), 32 deletions(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 822485db234e..a97a3eee426b 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -1025,7 +1025,7 @@ static int ceph_writepages_start(struct address_space *mapping,
int num_ops = 0, op_idx;
unsigned i, nr_folios, max_pages, locked_pages = 0;
struct page **pages = NULL, **data_pages;
- struct page *page;
+ struct folio *folio;
pgoff_t strip_unit_end = 0;
u64 offset = 0, len = 0;
bool from_pool = false;
@@ -1039,24 +1039,23 @@ static int ceph_writepages_start(struct address_space *mapping,
if (!nr_folios && !locked_pages)
break;
for (i = 0; i < nr_folios && locked_pages < max_pages; i++) {
- struct folio *folio = fbatch.folios[i];
+ folio = fbatch.folios[i];
- page = &folio->page;
- doutc(cl, "? %p idx %lu\n", page, page->index);
+ doutc(cl, "? %p idx %lu\n", folio, folio->index);
if (locked_pages == 0)
- lock_page(page); /* first page */
- else if (!trylock_page(page))
+ folio_lock(folio); /* first page */
+ else if (!folio_trylock(folio))
break;
/* only dirty pages, or our accounting breaks */
- if (unlikely(!PageDirty(page)) ||
- unlikely(page->mapping != mapping)) {
- doutc(cl, "!dirty or !mapping %p\n", page);
- unlock_page(page);
+ if (unlikely(!folio_test_dirty(folio)) ||
+ unlikely(folio->mapping != mapping)) {
+ doutc(cl, "!dirty or !mapping %p\n", folio);
+ folio_unlock(folio);
continue;
}
/* only if matching snap context */
- pgsnapc = page_snap_context(page);
+ pgsnapc = page_snap_context(&folio->page);
if (pgsnapc != snapc) {
doutc(cl, "page snapc %p %lld != oldest %p %lld\n",
pgsnapc, pgsnapc->seq, snapc, snapc->seq);
@@ -1064,10 +1063,10 @@ static int ceph_writepages_start(struct address_space *mapping,
!ceph_wbc.head_snapc &&
wbc->sync_mode != WB_SYNC_NONE)
should_loop = true;
- unlock_page(page);
+ folio_unlock(folio);
continue;
}
- if (page_offset(page) >= ceph_wbc.i_size) {
+ if (folio_pos(folio) >= ceph_wbc.i_size) {
doutc(cl, "folio at %lu beyond eof %llu\n",
folio->index, ceph_wbc.i_size);
if ((ceph_wbc.size_stable ||
@@ -1078,9 +1077,9 @@ static int ceph_writepages_start(struct address_space *mapping,
folio_unlock(folio);
continue;
}
- if (strip_unit_end && (page->index > strip_unit_end)) {
- doutc(cl, "end of strip unit %p\n", page);
- unlock_page(page);
+ if (strip_unit_end && (folio->index > strip_unit_end)) {
+ doutc(cl, "end of strip unit %p\n", folio);
+ folio_unlock(folio);
break;
}
if (folio_test_writeback(folio) ||
@@ -1095,9 +1094,9 @@ static int ceph_writepages_start(struct address_space *mapping,
folio_wait_private_2(folio); /* [DEPRECATED] */
}
- if (!clear_page_dirty_for_io(page)) {
- doutc(cl, "%p !clear_page_dirty_for_io\n", page);
- unlock_page(page);
+ if (!folio_clear_dirty_for_io(folio)) {
+ doutc(cl, "%p !clear_page_dirty_for_io\n", folio);
+ folio_unlock(folio);
continue;
}
@@ -1113,7 +1112,7 @@ static int ceph_writepages_start(struct address_space *mapping,
u32 xlen;
/* prepare async write request */
- offset = (u64)page_offset(page);
+ offset = folio_pos(folio);
ceph_calc_file_object_mapping(&ci->i_layout,
offset, wsize,
&objnum, &objoff,
@@ -1121,7 +1120,7 @@ static int ceph_writepages_start(struct address_space *mapping,
len = xlen;
num_ops = 1;
- strip_unit_end = page->index +
+ strip_unit_end = folio->index +
((len - 1) >> PAGE_SHIFT);
BUG_ON(pages);
@@ -1136,23 +1135,23 @@ static int ceph_writepages_start(struct address_space *mapping,
}
len = 0;
- } else if (page->index !=
+ } else if (folio->index !=
(offset + len) >> PAGE_SHIFT) {
if (num_ops >= (from_pool ? CEPH_OSD_SLAB_OPS :
CEPH_OSD_MAX_OPS)) {
- redirty_page_for_writepage(wbc, page);
- unlock_page(page);
+ folio_redirty_for_writepage(wbc, folio);
+ folio_unlock(folio);
break;
}
num_ops++;
- offset = (u64)page_offset(page);
+ offset = folio_pos(folio);
len = 0;
}
/* note position of first page in fbatch */
doutc(cl, "%llx.%llx will write page %p idx %lu\n",
- ceph_vinop(inode), page, page->index);
+ ceph_vinop(inode), folio, folio->index);
if (atomic_long_inc_return(&fsc->writeback_count) >
CONGESTION_ON_THRESH(
@@ -1161,7 +1160,7 @@ static int ceph_writepages_start(struct address_space *mapping,
if (IS_ENCRYPTED(inode)) {
pages[locked_pages] =
- fscrypt_encrypt_pagecache_blocks(page,
+ fscrypt_encrypt_pagecache_blocks(&folio->page,
PAGE_SIZE, 0,
locked_pages ? GFP_NOWAIT : GFP_NOFS);
if (IS_ERR(pages[locked_pages])) {
@@ -1172,17 +1171,17 @@ static int ceph_writepages_start(struct address_space *mapping,
/* better not fail on first page! */
BUG_ON(locked_pages == 0);
pages[locked_pages] = NULL;
- redirty_page_for_writepage(wbc, page);
- unlock_page(page);
+ folio_redirty_for_writepage(wbc, folio);
+ folio_unlock(folio);
break;
}
++locked_pages;
} else {
- pages[locked_pages++] = page;
+ pages[locked_pages++] = &folio->page;
}
fbatch.folios[i] = NULL;
- len += thp_size(page);
+ len += folio_size(folio);
}
/* did we get anything? */
@@ -1289,7 +1288,7 @@ static int ceph_writepages_start(struct address_space *mapping,
/* writepages_finish() clears writeback pages
* according to the data length, so make sure
* data length covers all locked pages */
- u64 min_len = len + 1 - thp_size(page);
+ u64 min_len = len + 1 - folio_size(folio);
len = get_writepages_data_length(inode, pages[i - 1],
offset);
len = max(len, min_len);
--
2.47.2
prev parent reply other threads:[~2025-02-14 15:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 15:57 [PATCH v2 0/7] Remove accesses to page->index from ceph Matthew Wilcox (Oracle)
2025-02-14 15:57 ` [PATCH v2 1/7] ceph: Do not look at the index of an encrypted page Matthew Wilcox (Oracle)
2025-02-14 15:57 ` [PATCH v2 2/7] ceph: Remove ceph_writepage() Matthew Wilcox (Oracle)
2025-02-14 15:57 ` [PATCH v2 3/7] ceph: Use a folio in ceph_page_mkwrite() Matthew Wilcox (Oracle)
2025-02-14 19:05 ` Viacheslav Dubeyko
2025-02-14 15:57 ` [PATCH v2 4/7] ceph: Convert ceph_find_incompatible() to take a folio Matthew Wilcox (Oracle)
2025-02-14 15:57 ` [PATCH v2 5/7] ceph: Convert ceph_readdir_cache_control to store " Matthew Wilcox (Oracle)
2025-02-14 19:10 ` Viacheslav Dubeyko
2025-02-14 19:34 ` Matthew Wilcox
2025-02-14 19:38 ` Viacheslav Dubeyko
2025-02-14 15:57 ` [PATCH v2 6/7] ceph: Convert writepage_nounlock() to write_folio_nounlock() Matthew Wilcox (Oracle)
2025-02-14 15:57 ` Matthew Wilcox (Oracle) [this message]
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=20250214155710.2790505-8-willy@infradead.org \
--to=willy@infradead.org \
--cc=ceph-devel@vger.kernel.org \
--cc=dhowells@redhat.com \
--cc=idryomov@gmail.com \
--cc=linux-fsdevel@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).