@@ -762,8 +762,8 @@ static noinline int cow_file_range_inline(struct btrfs_inode *inode, u64 offset,
762
762
return ret ;
763
763
}
764
764
765
- free_extent_state ( cached );
766
- extent_clear_unlock_delalloc ( inode , offset , end , NULL , clear_flags ,
765
+ extent_clear_unlock_delalloc ( inode , offset , end , NULL , & cached ,
766
+ clear_flags ,
767
767
PAGE_UNLOCK | PAGE_START_WRITEBACK |
768
768
PAGE_END_WRITEBACK );
769
769
return ret ;
@@ -1154,6 +1154,7 @@ static void submit_one_async_extent(struct async_chunk *async_chunk,
1154
1154
struct btrfs_ordered_extent * ordered ;
1155
1155
struct btrfs_key ins ;
1156
1156
struct page * locked_page = NULL ;
1157
+ struct extent_state * cached = NULL ;
1157
1158
struct extent_map * em ;
1158
1159
int ret = 0 ;
1159
1160
u64 start = async_extent -> start ;
@@ -1194,7 +1195,7 @@ static void submit_one_async_extent(struct async_chunk *async_chunk,
1194
1195
goto done ;
1195
1196
}
1196
1197
1197
- lock_extent (io_tree , start , end , NULL );
1198
+ lock_extent (io_tree , start , end , & cached );
1198
1199
1199
1200
/* Here we're doing allocation and writeback of the compressed pages */
1200
1201
em = create_io_em (inode , start ,
@@ -1229,7 +1230,7 @@ static void submit_one_async_extent(struct async_chunk *async_chunk,
1229
1230
1230
1231
/* Clear dirty, set writeback and unlock the pages. */
1231
1232
extent_clear_unlock_delalloc (inode , start , end ,
1232
- NULL , EXTENT_LOCKED | EXTENT_DELALLOC ,
1233
+ NULL , & cached , EXTENT_LOCKED | EXTENT_DELALLOC ,
1233
1234
PAGE_UNLOCK | PAGE_START_WRITEBACK );
1234
1235
btrfs_submit_compressed_write (ordered ,
1235
1236
async_extent -> folios , /* compressed_folios */
@@ -1247,7 +1248,8 @@ static void submit_one_async_extent(struct async_chunk *async_chunk,
1247
1248
btrfs_free_reserved_extent (fs_info , ins .objectid , ins .offset , 1 );
1248
1249
mapping_set_error (inode -> vfs_inode .i_mapping , - EIO );
1249
1250
extent_clear_unlock_delalloc (inode , start , end ,
1250
- NULL , EXTENT_LOCKED | EXTENT_DELALLOC |
1251
+ NULL , & cached ,
1252
+ EXTENT_LOCKED | EXTENT_DELALLOC |
1251
1253
EXTENT_DELALLOC_NEW |
1252
1254
EXTENT_DEFRAG | EXTENT_DO_ACCOUNTING ,
1253
1255
PAGE_UNLOCK | PAGE_START_WRITEBACK |
@@ -1329,6 +1331,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
1329
1331
{
1330
1332
struct btrfs_root * root = inode -> root ;
1331
1333
struct btrfs_fs_info * fs_info = root -> fs_info ;
1334
+ struct extent_state * cached = NULL ;
1332
1335
u64 alloc_hint = 0 ;
1333
1336
u64 orig_start = start ;
1334
1337
u64 num_bytes ;
@@ -1429,7 +1432,8 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
1429
1432
1430
1433
ram_size = ins .offset ;
1431
1434
1432
- lock_extent (& inode -> io_tree , start , start + ram_size - 1 , NULL );
1435
+ lock_extent (& inode -> io_tree , start , start + ram_size - 1 ,
1436
+ & cached );
1433
1437
1434
1438
em = create_io_em (inode , start , ins .offset , /* len */
1435
1439
start , /* orig_start */
@@ -1441,7 +1445,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
1441
1445
BTRFS_ORDERED_REGULAR /* type */ );
1442
1446
if (IS_ERR (em )) {
1443
1447
unlock_extent (& inode -> io_tree , start ,
1444
- start + ram_size - 1 , NULL );
1448
+ start + ram_size - 1 , & cached );
1445
1449
ret = PTR_ERR (em );
1446
1450
goto out_reserve ;
1447
1451
}
@@ -1453,7 +1457,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
1453
1457
BTRFS_COMPRESS_NONE );
1454
1458
if (IS_ERR (ordered )) {
1455
1459
unlock_extent (& inode -> io_tree , start ,
1456
- start + ram_size - 1 , NULL );
1460
+ start + ram_size - 1 , & cached );
1457
1461
ret = PTR_ERR (ordered );
1458
1462
goto out_drop_extent_cache ;
1459
1463
}
@@ -1493,7 +1497,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
1493
1497
page_ops |= PAGE_SET_ORDERED ;
1494
1498
1495
1499
extent_clear_unlock_delalloc (inode , start , start + ram_size - 1 ,
1496
- locked_page ,
1500
+ locked_page , & cached ,
1497
1501
EXTENT_LOCKED | EXTENT_DELALLOC ,
1498
1502
page_ops );
1499
1503
if (num_bytes < cur_alloc_size )
@@ -1552,7 +1556,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
1552
1556
if (!locked_page )
1553
1557
mapping_set_error (inode -> vfs_inode .i_mapping , ret );
1554
1558
extent_clear_unlock_delalloc (inode , orig_start , start - 1 ,
1555
- locked_page , 0 , page_ops );
1559
+ locked_page , NULL , 0 , page_ops );
1556
1560
}
1557
1561
1558
1562
/*
@@ -1575,7 +1579,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
1575
1579
if (extent_reserved ) {
1576
1580
extent_clear_unlock_delalloc (inode , start ,
1577
1581
start + cur_alloc_size - 1 ,
1578
- locked_page ,
1582
+ locked_page , & cached ,
1579
1583
clear_bits ,
1580
1584
page_ops );
1581
1585
start += cur_alloc_size ;
@@ -1590,7 +1594,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
1590
1594
if (start < end ) {
1591
1595
clear_bits |= EXTENT_CLEAR_DATA_RESV ;
1592
1596
extent_clear_unlock_delalloc (inode , start , end , locked_page ,
1593
- clear_bits , page_ops );
1597
+ & cached , clear_bits , page_ops );
1594
1598
}
1595
1599
return ret ;
1596
1600
}
@@ -2206,11 +2210,10 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
2206
2210
btrfs_put_ordered_extent (ordered );
2207
2211
2208
2212
extent_clear_unlock_delalloc (inode , cur_offset , nocow_end ,
2209
- locked_page , EXTENT_LOCKED |
2210
- EXTENT_DELALLOC |
2213
+ locked_page , & cached_state ,
2214
+ EXTENT_LOCKED | EXTENT_DELALLOC |
2211
2215
EXTENT_CLEAR_DATA_RESV ,
2212
2216
PAGE_UNLOCK | PAGE_SET_ORDERED );
2213
- free_extent_state (cached_state );
2214
2217
2215
2218
cur_offset = extent_end ;
2216
2219
@@ -2252,10 +2255,13 @@ static noinline int run_delalloc_nocow(struct btrfs_inode *inode,
2252
2255
* we're not locked at this point.
2253
2256
*/
2254
2257
if (cur_offset < end ) {
2255
- lock_extent (& inode -> io_tree , cur_offset , end , NULL );
2258
+ struct extent_state * cached = NULL ;
2259
+
2260
+ lock_extent (& inode -> io_tree , cur_offset , end , & cached );
2256
2261
extent_clear_unlock_delalloc (inode , cur_offset , end ,
2257
- locked_page , EXTENT_LOCKED |
2258
- EXTENT_DELALLOC | EXTENT_DEFRAG |
2262
+ locked_page , & cached ,
2263
+ EXTENT_LOCKED | EXTENT_DELALLOC |
2264
+ EXTENT_DEFRAG |
2259
2265
EXTENT_DO_ACCOUNTING , PAGE_UNLOCK |
2260
2266
PAGE_START_WRITEBACK |
2261
2267
PAGE_END_WRITEBACK );
0 commit comments