All of lore.kernel.org
 help / color / mirror / Atom feed
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 v2 05/11] ntfs3: Convert attr_data_write_resident to use a folio
Date: Mon, 22 Apr 2024 20:31:55 +0100	[thread overview]
Message-ID: <20240422193203.3534108-6-willy@infradead.org> (raw)
In-Reply-To: <20240422193203.3534108-1-willy@infradead.org>

Now that both callers of attr_data_write_resident() have a folio, pass
it in and use memcpy_from_folio() to handle all the gnarly highmem
multi-page problems.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 fs/ntfs3/attrib.c  | 12 ++++--------
 fs/ntfs3/inode.c   |  4 ++--
 fs/ntfs3/ntfs_fs.h |  2 +-
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c
index 676489b05a1f..02fa3245850a 100644
--- a/fs/ntfs3/attrib.c
+++ b/fs/ntfs3/attrib.c
@@ -1267,7 +1267,7 @@ int attr_data_read_resident(struct ntfs_inode *ni, struct folio *folio)
 	return 0;
 }
 
-int attr_data_write_resident(struct ntfs_inode *ni, struct page *page)
+int attr_data_write_resident(struct ntfs_inode *ni, struct folio *folio)
 {
 	u64 vbo;
 	struct mft_inode *mi;
@@ -1283,17 +1283,13 @@ int attr_data_write_resident(struct ntfs_inode *ni, struct page *page)
 		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) {
 		char *data = resident_data(attr);
-		char *kaddr = kmap_atomic(page);
-		u32 use = data_size - vbo;
+		size_t len = min(data_size - vbo, folio_size(folio));
 
-		if (use > PAGE_SIZE)
-			use = PAGE_SIZE;
-		memcpy(data + vbo, kaddr, use);
-		kunmap_atomic(kaddr);
+		memcpy_from_folio(data + vbo, folio, 0, len);
 		mi->dirty = true;
 	}
 	ni->i_valid = data_size;
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index e9c1cba44741..69dd51d7cf83 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -871,7 +871,7 @@ static int ntfs_resident_writepage(struct folio *folio,
 		return -EIO;
 
 	ni_lock(ni);
-	ret = attr_data_write_resident(ni, &folio->page);
+	ret = attr_data_write_resident(ni, folio);
 	ni_unlock(ni);
 
 	if (ret != E_NTFS_NONRESIDENT)
@@ -959,7 +959,7 @@ int ntfs_write_end(struct file *file, struct address_space *mapping, loff_t pos,
 
 	if (is_resident(ni)) {
 		ni_lock(ni);
-		err = attr_data_write_resident(ni, page);
+		err = attr_data_write_resident(ni, folio);
 		ni_unlock(ni);
 		if (!err) {
 			struct buffer_head *head = folio_buffers(folio);
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index bd8c9b520269..275def366443 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -446,7 +446,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type,
 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 folio *folio);
-int attr_data_write_resident(struct ntfs_inode *ni, struct page *page);
+int attr_data_write_resident(struct ntfs_inode *ni, struct folio *folio);
 int attr_load_runs_vcn(struct ntfs_inode *ni, enum ATTR_TYPE type,
 		       const __le16 *name, u8 name_len, struct runs_tree *run,
 		       CLST vcn);
-- 
2.43.0


  parent reply	other threads:[~2024-04-22 19:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 19:31 [PATCH v2 00/11] Convert (most of) ntfs3 to use folios Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 01/11] ntfs3: Convert ntfs_read_folio to use a folio Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 02/11] ntfs3: Convert ntfs_write_begin " Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 03/11] ntfs3: Convert attr_data_read_resident() to take " Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 04/11] ntfs3: Convert ntfs_write_end() to work on " Matthew Wilcox (Oracle)
2024-04-22 19:31 ` Matthew Wilcox (Oracle) [this message]
2024-04-22 19:31 ` [PATCH v2 06/11] ntfs3: Convert attr_make_nonresident to use " Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 07/11] ntfs3: Convert inode_read_data() to use folios Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 08/11] ntfs3: Remove calls to set/clear the error flag Matthew Wilcox (Oracle)
2024-04-22 19:31 ` [PATCH v2 09/11] ntfs3: Convert attr_wof_frame_info() to use a folio Matthew Wilcox (Oracle)
2024-04-22 19:32 ` [PATCH v2 10/11] ntfs3: Convert ntfs_get_frame_pages() " Matthew Wilcox (Oracle)
2024-04-22 19:32 ` [PATCH v2 11/11] ntfs3: Convert ni_readpage_cmpr() to take " Matthew Wilcox (Oracle)
2024-04-23 14:51 ` [PATCH v2 00/11] Convert (most of) ntfs3 to use folios Konstantin Komarov

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=20240422193203.3534108-6-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 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.