Lines Matching full:mp

33 #define metapage_locked(mp) test_bit(META_locked, &(mp)->flag)  argument
34 #define trylock_metapage(mp) test_and_set_bit_lock(META_locked, &(mp)->flag) argument
36 static inline void unlock_metapage(struct metapage *mp) in unlock_metapage() argument
38 clear_bit_unlock(META_locked, &mp->flag); in unlock_metapage()
39 wake_up(&mp->wait); in unlock_metapage()
42 static inline void __lock_metapage(struct metapage *mp) in __lock_metapage() argument
46 add_wait_queue_exclusive(&mp->wait, &wait); in __lock_metapage()
49 if (metapage_locked(mp)) { in __lock_metapage()
50 folio_unlock(mp->folio); in __lock_metapage()
52 folio_lock(mp->folio); in __lock_metapage()
54 } while (trylock_metapage(mp)); in __lock_metapage()
56 remove_wait_queue(&mp->wait, &wait); in __lock_metapage()
60 * Must have mp->folio locked
62 static inline void lock_metapage(struct metapage *mp) in lock_metapage() argument
64 if (trylock_metapage(mp)) in lock_metapage()
65 __lock_metapage(mp); in lock_metapage()
80 struct metapage *mp[MPS_PER_PAGE]; member
89 return anchor->mp[offset >> L2PSIZE]; in folio_to_mp()
92 static inline int insert_metapage(struct folio *folio, struct metapage *mp) in insert_metapage() argument
107 if (mp) { in insert_metapage()
109 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1); in insert_metapage()
111 a->mp[index] = mp; in insert_metapage()
117 static inline void remove_metapage(struct folio *folio, struct metapage *mp) in remove_metapage() argument
123 index = (mp->index >> l2mp_blocks) & (MPS_PER_PAGE - 1); in remove_metapage()
125 BUG_ON(a->mp[index] != mp); in remove_metapage()
127 a->mp[index] = NULL; in remove_metapage()
160 static inline int insert_metapage(struct folio *folio, struct metapage *mp) in insert_metapage() argument
162 if (mp) { in insert_metapage()
163 folio_attach_private(folio, mp); in insert_metapage()
169 static inline void remove_metapage(struct folio *folio, struct metapage *mp) in remove_metapage() argument
182 struct metapage *mp = mempool_alloc(metapage_mempool, gfp_mask); in alloc_metapage() local
184 if (mp) { in alloc_metapage()
185 mp->lid = 0; in alloc_metapage()
186 mp->lsn = 0; in alloc_metapage()
187 mp->data = NULL; in alloc_metapage()
188 mp->clsn = 0; in alloc_metapage()
189 mp->log = NULL; in alloc_metapage()
190 init_waitqueue_head(&mp->wait); in alloc_metapage()
192 return mp; in alloc_metapage()
195 static inline void free_metapage(struct metapage *mp) in free_metapage() argument
197 mempool_free(mp, metapage_mempool); in free_metapage()
227 static inline void drop_metapage(struct folio *folio, struct metapage *mp) in drop_metapage() argument
229 if (mp->count || mp->nohomeok || test_bit(META_dirty, &mp->flag) || in drop_metapage()
230 test_bit(META_io, &mp->flag)) in drop_metapage()
232 remove_metapage(folio, mp); in drop_metapage()
234 free_metapage(mp); in drop_metapage()
283 static void remove_from_logsync(struct metapage *mp) in remove_from_logsync() argument
285 struct jfs_log *log = mp->log; in remove_from_logsync()
295 if (mp->lsn) { in remove_from_logsync()
296 mp->log = NULL; in remove_from_logsync()
297 mp->lsn = 0; in remove_from_logsync()
298 mp->clsn = 0; in remove_from_logsync()
300 list_del(&mp->synclist); in remove_from_logsync()
307 struct metapage *mp; in last_write_complete() local
317 mp = folio_to_mp(folio, offset); in last_write_complete()
318 if (mp && test_bit(META_io, &mp->flag)) { in last_write_complete()
319 if (mp->lsn) in last_write_complete()
320 remove_from_logsync(mp); in last_write_complete()
321 clear_bit(META_io, &mp->flag); in last_write_complete()
345 int block_offset; /* block offset of mp within page */ in metapage_write_folio()
350 struct metapage *mp; in metapage_write_folio() local
368 mp = folio_to_mp(folio, offset); in metapage_write_folio()
370 if (!mp || !test_bit(META_dirty, &mp->flag)) in metapage_write_folio()
373 if (mp->nohomeok && !test_bit(META_forcewrite, &mp->flag)) { in metapage_write_folio()
379 if (mp->log && !(mp->log->cflag & logGC_PAGEOUT)) in metapage_write_folio()
380 jfs_flush_journal(mp->log, 0); in metapage_write_folio()
384 clear_bit(META_dirty, &mp->flag); in metapage_write_folio()
385 set_bit(META_io, &mp->flag); in metapage_write_folio()
530 struct metapage *mp; in metapage_release_folio() local
535 mp = folio_to_mp(folio, offset); in metapage_release_folio()
537 if (!mp) in metapage_release_folio()
540 jfs_info("metapage_release_folio: mp = 0x%p", mp); in metapage_release_folio()
541 if (mp->count || mp->nohomeok || in metapage_release_folio()
542 test_bit(META_dirty, &mp->flag)) { in metapage_release_folio()
543 jfs_info("count = %ld, nohomeok = %d", mp->count, in metapage_release_folio()
544 mp->nohomeok); in metapage_release_folio()
548 if (mp->lsn) in metapage_release_folio()
549 remove_from_logsync(mp); in metapage_release_folio()
550 remove_metapage(folio, mp); in metapage_release_folio()
552 free_metapage(mp); in metapage_release_folio()
582 struct metapage *mp = NULL; in __get_metapage() local
629 mp = folio_to_mp(folio, 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->folio = folio; 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 = folio_address(folio) + page_offset; in __get_metapage()
663 mp->index = lblock; in __get_metapage()
664 if (unlikely(insert_metapage(folio, 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 folio_get(mp->folio); in grab_metapage()
689 folio_lock(mp->folio); in grab_metapage()
690 mp->count++; in grab_metapage()
691 lock_metapage(mp); in grab_metapage()
692 folio_unlock(mp->folio); in grab_metapage()
723 void force_metapage(struct metapage *mp) in force_metapage() argument
725 struct folio *folio = mp->folio; 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 folio_lock(mp->folio); in hold_metapage()
743 void put_metapage(struct metapage *mp) in put_metapage() argument
745 if (mp->count || mp->nohomeok) { in put_metapage()
747 folio_unlock(mp->folio); in put_metapage()
750 folio_get(mp->folio); in put_metapage()
751 mp->count++; in put_metapage()
752 lock_metapage(mp); in put_metapage()
753 folio_unlock(mp->folio); in put_metapage()
754 release_metapage(mp); in put_metapage()
757 void release_metapage(struct metapage * mp) in release_metapage() argument
759 struct folio *folio = mp->folio; in release_metapage()
760 jfs_info("release_metapage: mp = 0x%p, flag = 0x%lx", mp, mp->flag); in release_metapage()
763 unlock_metapage(mp); in release_metapage()
765 assert(mp->count); in release_metapage()
766 if (--mp->count || mp->nohomeok) { in release_metapage()
772 if (test_bit(META_dirty, &mp->flag)) { in release_metapage()
774 if (test_bit(META_sync, &mp->flag)) { in release_metapage()
775 clear_bit(META_sync, &mp->flag); in release_metapage()
777 jfs_error(mp->sb, "metapage_write_one() failed\n"); in release_metapage()
780 } else if (mp->lsn) /* discard_metapage doesn't remove it */ in release_metapage()
781 remove_from_logsync(mp); in release_metapage()
784 drop_metapage(folio, mp); in release_metapage()
798 struct metapage *mp; in __invalidate_metapages() local
812 mp = folio_to_mp(folio, offset); in __invalidate_metapages()
813 if (!mp) in __invalidate_metapages()
815 if (mp->index < addr) in __invalidate_metapages()
817 if (mp->index >= addr + len) in __invalidate_metapages()
820 clear_bit(META_dirty, &mp->flag); in __invalidate_metapages()
821 set_bit(META_discard, &mp->flag); in __invalidate_metapages()
822 if (mp->lsn) in __invalidate_metapages()
823 remove_from_logsync(mp); in __invalidate_metapages()