btrfs: fix the folio leak on S390 hardware acceleration
Subsystems (2)
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().
--- fs/btrfs/zlib.c | 1 + 1 file changed, 1 insertion(+)
fs/btrfs/zlib.c +1 -0
@@ -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
Quoted 14 lines · Qu Wenruo
[BUG]
After commitaa60fe12b4f4("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned bybtrfs_compress_filemap_get_folio()for S390 hardware accerlation path.[CAUSE]
Before that commit, we callkumap_local()andfolio_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 missingfolio_put()forcopy_data_into_buffer().Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")
Quoted 20 lines
Signed-off-by Qu Wenruo <[email protected]>--- fs/btrfs/zlib.c | 1 + 1 file changed, 1 insertion(+)fs/btrfs/zlib.c +1
-0@@ -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
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 commitaa60fe12b4f4("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned bybtrfs_compress_filemap_get_folio()for S390 hardware accerlation path.[CAUSE]
Before that commit, we callkumap_local()andfolio_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 missingfolio_put()forcopy_data_into_buffer().Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")Signed-off-by Qu Wenruo <[email protected]>--- fs/btrfs/zlib.c | 1 + 1 file changed, 1 insertion(+)fs/btrfs/zlib.c +1
-0@@ -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 ;
Heiko Carstens
maintainerQuoted 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,
QuQuoted 27 lines · Qu Wenruo
[BUG]
After commitaa60fe12b4f4("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned bybtrfs_compress_filemap_get_folio()for S390 hardware accerlation path.[CAUSE]
Before that commit, we callkumap_local()andfolio_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 missingfolio_put()forcopy_data_into_buffer().Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")Signed-off-by Qu Wenruo <[email protected]>--- 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@@ -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?
Mikhail Zaslonko
Tested-byHello 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,
QuQuoted 39 lines · Qu Wenruo
[BUG]
After commitaa60fe12b4f4("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned bybtrfs_compress_filemap_get_folio()for S390 hardware accerlation path.[CAUSE]
Before that commit, we callkumap_local()andfolio_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 missingfolio_put()forcopy_data_into_buffer().Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")Signed-off-by Qu Wenruo <[email protected]>---
fs/btrfs/zlib.c| 1 +1 file changed, 1 insertion(+)fs/btrfs/zlib.c +1
-0@@ -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;
Quoted 6 lines · Mikhail Zaslonko
Hello Qu,
Sorry for the late response.
I ran some test on s390 including folio-leak verification. LGTM.Tested-by Mikhail Zaslonko <[email protected]>
Thanks for testing, the patch has been merged to 6.19.
Quoted 17 lines · Qu Wenruo
[BUG]
After commitaa60fe12b4f4("btrfs: zlib: refactor S390x HW acceleration buffer preparation"), we no longer release the folio of the page cache of folio returned bybtrfs_compress_filemap_get_folio()for S390 hardware accerlation path.[CAUSE]
Before that commit, we callkumap_local()andfolio_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 missingfolio_put()forcopy_data_into_buffer().Cc linux-s390@vger.kernel.orgaa60fe12b4f49f49fc73e5023f8675e2df1f7805Fixes aa60fe12b4f4 ("btrfs: zlib: refactor S390x HW acceleration buffer preparation")Signed-off-by Qu Wenruo <[email protected]>