Linux Audio

Check our new training course

Loading...
v4.17
 
  1/*
  2 *   Copyright (C) International Business Machines Corp., 2000-2004
  3 *   Portions Copyright (C) Christoph Hellwig, 2001-2002
  4 *
  5 *   This program is free software;  you can redistribute it and/or modify
  6 *   it under the terms of the GNU General Public License as published by
  7 *   the Free Software Foundation; either version 2 of the License, or
  8 *   (at your option) any later version.
  9 *
 10 *   This program is distributed in the hope that it will be useful,
 11 *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
 12 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
 13 *   the GNU General Public License for more details.
 14 *
 15 *   You should have received a copy of the GNU General Public License
 16 *   along with this program;  if not, write to the Free Software
 17 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 18 */
 19#ifndef _H_JFS_INCORE
 20#define _H_JFS_INCORE
 21
 22#include <linux/mutex.h>
 23#include <linux/rwsem.h>
 24#include <linux/slab.h>
 25#include <linux/bitops.h>
 
 
 26#include "jfs_types.h"
 27#include "jfs_xtree.h"
 28#include "jfs_dtree.h"
 29
 30/*
 31 * JFS magic number
 32 */
 33#define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */
 34
 35/*
 36 * JFS-private inode information
 37 */
 38struct jfs_inode_info {
 39	int	fileset;	/* fileset number (always 16)*/
 40	uint	mode2;		/* jfs-specific mode		*/
 41	kuid_t	saved_uid;	/* saved for uid mount option */
 42	kgid_t	saved_gid;	/* saved for gid mount option */
 43	pxd_t	ixpxd;		/* inode extent descriptor	*/
 44	dxd_t	acl;		/* dxd describing acl	*/
 45	dxd_t	ea;		/* dxd describing ea	*/
 46	time_t	otime;		/* time created	*/
 47	uint	next_index;	/* next available directory entry index */
 48	int	acltype;	/* Type of ACL	*/
 49	short	btorder;	/* access order	*/
 50	short	btindex;	/* btpage entry index*/
 51	struct inode *ipimap;	/* inode map			*/
 52	unsigned long cflag;	/* commit flags		*/
 53	u64	agstart;	/* agstart of the containing IAG */
 54	u16	bxflag;		/* xflag of pseudo buffer?	*/
 55	unchar	pad;
 56	signed char active_ag;	/* ag currently allocating from	*/
 57	lid_t	blid;		/* lid of pseudo buffer?	*/
 58	lid_t	atlhead;	/* anonymous tlock list head	*/
 59	lid_t	atltail;	/* anonymous tlock list tail	*/
 60	spinlock_t ag_lock;	/* protects active_ag		*/
 61	struct list_head anon_inode_list; /* inodes having anonymous txns */
 62	/*
 63	 * rdwrlock serializes xtree between reads & writes and synchronizes
 64	 * changes to special inodes.  It's use would be redundant on
 65	 * directories since the i_mutex taken in the VFS is sufficient.
 66	 */
 67	struct rw_semaphore rdwrlock;
 68	/*
 69	 * commit_mutex serializes transaction processing on an inode.
 70	 * It must be taken after beginning a transaction (txBegin), since
 71	 * dirty inodes may be committed while a new transaction on the
 72	 * inode is blocked in txBegin or TxBeginAnon
 73	 */
 74	struct mutex commit_mutex;
 75	/* xattr_sem allows us to access the xattrs without taking i_mutex */
 76	struct rw_semaphore xattr_sem;
 77	lid_t	xtlid;		/* lid of xtree lock on directory */
 78	union {
 79		struct {
 80			xtpage_t _xtroot;	/* 288: xtree root */
 81			struct inomap *_imap;	/* 4: inode map header	*/
 82		} file;
 83		struct {
 84			struct dir_table_slot _table[12]; /* 96: dir index */
 85			dtroot_t _dtroot;	/* 288: dtree root */
 86		} dir;
 87		struct {
 88			unchar _unused[16];	/* 16: */
 89			dxd_t _dxd;		/* 16: */
 90			unchar _inline[128];	/* 128: inline symlink */
 91			/* _inline_ea may overlay the last part of
 92			 * file._xtroot if maxentry = XTROOTINITSLOT
 93			 */
 94			unchar _inline_ea[128];	/* 128: inline extended attr */
 
 
 
 
 
 
 
 
 95		} link;
 96	} u;
 97#ifdef CONFIG_QUOTA
 98	struct dquot *i_dquot[MAXQUOTAS];
 99#endif
100	u32 dev;	/* will die when we get wide dev_t */
101	struct inode	vfs_inode;
102};
103#define i_xtroot u.file._xtroot
104#define i_imap u.file._imap
105#define i_dirtable u.dir._table
106#define i_dtroot u.dir._dtroot
107#define i_inline u.link._inline
108#define i_inline_ea u.link._inline_ea
 
109
110#define IREAD_LOCK(ip, subclass) \
111	down_read_nested(&JFS_IP(ip)->rdwrlock, subclass)
112#define IREAD_UNLOCK(ip)	up_read(&JFS_IP(ip)->rdwrlock)
113#define IWRITE_LOCK(ip, subclass) \
114	down_write_nested(&JFS_IP(ip)->rdwrlock, subclass)
115#define IWRITE_UNLOCK(ip)	up_write(&JFS_IP(ip)->rdwrlock)
116
117/*
118 * cflag
119 */
120enum cflags {
121	COMMIT_Nolink,		/* inode committed with zero link count */
122	COMMIT_Inlineea,	/* commit inode inline EA */
123	COMMIT_Freewmap,	/* free WMAP at iClose() */
124	COMMIT_Dirty,		/* Inode is really dirty */
125	COMMIT_Dirtable,	/* commit changes to di_dirtable */
126	COMMIT_Stale,		/* data extent is no longer valid */
127	COMMIT_Synclist,	/* metadata pages on group commit synclist */
128};
129
130/*
131 * commit_mutex nesting subclasses:
132 */
133enum commit_mutex_class
134{
135	COMMIT_MUTEX_PARENT,
136	COMMIT_MUTEX_CHILD,
137	COMMIT_MUTEX_SECOND_PARENT,	/* Renaming */
138	COMMIT_MUTEX_VICTIM		/* Inode being unlinked due to rename */
139};
140
141/*
142 * rdwrlock subclasses:
143 * The dmap inode may be locked while a normal inode or the imap inode are
144 * locked.
145 */
146enum rdwrlock_class
147{
148	RDWRLOCK_NORMAL,
149	RDWRLOCK_IMAP,
150	RDWRLOCK_DMAP
151};
152
153#define set_cflag(flag, ip)	set_bit(flag, &(JFS_IP(ip)->cflag))
154#define clear_cflag(flag, ip)	clear_bit(flag, &(JFS_IP(ip)->cflag))
155#define test_cflag(flag, ip)	test_bit(flag, &(JFS_IP(ip)->cflag))
156#define test_and_clear_cflag(flag, ip) \
157	test_and_clear_bit(flag, &(JFS_IP(ip)->cflag))
158/*
159 * JFS-private superblock information.
160 */
161struct jfs_sb_info {
162	struct super_block *sb;		/* Point back to vfs super block */
163	unsigned long	mntflag;	/* aggregate attributes	*/
164	struct inode	*ipbmap;	/* block map inode		*/
165	struct inode	*ipaimap;	/* aggregate inode map inode	*/
166	struct inode	*ipaimap2;	/* secondary aimap inode	*/
167	struct inode	*ipimap;	/* aggregate inode map inode	*/
168	struct jfs_log	*log;		/* log			*/
169	struct list_head log_list;	/* volumes associated with a journal */
170	short		bsize;		/* logical block size	*/
171	short		l2bsize;	/* log2 logical block size	*/
172	short		nbperpage;	/* blocks per page		*/
173	short		l2nbperpage;	/* log2 blocks per page	*/
174	short		l2niperblk;	/* log2 inodes per page	*/
175	dev_t		logdev;		/* external log device	*/
176	uint		aggregate;	/* volume identifier in log record */
177	pxd_t		logpxd;		/* pxd describing log	*/
178	pxd_t		fsckpxd;	/* pxd describing fsck wkspc */
179	pxd_t		ait2;		/* pxd describing AIT copy	*/
180	char		uuid[16];	/* 128-bit uuid for volume	*/
181	char		loguuid[16];	/* 128-bit uuid for log	*/
182	/*
183	 * commit_state is used for synchronization of the jfs_commit
184	 * threads.  It is protected by LAZY_LOCK().
185	 */
186	int		commit_state;	/* commit state */
187	/* Formerly in ipimap */
188	uint		gengen;		/* inode generation generator*/
189	uint		inostamp;	/* shows inode belongs to fileset*/
190
191	/* Formerly in ipbmap */
192	struct bmap	*bmap;		/* incore bmap descriptor	*/
193	struct nls_table *nls_tab;	/* current codepage		*/
194	struct inode *direct_inode;	/* metadata inode */
195	uint		state;		/* mount/recovery state	*/
196	unsigned long	flag;		/* mount time flags */
197	uint		p_state;	/* state prior to going no integrity */
198	kuid_t		uid;		/* uid to override on-disk uid */
199	kgid_t		gid;		/* gid to override on-disk gid */
200	uint		umask;		/* umask to override on-disk umask */
201	uint		minblks_trim;	/* minimum blocks, for online trim */
202};
203
204/* jfs_sb_info commit_state */
205#define IN_LAZYCOMMIT 1
206
207static inline struct jfs_inode_info *JFS_IP(struct inode *inode)
208{
209	return container_of(inode, struct jfs_inode_info, vfs_inode);
210}
211
212static inline int jfs_dirtable_inline(struct inode *inode)
213{
214	return (JFS_IP(inode)->next_index <= (MAX_INLINE_DIRTABLE_ENTRY + 1));
215}
216
217static inline struct jfs_sb_info *JFS_SBI(struct super_block *sb)
218{
219	return sb->s_fs_info;
220}
221
222static inline int isReadOnly(struct inode *inode)
223{
224	if (JFS_SBI(inode->i_sb)->log)
225		return 0;
226	return 1;
227}
228#endif /* _H_JFS_INCORE */
v6.13.7
  1/* SPDX-License-Identifier: GPL-2.0-or-later */
  2/*
  3 *   Copyright (C) International Business Machines Corp., 2000-2004
  4 *   Portions Copyright (C) Christoph Hellwig, 2001-2002
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  5 */
  6#ifndef _H_JFS_INCORE
  7#define _H_JFS_INCORE
  8
  9#include <linux/mutex.h>
 10#include <linux/rwsem.h>
 11#include <linux/slab.h>
 12#include <linux/bitops.h>
 13#include <linux/uuid.h>
 14
 15#include "jfs_types.h"
 16#include "jfs_xtree.h"
 17#include "jfs_dtree.h"
 18
 19/*
 20 * JFS magic number
 21 */
 22#define JFS_SUPER_MAGIC 0x3153464a /* "JFS1" */
 23
 24/*
 25 * JFS-private inode information
 26 */
 27struct jfs_inode_info {
 28	int	fileset;	/* fileset number (always 16)*/
 29	uint	mode2;		/* jfs-specific mode		*/
 30	kuid_t	saved_uid;	/* saved for uid mount option */
 31	kgid_t	saved_gid;	/* saved for gid mount option */
 32	pxd_t	ixpxd;		/* inode extent descriptor	*/
 33	dxd_t	acl;		/* dxd describing acl	*/
 34	dxd_t	ea;		/* dxd describing ea	*/
 35	time64_t otime;		/* time created	*/
 36	uint	next_index;	/* next available directory entry index */
 37	int	acltype;	/* Type of ACL	*/
 38	short	btorder;	/* access order	*/
 39	short	btindex;	/* btpage entry index*/
 40	struct inode *ipimap;	/* inode map			*/
 41	unsigned long cflag;	/* commit flags		*/
 42	u64	agstart;	/* agstart of the containing IAG */
 43	u16	bxflag;		/* xflag of pseudo buffer?	*/
 44	unchar	pad;
 45	signed char active_ag;	/* ag currently allocating from	*/
 46	lid_t	blid;		/* lid of pseudo buffer?	*/
 47	lid_t	atlhead;	/* anonymous tlock list head	*/
 48	lid_t	atltail;	/* anonymous tlock list tail	*/
 49	spinlock_t ag_lock;	/* protects active_ag		*/
 50	struct list_head anon_inode_list; /* inodes having anonymous txns */
 51	/*
 52	 * rdwrlock serializes xtree between reads & writes and synchronizes
 53	 * changes to special inodes.  It's use would be redundant on
 54	 * directories since the i_mutex taken in the VFS is sufficient.
 55	 */
 56	struct rw_semaphore rdwrlock;
 57	/*
 58	 * commit_mutex serializes transaction processing on an inode.
 59	 * It must be taken after beginning a transaction (txBegin), since
 60	 * dirty inodes may be committed while a new transaction on the
 61	 * inode is blocked in txBegin or TxBeginAnon
 62	 */
 63	struct mutex commit_mutex;
 64	/* xattr_sem allows us to access the xattrs without taking i_mutex */
 65	struct rw_semaphore xattr_sem;
 66	lid_t	xtlid;		/* lid of xtree lock on directory */
 67	union {
 68		struct {
 69			xtroot_t _xtroot;	/* 288: xtree root */
 70			struct inomap *_imap;	/* 4: inode map header	*/
 71		} file;
 72		struct {
 73			struct dir_table_slot _table[12]; /* 96: dir index */
 74			dtroot_t _dtroot;	/* 288: dtree root */
 75		} dir;
 76		struct {
 77			unchar _unused[16];	/* 16: */
 78			dxd_t _dxd;		/* 16: */
 79			/* _inline may overflow into _inline_ea when needed */
 80			/* _inline_ea may overlay the last part of
 81			 * file._xtroot if maxentry = XTROOTINITSLOT
 82			 */
 83			union {
 84				struct {
 85					/* 128: inline symlink */
 86					unchar _inline[128];
 87					/* 128: inline extended attr */
 88					unchar _inline_ea[128];
 89				};
 90				unchar _inline_all[256];
 91			};
 92		} link;
 93	} u;
 94#ifdef CONFIG_QUOTA
 95	struct dquot __rcu *i_dquot[MAXQUOTAS];
 96#endif
 97	u32 dev;	/* will die when we get wide dev_t */
 98	struct inode	vfs_inode;
 99};
100#define i_xtroot u.file._xtroot
101#define i_imap u.file._imap
102#define i_dirtable u.dir._table
103#define i_dtroot u.dir._dtroot
104#define i_inline u.link._inline
105#define i_inline_ea u.link._inline_ea
106#define i_inline_all u.link._inline_all
107
108#define IREAD_LOCK(ip, subclass) \
109	down_read_nested(&JFS_IP(ip)->rdwrlock, subclass)
110#define IREAD_UNLOCK(ip)	up_read(&JFS_IP(ip)->rdwrlock)
111#define IWRITE_LOCK(ip, subclass) \
112	down_write_nested(&JFS_IP(ip)->rdwrlock, subclass)
113#define IWRITE_UNLOCK(ip)	up_write(&JFS_IP(ip)->rdwrlock)
114
115/*
116 * cflag
117 */
118enum cflags {
119	COMMIT_Nolink,		/* inode committed with zero link count */
120	COMMIT_Inlineea,	/* commit inode inline EA */
121	COMMIT_Freewmap,	/* free WMAP at iClose() */
122	COMMIT_Dirty,		/* Inode is really dirty */
123	COMMIT_Dirtable,	/* commit changes to di_dirtable */
124	COMMIT_Stale,		/* data extent is no longer valid */
125	COMMIT_Synclist,	/* metadata pages on group commit synclist */
126};
127
128/*
129 * commit_mutex nesting subclasses:
130 */
131enum commit_mutex_class
132{
133	COMMIT_MUTEX_PARENT,
134	COMMIT_MUTEX_CHILD,
135	COMMIT_MUTEX_SECOND_PARENT,	/* Renaming */
136	COMMIT_MUTEX_VICTIM		/* Inode being unlinked due to rename */
137};
138
139/*
140 * rdwrlock subclasses:
141 * The dmap inode may be locked while a normal inode or the imap inode are
142 * locked.
143 */
144enum rdwrlock_class
145{
146	RDWRLOCK_NORMAL,
147	RDWRLOCK_IMAP,
148	RDWRLOCK_DMAP
149};
150
151#define set_cflag(flag, ip)	set_bit(flag, &(JFS_IP(ip)->cflag))
152#define clear_cflag(flag, ip)	clear_bit(flag, &(JFS_IP(ip)->cflag))
153#define test_cflag(flag, ip)	test_bit(flag, &(JFS_IP(ip)->cflag))
154#define test_and_clear_cflag(flag, ip) \
155	test_and_clear_bit(flag, &(JFS_IP(ip)->cflag))
156/*
157 * JFS-private superblock information.
158 */
159struct jfs_sb_info {
160	struct super_block *sb;		/* Point back to vfs super block */
161	unsigned long	mntflag;	/* aggregate attributes	*/
162	struct inode	*ipbmap;	/* block map inode		*/
163	struct inode	*ipaimap;	/* aggregate inode map inode	*/
164	struct inode	*ipaimap2;	/* secondary aimap inode	*/
165	struct inode	*ipimap;	/* aggregate inode map inode	*/
166	struct jfs_log	*log;		/* log			*/
167	struct list_head log_list;	/* volumes associated with a journal */
168	short		bsize;		/* logical block size	*/
169	short		l2bsize;	/* log2 logical block size	*/
170	short		nbperpage;	/* blocks per page		*/
171	short		l2nbperpage;	/* log2 blocks per page	*/
172	short		l2niperblk;	/* log2 inodes per page	*/
173	dev_t		logdev;		/* external log device	*/
174	uint		aggregate;	/* volume identifier in log record */
175	pxd_t		logpxd;		/* pxd describing log	*/
176	pxd_t		fsckpxd;	/* pxd describing fsck wkspc */
177	pxd_t		ait2;		/* pxd describing AIT copy	*/
178	uuid_t		uuid;		/* 128-bit uuid for volume	*/
179	uuid_t		loguuid;	/* 128-bit uuid for log	*/
180	/*
181	 * commit_state is used for synchronization of the jfs_commit
182	 * threads.  It is protected by LAZY_LOCK().
183	 */
184	int		commit_state;	/* commit state */
185	/* Formerly in ipimap */
186	uint		gengen;		/* inode generation generator*/
187	uint		inostamp;	/* shows inode belongs to fileset*/
188
189	/* Formerly in ipbmap */
190	struct bmap	*bmap;		/* incore bmap descriptor	*/
191	struct nls_table *nls_tab;	/* current codepage		*/
192	struct inode *direct_inode;	/* metadata inode */
193	uint		state;		/* mount/recovery state	*/
194	unsigned long	flag;		/* mount time flags */
195	uint		p_state;	/* state prior to going no integrity */
196	kuid_t		uid;		/* uid to override on-disk uid */
197	kgid_t		gid;		/* gid to override on-disk gid */
198	uint		umask;		/* umask to override on-disk umask */
199	uint		minblks_trim;	/* minimum blocks, for online trim */
200};
201
202/* jfs_sb_info commit_state */
203#define IN_LAZYCOMMIT 1
204
205static inline struct jfs_inode_info *JFS_IP(struct inode *inode)
206{
207	return container_of(inode, struct jfs_inode_info, vfs_inode);
208}
209
210static inline int jfs_dirtable_inline(struct inode *inode)
211{
212	return (JFS_IP(inode)->next_index <= (MAX_INLINE_DIRTABLE_ENTRY + 1));
213}
214
215static inline struct jfs_sb_info *JFS_SBI(struct super_block *sb)
216{
217	return sb->s_fs_info;
218}
219
220static inline int isReadOnly(struct inode *inode)
221{
222	if (JFS_SBI(inode->i_sb)->log)
223		return 0;
224	return 1;
225}
226#endif /* _H_JFS_INCORE */