Blame view

fs/xfs/xfs_ialloc.h 5.14 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
7b7187698   Nathan Scott   [XFS] Update lice...
2
3
   * Copyright (c) 2000,2005 Silicon Graphics, Inc.
   * All Rights Reserved.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
4
   *
7b7187698   Nathan Scott   [XFS] Update lice...
5
6
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License as
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
   * published by the Free Software Foundation.
   *
7b7187698   Nathan Scott   [XFS] Update lice...
9
10
11
12
   * This program is distributed in the hope that it would 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.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
13
   *
7b7187698   Nathan Scott   [XFS] Update lice...
14
15
16
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write the Free Software Foundation,
   * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
17
18
19
20
21
22
   */
  #ifndef __XFS_IALLOC_H__
  #define	__XFS_IALLOC_H__
  
  struct xfs_buf;
  struct xfs_dinode;
94e1b69d1   Christoph Hellwig   [XFS] merge xfs_i...
23
  struct xfs_imap;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
24
25
26
27
28
29
  struct xfs_mount;
  struct xfs_trans;
  
  /*
   * Allocation parameters for inode allocation.
   */
a844f4510   Nathan Scott   [XFS] Remove xfs_...
30
31
  #define	XFS_IALLOC_INODES(mp)	(mp)->m_ialloc_inos
  #define	XFS_IALLOC_BLOCKS(mp)	(mp)->m_ialloc_blks
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
32
33
  
  /*
425f9ddd5   Eric Sandeen   [XFS] Pick a sing...
34
   * Move inodes in clusters of this size.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
35
36
   */
  #define	XFS_INODE_BIG_CLUSTER_SIZE	8192
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
37
38
39
40
41
  #define	XFS_INODE_CLUSTER_SIZE(mp)	(mp)->m_inode_cluster_size
  
  /*
   * Make an inode pointer out of the buffer/offset.
   */
a844f4510   Nathan Scott   [XFS] Remove xfs_...
42
43
44
45
46
47
  static inline struct xfs_dinode *
  xfs_make_iptr(struct xfs_mount *mp, struct xfs_buf *b, int o)
  {
  	return (xfs_dinode_t *)
  		(xfs_buf_offset(b, o << (mp)->m_sb.sb_inodelog));
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
48
49
50
51
  
  /*
   * Find a free (set) bit in the inode bitmask.
   */
a844f4510   Nathan Scott   [XFS] Remove xfs_...
52
53
54
55
  static inline int xfs_ialloc_find_free(xfs_inofree_t *fp)
  {
  	return xfs_lowbit64(*fp);
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  /*
   * Allocate an inode on disk.
   * Mode is used to tell whether the new inode will need space, and whether
   * it is a directory.
   *
   * To work within the constraint of one allocation per transaction,
   * xfs_dialloc() is designed to be called twice if it has to do an
   * allocation to make more free inodes.  If an inode is
   * available without an allocation, agbp would be set to the current
   * agbp and alloc_done set to false.
   * If an allocation needed to be done, agbp would be set to the
   * inode header of the allocation group and alloc_done set to true.
   * The caller should then commit the current transaction and allocate a new
   * transaction.  xfs_dialloc() should then be called again with
   * the agbp value returned from the previous call.
   *
   * Once we successfully pick an inode its number is returned and the
   * on-disk data structures are updated.  The inode itself is not read
   * in, since doing so would break ordering constraints with xfs_reclaim.
   *
   * *agbp should be set to NULL on the first call, *alloc_done set to FALSE.
   */
  int					/* error */
  xfs_dialloc(
  	struct xfs_trans *tp,		/* transaction pointer */
  	xfs_ino_t	parent,		/* parent inode (directory) */
  	mode_t		mode,		/* mode bits for new inode */
  	int		okalloc,	/* ok to allocate more space */
  	struct xfs_buf	**agbp,		/* buf for a.g. inode header */
  	boolean_t	*alloc_done,	/* an allocation was done to replenish
  					   the free inodes */
  	xfs_ino_t	*inop);		/* inode number allocated */
  
  /*
   * Free disk inode.  Carefully avoids touching the incore inode, all
   * manipulations incore are the caller's responsibility.
   * The on-disk inode is not changed by this operation, only the
   * btree (free inode mask) is changed.
   */
  int					/* error */
  xfs_difree(
  	struct xfs_trans *tp,		/* transaction pointer */
  	xfs_ino_t	inode,		/* inode to be freed */
  	struct xfs_bmap_free *flist,	/* extents to free */
  	int		*delete,	/* set if inode cluster was deleted */
  	xfs_ino_t	*first_ino);	/* first inode in deleted cluster */
  
  /*
94e1b69d1   Christoph Hellwig   [XFS] merge xfs_i...
105
   * Return the location of the inode in imap, for mapping it into a buffer.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
107
   */
  int
94e1b69d1   Christoph Hellwig   [XFS] merge xfs_i...
108
  xfs_imap(
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
109
110
111
  	struct xfs_mount *mp,		/* file system mount structure */
  	struct xfs_trans *tp,		/* transaction pointer */
  	xfs_ino_t	ino,		/* inode to locate */
94e1b69d1   Christoph Hellwig   [XFS] merge xfs_i...
112
  	struct xfs_imap	*imap,		/* location map structure */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
  	uint		flags);		/* flags for inode btree lookup */
  
  /*
   * Compute and fill in value of m_in_maxlevels.
   */
  void
  xfs_ialloc_compute_maxlevels(
  	struct xfs_mount *mp);		/* file system mount structure */
  
  /*
   * Log specified fields for the ag hdr (inode section)
   */
  void
  xfs_ialloc_log_agi(
  	struct xfs_trans *tp,		/* transaction pointer */
  	struct xfs_buf	*bp,		/* allocation group header buffer */
  	int		fields);	/* bitmask of fields to log */
  
  /*
   * Read in the allocation group header (inode allocation section)
   */
  int					/* error */
  xfs_ialloc_read_agi(
  	struct xfs_mount *mp,		/* file system mount structure */
  	struct xfs_trans *tp,		/* transaction pointer */
  	xfs_agnumber_t	agno,		/* allocation group number */
  	struct xfs_buf	**bpp);		/* allocation group hdr buf */
92821e2ba   David Chinner   [XFS] Lazy Superb...
140
141
142
143
144
145
146
147
148
  /*
   * Read in the allocation group header to initialise the per-ag data
   * in the mount structure
   */
  int
  xfs_ialloc_pagi_init(
  	struct xfs_mount *mp,		/* file system mount structure */
  	struct xfs_trans *tp,		/* transaction pointer */
          xfs_agnumber_t  agno);		/* allocation group number */
fe033cc84   Christoph Hellwig   [XFS] implement g...
149
  /*
218755052   Christoph Hellwig   xfs: rationalize ...
150
   * Lookup a record by ino in the btree given by cur.
fe033cc84   Christoph Hellwig   [XFS] implement g...
151
   */
218755052   Christoph Hellwig   xfs: rationalize ...
152
153
  int xfs_inobt_lookup(struct xfs_btree_cur *cur, xfs_agino_t ino,
  		xfs_lookup_t dir, int *stat);
fe033cc84   Christoph Hellwig   [XFS] implement g...
154

8cc938fe4   Christoph Hellwig   [XFS] implement g...
155
156
157
  /*
   * Get the data from the pointed-to record.
   */
2e287a731   Christoph Hellwig   xfs: improve xfs_...
158
159
  extern int xfs_inobt_get_rec(struct xfs_btree_cur *cur,
  		xfs_inobt_rec_incore_t *rec, int *stat);
fe033cc84   Christoph Hellwig   [XFS] implement g...
160

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
161
  #endif	/* __XFS_IALLOC_H__ */