ia64/linux-2.6.18-xen.hg

annotate fs/jfs/jfs_metapage.h @ 524:7f8b544237bf

netfront: Allow netfront in domain 0.

This is useful if your physical network device is in a utility domain.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Apr 15 15:18:58 2008 +0100 (2008-04-15)
parents 831230e53067
children
rev   line source
ian@0 1 /*
ian@0 2 * Copyright (C) International Business Machines Corp., 2000-2002
ian@0 3 * Portions Copyright (C) Christoph Hellwig, 2001-2002
ian@0 4 *
ian@0 5 * This program is free software; you can redistribute it and/or modify
ian@0 6 * it under the terms of the GNU General Public License as published by
ian@0 7 * the Free Software Foundation; either version 2 of the License, or
ian@0 8 * (at your option) any later version.
ian@0 9 *
ian@0 10 * This program is distributed in the hope that it will be useful,
ian@0 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ian@0 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
ian@0 13 * the GNU General Public License for more details.
ian@0 14 *
ian@0 15 * You should have received a copy of the GNU General Public License
ian@0 16 * along with this program; if not, write to the Free Software
ian@0 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ian@0 18 */
ian@0 19 #ifndef _H_JFS_METAPAGE
ian@0 20 #define _H_JFS_METAPAGE
ian@0 21
ian@0 22 #include <linux/pagemap.h>
ian@0 23
ian@0 24 struct metapage {
ian@0 25 /* Common logsyncblk prefix (see jfs_logmgr.h) */
ian@0 26 u16 xflag;
ian@0 27 u16 unused;
ian@0 28 lid_t lid;
ian@0 29 int lsn;
ian@0 30 struct list_head synclist;
ian@0 31 /* End of logsyncblk prefix */
ian@0 32
ian@0 33 unsigned long flag; /* See Below */
ian@0 34 unsigned long count; /* Reference count */
ian@0 35 void *data; /* Data pointer */
ian@0 36 sector_t index; /* block address of page */
ian@0 37 wait_queue_head_t wait;
ian@0 38
ian@0 39 /* implementation */
ian@0 40 struct page *page;
ian@0 41 unsigned int logical_size;
ian@0 42
ian@0 43 /* Journal management */
ian@0 44 int clsn;
ian@0 45 int nohomeok;
ian@0 46 struct jfs_log *log;
ian@0 47 };
ian@0 48
ian@0 49 /* metapage flag */
ian@0 50 #define META_locked 0
ian@0 51 #define META_free 1
ian@0 52 #define META_dirty 2
ian@0 53 #define META_sync 3
ian@0 54 #define META_discard 4
ian@0 55 #define META_forcewrite 5
ian@0 56 #define META_io 6
ian@0 57
ian@0 58 #define mark_metapage_dirty(mp) set_bit(META_dirty, &(mp)->flag)
ian@0 59
ian@0 60 /* function prototypes */
ian@0 61 extern int metapage_init(void);
ian@0 62 extern void metapage_exit(void);
ian@0 63 extern struct metapage *__get_metapage(struct inode *inode,
ian@0 64 unsigned long lblock, unsigned int size,
ian@0 65 int absolute, unsigned long new);
ian@0 66
ian@0 67 #define read_metapage(inode, lblock, size, absolute)\
ian@0 68 __get_metapage(inode, lblock, size, absolute, FALSE)
ian@0 69
ian@0 70 #define get_metapage(inode, lblock, size, absolute)\
ian@0 71 __get_metapage(inode, lblock, size, absolute, TRUE)
ian@0 72
ian@0 73 extern void release_metapage(struct metapage *);
ian@0 74 extern void grab_metapage(struct metapage *);
ian@0 75 extern void force_metapage(struct metapage *);
ian@0 76
ian@0 77 /*
ian@0 78 * hold_metapage and put_metapage are used in conjuction. The page lock
ian@0 79 * is not dropped between the two, so no other threads can get or release
ian@0 80 * the metapage
ian@0 81 */
ian@0 82 extern void hold_metapage(struct metapage *);
ian@0 83 extern void put_metapage(struct metapage *);
ian@0 84
ian@0 85 static inline void write_metapage(struct metapage *mp)
ian@0 86 {
ian@0 87 set_bit(META_dirty, &mp->flag);
ian@0 88 release_metapage(mp);
ian@0 89 }
ian@0 90
ian@0 91 static inline void flush_metapage(struct metapage *mp)
ian@0 92 {
ian@0 93 set_bit(META_sync, &mp->flag);
ian@0 94 write_metapage(mp);
ian@0 95 }
ian@0 96
ian@0 97 static inline void discard_metapage(struct metapage *mp)
ian@0 98 {
ian@0 99 clear_bit(META_dirty, &mp->flag);
ian@0 100 set_bit(META_discard, &mp->flag);
ian@0 101 release_metapage(mp);
ian@0 102 }
ian@0 103
ian@0 104 static inline void metapage_nohomeok(struct metapage *mp)
ian@0 105 {
ian@0 106 struct page *page = mp->page;
ian@0 107 lock_page(page);
ian@0 108 if (!mp->nohomeok++) {
ian@0 109 mark_metapage_dirty(mp);
ian@0 110 page_cache_get(page);
ian@0 111 wait_on_page_writeback(page);
ian@0 112 }
ian@0 113 unlock_page(page);
ian@0 114 }
ian@0 115
ian@0 116 /*
ian@0 117 * This serializes access to mp->lsn when metapages are added to logsynclist
ian@0 118 * without setting nohomeok. i.e. updating imap & dmap
ian@0 119 */
ian@0 120 static inline void metapage_wait_for_io(struct metapage *mp)
ian@0 121 {
ian@0 122 if (test_bit(META_io, &mp->flag))
ian@0 123 wait_on_page_writeback(mp->page);
ian@0 124 }
ian@0 125
ian@0 126 /*
ian@0 127 * This is called when already holding the metapage
ian@0 128 */
ian@0 129 static inline void _metapage_homeok(struct metapage *mp)
ian@0 130 {
ian@0 131 if (!--mp->nohomeok)
ian@0 132 page_cache_release(mp->page);
ian@0 133 }
ian@0 134
ian@0 135 static inline void metapage_homeok(struct metapage *mp)
ian@0 136 {
ian@0 137 hold_metapage(mp);
ian@0 138 _metapage_homeok(mp);
ian@0 139 put_metapage(mp);
ian@0 140 }
ian@0 141
ian@0 142 extern const struct address_space_operations jfs_metapage_aops;
ian@0 143
ian@0 144 /*
ian@0 145 * This routines invalidate all pages for an extent.
ian@0 146 */
ian@0 147 extern void __invalidate_metapages(struct inode *, s64, int);
ian@0 148 #define invalidate_pxd_metapages(ip, pxd) \
ian@0 149 __invalidate_metapages((ip), addressPXD(&(pxd)), lengthPXD(&(pxd)))
ian@0 150 #define invalidate_dxd_metapages(ip, dxd) \
ian@0 151 __invalidate_metapages((ip), addressDXD(&(dxd)), lengthDXD(&(dxd)))
ian@0 152 #define invalidate_xad_metapages(ip, xad) \
ian@0 153 __invalidate_metapages((ip), addressXAD(&(xad)), lengthXAD(&(xad)))
ian@0 154
ian@0 155 #endif /* _H_JFS_METAPAGE */