1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright (C) International Business Machines Corp., 2000-2002
4 * Portions Copyright (C) Christoph Hellwig, 2001-2002
6 #ifndef _H_JFS_METAPAGE
7 #define _H_JFS_METAPAGE
9 #include <linux/pagemap.h>
12 /* Common logsyncblk prefix (see jfs_logmgr.h) */
17 struct list_head synclist
;
18 /* End of logsyncblk prefix */
20 unsigned long flag
; /* See Below */
21 unsigned long count
; /* Reference count */
22 void *data
; /* Data pointer */
23 sector_t index
; /* block address of page */
24 wait_queue_head_t wait
;
28 struct super_block
*sb
;
29 unsigned int logical_size
;
31 /* Journal management */
41 #define META_discard 4
42 #define META_forcewrite 5
45 #define mark_metapage_dirty(mp) set_bit(META_dirty, &(mp)->flag)
47 /* function prototypes */
48 extern int metapage_init(void);
49 extern void metapage_exit(void);
50 extern struct metapage
*__get_metapage(struct inode
*inode
,
51 unsigned long lblock
, unsigned int size
,
52 int absolute
, unsigned long new);
54 #define read_metapage(inode, lblock, size, absolute)\
55 __get_metapage(inode, lblock, size, absolute, false)
57 #define get_metapage(inode, lblock, size, absolute)\
58 __get_metapage(inode, lblock, size, absolute, true)
60 extern void release_metapage(struct metapage
*);
61 extern void grab_metapage(struct metapage
*);
62 extern void force_metapage(struct metapage
*);
65 * hold_metapage and put_metapage are used in conjunction. The page lock
66 * is not dropped between the two, so no other threads can get or release
69 extern void hold_metapage(struct metapage
*);
70 extern void put_metapage(struct metapage
*);
72 static inline void write_metapage(struct metapage
*mp
)
74 set_bit(META_dirty
, &mp
->flag
);
78 static inline void flush_metapage(struct metapage
*mp
)
80 set_bit(META_sync
, &mp
->flag
);
84 static inline void discard_metapage(struct metapage
*mp
)
86 clear_bit(META_dirty
, &mp
->flag
);
87 set_bit(META_discard
, &mp
->flag
);
91 static inline void metapage_nohomeok(struct metapage
*mp
)
93 struct page
*page
= mp
->page
;
95 if (!mp
->nohomeok
++) {
96 mark_metapage_dirty(mp
);
98 wait_on_page_writeback(page
);
104 * This serializes access to mp->lsn when metapages are added to logsynclist
105 * without setting nohomeok. i.e. updating imap & dmap
107 static inline void metapage_wait_for_io(struct metapage
*mp
)
109 if (test_bit(META_io
, &mp
->flag
))
110 wait_on_page_writeback(mp
->page
);
114 * This is called when already holding the metapage
116 static inline void _metapage_homeok(struct metapage
*mp
)
122 static inline void metapage_homeok(struct metapage
*mp
)
125 _metapage_homeok(mp
);
129 extern const struct address_space_operations jfs_metapage_aops
;
132 * This routines invalidate all pages for an extent.
134 extern void __invalidate_metapages(struct inode
*, s64
, int);
135 #define invalidate_pxd_metapages(ip, pxd) \
136 __invalidate_metapages((ip), addressPXD(&(pxd)), lengthPXD(&(pxd)))
137 #define invalidate_dxd_metapages(ip, dxd) \
138 __invalidate_metapages((ip), addressDXD(&(dxd)), lengthDXD(&(dxd)))
139 #define invalidate_xad_metapages(ip, xad) \
140 __invalidate_metapages((ip), addressXAD(&(xad)), lengthXAD(&(xad)))
142 #endif /* _H_JFS_METAPAGE */