Lines Matching refs:mp
31 #define metapage_locked(mp) test_bit(META_locked, &(mp)->flag) argument
32 #define trylock_metapage(mp) test_and_set_bit_lock(META_locked, &(mp)->flag) argument
34 static inline void unlock_metapage(struct metapage *mp) in unlock_metapage() argument
36 clear_bit_unlock(META_locked, &mp->flag); in unlock_metapage()
37 wake_up(&mp->wait); in unlock_metapage()
40 static inline void __lock_metapage(struct metapage *mp) in __lock_metapage() argument
44 add_wait_queue_exclusive(&mp->wait, &wait); in __lock_metapage()
47 if (metapage_locked(mp)) { in __lock_metapage()
48 unlock_page(mp->page); in __lock_metapage()
50 lock_page(mp->page); in __lock_metapage()
52 } while (trylock_metapage(mp)); in __lock_metapage()
54 remove_wait_queue(&mp->wait, &wait); in __lock_metapage()
60 static inline void lock_metapage(struct metapage *mp) in lock_metapage() argument
62 if (trylock_metapage(mp)) in lock_metapage()
63 __lock_metapage(mp); in lock_metapage()
77 struct metapage *mp[MPS_PER_PAGE]; member
85 return mp_anchor(page)->mp[offset >> L2PSIZE]; in page_to_mp()
88 static inline int insert_metapage(struct page *page, struct metapage *mp) in insert_metapage() argument
105 if (mp) { in insert_metapage()
107 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1); in insert_metapage()
109 a->mp[index] = mp; in insert_metapage()
115 static inline void remove_metapage(struct page *page, struct metapage *mp) in remove_metapage() argument
121 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1); in remove_metapage()
123 BUG_ON(a->mp[index] != mp); in remove_metapage()
125 a->mp[index] = NULL; in remove_metapage()
151 static inline int insert_metapage(struct page *page, struct metapage *mp) in insert_metapage() argument
153 if (mp) { in insert_metapage()
154 set_page_private(page, (unsigned long)mp); in insert_metapage()
161 static inline void remove_metapage(struct page *page, struct metapage *mp) in remove_metapage() argument
175 struct metapage *mp = mempool_alloc(metapage_mempool, gfp_mask); in alloc_metapage() local
177 if (mp) { in alloc_metapage()
178 mp->lid = 0; in alloc_metapage()
179 mp->lsn = 0; in alloc_metapage()
180 mp->data = NULL; in alloc_metapage()
181 mp->clsn = 0; in alloc_metapage()
182 mp->log = NULL; in alloc_metapage()
183 init_waitqueue_head(&mp->wait); in alloc_metapage()
185 return mp; in alloc_metapage()
188 static inline void free_metapage(struct metapage *mp) in free_metapage() argument
190 mempool_free(mp, metapage_mempool); in free_metapage()
220 static inline void drop_metapage(struct page *page, struct metapage *mp) in drop_metapage() argument
222 if (mp->count || mp->nohomeok || test_bit(META_dirty, &mp->flag) || in drop_metapage()
223 test_bit(META_io, &mp->flag)) in drop_metapage()
225 remove_metapage(page, mp); in drop_metapage()
227 free_metapage(mp); in drop_metapage()
279 static void remove_from_logsync(struct metapage *mp) in remove_from_logsync() argument
281 struct jfs_log *log = mp->log; in remove_from_logsync()
291 if (mp->lsn) { in remove_from_logsync()
292 mp->log = NULL; in remove_from_logsync()
293 mp->lsn = 0; in remove_from_logsync()
294 mp->clsn = 0; in remove_from_logsync()
296 list_del(&mp->synclist); in remove_from_logsync()
303 struct metapage *mp; in last_write_complete() local
307 mp = page_to_mp(page, offset); in last_write_complete()
308 if (mp && test_bit(META_io, &mp->flag)) { in last_write_complete()
309 if (mp->lsn) in last_write_complete()
310 remove_from_logsync(mp); in last_write_complete()
311 clear_bit(META_io, &mp->flag); in last_write_complete()
343 struct metapage *mp; in metapage_writepage() local
362 mp = page_to_mp(page, offset); in metapage_writepage()
364 if (!mp || !test_bit(META_dirty, &mp->flag)) in metapage_writepage()
367 if (mp->nohomeok && !test_bit(META_forcewrite, &mp->flag)) { in metapage_writepage()
373 if (mp->log && !(mp->log->cflag & logGC_PAGEOUT)) in metapage_writepage()
374 jfs_flush_journal(mp->log, 0); in metapage_writepage()
378 clear_bit(META_dirty, &mp->flag); in metapage_writepage()
379 set_bit(META_io, &mp->flag); in metapage_writepage()
530 struct metapage *mp; in metapage_releasepage() local
535 mp = page_to_mp(page, offset); in metapage_releasepage()
537 if (!mp) in metapage_releasepage()
540 jfs_info("metapage_releasepage: mp = 0x%p", mp); in metapage_releasepage()
541 if (mp->count || mp->nohomeok || in metapage_releasepage()
542 test_bit(META_dirty, &mp->flag)) { in metapage_releasepage()
543 jfs_info("count = %ld, nohomeok = %d", mp->count, in metapage_releasepage()
544 mp->nohomeok); in metapage_releasepage()
548 if (mp->lsn) in metapage_releasepage()
549 remove_from_logsync(mp); in metapage_releasepage()
550 remove_metapage(page, mp); in metapage_releasepage()
552 free_metapage(mp); in metapage_releasepage()
582 struct metapage *mp = NULL; in __get_metapage() local
629 mp = page_to_mp(page, page_offset); in __get_metapage()
630 if (mp) { in __get_metapage()
631 if (mp->logical_size != size) { in __get_metapage()
635 mp->logical_size, size); in __get_metapage()
639 mp->count++; in __get_metapage()
640 lock_metapage(mp); in __get_metapage()
641 if (test_bit(META_discard, &mp->flag)) { in __get_metapage()
645 discard_metapage(mp); in __get_metapage()
648 clear_bit(META_discard, &mp->flag); in __get_metapage()
652 mp = alloc_metapage(GFP_NOFS); in __get_metapage()
653 if (!mp) in __get_metapage()
655 mp->page = page; in __get_metapage()
656 mp->sb = inode->i_sb; in __get_metapage()
657 mp->flag = 0; in __get_metapage()
658 mp->xflag = COMMIT_PAGE; in __get_metapage()
659 mp->count = 1; in __get_metapage()
660 mp->nohomeok = 0; in __get_metapage()
661 mp->logical_size = size; in __get_metapage()
662 mp->data = page_address(page) + page_offset; in __get_metapage()
663 mp->index = lblock; in __get_metapage()
664 if (unlikely(insert_metapage(page, mp))) { in __get_metapage()
665 free_metapage(mp); in __get_metapage()
668 lock_metapage(mp); in __get_metapage()
672 jfs_info("zeroing mp = 0x%p", mp); in __get_metapage()
673 memset(mp->data, 0, PSIZE); in __get_metapage()
677 jfs_info("__get_metapage: returning = 0x%p data = 0x%p", mp, mp->data); in __get_metapage()
678 return mp; in __get_metapage()
685 void grab_metapage(struct metapage * mp) in grab_metapage() argument
687 jfs_info("grab_metapage: mp = 0x%p", mp); in grab_metapage()
688 get_page(mp->page); in grab_metapage()
689 lock_page(mp->page); in grab_metapage()
690 mp->count++; in grab_metapage()
691 lock_metapage(mp); in grab_metapage()
692 unlock_page(mp->page); in grab_metapage()
695 void force_metapage(struct metapage *mp) in force_metapage() argument
697 struct page *page = mp->page; in force_metapage()
698 jfs_info("force_metapage: mp = 0x%p", mp); in force_metapage()
699 set_bit(META_forcewrite, &mp->flag); in force_metapage()
700 clear_bit(META_sync, &mp->flag); in force_metapage()
705 jfs_error(mp->sb, "write_one_page() failed\n"); in force_metapage()
706 clear_bit(META_forcewrite, &mp->flag); in force_metapage()
710 void hold_metapage(struct metapage *mp) in hold_metapage() argument
712 lock_page(mp->page); in hold_metapage()
715 void put_metapage(struct metapage *mp) in put_metapage() argument
717 if (mp->count || mp->nohomeok) { in put_metapage()
719 unlock_page(mp->page); in put_metapage()
722 get_page(mp->page); in put_metapage()
723 mp->count++; in put_metapage()
724 lock_metapage(mp); in put_metapage()
725 unlock_page(mp->page); in put_metapage()
726 release_metapage(mp); in put_metapage()
729 void release_metapage(struct metapage * mp) in release_metapage() argument
731 struct page *page = mp->page; in release_metapage()
732 jfs_info("release_metapage: mp = 0x%p, flag = 0x%lx", mp, mp->flag); in release_metapage()
737 unlock_metapage(mp); in release_metapage()
739 assert(mp->count); in release_metapage()
740 if (--mp->count || mp->nohomeok) { in release_metapage()
746 if (test_bit(META_dirty, &mp->flag)) { in release_metapage()
748 if (test_bit(META_sync, &mp->flag)) { in release_metapage()
749 clear_bit(META_sync, &mp->flag); in release_metapage()
751 jfs_error(mp->sb, "write_one_page() failed\n"); in release_metapage()
754 } else if (mp->lsn) /* discard_metapage doesn't remove it */ in release_metapage()
755 remove_from_logsync(mp); in release_metapage()
758 drop_metapage(page, mp); in release_metapage()
772 struct metapage *mp; in __invalidate_metapages() local
786 mp = page_to_mp(page, offset); in __invalidate_metapages()
787 if (!mp) in __invalidate_metapages()
789 if (mp->index < addr) in __invalidate_metapages()
791 if (mp->index >= addr + len) in __invalidate_metapages()
794 clear_bit(META_dirty, &mp->flag); in __invalidate_metapages()
795 set_bit(META_discard, &mp->flag); in __invalidate_metapages()
796 if (mp->lsn) in __invalidate_metapages()
797 remove_from_logsync(mp); in __invalidate_metapages()