[PATCH] vboxsf: Convert vboxsf_write_end() to use kmap_local_folio()

Tal Zussman posted 1 patch 1 month, 3 weeks ago
fs/vboxsf/file.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] vboxsf: Convert vboxsf_write_end() to use kmap_local_folio()
Posted by Tal Zussman 1 month, 3 weeks ago
Now that vboxsf_write_end() takes a folio, convert the kmap() call to
kmap_local_folio(). This removes two instances of &folio->page as
well.

Compile-tested only.

Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
 fs/vboxsf/file.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/vboxsf/file.c b/fs/vboxsf/file.c
index 4bebd947314a..178fc74e399f 100644
--- a/fs/vboxsf/file.c
+++ b/fs/vboxsf/file.c
@@ -316,10 +316,10 @@ static int vboxsf_write_end(const struct kiocb *iocb,
 	if (!folio_test_uptodate(folio) && copied < len)
 		folio_zero_range(folio, from + copied, len - copied);
 
-	buf = kmap(&folio->page);
+	buf = kmap_local_folio(folio, 0);
 	err = vboxsf_write(sf_handle->root, sf_handle->handle,
 			   pos, &nwritten, buf + from);
-	kunmap(&folio->page);
+	kunmap_local(buf);
 
 	if (err) {
 		nwritten = 0;

---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250811-vboxsf_folio-343a7cd9e9b2

Best regards,
-- 
Tal Zussman <tz2294@columbia.edu>
Re: [PATCH] vboxsf: Convert vboxsf_write_end() to use kmap_local_folio()
Posted by Matthew Wilcox 1 month, 3 weeks ago
On Mon, Aug 11, 2025 at 05:42:00PM -0400, Tal Zussman wrote:
> Now that vboxsf_write_end() takes a folio, convert the kmap() call to
> kmap_local_folio(). This removes two instances of &folio->page as
> well.

Oh; something I should have said.  If you have an interest in vboxsf,
it looks like there's a communication protocol that lets you pass in a
physical address and length rather than a virtual address and length.
Redesigning the Linux driver to use that would be a big win and we could
drop the kmap calls entirely.
Re: [PATCH] vboxsf: Convert vboxsf_write_end() to use kmap_local_folio()
Posted by Matthew Wilcox 1 month, 3 weeks ago
On Mon, Aug 11, 2025 at 05:42:00PM -0400, Tal Zussman wrote:
> Now that vboxsf_write_end() takes a folio, convert the kmap() call to
> kmap_local_folio(). This removes two instances of &folio->page as
> well.
> 
> Compile-tested only.

Yeah ... I don't know if this is safe or not.  Needs actual testing.
Re: [PATCH] vboxsf: Convert vboxsf_write_end() to use kmap_local_folio()
Posted by Tal Zussman 1 month, 3 weeks ago
On Tue, Aug 12, 2025 at 1:12 AM Matthew Wilcox <willy@infradead.org> wrote:
> On Mon, Aug 11, 2025 at 05:42:00PM -0400, Tal Zussman wrote:
> > Now that vboxsf_write_end() takes a folio, convert the kmap() call to
> > kmap_local_folio(). This removes two instances of &folio->page as
> > well.
> >
> > Compile-tested only.
>
> Yeah ... I don't know if this is safe or not.  Needs actual testing.

Could you elaborate on why this might be unsafe? I assumed that (1) this is
similar to the conversion done in vboxsf_writepages() and (2) that the
kmap() call here could be simply converted to kmap_local_page() and then to
kmap_local_folio(), but clearly I'm missing something...