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 03/10] ntfs3: Convert attr_data_read_resident() to take a folio
Date: Wed, 17 Apr 2024 18:09:31 +0100 [thread overview]
Message-ID: <20240417170941.797116-4-willy@infradead.org> (raw)
In-Reply-To: <20240417170941.797116-1-willy@infradead.org>
Now that all three callers have a folio, pass it in and use
folio_fill_tail() to do the hard work of filling the folio.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
fs/ntfs3/attrib.c | 27 +++++++++------------------
fs/ntfs3/inode.c | 6 +++---
fs/ntfs3/ntfs_fs.h | 2 +-
3 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 7aadf5010999..11f90b140122 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -1223,11 +1223,12 @@ int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
goto out;
}
-int attr_data_read_resident(struct ntfs_inode *ni, struct page *page)
+int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio)
{
u64 vbo;
struct ATTRIB *attr;
u32 data_size;
+ size_t len;
attr = ni_find_attr(ni, NULL, NULL, ATTR_DATA, NULL, 0, NULL, NULL);
if (!attr)
@@ -1236,25 +1237,15 @@ int attr_data_read_resident(struct ntfs_inode *ni, struct page *page)
if (attr->non_res)
return E_NTFS_NONRESIDENT;
- vbo = page->index << PAGE_SHIFT;
+ vbo = folio->index << PAGE_SHIFT;
data_size = le32_to_cpu(attr->res.data_size);
- if (vbo < data_size) {
- const char *data = resident_data(attr);
- char *kaddr = kmap_atomic(page);
- u32 use = data_size - vbo;
-
- if (use > PAGE_SIZE)
- use = PAGE_SIZE;
+ if (vbo > data_size)
+ len = 0;
+ else
+ len = min(data_size - vbo, folio_size(folio));
- memcpy(kaddr, data + vbo, use);
- memset(kaddr + use, 0, PAGE_SIZE - use);
- kunmap_atomic(kaddr);
- flush_dcache_page(page);
- SetPageUptodate(page);
- } else if (!PageUptodate(page)) {
- zero_user_segment(page, 0, PAGE_SIZE);
- SetPageUptodate(page);
- }
+ folio_fill_tail(folio, 0, resident_data(attr) + vbo, len);
+ folio_mark_uptodate(folio);
return 0;
}
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 25be12e68d6e..1eb11c3b480d 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -571,7 +571,7 @@ static noinline int ntfs_get_block_vbo(struct inode *inode, u64 vbo,
if (is_resident(ni)) {
ni_lock(ni);
- err = attr_data_read_resident(ni, &folio->page);
+ err = attr_data_read_resident(ni, folio);
ni_unlock(ni);
if (!err)
@@ -705,7 +705,7 @@ static int ntfs_read_folio(struct file *file, struct folio *folio)
if (is_resident(ni)) {
ni_lock(ni);
- err = attr_data_read_resident(ni, &folio->page);
+ err = attr_data_read_resident(ni, folio);
ni_unlock(ni);
if (err != E_NTFS_NONRESIDENT) {
folio_unlock(folio);
@@ -911,7 +911,7 @@ int ntfs_write_begin(struct file *file, struct address_space *mapping,
}
ni_lock(ni);
- err = attr_data_read_resident(ni, &folio->page);
+ err = attr_data_read_resident(ni, folio);
ni_unlock(ni);
if (!err) {
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index ea5b5e814e63..0b518bf8182a 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -434,7 +434,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type,
struct ATTRIB **ret);
int attr_data_get_block(struct ntfs_inode *ni, CLST vcn, CLST clen, CLST *lcn,
CLST *len, bool *new, bool zero);
-int attr_data_read_resident(struct ntfs_inode *ni, struct page *page);
+int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio);
int attr_data_write_resident(struct ntfs_inode *ni, struct page *page);
int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type,
const __le16 *name, u8 name_len, struct runs_tree *run,
--
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 ` Matthew Wilcox (Oracle) [this message]
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 ` [PATCH 06/10] ntfs3: Convert attr_make_nonresident " Matthew Wilcox (Oracle)
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-4-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).