Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *   Copyright (C) International Business Machines Corp., 2000-2002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *   Portions Copyright (C) Christoph Hellwig, 2001-2002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #ifndef	_H_JFS_METAPAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #define _H_JFS_METAPAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) struct metapage {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 	/* Common logsyncblk prefix (see jfs_logmgr.h) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 	u16 xflag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	u16 unused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	lid_t lid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	int lsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	struct list_head synclist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	/* End of logsyncblk prefix */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 	unsigned long flag;	/* See Below */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 	unsigned long count;	/* Reference count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	void *data;		/* Data pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	sector_t index;		/* block address of page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	wait_queue_head_t wait;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	/* implementation */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	struct page *page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	struct super_block *sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	unsigned int logical_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	/* Journal management */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	int clsn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	int nohomeok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct jfs_log *log;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) /* metapage flag */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) #define META_locked	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define META_dirty	2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) #define META_sync	3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define META_discard	4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #define META_forcewrite	5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) #define META_io		6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #define mark_metapage_dirty(mp) set_bit(META_dirty, &(mp)->flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) /* function prototypes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) extern int metapage_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) extern void metapage_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) extern struct metapage *__get_metapage(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 				  unsigned long lblock, unsigned int size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 				  int absolute, unsigned long new);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #define read_metapage(inode, lblock, size, absolute)\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	 __get_metapage(inode, lblock, size, absolute, false)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) #define get_metapage(inode, lblock, size, absolute)\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	 __get_metapage(inode, lblock, size, absolute, true)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) extern void release_metapage(struct metapage *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) extern void grab_metapage(struct metapage *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) extern void force_metapage(struct metapage *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * hold_metapage and put_metapage are used in conjunction.  The page lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * is not dropped between the two, so no other threads can get or release
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  * the metapage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) extern void hold_metapage(struct metapage *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) extern void put_metapage(struct metapage *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) static inline void write_metapage(struct metapage *mp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	set_bit(META_dirty, &mp->flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	release_metapage(mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static inline void flush_metapage(struct metapage *mp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	set_bit(META_sync, &mp->flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	write_metapage(mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) static inline void discard_metapage(struct metapage *mp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	clear_bit(META_dirty, &mp->flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	set_bit(META_discard, &mp->flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	release_metapage(mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) static inline void metapage_nohomeok(struct metapage *mp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	struct page *page = mp->page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	lock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	if (!mp->nohomeok++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		mark_metapage_dirty(mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		get_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		wait_on_page_writeback(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	unlock_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)  * This serializes access to mp->lsn when metapages are added to logsynclist
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)  * without setting nohomeok.  i.e. updating imap & dmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) static inline void metapage_wait_for_io(struct metapage *mp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	if (test_bit(META_io, &mp->flag))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		wait_on_page_writeback(mp->page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)  * This is called when already holding the metapage
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static inline void _metapage_homeok(struct metapage *mp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	if (!--mp->nohomeok)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		put_page(mp->page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static inline void metapage_homeok(struct metapage *mp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	hold_metapage(mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	_metapage_homeok(mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	put_metapage(mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) extern const struct address_space_operations jfs_metapage_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)  * This routines invalidate all pages for an extent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) extern void __invalidate_metapages(struct inode *, s64, int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) #define invalidate_pxd_metapages(ip, pxd) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	__invalidate_metapages((ip), addressPXD(&(pxd)), lengthPXD(&(pxd)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) #define invalidate_dxd_metapages(ip, dxd) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	__invalidate_metapages((ip), addressDXD(&(dxd)), lengthDXD(&(dxd)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) #define invalidate_xad_metapages(ip, xad) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	__invalidate_metapages((ip), addressXAD(&(xad)), lengthXAD(&(xad)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) #endif				/* _H_JFS_METAPAGE */