Skip to contentSkip to conversation

btrfs: fix the folio leak on S390 hardware acceleration

PATCH In review Qu Wenruo 5 participants 7 messages Jan 19 – Feb 6

Subsystems (2)
lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 btrfs: fix the folio leak on S390 hardware acceleration

[BUG]
After commit aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned by btrfs_compress_filemap_get_folio() for S390 hardware accerlation path.

[CAUSE]
Before that commit, we call kumap_local() and folio_put() after handling each folio.

Although the timing is not ideal (it release previous folio at the beginning of the loop, and rely on some extra cleanup out of the loop), it at least handles the folio release correctly.

Meanwhile the refactored code is easier to read, it lacks the call to release the filemap folio.

[FIX]
Add the missing folio_put() for copy_data_into_buffer().

Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805
Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")
---
 fs/btrfs/zlib.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/zlib.c +1 -0
index 6caba8be7c84..10ed48d4a846 100644
@@ -139,6 +139,7 @@ static int copy_data_into_buffer(struct address_space *mapping,
 		data_in = kmap_local_folio(folio, offset);
 		memcpy(workspace->buf + cur - filepos, data_in, copy_length);
 		kunmap_local(data_in);
+		folio_put(folio);
 		cur += copy_length;
 	}
 	return 0;
Signature · 1 line
2.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Qu Wenruo

[BUG]
After commit aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned by btrfs_compress_filemap_get_folio() for S390 hardware accerlation path.

[CAUSE]
Before that commit, we call kumap_local() and folio_put() after handling each folio.

Although the timing is not ideal (it release previous folio at the beginning of the loop, and rely on some extra cleanup out of the loop), it at least handles the folio release correctly.

Quoted 8 lines

Meanwhile the refactored code is easier to read, it lacks the call to release the filemap folio.

[FIX]
Add the missing folio_put() for copy_data_into_buffer().

Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805
Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")
Quoted 20 lines
---
 fs/btrfs/zlib.c | 1 +
 1 file changed, 1 insertion(+)
fs/btrfs/zlib.c +1 -0
index 6caba8be7c84..10ed48d4a846 100644
@@ -139,6 +139,7 @@ static int copy_data_into_buffer(struct address_space *mapping,
 		data_in = kmap_local_folio(folio, offset);
 		memcpy(workspace->buf + cur - filepos, data_in, copy_length);
 		kunmap_local(data_in);
+		folio_put(folio);
 		cur += copy_length;
 	}
 	return 0;
Signature · 1 line
2.52.0
author
#2 lore raw
In reply to Qu Wenruo

Adding S390 to the mailing list, I got the incorrect address in the initial patch.

Much appreciated if S390 people can give it a test.

Thanks,
Qu

Quoted 39 lines · Qu Wenruo

[BUG]
After commit aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned by btrfs_compress_filemap_get_folio() for S390 hardware accerlation path.

[CAUSE]
Before that commit, we call kumap_local() and folio_put() after handling each folio.

Although the timing is not ideal (it release previous folio at the beginning of the loop, and rely on some extra cleanup out of the loop), it at least handles the folio release correctly.

Meanwhile the refactored code is easier to read, it lacks the call to release the filemap folio.

[FIX]
Add the missing folio_put() for copy_data_into_buffer().

Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805
Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")
---
  fs/btrfs/zlib.c | 1 +
  1 file changed, 1 insertion(+)
fs/btrfs/zlib.c +1 -0
index 6caba8be7c84..10ed48d4a846 100644
@@ -139,6 +139,7 @@ static int copy_data_into_buffer(struct address_space *mapping,
  		data_in = kmap_local_folio(folio, offset);
  		memcpy(workspace->buf + cur - filepos, data_in, copy_length);
  		kunmap_local(data_in);
+		folio_put(folio);
  		cur += copy_length;
  	}
  	return 0;
maintainer
#3 lore raw
Quoted 36 lines · Qu Wenruo

Adding S390 to the mailing list, I got the incorrect address in the initial patch.

Much appreciated if S390 people can give it a test.

Thanks,
Qu

Quoted 27 lines · Qu Wenruo

[BUG]
After commit aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned by btrfs_compress_filemap_get_folio() for S390 hardware accerlation path.

[CAUSE]
Before that commit, we call kumap_local() and folio_put() after handling each folio.

Although the timing is not ideal (it release previous folio at the beginning of the loop, and rely on some extra cleanup out of the loop), it at least handles the folio release correctly.

Meanwhile the refactored code is easier to read, it lacks the call to release the filemap folio.

[FIX]
Add the missing folio_put() for copy_data_into_buffer().

Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805
Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")
---
  fs/btrfs/zlib.c | 1 +
  1 file changed, 1 insertion(+)
Quoted 12 lines

fs/btrfs/zlib.c static int copy_data_into_buffer(struct address_space *mapping, · line 145

Quoted 12 lines
fs/btrfs/zlib.c +1 -0
index 6caba8be7c84..10ed48d4a846 100644
@@ -139,6 +139,7 @@ static int copy_data_into_buffer(struct address_space *mapping,
  		data_in = kmap_local_folio(folio, offset);
  		memcpy(workspace->buf + cur - filepos, data_in, copy_length);
  		kunmap_local(data_in);
+		folio_put(folio);
  		cur += copy_length;
  	}
  	return 0;

Mikhail, can you have a look at this, please?

#4 lore raw
In reply to Qu Wenruo

Hello Qu,

Sorry for the late response.
I ran some test on s390 including folio-leak verification. LGTM.

Quoted 50 lines · Qu Wenruo

Adding S390 to the mailing list, I got the incorrect address in the initial patch.

Much appreciated if S390 people can give it a test.

Thanks,
Qu

Quoted 39 lines · Qu Wenruo

[BUG]
After commit aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned by btrfs_compress_filemap_get_folio() for S390 hardware accerlation path.

[CAUSE]
Before that commit, we call kumap_local() and folio_put() after handling each folio.

Although the timing is not ideal (it release previous folio at the beginning of the loop, and rely on some extra cleanup out of the loop), it at least handles the folio release correctly.

Meanwhile the refactored code is easier to read, it lacks the call to release the filemap folio.

[FIX]
Add the missing folio_put() for copy_data_into_buffer().

Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805
Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")

---
  fs/btrfs/zlib.c | 1 +

  1 file changed, 1 insertion(+)
fs/btrfs/zlib.c +1 -0
index 6caba8be7c84..10ed48d4a846 100644
@@ -139,6 +139,7 @@ static int copy_data_into_buffer(struct address_space *mapping,
           data_in = kmap_local_folio(folio, offset);
           memcpy(workspace->buf + cur - filepos, data_in, copy_length);
           kunmap_local(data_in);
+        folio_put(folio);
           cur += copy_length;
       }
       return 0;
Reviewed-by on v1 1/1
#6 lore raw
In reply to Qu Wenruo
Quoted 17 lines · Qu Wenruo

[BUG]
After commit aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned by btrfs_compress_filemap_get_folio() for S390 hardware accerlation path.

[CAUSE]
Before that commit, we call kumap_local() and folio_put() after handling each folio.

Although the timing is not ideal (it release previous folio at the beginning of the loop, and rely on some extra cleanup out of the loop), it at least handles the folio release correctly.

Meanwhile the refactored code is easier to read, it lacks the call to release the filemap folio.

Quoted 6 lines

[FIX]
Add the missing folio_put() for copy_data_into_buffer().

Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805
Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")