From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
ntfs3@lists.linux.dev, linux-fsdevel@vger.kernel.org
Subject: [PATCH 06/10] ntfs3: Convert attr_make_nonresident to use a folio
Date: Wed, 17 Apr 2024 18:09:34 +0100 [thread overview]
Message-ID: <20240417170941.797116-7-willy@infradead.org> (raw)
In-Reply-To: <20240417170941.797116-1-willy@infradead.org>
Fetch a folio from the page cache instead of a page and operate on it.
Take advantage of the new helpers to avoid handling highmem ourselves,
and combine the uptodate + unlock operations into folio_end_read().
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ntfs3/attrib.c | 26 ++++++++++++--------------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 64b526fd2dbc..1972213a663e 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -285,22 +285,20 @@ int attr_make_nonresident(struct ntfs_inode *ni, struct ATTRIB *attr,
if (err)
goto out2;
} else if (!page) {
- char *kaddr;
-
- page = grab_cache_page(ni->vfs_inode.i_mapping, 0);
- if (!page) {
- err = -ENOMEM;
+ struct address_space *mapping = ni->vfs_inode.i_mapping;
+ struct folio *folio;
+
+ folio = __filemap_get_folio(mapping, 0,
+ FGP_LOCK | FGP_ACCESSED | FGP_CREAT,
+ mapping_gfp_mask(mapping));
+ if (IS_ERR(folio)) {
+ err = PTR_ERR(folio);
goto out2;
}
- kaddr = kmap_atomic(page);
- memcpy(kaddr, data, rsize);
- memset(kaddr + rsize, 0, PAGE_SIZE - rsize);
- kunmap_atomic(kaddr);
- flush_dcache_page(page);
- SetPageUptodate(page);
- set_page_dirty(page);
- unlock_page(page);
- put_page(page);
+ folio_fill_tail(folio, 0, data, rsize);
+ folio_mark_dirty(folio);
+ folio_end_read(folio, true);
+ folio_put(folio);
}
}
--
2.43.0
next prev parent reply other threads:[~2024-04-17 17:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-17 17:09 [PATCH 00/10] ntfs3: Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 01/10] ntfs3: Convert ntfs_read_folio to use a folio Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 02/10] ntfs3: Convert ntfs_write_begin " Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 03/10] ntfs3: Convert attr_data_read_resident() to take " Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 04/10] ntfs3: Convert ntfs_write_end() to work on " Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 05/10] ntfs3: Convert attr_data_write_resident to use " Matthew Wilcox (Oracle)
2024-04-17 17:09 ` Matthew Wilcox (Oracle) [this message]
2024-04-17 17:09 ` [PATCH 07/10] ntfs3: Convert reading $AttrDef to use folios Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 08/10] ntfs3: Use a folio to read UpCase Matthew Wilcox (Oracle)
2024-04-17 17:32 ` Matthew Wilcox
2024-04-19 0:30 ` kernel test robot
2024-04-19 1:12 ` kernel test robot
2024-04-17 17:09 ` [PATCH 09/10] ntfs3: Remove inode_write_data() Matthew Wilcox (Oracle)
2024-04-17 17:09 ` [PATCH 10/10] ntfs3: Remove ntfs_map_page and ntfs_unmap_page Matthew Wilcox (Oracle)
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=20240417170941.797116-7-willy@infradead.org \
--to=willy@infradead.org \
--cc=almaz.alexandrovich@paragon-software.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=ntfs3@lists.linux.dev \
/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).