Commit 00276f9f authored by Matthew Wilcox (Oracle)'s avatar Matthew Wilcox (Oracle) Committed by Kent Overstreet

bcachefs: Use attach_page_private and detach_page_private

These recently added helpers simplify the code.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
parent 96fee47e
...@@ -273,28 +273,13 @@ static inline struct bch_page_state *bch2_page_state(struct page *page) ...@@ -273,28 +273,13 @@ static inline struct bch_page_state *bch2_page_state(struct page *page)
/* for newly allocated pages: */ /* for newly allocated pages: */
static void __bch2_page_state_release(struct page *page) static void __bch2_page_state_release(struct page *page)
{ {
struct bch_page_state *s = __bch2_page_state(page); kfree(detach_page_private(page));
if (!s)
return;
ClearPagePrivate(page);
set_page_private(page, 0);
put_page(page);
kfree(s);
} }
static void bch2_page_state_release(struct page *page) static void bch2_page_state_release(struct page *page)
{ {
struct bch_page_state *s = bch2_page_state(page); EBUG_ON(!PageLocked(page));
__bch2_page_state_release(page);
if (!s)
return;
ClearPagePrivate(page);
set_page_private(page, 0);
put_page(page);
kfree(s);
} }
/* for newly allocated pages: */ /* for newly allocated pages: */
...@@ -308,13 +293,7 @@ static struct bch_page_state *__bch2_page_state_create(struct page *page, ...@@ -308,13 +293,7 @@ static struct bch_page_state *__bch2_page_state_create(struct page *page,
return NULL; return NULL;
spin_lock_init(&s->lock); spin_lock_init(&s->lock);
/* attach_page_private(page, s);
* migrate_page_move_mapping() assumes that pages with private data
* have their count elevated by 1.
*/
get_page(page);
set_page_private(page, (unsigned long) s);
SetPagePrivate(page);
return s; return s;
} }
......
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