From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: reiserfs-devel@vger.kernel.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org,
"Fabio M. De Francesco" <fmdefrancesco@gmail.com>,
Ira Weiny <ira.weiny@intel.com>
Subject: [PATCH 7/8] reiserfs: Convert convert_tail_for_hole() to use folios
Date: Fri, 16 Dec 2022 20:53:46 +0000 [thread overview]
Message-ID: <20221216205348.3781217-8-willy@infradead.org> (raw)
In-Reply-To: <20221216205348.3781217-1-willy@infradead.org>
It's not clear to me that reiserfs will ever support large folios, but
now this function will operate correctly if they are enabled.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/reiserfs/inode.c | 45 +++++++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index b79848111957..008855ddb365 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -571,57 +571,58 @@ static int convert_tail_for_hole(struct inode *inode,
unsigned long index;
unsigned long tail_end;
unsigned long tail_start;
- struct page *tail_page;
- struct page *hole_page = bh_result->b_page;
+ struct folio *tail_folio;
+ struct folio *hole_folio = bh_result->b_folio;
int retval = 0;
if ((tail_offset & (bh_result->b_size - 1)) != 1)
return -EIO;
- /* always try to read until the end of the block */
- tail_start = tail_offset & (PAGE_SIZE - 1);
- tail_end = (tail_start | (bh_result->b_size - 1)) + 1;
-
index = tail_offset >> PAGE_SHIFT;
/*
- * hole_page can be zero in case of direct_io, we are sure
+ * hole_folio can be zero in case of direct_io, we are sure
* that we cannot get here if we write with O_DIRECT into tail page
*/
- if (!hole_page || index != hole_page->index) {
- tail_page = grab_cache_page(inode->i_mapping, index);
+ if (!hole_folio || !folio_contains(hole_folio, index)) {
+ tail_folio = __filemap_get_folio(inode->i_mapping, index,
+ FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
+ mapping_gfp_mask(inode->i_mapping));
retval = -ENOMEM;
- if (!tail_page) {
+ if (!tail_folio)
goto out;
- }
} else {
- tail_page = hole_page;
+ tail_folio = hole_folio;
}
+ /* always try to read until the end of the block */
+ tail_start = offset_in_folio(tail_folio, tail_offset);
+ tail_end = (tail_start | (bh_result->b_size - 1)) + 1;
+
/*
* we don't have to make sure the conversion did not happen while
- * we were locking the page because anyone that could convert
+ * we were locking the folio because anyone that could convert
* must first take i_mutex.
*
- * We must fix the tail page for writing because it might have buffers
+ * We must fix the tail folio for writing because it might have buffers
* that are mapped, but have a block number of 0. This indicates tail
- * data that has been read directly into the page, and
+ * data that has been read directly into the folio, and
* __block_write_begin won't trigger a get_block in this case.
*/
- fix_tail_page_for_writing(tail_page);
- retval = __reiserfs_write_begin(tail_page, tail_start,
+ fix_tail_page_for_writing(&tail_folio->page);
+ retval = __reiserfs_write_begin(&tail_folio->page, tail_start,
tail_end - tail_start);
if (retval)
goto unlock;
/* tail conversion might change the data in the page */
- flush_dcache_page(tail_page);
+ flush_dcache_folio(tail_folio);
- retval = reiserfs_commit_write(NULL, tail_page, tail_start, tail_end);
+ retval = reiserfs_commit_write(NULL, &tail_folio->page, tail_start, tail_end);
unlock:
- if (tail_page != hole_page) {
- unlock_page(tail_page);
- put_page(tail_page);
+ if (tail_folio != hole_folio) {
+ folio_unlock(tail_folio);
+ folio_put(tail_folio);
}
out:
return retval;
--
2.35.1
next prev parent reply other threads:[~2022-12-16 20:54 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-16 20:53 [PATCH 0/8] Convert reiserfs from b_page to b_folio Matthew Wilcox (Oracle)
2022-12-16 20:53 ` [PATCH 1/8] reiserfs: use b_folio instead of b_page in some obvious cases Matthew Wilcox (Oracle)
2022-12-16 20:53 ` [PATCH 2/8] reiserfs: use kmap_local_folio() in _get_block_create_0() Matthew Wilcox (Oracle)
2022-12-17 17:14 ` Ira Weiny
2022-12-17 19:07 ` Matthew Wilcox
2022-12-17 23:33 ` Ira Weiny
2022-12-19 10:42 ` Jan Kara
2022-12-16 20:53 ` [PATCH 3/8] reiserfs: Convert direct2indirect() to call folio_zero_range() Matthew Wilcox (Oracle)
2022-12-17 21:08 ` Ira Weiny
2022-12-16 20:53 ` [PATCH 4/8] reiserfs: Convert reiserfs_delete_item() to use kmap_local_folio() Matthew Wilcox (Oracle)
2022-12-17 23:44 ` Ira Weiny
2022-12-16 20:53 ` [PATCH 5/8] reiserfs: Convert do_journal_end() " Matthew Wilcox (Oracle)
2022-12-17 23:52 ` Ira Weiny
2022-12-20 9:35 ` Matthew Wilcox
2022-12-20 11:18 ` Jan Kara
2022-12-20 16:58 ` Ira Weiny
2022-12-20 18:34 ` Matthew Wilcox
2022-12-20 23:59 ` Ira Weiny
2022-12-21 19:04 ` Matthew Wilcox
2022-12-22 10:37 ` Jan Kara
2022-12-16 20:53 ` [PATCH 6/8] reiserfs: Convert map_block_for_writepage() " Matthew Wilcox (Oracle)
2022-12-18 0:02 ` Ira Weiny
2022-12-16 20:53 ` Matthew Wilcox (Oracle) [this message]
2022-12-16 20:53 ` [PATCH 8/8] reiserfs: Use flush_dcache_folio() in reiserfs_quota_write() Matthew Wilcox (Oracle)
2022-12-17 20:43 ` [PATCH 0/8] Convert reiserfs from b_page to b_folio Fabio M. De Francesco
2022-12-17 23:39 ` Ira Weiny
2022-12-18 8:09 ` Fabio M. De Francesco
2022-12-18 17:59 ` 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=20221216205348.3781217-8-willy@infradead.org \
--to=willy@infradead.org \
--cc=fmdefrancesco@gmail.com \
--cc=ira.weiny@intel.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=reiserfs-devel@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).