23
23
static struct kmem_cache * cic_entry_slab ;
24
24
static struct kmem_cache * dic_entry_slab ;
25
25
26
- static void * page_array_alloc (struct inode * inode , int nr )
26
+ static void * page_array_alloc (struct f2fs_sb_info * sbi , int nr )
27
27
{
28
- struct f2fs_sb_info * sbi = F2FS_I_SB (inode );
29
28
unsigned int size = sizeof (struct page * ) * nr ;
30
29
31
30
if (likely (size <= sbi -> page_array_slab_size ))
32
31
return f2fs_kmem_cache_alloc (sbi -> page_array_slab ,
33
- GFP_F2FS_ZERO , false, F2FS_I_SB ( inode ) );
32
+ GFP_F2FS_ZERO , false, sbi );
34
33
return f2fs_kzalloc (sbi , size , GFP_NOFS );
35
34
}
36
35
37
- static void page_array_free (struct inode * inode , void * pages , int nr )
36
+ static void page_array_free (struct f2fs_sb_info * sbi , void * pages , int nr )
38
37
{
39
- struct f2fs_sb_info * sbi = F2FS_I_SB (inode );
40
38
unsigned int size = sizeof (struct page * ) * nr ;
41
39
42
40
if (!pages )
@@ -149,13 +147,13 @@ int f2fs_init_compress_ctx(struct compress_ctx *cc)
149
147
if (cc -> rpages )
150
148
return 0 ;
151
149
152
- cc -> rpages = page_array_alloc (cc -> inode , cc -> cluster_size );
150
+ cc -> rpages = page_array_alloc (F2FS_I_SB ( cc -> inode ) , cc -> cluster_size );
153
151
return cc -> rpages ? 0 : - ENOMEM ;
154
152
}
155
153
156
154
void f2fs_destroy_compress_ctx (struct compress_ctx * cc , bool reuse )
157
155
{
158
- page_array_free (cc -> inode , cc -> rpages , cc -> cluster_size );
156
+ page_array_free (F2FS_I_SB ( cc -> inode ) , cc -> rpages , cc -> cluster_size );
159
157
cc -> rpages = NULL ;
160
158
cc -> nr_rpages = 0 ;
161
159
cc -> nr_cpages = 0 ;
@@ -622,6 +620,7 @@ static void *f2fs_vmap(struct page **pages, unsigned int count)
622
620
623
621
static int f2fs_compress_pages (struct compress_ctx * cc )
624
622
{
623
+ struct f2fs_sb_info * sbi = F2FS_I_SB (cc -> inode );
625
624
struct f2fs_inode_info * fi = F2FS_I (cc -> inode );
626
625
const struct f2fs_compress_ops * cops =
627
626
f2fs_cops [fi -> i_compress_algorithm ];
@@ -642,7 +641,7 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
642
641
cc -> nr_cpages = DIV_ROUND_UP (max_len , PAGE_SIZE );
643
642
cc -> valid_nr_cpages = cc -> nr_cpages ;
644
643
645
- cc -> cpages = page_array_alloc (cc -> inode , cc -> nr_cpages );
644
+ cc -> cpages = page_array_alloc (sbi , cc -> nr_cpages );
646
645
if (!cc -> cpages ) {
647
646
ret = - ENOMEM ;
648
647
goto destroy_compress_ctx ;
@@ -716,7 +715,7 @@ static int f2fs_compress_pages(struct compress_ctx *cc)
716
715
if (cc -> cpages [i ])
717
716
f2fs_compress_free_page (cc -> cpages [i ]);
718
717
}
719
- page_array_free (cc -> inode , cc -> cpages , cc -> nr_cpages );
718
+ page_array_free (sbi , cc -> cpages , cc -> nr_cpages );
720
719
cc -> cpages = NULL ;
721
720
destroy_compress_ctx :
722
721
if (cops -> destroy_compress_ctx )
@@ -1340,7 +1339,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
1340
1339
cic -> magic = F2FS_COMPRESSED_PAGE_MAGIC ;
1341
1340
cic -> inode = inode ;
1342
1341
atomic_set (& cic -> pending_pages , cc -> valid_nr_cpages );
1343
- cic -> rpages = page_array_alloc (cc -> inode , cc -> cluster_size );
1342
+ cic -> rpages = page_array_alloc (sbi , cc -> cluster_size );
1344
1343
if (!cic -> rpages )
1345
1344
goto out_put_cic ;
1346
1345
@@ -1442,13 +1441,13 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
1442
1441
spin_unlock (& fi -> i_size_lock );
1443
1442
1444
1443
f2fs_put_rpages (cc );
1445
- page_array_free (cc -> inode , cc -> cpages , cc -> nr_cpages );
1444
+ page_array_free (sbi , cc -> cpages , cc -> nr_cpages );
1446
1445
cc -> cpages = NULL ;
1447
1446
f2fs_destroy_compress_ctx (cc , false);
1448
1447
return 0 ;
1449
1448
1450
1449
out_destroy_crypt :
1451
- page_array_free (cc -> inode , cic -> rpages , cc -> cluster_size );
1450
+ page_array_free (sbi , cic -> rpages , cc -> cluster_size );
1452
1451
1453
1452
for (-- i ; i >= 0 ; i -- ) {
1454
1453
if (!cc -> cpages [i ])
@@ -1469,7 +1468,7 @@ static int f2fs_write_compressed_pages(struct compress_ctx *cc,
1469
1468
f2fs_compress_free_page (cc -> cpages [i ]);
1470
1469
cc -> cpages [i ] = NULL ;
1471
1470
}
1472
- page_array_free (cc -> inode , cc -> cpages , cc -> nr_cpages );
1471
+ page_array_free (sbi , cc -> cpages , cc -> nr_cpages );
1473
1472
cc -> cpages = NULL ;
1474
1473
return - EAGAIN ;
1475
1474
}
@@ -1499,7 +1498,7 @@ void f2fs_compress_write_end_io(struct bio *bio, struct page *page)
1499
1498
end_page_writeback (cic -> rpages [i ]);
1500
1499
}
1501
1500
1502
- page_array_free (cic -> inode , cic -> rpages , cic -> nr_rpages );
1501
+ page_array_free (sbi , cic -> rpages , cic -> nr_rpages );
1503
1502
kmem_cache_free (cic_entry_slab , cic );
1504
1503
}
1505
1504
@@ -1640,7 +1639,7 @@ static int f2fs_prepare_decomp_mem(struct decompress_io_ctx *dic,
1640
1639
if (!allow_memalloc_for_decomp (F2FS_I_SB (dic -> inode ), pre_alloc ))
1641
1640
return 0 ;
1642
1641
1643
- dic -> tpages = page_array_alloc (dic -> inode , dic -> cluster_size );
1642
+ dic -> tpages = page_array_alloc (F2FS_I_SB ( dic -> inode ) , dic -> cluster_size );
1644
1643
if (!dic -> tpages )
1645
1644
return - ENOMEM ;
1646
1645
@@ -1700,7 +1699,7 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc)
1700
1699
if (!dic )
1701
1700
return ERR_PTR (- ENOMEM );
1702
1701
1703
- dic -> rpages = page_array_alloc (cc -> inode , cc -> cluster_size );
1702
+ dic -> rpages = page_array_alloc (sbi , cc -> cluster_size );
1704
1703
if (!dic -> rpages ) {
1705
1704
kmem_cache_free (dic_entry_slab , dic );
1706
1705
return ERR_PTR (- ENOMEM );
@@ -1721,7 +1720,7 @@ struct decompress_io_ctx *f2fs_alloc_dic(struct compress_ctx *cc)
1721
1720
dic -> rpages [i ] = cc -> rpages [i ];
1722
1721
dic -> nr_rpages = cc -> cluster_size ;
1723
1722
1724
- dic -> cpages = page_array_alloc (dic -> inode , dic -> nr_cpages );
1723
+ dic -> cpages = page_array_alloc (sbi , dic -> nr_cpages );
1725
1724
if (!dic -> cpages ) {
1726
1725
ret = - ENOMEM ;
1727
1726
goto out_free ;
@@ -1751,6 +1750,7 @@ static void f2fs_free_dic(struct decompress_io_ctx *dic,
1751
1750
bool bypass_destroy_callback )
1752
1751
{
1753
1752
int i ;
1753
+ struct f2fs_sb_info * sbi = F2FS_I_SB (dic -> inode );
1754
1754
1755
1755
f2fs_release_decomp_mem (dic , bypass_destroy_callback , true);
1756
1756
@@ -1762,7 +1762,7 @@ static void f2fs_free_dic(struct decompress_io_ctx *dic,
1762
1762
continue ;
1763
1763
f2fs_compress_free_page (dic -> tpages [i ]);
1764
1764
}
1765
- page_array_free (dic -> inode , dic -> tpages , dic -> cluster_size );
1765
+ page_array_free (sbi , dic -> tpages , dic -> cluster_size );
1766
1766
}
1767
1767
1768
1768
if (dic -> cpages ) {
@@ -1771,10 +1771,10 @@ static void f2fs_free_dic(struct decompress_io_ctx *dic,
1771
1771
continue ;
1772
1772
f2fs_compress_free_page (dic -> cpages [i ]);
1773
1773
}
1774
- page_array_free (dic -> inode , dic -> cpages , dic -> nr_cpages );
1774
+ page_array_free (sbi , dic -> cpages , dic -> nr_cpages );
1775
1775
}
1776
1776
1777
- page_array_free (dic -> inode , dic -> rpages , dic -> nr_rpages );
1777
+ page_array_free (sbi , dic -> rpages , dic -> nr_rpages );
1778
1778
kmem_cache_free (dic_entry_slab , dic );
1779
1779
}
1780
1780
0 commit comments