Skip to contentSkip to conversation

btrfs: fix wrong sizeof in btrfs_do_encoded_write

PATCH In review Mark Harmstone 3 participants 3 messages Oct 15, 2024 – Oct 16, 2024 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: fix wrong sizeof in btrfs_do_encoded_write

btrfs_do_encoded_write was converted to use folios in 400b172b8cdc, but we're still allocating based on sizeof(struct page *) rather than sizeof(struct folio *).

---
 fs/btrfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
index 5618ca02934a..5bffc2c77718 100644
@@ -9495,7 +9495,7 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
 	 */
 	disk_num_bytes = ALIGN(orig_count, fs_info->sectorsize);
 	nr_folios = DIV_ROUND_UP(disk_num_bytes, PAGE_SIZE);
-	folios = kvcalloc(nr_folios, sizeof(struct page *), GFP_KERNEL_ACCOUNT);
+	folios = kvcalloc(nr_folios, sizeof(struct folio *), GFP_KERNEL_ACCOUNT);
 	if (!folios)
 		return -ENOMEM;
 	for (i = 0; i < nr_folios; i++) {
Signature · 1 line
2.44.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Mark Harmstone

btrfs_do_encoded_write was converted to use folios in 400b172b8cdc, but we're still allocating based on sizeof(struct page *) rather than sizeof(struct folio *).

Quoted 20 lines
---
 fs/btrfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/inode.c +1 -1
index 5618ca02934a..5bffc2c77718 100644
@@ -9495,7 +9495,7 @@ ssize_t btrfs_do_encoded_write(struct kiocb *iocb, struct iov_iter *from,
 	 */
 	disk_num_bytes = ALIGN(orig_count, fs_info->sectorsize);
 	nr_folios = DIV_ROUND_UP(disk_num_bytes, PAGE_SIZE);
-	folios = kvcalloc(nr_folios, sizeof(struct page *), GFP_KERNEL_ACCOUNT);
+	folios = kvcalloc(nr_folios, sizeof(struct folio *), GFP_KERNEL_ACCOUNT);
 	if (!folios)
 		return -ENOMEM;
 	for (i = 0; i < nr_folios; i++) {
Signature · 1 line
2.44.2
Reviewed-by on v1 1/1
#2 lore raw
In reply to Mark Harmstone
Quoted 3 lines · Mark Harmstone

btrfs_do_encoded_write was converted to use folios in 400b172b8cdc, but we're still allocating based on sizeof(struct page *) rather than sizeof(struct folio *).

It's wrong that we should use folio, but both are a sizeof of a pointer, so it's not wrong in the functionality sense.

Quoted 1 line