1 // SPDX-License-Identifier: GPL-2.0
3 #include <linux/slab.h>
7 #include "btrfs_inode.h"
10 * Subpage (sectorsize < PAGE_SIZE) support overview:
14 * - Only support 64K page size for now
15 * This is to make metadata handling easier, as 64K page would ensure
16 * all nodesize would fit inside one page, thus we don't need to handle
17 * cases where a tree block crosses several pages.
19 * - Only metadata read-write for now
20 * The data read-write part is in development.
22 * - Metadata can't cross 64K page boundary
23 * btrfs-progs and kernel have done that for a while, thus only ancient
24 * filesystems could have such problem. For such case, do a graceful
30 * Metadata read is fully supported.
31 * Meaning when reading one tree block will only trigger the read for the
32 * needed range, other unrelated range in the same page will not be touched.
34 * Metadata write support is partial.
35 * The writeback is still for the full page, but we will only submit
36 * the dirty extent buffers in the page.
38 * This means, if we have a metadata page like this:
42 * |/////////| |///////////|
43 * \- Tree block A \- Tree block B
45 * Even if we just want to writeback tree block A, we will also writeback
46 * tree block B if it's also dirty.
48 * This may cause extra metadata writeback which results more COW.
53 * Both metadata and data will use a new structure, btrfs_subpage, to
54 * record the status of each sector inside a page. This provides the extra
58 * Since we have multiple tree blocks inside one page, we can't rely on page
59 * locking anymore, or we will have greatly reduced concurrency or even
60 * deadlocks (hold one tree lock while trying to lock another tree lock in
63 * Thus for metadata locking, subpage support relies on io_tree locking only.
64 * This means a slightly higher tree locking latency.
67 bool btrfs_is_subpage(const struct btrfs_fs_info *fs_info, struct page *page)
69 if (fs_info->sectorsize >= PAGE_SIZE)
73 * Only data pages (either through DIO or compression) can have no
74 * mapping. And if page->mapping->host is data inode, it's subpage.
75 * As we have ruled our sectorsize >= PAGE_SIZE case already.
77 if (!page->mapping || !page->mapping->host ||
78 is_data_inode(page->mapping->host))
82 * Now the only remaining case is metadata, which we only go subpage
83 * routine if nodesize < PAGE_SIZE.
85 if (fs_info->nodesize < PAGE_SIZE)
90 void btrfs_init_subpage_info(struct btrfs_subpage_info *subpage_info, u32 sectorsize)
95 ASSERT(IS_ALIGNED(PAGE_SIZE, sectorsize));
97 nr_bits = PAGE_SIZE / sectorsize;
98 subpage_info->bitmap_nr_bits = nr_bits;
100 subpage_info->uptodate_offset = cur;
103 subpage_info->dirty_offset = cur;
106 subpage_info->writeback_offset = cur;
109 subpage_info->ordered_offset = cur;
112 subpage_info->checked_offset = cur;
115 subpage_info->total_nr_bits = cur;
118 int btrfs_attach_subpage(const struct btrfs_fs_info *fs_info,
119 struct page *page, enum btrfs_subpage_type type)
121 struct btrfs_subpage *subpage;
124 * We have cases like a dummy extent buffer page, which is not mapped
125 * and doesn't need to be locked.
128 ASSERT(PageLocked(page));
130 /* Either not subpage, or the page already has private attached */
131 if (!btrfs_is_subpage(fs_info, page) || PagePrivate(page))
134 subpage = btrfs_alloc_subpage(fs_info, type);
136 return PTR_ERR(subpage);
138 attach_page_private(page, subpage);
142 void btrfs_detach_subpage(const struct btrfs_fs_info *fs_info,
145 struct btrfs_subpage *subpage;
147 /* Either not subpage, or already detached */
148 if (!btrfs_is_subpage(fs_info, page) || !PagePrivate(page))
151 subpage = detach_page_private(page);
153 btrfs_free_subpage(subpage);
156 struct btrfs_subpage *btrfs_alloc_subpage(const struct btrfs_fs_info *fs_info,
157 enum btrfs_subpage_type type)
159 struct btrfs_subpage *ret;
160 unsigned int real_size;
162 ASSERT(fs_info->sectorsize < PAGE_SIZE);
164 real_size = struct_size(ret, bitmaps,
165 BITS_TO_LONGS(fs_info->subpage_info->total_nr_bits));
166 ret = kzalloc(real_size, GFP_NOFS);
168 return ERR_PTR(-ENOMEM);
170 spin_lock_init(&ret->lock);
171 if (type == BTRFS_SUBPAGE_METADATA) {
172 atomic_set(&ret->eb_refs, 0);
174 atomic_set(&ret->readers, 0);
175 atomic_set(&ret->writers, 0);
180 void btrfs_free_subpage(struct btrfs_subpage *subpage)
186 * Increase the eb_refs of current subpage.
188 * This is important for eb allocation, to prevent race with last eb freeing
190 * With the eb_refs increased before the eb inserted into radix tree,
191 * detach_extent_buffer_page() won't detach the page private while we're still
192 * allocating the extent buffer.
194 void btrfs_page_inc_eb_refs(const struct btrfs_fs_info *fs_info,
197 struct btrfs_subpage *subpage;
199 if (!btrfs_is_subpage(fs_info, page))
202 ASSERT(PagePrivate(page) && page->mapping);
203 lockdep_assert_held(&page->mapping->private_lock);
205 subpage = (struct btrfs_subpage *)page->private;
206 atomic_inc(&subpage->eb_refs);
209 void btrfs_page_dec_eb_refs(const struct btrfs_fs_info *fs_info,
212 struct btrfs_subpage *subpage;
214 if (!btrfs_is_subpage(fs_info, page))
217 ASSERT(PagePrivate(page) && page->mapping);
218 lockdep_assert_held(&page->mapping->private_lock);
220 subpage = (struct btrfs_subpage *)page->private;
221 ASSERT(atomic_read(&subpage->eb_refs));
222 atomic_dec(&subpage->eb_refs);
225 static void btrfs_subpage_assert(const struct btrfs_fs_info *fs_info,
226 struct page *page, u64 start, u32 len)
229 ASSERT(PagePrivate(page) && page->private);
230 ASSERT(IS_ALIGNED(start, fs_info->sectorsize) &&
231 IS_ALIGNED(len, fs_info->sectorsize));
233 * The range check only works for mapped page, we can still have
234 * unmapped page like dummy extent buffer pages.
237 ASSERT(page_offset(page) <= start &&
238 start + len <= page_offset(page) + PAGE_SIZE);
241 void btrfs_subpage_start_reader(const struct btrfs_fs_info *fs_info,
242 struct page *page, u64 start, u32 len)
244 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
245 const int nbits = len >> fs_info->sectorsize_bits;
247 btrfs_subpage_assert(fs_info, page, start, len);
249 atomic_add(nbits, &subpage->readers);
252 void btrfs_subpage_end_reader(const struct btrfs_fs_info *fs_info,
253 struct page *page, u64 start, u32 len)
255 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
256 const int nbits = len >> fs_info->sectorsize_bits;
260 btrfs_subpage_assert(fs_info, page, start, len);
261 is_data = is_data_inode(page->mapping->host);
262 ASSERT(atomic_read(&subpage->readers) >= nbits);
263 last = atomic_sub_and_test(nbits, &subpage->readers);
266 * For data we need to unlock the page if the last read has finished.
268 * And please don't replace @last with atomic_sub_and_test() call
269 * inside if () condition.
270 * As we want the atomic_sub_and_test() to be always executed.
276 static void btrfs_subpage_clamp_range(struct page *page, u64 *start, u32 *len)
278 u64 orig_start = *start;
281 *start = max_t(u64, page_offset(page), orig_start);
283 * For certain call sites like btrfs_drop_pages(), we may have pages
284 * beyond the target range. In that case, just set @len to 0, subpage
285 * helpers can handle @len == 0 without any problem.
287 if (page_offset(page) >= orig_start + orig_len)
290 *len = min_t(u64, page_offset(page) + PAGE_SIZE,
291 orig_start + orig_len) - *start;
294 void btrfs_subpage_start_writer(const struct btrfs_fs_info *fs_info,
295 struct page *page, u64 start, u32 len)
297 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
298 const int nbits = (len >> fs_info->sectorsize_bits);
301 btrfs_subpage_assert(fs_info, page, start, len);
303 ASSERT(atomic_read(&subpage->readers) == 0);
304 ret = atomic_add_return(nbits, &subpage->writers);
305 ASSERT(ret == nbits);
308 bool btrfs_subpage_end_and_test_writer(const struct btrfs_fs_info *fs_info,
309 struct page *page, u64 start, u32 len)
311 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
312 const int nbits = (len >> fs_info->sectorsize_bits);
314 btrfs_subpage_assert(fs_info, page, start, len);
317 * We have call sites passing @lock_page into
318 * extent_clear_unlock_delalloc() for compression path.
320 * This @locked_page is locked by plain lock_page(), thus its
321 * subpage::writers is 0. Handle them in a special way.
323 if (atomic_read(&subpage->writers) == 0)
326 ASSERT(atomic_read(&subpage->writers) >= nbits);
327 return atomic_sub_and_test(nbits, &subpage->writers);
331 * Lock a page for delalloc page writeback.
333 * Return -EAGAIN if the page is not properly initialized.
334 * Return 0 with the page locked, and writer counter updated.
336 * Even with 0 returned, the page still need extra check to make sure
337 * it's really the correct page, as the caller is using
338 * filemap_get_folios_contig(), which can race with page invalidating.
340 int btrfs_page_start_writer_lock(const struct btrfs_fs_info *fs_info,
341 struct page *page, u64 start, u32 len)
343 if (unlikely(!fs_info) || !btrfs_is_subpage(fs_info, page)) {
348 if (!PagePrivate(page) || !page->private) {
352 btrfs_subpage_clamp_range(page, &start, &len);
353 btrfs_subpage_start_writer(fs_info, page, start, len);
357 void btrfs_page_end_writer_lock(const struct btrfs_fs_info *fs_info,
358 struct page *page, u64 start, u32 len)
360 if (unlikely(!fs_info) || !btrfs_is_subpage(fs_info, page))
361 return unlock_page(page);
362 btrfs_subpage_clamp_range(page, &start, &len);
363 if (btrfs_subpage_end_and_test_writer(fs_info, page, start, len))
367 #define subpage_calc_start_bit(fs_info, page, name, start, len) \
369 unsigned int start_bit; \
371 btrfs_subpage_assert(fs_info, page, start, len); \
372 start_bit = offset_in_page(start) >> fs_info->sectorsize_bits; \
373 start_bit += fs_info->subpage_info->name##_offset; \
377 #define subpage_test_bitmap_all_set(fs_info, subpage, name) \
378 bitmap_test_range_all_set(subpage->bitmaps, \
379 fs_info->subpage_info->name##_offset, \
380 fs_info->subpage_info->bitmap_nr_bits)
382 #define subpage_test_bitmap_all_zero(fs_info, subpage, name) \
383 bitmap_test_range_all_zero(subpage->bitmaps, \
384 fs_info->subpage_info->name##_offset, \
385 fs_info->subpage_info->bitmap_nr_bits)
387 void btrfs_subpage_set_uptodate(const struct btrfs_fs_info *fs_info,
388 struct page *page, u64 start, u32 len)
390 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
391 unsigned int start_bit = subpage_calc_start_bit(fs_info, page,
392 uptodate, start, len);
395 spin_lock_irqsave(&subpage->lock, flags);
396 bitmap_set(subpage->bitmaps, start_bit, len >> fs_info->sectorsize_bits);
397 if (subpage_test_bitmap_all_set(fs_info, subpage, uptodate))
398 SetPageUptodate(page);
399 spin_unlock_irqrestore(&subpage->lock, flags);
402 void btrfs_subpage_clear_uptodate(const struct btrfs_fs_info *fs_info,
403 struct page *page, u64 start, u32 len)
405 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
406 unsigned int start_bit = subpage_calc_start_bit(fs_info, page,
407 uptodate, start, len);
410 spin_lock_irqsave(&subpage->lock, flags);
411 bitmap_clear(subpage->bitmaps, start_bit, len >> fs_info->sectorsize_bits);
412 ClearPageUptodate(page);
413 spin_unlock_irqrestore(&subpage->lock, flags);
416 void btrfs_subpage_set_dirty(const struct btrfs_fs_info *fs_info,
417 struct page *page, u64 start, u32 len)
419 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
420 unsigned int start_bit = subpage_calc_start_bit(fs_info, page,
424 spin_lock_irqsave(&subpage->lock, flags);
425 bitmap_set(subpage->bitmaps, start_bit, len >> fs_info->sectorsize_bits);
426 spin_unlock_irqrestore(&subpage->lock, flags);
427 set_page_dirty(page);
431 * Extra clear_and_test function for subpage dirty bitmap.
433 * Return true if we're the last bits in the dirty_bitmap and clear the
435 * Return false otherwise.
437 * NOTE: Callers should manually clear page dirty for true case, as we have
438 * extra handling for tree blocks.
440 bool btrfs_subpage_clear_and_test_dirty(const struct btrfs_fs_info *fs_info,
441 struct page *page, u64 start, u32 len)
443 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
444 unsigned int start_bit = subpage_calc_start_bit(fs_info, page,
449 spin_lock_irqsave(&subpage->lock, flags);
450 bitmap_clear(subpage->bitmaps, start_bit, len >> fs_info->sectorsize_bits);
451 if (subpage_test_bitmap_all_zero(fs_info, subpage, dirty))
453 spin_unlock_irqrestore(&subpage->lock, flags);
457 void btrfs_subpage_clear_dirty(const struct btrfs_fs_info *fs_info,
458 struct page *page, u64 start, u32 len)
462 last = btrfs_subpage_clear_and_test_dirty(fs_info, page, start, len);
464 clear_page_dirty_for_io(page);
467 void btrfs_subpage_set_writeback(const struct btrfs_fs_info *fs_info,
468 struct page *page, u64 start, u32 len)
470 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
471 unsigned int start_bit = subpage_calc_start_bit(fs_info, page,
472 writeback, start, len);
475 spin_lock_irqsave(&subpage->lock, flags);
476 bitmap_set(subpage->bitmaps, start_bit, len >> fs_info->sectorsize_bits);
477 set_page_writeback(page);
478 spin_unlock_irqrestore(&subpage->lock, flags);
481 void btrfs_subpage_clear_writeback(const struct btrfs_fs_info *fs_info,
482 struct page *page, u64 start, u32 len)
484 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
485 unsigned int start_bit = subpage_calc_start_bit(fs_info, page,
486 writeback, start, len);
489 spin_lock_irqsave(&subpage->lock, flags);
490 bitmap_clear(subpage->bitmaps, start_bit, len >> fs_info->sectorsize_bits);
491 if (subpage_test_bitmap_all_zero(fs_info, subpage, writeback)) {
492 ASSERT(PageWriteback(page));
493 end_page_writeback(page);
495 spin_unlock_irqrestore(&subpage->lock, flags);
498 void btrfs_subpage_set_ordered(const struct btrfs_fs_info *fs_info,
499 struct page *page, u64 start, u32 len)
501 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
502 unsigned int start_bit = subpage_calc_start_bit(fs_info, page,
503 ordered, start, len);
506 spin_lock_irqsave(&subpage->lock, flags);
507 bitmap_set(subpage->bitmaps, start_bit, len >> fs_info->sectorsize_bits);
508 SetPageOrdered(page);
509 spin_unlock_irqrestore(&subpage->lock, flags);
512 void btrfs_subpage_clear_ordered(const struct btrfs_fs_info *fs_info,
513 struct page *page, u64 start, u32 len)
515 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
516 unsigned int start_bit = subpage_calc_start_bit(fs_info, page,
517 ordered, start, len);
520 spin_lock_irqsave(&subpage->lock, flags);
521 bitmap_clear(subpage->bitmaps, start_bit, len >> fs_info->sectorsize_bits);
522 if (subpage_test_bitmap_all_zero(fs_info, subpage, ordered))
523 ClearPageOrdered(page);
524 spin_unlock_irqrestore(&subpage->lock, flags);
527 void btrfs_subpage_set_checked(const struct btrfs_fs_info *fs_info,
528 struct page *page, u64 start, u32 len)
530 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
531 unsigned int start_bit = subpage_calc_start_bit(fs_info, page,
532 checked, start, len);
535 spin_lock_irqsave(&subpage->lock, flags);
536 bitmap_set(subpage->bitmaps, start_bit, len >> fs_info->sectorsize_bits);
537 if (subpage_test_bitmap_all_set(fs_info, subpage, checked))
538 SetPageChecked(page);
539 spin_unlock_irqrestore(&subpage->lock, flags);
542 void btrfs_subpage_clear_checked(const struct btrfs_fs_info *fs_info,
543 struct page *page, u64 start, u32 len)
545 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
546 unsigned int start_bit = subpage_calc_start_bit(fs_info, page,
547 checked, start, len);
550 spin_lock_irqsave(&subpage->lock, flags);
551 bitmap_clear(subpage->bitmaps, start_bit, len >> fs_info->sectorsize_bits);
552 ClearPageChecked(page);
553 spin_unlock_irqrestore(&subpage->lock, flags);
557 * Unlike set/clear which is dependent on each page status, for test all bits
558 * are tested in the same way.
560 #define IMPLEMENT_BTRFS_SUBPAGE_TEST_OP(name) \
561 bool btrfs_subpage_test_##name(const struct btrfs_fs_info *fs_info, \
562 struct page *page, u64 start, u32 len) \
564 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private; \
565 unsigned int start_bit = subpage_calc_start_bit(fs_info, page, \
567 unsigned long flags; \
570 spin_lock_irqsave(&subpage->lock, flags); \
571 ret = bitmap_test_range_all_set(subpage->bitmaps, start_bit, \
572 len >> fs_info->sectorsize_bits); \
573 spin_unlock_irqrestore(&subpage->lock, flags); \
576 IMPLEMENT_BTRFS_SUBPAGE_TEST_OP(uptodate);
577 IMPLEMENT_BTRFS_SUBPAGE_TEST_OP(dirty);
578 IMPLEMENT_BTRFS_SUBPAGE_TEST_OP(writeback);
579 IMPLEMENT_BTRFS_SUBPAGE_TEST_OP(ordered);
580 IMPLEMENT_BTRFS_SUBPAGE_TEST_OP(checked);
583 * Note that, in selftests (extent-io-tests), we can have empty fs_info passed
584 * in. We only test sectorsize == PAGE_SIZE cases so far, thus we can fall
585 * back to regular sectorsize branch.
587 #define IMPLEMENT_BTRFS_PAGE_OPS(name, set_page_func, clear_page_func, \
589 void btrfs_page_set_##name(const struct btrfs_fs_info *fs_info, \
590 struct page *page, u64 start, u32 len) \
592 if (unlikely(!fs_info) || !btrfs_is_subpage(fs_info, page)) { \
593 set_page_func(page); \
596 btrfs_subpage_set_##name(fs_info, page, start, len); \
598 void btrfs_page_clear_##name(const struct btrfs_fs_info *fs_info, \
599 struct page *page, u64 start, u32 len) \
601 if (unlikely(!fs_info) || !btrfs_is_subpage(fs_info, page)) { \
602 clear_page_func(page); \
605 btrfs_subpage_clear_##name(fs_info, page, start, len); \
607 bool btrfs_page_test_##name(const struct btrfs_fs_info *fs_info, \
608 struct page *page, u64 start, u32 len) \
610 if (unlikely(!fs_info) || !btrfs_is_subpage(fs_info, page)) \
611 return test_page_func(page); \
612 return btrfs_subpage_test_##name(fs_info, page, start, len); \
614 void btrfs_page_clamp_set_##name(const struct btrfs_fs_info *fs_info, \
615 struct page *page, u64 start, u32 len) \
617 if (unlikely(!fs_info) || !btrfs_is_subpage(fs_info, page)) { \
618 set_page_func(page); \
621 btrfs_subpage_clamp_range(page, &start, &len); \
622 btrfs_subpage_set_##name(fs_info, page, start, len); \
624 void btrfs_page_clamp_clear_##name(const struct btrfs_fs_info *fs_info, \
625 struct page *page, u64 start, u32 len) \
627 if (unlikely(!fs_info) || !btrfs_is_subpage(fs_info, page)) { \
628 clear_page_func(page); \
631 btrfs_subpage_clamp_range(page, &start, &len); \
632 btrfs_subpage_clear_##name(fs_info, page, start, len); \
634 bool btrfs_page_clamp_test_##name(const struct btrfs_fs_info *fs_info, \
635 struct page *page, u64 start, u32 len) \
637 if (unlikely(!fs_info) || !btrfs_is_subpage(fs_info, page)) \
638 return test_page_func(page); \
639 btrfs_subpage_clamp_range(page, &start, &len); \
640 return btrfs_subpage_test_##name(fs_info, page, start, len); \
642 IMPLEMENT_BTRFS_PAGE_OPS(uptodate, SetPageUptodate, ClearPageUptodate,
644 IMPLEMENT_BTRFS_PAGE_OPS(dirty, set_page_dirty, clear_page_dirty_for_io,
646 IMPLEMENT_BTRFS_PAGE_OPS(writeback, set_page_writeback, end_page_writeback,
648 IMPLEMENT_BTRFS_PAGE_OPS(ordered, SetPageOrdered, ClearPageOrdered,
650 IMPLEMENT_BTRFS_PAGE_OPS(checked, SetPageChecked, ClearPageChecked, PageChecked);
653 * Make sure not only the page dirty bit is cleared, but also subpage dirty bit
656 void btrfs_page_assert_not_dirty(const struct btrfs_fs_info *fs_info,
659 struct btrfs_subpage *subpage = (struct btrfs_subpage *)page->private;
661 if (!IS_ENABLED(CONFIG_BTRFS_ASSERT))
664 ASSERT(!PageDirty(page));
665 if (!btrfs_is_subpage(fs_info, page))
668 ASSERT(PagePrivate(page) && page->private);
669 ASSERT(subpage_test_bitmap_all_zero(fs_info, subpage, dirty));
673 * Handle different locked pages with different page sizes:
675 * - Page locked by plain lock_page()
676 * It should not have any subpage::writers count.
677 * Can be unlocked by unlock_page().
678 * This is the most common locked page for __extent_writepage() called
679 * inside extent_write_cache_pages().
680 * Rarer cases include the @locked_page from extent_write_locked_range().
682 * - Page locked by lock_delalloc_pages()
683 * There is only one caller, all pages except @locked_page for
684 * extent_write_locked_range().
685 * In this case, we have to call subpage helper to handle the case.
687 void btrfs_page_unlock_writer(struct btrfs_fs_info *fs_info, struct page *page,
690 struct btrfs_subpage *subpage;
692 ASSERT(PageLocked(page));
693 /* For non-subpage case, we just unlock the page */
694 if (!btrfs_is_subpage(fs_info, page))
695 return unlock_page(page);
697 ASSERT(PagePrivate(page) && page->private);
698 subpage = (struct btrfs_subpage *)page->private;
701 * For subpage case, there are two types of locked page. With or
702 * without writers number.
704 * Since we own the page lock, no one else could touch subpage::writers
705 * and we are safe to do several atomic operations without spinlock.
707 if (atomic_read(&subpage->writers) == 0)
708 /* No writers, locked by plain lock_page() */
709 return unlock_page(page);
711 /* Have writers, use proper subpage helper to end it */
712 btrfs_page_end_writer_lock(fs_info, page, start, len);
715 #define GET_SUBPAGE_BITMAP(subpage, subpage_info, name, dst) \
716 bitmap_cut(dst, subpage->bitmaps, 0, \
717 subpage_info->name##_offset, subpage_info->bitmap_nr_bits)
719 void __cold btrfs_subpage_dump_bitmap(const struct btrfs_fs_info *fs_info,
720 struct page *page, u64 start, u32 len)
722 struct btrfs_subpage_info *subpage_info = fs_info->subpage_info;
723 struct btrfs_subpage *subpage;
724 unsigned long uptodate_bitmap;
725 unsigned long error_bitmap;
726 unsigned long dirty_bitmap;
727 unsigned long writeback_bitmap;
728 unsigned long ordered_bitmap;
729 unsigned long checked_bitmap;
732 ASSERT(PagePrivate(page) && page->private);
733 ASSERT(subpage_info);
734 subpage = (struct btrfs_subpage *)page->private;
736 spin_lock_irqsave(&subpage->lock, flags);
737 GET_SUBPAGE_BITMAP(subpage, subpage_info, uptodate, &uptodate_bitmap);
738 GET_SUBPAGE_BITMAP(subpage, subpage_info, dirty, &dirty_bitmap);
739 GET_SUBPAGE_BITMAP(subpage, subpage_info, writeback, &writeback_bitmap);
740 GET_SUBPAGE_BITMAP(subpage, subpage_info, ordered, &ordered_bitmap);
741 GET_SUBPAGE_BITMAP(subpage, subpage_info, checked, &checked_bitmap);
742 spin_unlock_irqrestore(&subpage->lock, flags);
744 dump_page(page, "btrfs subpage dump");
746 "start=%llu len=%u page=%llu, bitmaps uptodate=%*pbl error=%*pbl dirty=%*pbl writeback=%*pbl ordered=%*pbl checked=%*pbl",
747 start, len, page_offset(page),
748 subpage_info->bitmap_nr_bits, &uptodate_bitmap,
749 subpage_info->bitmap_nr_bits, &error_bitmap,
750 subpage_info->bitmap_nr_bits, &dirty_bitmap,
751 subpage_info->bitmap_nr_bits, &writeback_bitmap,
752 subpage_info->bitmap_nr_bits, &ordered_bitmap,
753 subpage_info->bitmap_nr_bits, &checked_bitmap);