jfs_metapage.h 3.28 KB
Newer Older
Dave Kleikamp's avatar
Dave Kleikamp committed
1
/*
2
 *   Copyright (c) International Business Machines Corp., 2000-2002
Dave Kleikamp's avatar
Dave Kleikamp committed
3
 *   Portions Copyright (c) Christoph Hellwig, 2001-2002
Dave Kleikamp's avatar
Dave Kleikamp committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 *   This program is free software;  you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or 
 *   (at your option) any later version.
 * 
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 *   the GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program;  if not, write to the Free Software 
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */
#ifndef	_H_JFS_METAPAGE
#define _H_JFS_METAPAGE

#include <linux/pagemap.h>

24
struct metapage {
Dave Kleikamp's avatar
Dave Kleikamp committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
	/* Common logsyncblk prefix (see jfs_logmgr.h) */
	u16 xflag;
	u16 unused;
	lid_t lid;
	int lsn;
	struct list_head synclist;
	/* End of logsyncblk prefix */

	unsigned long flag;	/* See Below */
	unsigned long count;	/* Reference count */
	void *data;		/* Data pointer */

	/* list management stuff */
	struct metapage *hash_prev;
	struct metapage *hash_next;	/* Also used for free list */

	/*
	 * mapping & index become redundant, but we need these here to
	 * add the metapage to the hash before we have the real page
	 */
	struct address_space *mapping;
	unsigned long index;
	wait_queue_head_t wait;

	/* implementation */
	struct page *page;
	unsigned long logical_size;

	/* Journal management */
	int clsn;
	atomic_t nohomeok;
	struct jfs_log *log;
57
};
Dave Kleikamp's avatar
Dave Kleikamp committed
58 59 60 61 62 63 64 65 66

/* metapage flag */
#define META_locked	0
#define META_absolute	1
#define META_free	2
#define META_dirty	3
#define META_sync	4
#define META_discard	5
#define META_forced	6
67
#define META_stale	7
Dave Kleikamp's avatar
Dave Kleikamp committed
68 69 70 71

#define mark_metapage_dirty(mp) set_bit(META_dirty, &(mp)->flag)

/* function prototypes */
72
extern struct metapage *__get_metapage(struct inode *inode,
Dave Kleikamp's avatar
Dave Kleikamp committed
73 74 75 76 77 78 79 80 81
				  unsigned long lblock, unsigned int size,
				  int absolute, unsigned long new);

#define read_metapage(inode, lblock, size, absolute)\
	 __get_metapage(inode, lblock, size, absolute, FALSE)

#define get_metapage(inode, lblock, size, absolute)\
	 __get_metapage(inode, lblock, size, absolute, TRUE)

82 83
extern void release_metapage(struct metapage *);
extern void hold_metapage(struct metapage *, int);
Dave Kleikamp's avatar
Dave Kleikamp committed
84

85
static inline void write_metapage(struct metapage *mp)
Dave Kleikamp's avatar
Dave Kleikamp committed
86 87 88
{
	set_bit(META_dirty, &mp->flag);
	release_metapage(mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
89 90
}

91
static inline void flush_metapage(struct metapage *mp)
Dave Kleikamp's avatar
Dave Kleikamp committed
92 93 94
{
	set_bit(META_sync, &mp->flag);
	write_metapage(mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
95 96
}

97
static inline void discard_metapage(struct metapage *mp)
Dave Kleikamp's avatar
Dave Kleikamp committed
98 99 100 101
{
	clear_bit(META_dirty, &mp->flag);
	set_bit(META_discard, &mp->flag);
	release_metapage(mp);
Dave Kleikamp's avatar
Dave Kleikamp committed
102 103 104
}

/*
105
 * This routines invalidate all pages for an extent.
Dave Kleikamp's avatar
Dave Kleikamp committed
106
 */
107 108 109 110 111
extern void __invalidate_metapages(struct inode *, s64, int);
#define invalidate_pxd_metapages(ip, pxd) \
	__invalidate_metapages((ip), addressPXD(&(pxd)), lengthPXD(&(pxd)))
#define invalidate_dxd_metapages(ip, dxd) \
	__invalidate_metapages((ip), addressDXD(&(dxd)), lengthDXD(&(dxd)))
112 113
#define invalidate_xad_metapages(ip, xad) \
	__invalidate_metapages((ip), addressXAD(&(xad)), lengthXAD(&(xad)))
Dave Kleikamp's avatar
Dave Kleikamp committed
114 115

#endif				/* _H_JFS_METAPAGE */