@@ -126,7 +126,7 @@ void extent_io_tree_init(struct btrfs_fs_info *fs_info,
126
126
* Empty an io tree, removing and freeing every extent state record from the
127
127
* tree. This should be called once we are sure no other task can access the
128
128
* tree anymore, so no tree updates happen after we empty the tree and there
129
- * aren't any waiters on any extent state record (EXTENT_LOCKED bit is never
129
+ * aren't any waiters on any extent state record (EXTENT_LOCK_BITS are never
130
130
* set on any extent state when calling this function).
131
131
*/
132
132
void extent_io_tree_release (struct extent_io_tree * tree )
@@ -141,7 +141,7 @@ void extent_io_tree_release(struct extent_io_tree *tree)
141
141
rbtree_postorder_for_each_entry_safe (state , tmp , & root , rb_node ) {
142
142
/* Clear node to keep free_extent_state() happy. */
143
143
RB_CLEAR_NODE (& state -> rb_node );
144
- ASSERT (!(state -> state & EXTENT_LOCKED ));
144
+ ASSERT (!(state -> state & EXTENT_LOCK_BITS ));
145
145
/*
146
146
* No need for a memory barrier here, as we are holding the tree
147
147
* lock and we only change the waitqueue while holding that lock
@@ -399,7 +399,7 @@ static void merge_next_state(struct extent_io_tree *tree, struct extent_state *s
399
399
*/
400
400
static void merge_state (struct extent_io_tree * tree , struct extent_state * state )
401
401
{
402
- if (state -> state & (EXTENT_LOCKED | EXTENT_BOUNDARY ))
402
+ if (state -> state & (EXTENT_LOCK_BITS | EXTENT_BOUNDARY ))
403
403
return ;
404
404
405
405
merge_prev_state (tree , state );
@@ -445,7 +445,7 @@ static struct extent_state *insert_state(struct extent_io_tree *tree,
445
445
struct rb_node * parent = NULL ;
446
446
const u64 start = state -> start - 1 ;
447
447
const u64 end = state -> end + 1 ;
448
- const bool try_merge = !(bits & (EXTENT_LOCKED | EXTENT_BOUNDARY ));
448
+ const bool try_merge = !(bits & (EXTENT_LOCK_BITS | EXTENT_BOUNDARY ));
449
449
450
450
set_state_bits (tree , state , bits , changeset );
451
451
@@ -616,9 +616,6 @@ static void set_gfp_mask_from_bits(u32 *bits, gfp_t *mask)
616
616
* inserting elements in the tree, so the gfp mask is used to indicate which
617
617
* allocations or sleeping are allowed.
618
618
*
619
- * Pass 'wake' == 1 to kick any sleepers, and 'delete' == 1 to remove the given
620
- * range from the tree regardless of state (ie for truncate).
621
- *
622
619
* The range [start, end] is inclusive.
623
620
*
624
621
* This takes the tree lock, and returns 0 on success and < 0 on error.
@@ -647,8 +644,8 @@ int __clear_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
647
644
if (bits & EXTENT_DELALLOC )
648
645
bits |= EXTENT_NORESERVE ;
649
646
650
- wake = (bits & EXTENT_LOCKED ) ? 1 : 0 ;
651
- if (bits & (EXTENT_LOCKED | EXTENT_BOUNDARY ))
647
+ wake = (( bits & EXTENT_LOCK_BITS ) ? 1 : 0 ) ;
648
+ if (bits & (EXTENT_LOCK_BITS | EXTENT_BOUNDARY ))
652
649
clear = 1 ;
653
650
again :
654
651
if (!prealloc ) {
@@ -861,8 +858,7 @@ static void cache_state_if_flags(struct extent_state *state,
861
858
static void cache_state (struct extent_state * state ,
862
859
struct extent_state * * cached_ptr )
863
860
{
864
- return cache_state_if_flags (state , cached_ptr ,
865
- EXTENT_LOCKED | EXTENT_BOUNDARY );
861
+ return cache_state_if_flags (state , cached_ptr , EXTENT_LOCK_BITS | EXTENT_BOUNDARY );
866
862
}
867
863
868
864
/*
@@ -1063,7 +1059,7 @@ static int __set_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
1063
1059
int ret = 0 ;
1064
1060
u64 last_start ;
1065
1061
u64 last_end ;
1066
- u32 exclusive_bits = (bits & EXTENT_LOCKED );
1062
+ u32 exclusive_bits = (bits & EXTENT_LOCK_BITS );
1067
1063
gfp_t mask ;
1068
1064
1069
1065
set_gfp_mask_from_bits (& bits , & mask );
@@ -1812,12 +1808,11 @@ int set_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
1812
1808
u32 bits , struct extent_changeset * changeset )
1813
1809
{
1814
1810
/*
1815
- * We don't support EXTENT_LOCKED yet, as current changeset will
1816
- * record any bits changed, so for EXTENT_LOCKED case, it will
1817
- * either fail with -EEXIST or changeset will record the whole
1818
- * range.
1811
+ * We don't support EXTENT_LOCK_BITS yet, as current changeset will
1812
+ * record any bits changed, so for EXTENT_LOCK_BITS case, it will either
1813
+ * fail with -EEXIST or changeset will record the whole range.
1819
1814
*/
1820
- ASSERT (!(bits & EXTENT_LOCKED ));
1815
+ ASSERT (!(bits & EXTENT_LOCK_BITS ));
1821
1816
1822
1817
return __set_extent_bit (tree , start , end , bits , NULL , NULL , NULL , changeset );
1823
1818
}
@@ -1826,26 +1821,25 @@ int clear_record_extent_bits(struct extent_io_tree *tree, u64 start, u64 end,
1826
1821
u32 bits , struct extent_changeset * changeset )
1827
1822
{
1828
1823
/*
1829
- * Don't support EXTENT_LOCKED case, same reason as
1824
+ * Don't support EXTENT_LOCK_BITS case, same reason as
1830
1825
* set_record_extent_bits().
1831
1826
*/
1832
- ASSERT (!(bits & EXTENT_LOCKED ));
1827
+ ASSERT (!(bits & EXTENT_LOCK_BITS ));
1833
1828
1834
1829
return __clear_extent_bit (tree , start , end , bits , NULL , changeset );
1835
1830
}
1836
1831
1837
- int try_lock_extent (struct extent_io_tree * tree , u64 start , u64 end ,
1838
- struct extent_state * * cached )
1832
+ bool __try_lock_extent (struct extent_io_tree * tree , u64 start , u64 end , u32 bits ,
1833
+ struct extent_state * * cached )
1839
1834
{
1840
1835
int err ;
1841
1836
u64 failed_start ;
1842
1837
1843
- err = __set_extent_bit (tree , start , end , EXTENT_LOCKED , & failed_start ,
1838
+ err = __set_extent_bit (tree , start , end , bits , & failed_start ,
1844
1839
NULL , cached , NULL );
1845
1840
if (err == - EEXIST ) {
1846
1841
if (failed_start > start )
1847
- clear_extent_bit (tree , start , failed_start - 1 ,
1848
- EXTENT_LOCKED , cached );
1842
+ clear_extent_bit (tree , start , failed_start - 1 , bits , cached );
1849
1843
return 0 ;
1850
1844
}
1851
1845
return 1 ;
@@ -1855,23 +1849,22 @@ int try_lock_extent(struct extent_io_tree *tree, u64 start, u64 end,
1855
1849
* Either insert or lock state struct between start and end use mask to tell
1856
1850
* us if waiting is desired.
1857
1851
*/
1858
- int lock_extent (struct extent_io_tree * tree , u64 start , u64 end ,
1859
- struct extent_state * * cached_state )
1852
+ int __lock_extent (struct extent_io_tree * tree , u64 start , u64 end , u32 bits ,
1853
+ struct extent_state * * cached_state )
1860
1854
{
1861
1855
struct extent_state * failed_state = NULL ;
1862
1856
int err ;
1863
1857
u64 failed_start ;
1864
1858
1865
- err = __set_extent_bit (tree , start , end , EXTENT_LOCKED , & failed_start ,
1859
+ err = __set_extent_bit (tree , start , end , bits , & failed_start ,
1866
1860
& failed_state , cached_state , NULL );
1867
1861
while (err == - EEXIST ) {
1868
1862
if (failed_start != start )
1869
1863
clear_extent_bit (tree , start , failed_start - 1 ,
1870
- EXTENT_LOCKED , cached_state );
1864
+ bits , cached_state );
1871
1865
1872
- wait_extent_bit (tree , failed_start , end , EXTENT_LOCKED ,
1873
- & failed_state );
1874
- err = __set_extent_bit (tree , start , end , EXTENT_LOCKED ,
1866
+ wait_extent_bit (tree , failed_start , end , bits , & failed_state );
1867
+ err = __set_extent_bit (tree , start , end , bits ,
1875
1868
& failed_start , & failed_state ,
1876
1869
cached_state , NULL );
1877
1870
}
0 commit comments