Commit de6f14e8 authored by Filipe Manana's avatar Filipe Manana Committed by David Sterba

btrfs: make try_release_extent_mapping() return a bool

Currently try_release_extent_mapping() as an int return type, but we
use it as a boolean. Its only caller, the release folio callback, also
returns a boolean which corresponds to try_release_extent_mapping()'s
return value. So change its return value type to bool as well as its
helper try_release_extent_state().
Reviewed-by: default avatarJohannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 2e504418
...@@ -2355,19 +2355,20 @@ int extent_invalidate_folio(struct extent_io_tree *tree, ...@@ -2355,19 +2355,20 @@ int extent_invalidate_folio(struct extent_io_tree *tree,
* are locked or under IO and drops the related state bits if it is safe * are locked or under IO and drops the related state bits if it is safe
* to drop the page. * to drop the page.
*/ */
static int try_release_extent_state(struct extent_io_tree *tree, static bool try_release_extent_state(struct extent_io_tree *tree,
struct page *page, gfp_t mask) struct page *page, gfp_t mask)
{ {
u64 start = page_offset(page); u64 start = page_offset(page);
u64 end = start + PAGE_SIZE - 1; u64 end = start + PAGE_SIZE - 1;
int ret = 1; bool ret;
if (test_range_bit_exists(tree, start, end, EXTENT_LOCKED)) { if (test_range_bit_exists(tree, start, end, EXTENT_LOCKED)) {
ret = 0; ret = false;
} else { } else {
u32 clear_bits = ~(EXTENT_LOCKED | EXTENT_NODATASUM | u32 clear_bits = ~(EXTENT_LOCKED | EXTENT_NODATASUM |
EXTENT_DELALLOC_NEW | EXTENT_CTLBITS | EXTENT_DELALLOC_NEW | EXTENT_CTLBITS |
EXTENT_QGROUP_RESERVED); EXTENT_QGROUP_RESERVED);
int ret2;
/* /*
* At this point we can safely clear everything except the * At this point we can safely clear everything except the
...@@ -2375,15 +2376,15 @@ static int try_release_extent_state(struct extent_io_tree *tree, ...@@ -2375,15 +2376,15 @@ static int try_release_extent_state(struct extent_io_tree *tree,
* The delalloc new bit will be cleared by ordered extent * The delalloc new bit will be cleared by ordered extent
* completion. * completion.
*/ */
ret = __clear_extent_bit(tree, start, end, clear_bits, NULL, NULL); ret2 = __clear_extent_bit(tree, start, end, clear_bits, NULL, NULL);
/* if clear_extent_bit failed for enomem reasons, /* if clear_extent_bit failed for enomem reasons,
* we can't allow the release to continue. * we can't allow the release to continue.
*/ */
if (ret < 0) if (ret2 < 0)
ret = 0; ret = false;
else else
ret = 1; ret = true;
} }
return ret; return ret;
} }
...@@ -2393,7 +2394,7 @@ static int try_release_extent_state(struct extent_io_tree *tree, ...@@ -2393,7 +2394,7 @@ static int try_release_extent_state(struct extent_io_tree *tree,
* in the range corresponding to the page, both state records and extent * in the range corresponding to the page, both state records and extent
* map records are removed * map records are removed
*/ */
int try_release_extent_mapping(struct page *page, gfp_t mask) bool try_release_extent_mapping(struct page *page, gfp_t mask)
{ {
u64 start = page_offset(page); u64 start = page_offset(page);
u64 end = start + PAGE_SIZE - 1; u64 end = start + PAGE_SIZE - 1;
......
...@@ -230,7 +230,7 @@ static inline void extent_changeset_free(struct extent_changeset *changeset) ...@@ -230,7 +230,7 @@ static inline void extent_changeset_free(struct extent_changeset *changeset)
kfree(changeset); kfree(changeset);
} }
int try_release_extent_mapping(struct page *page, gfp_t mask); bool try_release_extent_mapping(struct page *page, gfp_t mask);
int try_release_extent_buffer(struct page *page); int try_release_extent_buffer(struct page *page);
int btrfs_read_folio(struct file *file, struct folio *folio); int btrfs_read_folio(struct file *file, struct folio *folio);
......
...@@ -7899,13 +7899,12 @@ static void wait_subpage_spinlock(struct page *page) ...@@ -7899,13 +7899,12 @@ static void wait_subpage_spinlock(struct page *page)
static bool __btrfs_release_folio(struct folio *folio, gfp_t gfp_flags) static bool __btrfs_release_folio(struct folio *folio, gfp_t gfp_flags)
{ {
int ret = try_release_extent_mapping(&folio->page, gfp_flags); if (try_release_extent_mapping(&folio->page, gfp_flags)) {
if (ret == 1) {
wait_subpage_spinlock(&folio->page); wait_subpage_spinlock(&folio->page);
clear_page_extent_mapped(&folio->page); clear_page_extent_mapped(&folio->page);
return true;
} }
return ret; return false;
} }
static bool btrfs_release_folio(struct folio *folio, gfp_t gfp_flags) static bool btrfs_release_folio(struct folio *folio, gfp_t gfp_flags)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment