Lines Matching refs:mp

32 #define metapage_locked(mp) test_bit(META_locked, &(mp)->flag)  argument
33 #define trylock_metapage(mp) test_and_set_bit_lock(META_locked, &(mp)->flag) argument
35 static inline void unlock_metapage(struct metapage *mp) in unlock_metapage() argument
37 clear_bit_unlock(META_locked, &mp->flag); in unlock_metapage()
38 wake_up(&mp->wait); in unlock_metapage()
41 static inline void __lock_metapage(struct metapage *mp) in __lock_metapage() argument
45 add_wait_queue_exclusive(&mp->wait, &wait); in __lock_metapage()
48 if (metapage_locked(mp)) { in __lock_metapage()
49 unlock_page(mp->page); in __lock_metapage()
51 lock_page(mp->page); in __lock_metapage()
53 } while (trylock_metapage(mp)); in __lock_metapage()
55 remove_wait_queue(&mp->wait, &wait); in __lock_metapage()
61 static inline void lock_metapage(struct metapage *mp) in lock_metapage() argument
63 if (trylock_metapage(mp)) in lock_metapage()
64 __lock_metapage(mp); in lock_metapage()
78 struct metapage *mp[MPS_PER_PAGE]; member
86 return mp_anchor(page)->mp[offset >> L2PSIZE]; in page_to_mp()
89 static inline int insert_metapage(struct page *page, struct metapage *mp) in insert_metapage() argument
106 if (mp) { in insert_metapage()
108 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1); in insert_metapage()
110 a->mp[index] = mp; in insert_metapage()
116 static inline void remove_metapage(struct page *page, struct metapage *mp) in remove_metapage() argument
122 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1); in remove_metapage()
124 BUG_ON(a->mp[index] != mp); in remove_metapage()
126 a->mp[index] = NULL; in remove_metapage()
152 static inline int insert_metapage(struct page *page, struct metapage *mp) in insert_metapage() argument
154 if (mp) { in insert_metapage()
155 set_page_private(page, (unsigned long)mp); in insert_metapage()
162 static inline void remove_metapage(struct page *page, struct metapage *mp) in remove_metapage() argument
176 struct metapage *mp = mempool_alloc(metapage_mempool, gfp_mask); in alloc_metapage() local
178 if (mp) { in alloc_metapage()
179 mp->lid = 0; in alloc_metapage()
180 mp->lsn = 0; in alloc_metapage()
181 mp->data = NULL; in alloc_metapage()
182 mp->clsn = 0; in alloc_metapage()
183 mp->log = NULL; in alloc_metapage()
184 init_waitqueue_head(&mp->wait); in alloc_metapage()
186 return mp; in alloc_metapage()
189 static inline void free_metapage(struct metapage *mp) in free_metapage() argument
191 mempool_free(mp, metapage_mempool); in free_metapage()
221 static inline void drop_metapage(struct page *page, struct metapage *mp) in drop_metapage() argument
223 if (mp->count || mp->nohomeok || test_bit(META_dirty, &mp->flag) || in drop_metapage()
224 test_bit(META_io, &mp->flag)) in drop_metapage()
226 remove_metapage(page, mp); in drop_metapage()
228 free_metapage(mp); in drop_metapage()
280 static void remove_from_logsync(struct metapage *mp) in remove_from_logsync() argument
282 struct jfs_log *log = mp->log; in remove_from_logsync()
292 if (mp->lsn) { in remove_from_logsync()
293 mp->log = NULL; in remove_from_logsync()
294 mp->lsn = 0; in remove_from_logsync()
295 mp->clsn = 0; in remove_from_logsync()
297 list_del(&mp->synclist); in remove_from_logsync()
304 struct metapage *mp; in last_write_complete() local
308 mp = page_to_mp(page, offset); in last_write_complete()
309 if (mp && test_bit(META_io, &mp->flag)) { in last_write_complete()
310 if (mp->lsn) in last_write_complete()
311 remove_from_logsync(mp); in last_write_complete()
312 clear_bit(META_io, &mp->flag); in last_write_complete()
344 struct metapage *mp; in metapage_writepage() local
363 mp = page_to_mp(page, offset); in metapage_writepage()
365 if (!mp || !test_bit(META_dirty, &mp->flag)) in metapage_writepage()
368 if (mp->nohomeok && !test_bit(META_forcewrite, &mp->flag)) { in metapage_writepage()
374 if (mp->log && !(mp->log->cflag & logGC_PAGEOUT)) in metapage_writepage()
375 jfs_flush_journal(mp->log, 0); in metapage_writepage()
379 clear_bit(META_dirty, &mp->flag); in metapage_writepage()
380 set_bit(META_io, &mp->flag); in metapage_writepage()
529 struct metapage *mp; in metapage_release_folio() local
534 mp = page_to_mp(&folio->page, offset); in metapage_release_folio()
536 if (!mp) in metapage_release_folio()
539 jfs_info("metapage_release_folio: mp = 0x%p", mp); in metapage_release_folio()
540 if (mp->count || mp->nohomeok || in metapage_release_folio()
541 test_bit(META_dirty, &mp->flag)) { in metapage_release_folio()
542 jfs_info("count = %ld, nohomeok = %d", mp->count, in metapage_release_folio()
543 mp->nohomeok); in metapage_release_folio()
547 if (mp->lsn) in metapage_release_folio()
548 remove_from_logsync(mp); in metapage_release_folio()
549 remove_metapage(&folio->page, mp); in metapage_release_folio()
551 free_metapage(mp); in metapage_release_folio()
581 struct metapage *mp = NULL; in __get_metapage() local
628 mp = page_to_mp(page, page_offset); in __get_metapage()
629 if (mp) { in __get_metapage()
630 if (mp->logical_size != size) { in __get_metapage()
634 mp->logical_size, size); in __get_metapage()
638 mp->count++; in __get_metapage()
639 lock_metapage(mp); in __get_metapage()
640 if (test_bit(META_discard, &mp->flag)) { in __get_metapage()
644 discard_metapage(mp); in __get_metapage()
647 clear_bit(META_discard, &mp->flag); in __get_metapage()
651 mp = alloc_metapage(GFP_NOFS); in __get_metapage()
652 if (!mp) in __get_metapage()
654 mp->page = page; in __get_metapage()
655 mp->sb = inode->i_sb; in __get_metapage()
656 mp->flag = 0; in __get_metapage()
657 mp->xflag = COMMIT_PAGE; in __get_metapage()
658 mp->count = 1; in __get_metapage()
659 mp->nohomeok = 0; in __get_metapage()
660 mp->logical_size = size; in __get_metapage()
661 mp->data = page_address(page) + page_offset; in __get_metapage()
662 mp->index = lblock; in __get_metapage()
663 if (unlikely(insert_metapage(page, mp))) { in __get_metapage()
664 free_metapage(mp); in __get_metapage()
667 lock_metapage(mp); in __get_metapage()
671 jfs_info("zeroing mp = 0x%p", mp); in __get_metapage()
672 memset(mp->data, 0, PSIZE); in __get_metapage()
676 jfs_info("__get_metapage: returning = 0x%p data = 0x%p", mp, mp->data); in __get_metapage()
677 return mp; in __get_metapage()
684 void grab_metapage(struct metapage * mp) in grab_metapage() argument
686 jfs_info("grab_metapage: mp = 0x%p", mp); in grab_metapage()
687 get_page(mp->page); in grab_metapage()
688 lock_page(mp->page); in grab_metapage()
689 mp->count++; in grab_metapage()
690 lock_metapage(mp); in grab_metapage()
691 unlock_page(mp->page); in grab_metapage()
723 void force_metapage(struct metapage *mp) in force_metapage() argument
725 struct page *page = mp->page; in force_metapage()
726 jfs_info("force_metapage: mp = 0x%p", mp); in force_metapage()
727 set_bit(META_forcewrite, &mp->flag); in force_metapage()
728 clear_bit(META_sync, &mp->flag); in force_metapage()
733 jfs_error(mp->sb, "metapage_write_one() failed\n"); in force_metapage()
734 clear_bit(META_forcewrite, &mp->flag); in force_metapage()
738 void hold_metapage(struct metapage *mp) in hold_metapage() argument
740 lock_page(mp->page); in hold_metapage()
743 void put_metapage(struct metapage *mp) in put_metapage() argument
745 if (mp->count || mp->nohomeok) { in put_metapage()
747 unlock_page(mp->page); in put_metapage()
750 get_page(mp->page); in put_metapage()
751 mp->count++; in put_metapage()
752 lock_metapage(mp); in put_metapage()
753 unlock_page(mp->page); in put_metapage()
754 release_metapage(mp); in put_metapage()
757 void release_metapage(struct metapage * mp) in release_metapage() argument
759 struct page *page = mp->page; in release_metapage()
760 jfs_info("release_metapage: mp = 0x%p, flag = 0x%lx", mp, mp->flag); in release_metapage()
765 unlock_metapage(mp); in release_metapage()
767 assert(mp->count); in release_metapage()
768 if (--mp->count || mp->nohomeok) { in release_metapage()
774 if (test_bit(META_dirty, &mp->flag)) { in release_metapage()
776 if (test_bit(META_sync, &mp->flag)) { in release_metapage()
777 clear_bit(META_sync, &mp->flag); in release_metapage()
779 jfs_error(mp->sb, "metapage_write_one() failed\n"); in release_metapage()
782 } else if (mp->lsn) /* discard_metapage doesn't remove it */ in release_metapage()
783 remove_from_logsync(mp); in release_metapage()
786 drop_metapage(page, mp); in release_metapage()
800 struct metapage *mp; in __invalidate_metapages() local
814 mp = page_to_mp(page, offset); in __invalidate_metapages()
815 if (!mp) in __invalidate_metapages()
817 if (mp->index < addr) in __invalidate_metapages()
819 if (mp->index >= addr + len) in __invalidate_metapages()
822 clear_bit(META_dirty, &mp->flag); in __invalidate_metapages()
823 set_bit(META_discard, &mp->flag); in __invalidate_metapages()
824 if (mp->lsn) in __invalidate_metapages()
825 remove_from_logsync(mp); in __invalidate_metapages()