diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-12 12:48:17 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-12 12:48:17 -0500 |
commit | c05e14f7b3145ac89635fa398934438240dace40 (patch) | |
tree | 5c28b928cf630ef10464e325a7dee03210b3793e /fs | |
parent | 9bfccec24e31f4f83445cfe0c1b0a5ef97900628 (diff) | |
parent | 6044e4386cd51dece882ea42352cdaaab0f24cad (diff) |
Merge tag 'xfs-for-linus-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs
Pull xfs update from Dave Chinner:
"There's relatively little change in this update; it is mainly bug
fixes, cleanups and more of the on-going libxfs restructuring and
on-disk format header consolidation work.
Details:
- more on-disk format header consolidation
- move some structures shared with userspace to libxfs
- new per-mount workqueue to fix for deadlocks between nested loop
mounted filesystems
- various bug fixes for ENOSPC, stats, quota off and preallocation
- a bunch of compiler warning fixes for set-but-unused variables
- various code cleanups"
* tag 'xfs-for-linus-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs: (24 commits)
xfs: split metadata and log buffer completion to separate workqueues
xfs: fix set-but-unused warnings
xfs: move type conversion functions to xfs_dir.h
xfs: move ftype conversion functions to libxfs
xfs: lobotomise xfs_trans_read_buf_map()
xfs: active inodes stat is broken
xfs: cleanup xfs_bmse_merge returns
xfs: cleanup xfs_bmse_shift_one goto mess
xfs: fix premature enospc on inode allocation
xfs: overflow in xfs_iomap_eof_align_last_fsb
xfs: fix simple_return.cocci warning in xfs_bmse_shift_one
xfs: fix simple_return.cocci warning in xfs_file_readdir
libxfs: fix simple_return.cocci warnings
xfs: remove unnecessary null checks
xfs: merge xfs_inum.h into xfs_format.h
xfs: move most of xfs_sb.h to xfs_format.h
xfs: merge xfs_ag.h into xfs_format.h
xfs: move acl structures to xfs_format.h
xfs: merge xfs_dinode.h into xfs_format.h
xfs: catch invalid negative blknos in _xfs_buf_find()
...
Diffstat (limited to 'fs')
89 files changed, 1467 insertions, 1835 deletions
diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h deleted file mode 100644 index 6e247a99f5db..000000000000 --- a/fs/xfs/libxfs/xfs_ag.h +++ /dev/null | |||
@@ -1,281 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | #ifndef __XFS_AG_H__ | ||
19 | #define __XFS_AG_H__ | ||
20 | |||
21 | /* | ||
22 | * Allocation group header | ||
23 | * This is divided into three structures, placed in sequential 512-byte | ||
24 | * buffers after a copy of the superblock (also in a 512-byte buffer). | ||
25 | */ | ||
26 | |||
27 | struct xfs_buf; | ||
28 | struct xfs_mount; | ||
29 | struct xfs_trans; | ||
30 | |||
31 | #define XFS_AGF_MAGIC 0x58414746 /* 'XAGF' */ | ||
32 | #define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */ | ||
33 | #define XFS_AGFL_MAGIC 0x5841464c /* 'XAFL' */ | ||
34 | #define XFS_AGF_VERSION 1 | ||
35 | #define XFS_AGI_VERSION 1 | ||
36 | |||
37 | #define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION) | ||
38 | #define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION) | ||
39 | |||
40 | /* | ||
41 | * Btree number 0 is bno, 1 is cnt. This value gives the size of the | ||
42 | * arrays below. | ||
43 | */ | ||
44 | #define XFS_BTNUM_AGF ((int)XFS_BTNUM_CNTi + 1) | ||
45 | |||
46 | /* | ||
47 | * The second word of agf_levels in the first a.g. overlaps the EFS | ||
48 | * superblock's magic number. Since the magic numbers valid for EFS | ||
49 | * are > 64k, our value cannot be confused for an EFS superblock's. | ||
50 | */ | ||
51 | |||
52 | typedef struct xfs_agf { | ||
53 | /* | ||
54 | * Common allocation group header information | ||
55 | */ | ||
56 | __be32 agf_magicnum; /* magic number == XFS_AGF_MAGIC */ | ||
57 | __be32 agf_versionnum; /* header version == XFS_AGF_VERSION */ | ||
58 | __be32 agf_seqno; /* sequence # starting from 0 */ | ||
59 | __be32 agf_length; /* size in blocks of a.g. */ | ||
60 | /* | ||
61 | * Freespace information | ||
62 | */ | ||
63 | __be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */ | ||
64 | __be32 agf_spare0; /* spare field */ | ||
65 | __be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */ | ||
66 | __be32 agf_spare1; /* spare field */ | ||
67 | |||
68 | __be32 agf_flfirst; /* first freelist block's index */ | ||
69 | __be32 agf_fllast; /* last freelist block's index */ | ||
70 | __be32 agf_flcount; /* count of blocks in freelist */ | ||
71 | __be32 agf_freeblks; /* total free blocks */ | ||
72 | |||
73 | __be32 agf_longest; /* longest free space */ | ||
74 | __be32 agf_btreeblks; /* # of blocks held in AGF btrees */ | ||
75 | uuid_t agf_uuid; /* uuid of filesystem */ | ||
76 | |||
77 | /* | ||
78 | * reserve some contiguous space for future logged fields before we add | ||
79 | * the unlogged fields. This makes the range logging via flags and | ||
80 | * structure offsets much simpler. | ||
81 | */ | ||
82 | __be64 agf_spare64[16]; | ||
83 | |||
84 | /* unlogged fields, written during buffer writeback. */ | ||
85 | __be64 agf_lsn; /* last write sequence */ | ||
86 | __be32 agf_crc; /* crc of agf sector */ | ||
87 | __be32 agf_spare2; | ||
88 | |||
89 | /* structure must be padded to 64 bit alignment */ | ||
90 | } xfs_agf_t; | ||
91 | |||
92 | #define XFS_AGF_CRC_OFF offsetof(struct xfs_agf, agf_crc) | ||
93 | |||
94 | #define XFS_AGF_MAGICNUM 0x00000001 | ||
95 | #define XFS_AGF_VERSIONNUM 0x00000002 | ||
96 | #define XFS_AGF_SEQNO 0x00000004 | ||
97 | #define XFS_AGF_LENGTH 0x00000008 | ||
98 | #define XFS_AGF_ROOTS 0x00000010 | ||
99 | #define XFS_AGF_LEVELS 0x00000020 | ||
100 | #define XFS_AGF_FLFIRST 0x00000040 | ||
101 | #define XFS_AGF_FLLAST 0x00000080 | ||
102 | #define XFS_AGF_FLCOUNT 0x00000100 | ||
103 | #define XFS_AGF_FREEBLKS 0x00000200 | ||
104 | #define XFS_AGF_LONGEST 0x00000400 | ||
105 | #define XFS_AGF_BTREEBLKS 0x00000800 | ||
106 | #define XFS_AGF_UUID 0x00001000 | ||
107 | #define XFS_AGF_NUM_BITS 13 | ||
108 | #define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) | ||
109 | |||
110 | #define XFS_AGF_FLAGS \ | ||
111 | { XFS_AGF_MAGICNUM, "MAGICNUM" }, \ | ||
112 | { XFS_AGF_VERSIONNUM, "VERSIONNUM" }, \ | ||
113 | { XFS_AGF_SEQNO, "SEQNO" }, \ | ||
114 | { XFS_AGF_LENGTH, "LENGTH" }, \ | ||
115 | { XFS_AGF_ROOTS, "ROOTS" }, \ | ||
116 | { XFS_AGF_LEVELS, "LEVELS" }, \ | ||
117 | { XFS_AGF_FLFIRST, "FLFIRST" }, \ | ||
118 | { XFS_AGF_FLLAST, "FLLAST" }, \ | ||
119 | { XFS_AGF_FLCOUNT, "FLCOUNT" }, \ | ||
120 | { XFS_AGF_FREEBLKS, "FREEBLKS" }, \ | ||
121 | { XFS_AGF_LONGEST, "LONGEST" }, \ | ||
122 | { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \ | ||
123 | { XFS_AGF_UUID, "UUID" } | ||
124 | |||
125 | /* disk block (xfs_daddr_t) in the AG */ | ||
126 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) | ||
127 | #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) | ||
128 | #define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)((bp)->b_addr)) | ||
129 | |||
130 | extern int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp, | ||
131 | xfs_agnumber_t agno, int flags, struct xfs_buf **bpp); | ||
132 | |||
133 | /* | ||
134 | * Size of the unlinked inode hash table in the agi. | ||
135 | */ | ||
136 | #define XFS_AGI_UNLINKED_BUCKETS 64 | ||
137 | |||
138 | typedef struct xfs_agi { | ||
139 | /* | ||
140 | * Common allocation group header information | ||
141 | */ | ||
142 | __be32 agi_magicnum; /* magic number == XFS_AGI_MAGIC */ | ||
143 | __be32 agi_versionnum; /* header version == XFS_AGI_VERSION */ | ||
144 | __be32 agi_seqno; /* sequence # starting from 0 */ | ||
145 | __be32 agi_length; /* size in blocks of a.g. */ | ||
146 | /* | ||
147 | * Inode information | ||
148 | * Inodes are mapped by interpreting the inode number, so no | ||
149 | * mapping data is needed here. | ||
150 | */ | ||
151 | __be32 agi_count; /* count of allocated inodes */ | ||
152 | __be32 agi_root; /* root of inode btree */ | ||
153 | __be32 agi_level; /* levels in inode btree */ | ||
154 | __be32 agi_freecount; /* number of free inodes */ | ||
155 | |||
156 | __be32 agi_newino; /* new inode just allocated */ | ||
157 | __be32 agi_dirino; /* last directory inode chunk */ | ||
158 | /* | ||
159 | * Hash table of inodes which have been unlinked but are | ||
160 | * still being referenced. | ||
161 | */ | ||
162 | __be32 agi_unlinked[XFS_AGI_UNLINKED_BUCKETS]; | ||
163 | /* | ||
164 | * This marks the end of logging region 1 and start of logging region 2. | ||
165 | */ | ||
166 | uuid_t agi_uuid; /* uuid of filesystem */ | ||
167 | __be32 agi_crc; /* crc of agi sector */ | ||
168 | __be32 agi_pad32; | ||
169 | __be64 agi_lsn; /* last write sequence */ | ||
170 | |||
171 | __be32 agi_free_root; /* root of the free inode btree */ | ||
172 | __be32 agi_free_level;/* levels in free inode btree */ | ||
173 | |||
174 | /* structure must be padded to 64 bit alignment */ | ||
175 | } xfs_agi_t; | ||
176 | |||
177 | #define XFS_AGI_CRC_OFF offsetof(struct xfs_agi, agi_crc) | ||
178 | |||
179 | #define XFS_AGI_MAGICNUM (1 << 0) | ||
180 | #define XFS_AGI_VERSIONNUM (1 << 1) | ||
181 | #define XFS_AGI_SEQNO (1 << 2) | ||
182 | #define XFS_AGI_LENGTH (1 << 3) | ||
183 | #define XFS_AGI_COUNT (1 << 4) | ||
184 | #define XFS_AGI_ROOT (1 << 5) | ||
185 | #define XFS_AGI_LEVEL (1 << 6) | ||
186 | #define XFS_AGI_FREECOUNT (1 << 7) | ||
187 | #define XFS_AGI_NEWINO (1 << 8) | ||
188 | #define XFS_AGI_DIRINO (1 << 9) | ||
189 | #define XFS_AGI_UNLINKED (1 << 10) | ||
190 | #define XFS_AGI_NUM_BITS_R1 11 /* end of the 1st agi logging region */ | ||
191 | #define XFS_AGI_ALL_BITS_R1 ((1 << XFS_AGI_NUM_BITS_R1) - 1) | ||
192 | #define XFS_AGI_FREE_ROOT (1 << 11) | ||
193 | #define XFS_AGI_FREE_LEVEL (1 << 12) | ||
194 | #define XFS_AGI_NUM_BITS_R2 13 | ||
195 | |||
196 | /* disk block (xfs_daddr_t) in the AG */ | ||
197 | #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) | ||
198 | #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) | ||
199 | #define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)((bp)->b_addr)) | ||
200 | |||
201 | extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, | ||
202 | xfs_agnumber_t agno, struct xfs_buf **bpp); | ||
203 | |||
204 | /* | ||
205 | * The third a.g. block contains the a.g. freelist, an array | ||
206 | * of block pointers to blocks owned by the allocation btree code. | ||
207 | */ | ||
208 | #define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) | ||
209 | #define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) | ||
210 | #define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)((bp)->b_addr)) | ||
211 | |||
212 | #define XFS_BUF_TO_AGFL_BNO(mp, bp) \ | ||
213 | (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ | ||
214 | &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \ | ||
215 | (__be32 *)(bp)->b_addr) | ||
216 | |||
217 | /* | ||
218 | * Size of the AGFL. For CRC-enabled filesystes we steal a couple of | ||
219 | * slots in the beginning of the block for a proper header with the | ||
220 | * location information and CRC. | ||
221 | */ | ||
222 | #define XFS_AGFL_SIZE(mp) \ | ||
223 | (((mp)->m_sb.sb_sectsize - \ | ||
224 | (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ | ||
225 | sizeof(struct xfs_agfl) : 0)) / \ | ||
226 | sizeof(xfs_agblock_t)) | ||
227 | |||
228 | typedef struct xfs_agfl { | ||
229 | __be32 agfl_magicnum; | ||
230 | __be32 agfl_seqno; | ||
231 | uuid_t agfl_uuid; | ||
232 | __be64 agfl_lsn; | ||
233 | __be32 agfl_crc; | ||
234 | __be32 agfl_bno[]; /* actually XFS_AGFL_SIZE(mp) */ | ||
235 | } xfs_agfl_t; | ||
236 | |||
237 | #define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc) | ||
238 | |||
239 | /* | ||
240 | * tags for inode radix tree | ||
241 | */ | ||
242 | #define XFS_ICI_NO_TAG (-1) /* special flag for an untagged lookup | ||
243 | in xfs_inode_ag_iterator */ | ||
244 | #define XFS_ICI_RECLAIM_TAG 0 /* inode is to be reclaimed */ | ||
245 | #define XFS_ICI_EOFBLOCKS_TAG 1 /* inode has blocks beyond EOF */ | ||
246 | |||
247 | #define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels) | ||
248 | #define XFS_MIN_FREELIST_RAW(bl,cl,mp) \ | ||
249 | (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + MIN(cl + 1, XFS_AG_MAXLEVELS(mp))) | ||
250 | #define XFS_MIN_FREELIST(a,mp) \ | ||
251 | (XFS_MIN_FREELIST_RAW( \ | ||
252 | be32_to_cpu((a)->agf_levels[XFS_BTNUM_BNOi]), \ | ||
253 | be32_to_cpu((a)->agf_levels[XFS_BTNUM_CNTi]), mp)) | ||
254 | #define XFS_MIN_FREELIST_PAG(pag,mp) \ | ||
255 | (XFS_MIN_FREELIST_RAW( \ | ||
256 | (unsigned int)(pag)->pagf_levels[XFS_BTNUM_BNOi], \ | ||
257 | (unsigned int)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp)) | ||
258 | |||
259 | #define XFS_AGB_TO_FSB(mp,agno,agbno) \ | ||
260 | (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno)) | ||
261 | #define XFS_FSB_TO_AGNO(mp,fsbno) \ | ||
262 | ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog)) | ||
263 | #define XFS_FSB_TO_AGBNO(mp,fsbno) \ | ||
264 | ((xfs_agblock_t)((fsbno) & xfs_mask32lo((mp)->m_sb.sb_agblklog))) | ||
265 | #define XFS_AGB_TO_DADDR(mp,agno,agbno) \ | ||
266 | ((xfs_daddr_t)XFS_FSB_TO_BB(mp, \ | ||
267 | (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno))) | ||
268 | #define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d)) | ||
269 | |||
270 | /* | ||
271 | * For checking for bad ranges of xfs_daddr_t's, covering multiple | ||
272 | * allocation groups or a single xfs_daddr_t that's a superblock copy. | ||
273 | */ | ||
274 | #define XFS_AG_CHECK_DADDR(mp,d,len) \ | ||
275 | ((len) == 1 ? \ | ||
276 | ASSERT((d) == XFS_SB_DADDR || \ | ||
277 | xfs_daddr_to_agbno(mp, d) != XFS_SB_DADDR) : \ | ||
278 | ASSERT(xfs_daddr_to_agno(mp, d) == \ | ||
279 | xfs_daddr_to_agno(mp, (d) + (len) - 1))) | ||
280 | |||
281 | #endif /* __XFS_AG_H__ */ | ||
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c index eff34218f405..a6fbf4472017 100644 --- a/fs/xfs/libxfs/xfs_alloc.c +++ b/fs/xfs/libxfs/xfs_alloc.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 27 | #include "xfs_inode.h" |
29 | #include "xfs_btree.h" | 28 | #include "xfs_btree.h" |
diff --git a/fs/xfs/libxfs/xfs_alloc.h b/fs/xfs/libxfs/xfs_alloc.h index feacb061bab7..d1b4b6a5c894 100644 --- a/fs/xfs/libxfs/xfs_alloc.h +++ b/fs/xfs/libxfs/xfs_alloc.h | |||
@@ -231,4 +231,7 @@ xfs_alloc_get_rec( | |||
231 | xfs_extlen_t *len, /* output: length of extent */ | 231 | xfs_extlen_t *len, /* output: length of extent */ |
232 | int *stat); /* output: success/failure */ | 232 | int *stat); /* output: success/failure */ |
233 | 233 | ||
234 | int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp, | ||
235 | xfs_agnumber_t agno, int flags, struct xfs_buf **bpp); | ||
236 | |||
234 | #endif /* __XFS_ALLOC_H__ */ | 237 | #endif /* __XFS_ALLOC_H__ */ |
diff --git a/fs/xfs/libxfs/xfs_alloc_btree.c b/fs/xfs/libxfs/xfs_alloc_btree.c index e0e83e24d3ef..59d521c09a17 100644 --- a/fs/xfs/libxfs/xfs_alloc_btree.c +++ b/fs/xfs/libxfs/xfs_alloc_btree.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
27 | #include "xfs_btree.h" | 26 | #include "xfs_btree.h" |
28 | #include "xfs_alloc_btree.h" | 27 | #include "xfs_alloc_btree.h" |
diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c index 353fb425faef..0a472fbe06d4 100644 --- a/fs/xfs/libxfs/xfs_attr.c +++ b/fs/xfs/libxfs/xfs_attr.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_da_format.h" | 26 | #include "xfs_da_format.h" |
29 | #include "xfs_da_btree.h" | 27 | #include "xfs_da_btree.h" |
@@ -42,7 +40,6 @@ | |||
42 | #include "xfs_quota.h" | 40 | #include "xfs_quota.h" |
43 | #include "xfs_trans_space.h" | 41 | #include "xfs_trans_space.h" |
44 | #include "xfs_trace.h" | 42 | #include "xfs_trace.h" |
45 | #include "xfs_dinode.h" | ||
46 | 43 | ||
47 | /* | 44 | /* |
48 | * xfs_attr.c | 45 | * xfs_attr.c |
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index b1f73dbbf3d8..5d38e8b8a913 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_bit.h" | 25 | #include "xfs_bit.h" |
26 | #include "xfs_sb.h" | 26 | #include "xfs_sb.h" |
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 27 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 28 | #include "xfs_da_format.h" |
30 | #include "xfs_da_btree.h" | 29 | #include "xfs_da_btree.h" |
@@ -41,7 +40,6 @@ | |||
41 | #include "xfs_trace.h" | 40 | #include "xfs_trace.h" |
42 | #include "xfs_buf_item.h" | 41 | #include "xfs_buf_item.h" |
43 | #include "xfs_cksum.h" | 42 | #include "xfs_cksum.h" |
44 | #include "xfs_dinode.h" | ||
45 | #include "xfs_dir2.h" | 43 | #include "xfs_dir2.h" |
46 | 44 | ||
47 | 45 | ||
diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index 7510ab8058a4..20de88d1bf86 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c | |||
@@ -23,8 +23,6 @@ | |||
23 | #include "xfs_log_format.h" | 23 | #include "xfs_log_format.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_bit.h" | 25 | #include "xfs_bit.h" |
26 | #include "xfs_sb.h" | ||
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 27 | #include "xfs_da_format.h" |
30 | #include "xfs_da_btree.h" | 28 | #include "xfs_da_btree.h" |
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 79c981984dca..b5eb4743f75a 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c | |||
@@ -22,9 +22,7 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_inum.h" | ||
26 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 27 | #include "xfs_da_format.h" |
30 | #include "xfs_da_btree.h" | 28 | #include "xfs_da_btree.h" |
@@ -46,7 +44,6 @@ | |||
46 | #include "xfs_trace.h" | 44 | #include "xfs_trace.h" |
47 | #include "xfs_symlink.h" | 45 | #include "xfs_symlink.h" |
48 | #include "xfs_attr_leaf.h" | 46 | #include "xfs_attr_leaf.h" |
49 | #include "xfs_dinode.h" | ||
50 | #include "xfs_filestream.h" | 47 | #include "xfs_filestream.h" |
51 | 48 | ||
52 | 49 | ||
@@ -5450,13 +5447,11 @@ xfs_bmse_merge( | |||
5450 | struct xfs_btree_cur *cur, | 5447 | struct xfs_btree_cur *cur, |
5451 | int *logflags) /* output */ | 5448 | int *logflags) /* output */ |
5452 | { | 5449 | { |
5453 | struct xfs_ifork *ifp; | ||
5454 | struct xfs_bmbt_irec got; | 5450 | struct xfs_bmbt_irec got; |
5455 | struct xfs_bmbt_irec left; | 5451 | struct xfs_bmbt_irec left; |
5456 | xfs_filblks_t blockcount; | 5452 | xfs_filblks_t blockcount; |
5457 | int error, i; | 5453 | int error, i; |
5458 | 5454 | ||
5459 | ifp = XFS_IFORK_PTR(ip, whichfork); | ||
5460 | xfs_bmbt_get_all(gotp, &got); | 5455 | xfs_bmbt_get_all(gotp, &got); |
5461 | xfs_bmbt_get_all(leftp, &left); | 5456 | xfs_bmbt_get_all(leftp, &left); |
5462 | blockcount = left.br_blockcount + got.br_blockcount; | 5457 | blockcount = left.br_blockcount + got.br_blockcount; |
@@ -5489,32 +5484,25 @@ xfs_bmse_merge( | |||
5489 | error = xfs_bmbt_lookup_eq(cur, got.br_startoff, got.br_startblock, | 5484 | error = xfs_bmbt_lookup_eq(cur, got.br_startoff, got.br_startblock, |
5490 | got.br_blockcount, &i); | 5485 | got.br_blockcount, &i); |
5491 | if (error) | 5486 | if (error) |
5492 | goto out_error; | 5487 | return error; |
5493 | XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); | 5488 | XFS_WANT_CORRUPTED_RETURN(i == 1); |
5494 | 5489 | ||
5495 | error = xfs_btree_delete(cur, &i); | 5490 | error = xfs_btree_delete(cur, &i); |
5496 | if (error) | 5491 | if (error) |
5497 | goto out_error; | 5492 | return error; |
5498 | XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); | 5493 | XFS_WANT_CORRUPTED_RETURN(i == 1); |
5499 | 5494 | ||
5500 | /* lookup and update size of the previous extent */ | 5495 | /* lookup and update size of the previous extent */ |
5501 | error = xfs_bmbt_lookup_eq(cur, left.br_startoff, left.br_startblock, | 5496 | error = xfs_bmbt_lookup_eq(cur, left.br_startoff, left.br_startblock, |
5502 | left.br_blockcount, &i); | 5497 | left.br_blockcount, &i); |
5503 | if (error) | 5498 | if (error) |
5504 | goto out_error; | 5499 | return error; |
5505 | XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); | 5500 | XFS_WANT_CORRUPTED_RETURN(i == 1); |
5506 | 5501 | ||
5507 | left.br_blockcount = blockcount; | 5502 | left.br_blockcount = blockcount; |
5508 | 5503 | ||
5509 | error = xfs_bmbt_update(cur, left.br_startoff, left.br_startblock, | 5504 | return xfs_bmbt_update(cur, left.br_startoff, left.br_startblock, |
5510 | left.br_blockcount, left.br_state); | 5505 | left.br_blockcount, left.br_state); |
5511 | if (error) | ||
5512 | goto out_error; | ||
5513 | |||
5514 | return 0; | ||
5515 | |||
5516 | out_error: | ||
5517 | return error; | ||
5518 | } | 5506 | } |
5519 | 5507 | ||
5520 | /* | 5508 | /* |
@@ -5544,35 +5532,29 @@ xfs_bmse_shift_one( | |||
5544 | startoff = got.br_startoff - offset_shift_fsb; | 5532 | startoff = got.br_startoff - offset_shift_fsb; |
5545 | 5533 | ||
5546 | /* delalloc extents should be prevented by caller */ | 5534 | /* delalloc extents should be prevented by caller */ |
5547 | XFS_WANT_CORRUPTED_GOTO(!isnullstartblock(got.br_startblock), | 5535 | XFS_WANT_CORRUPTED_RETURN(!isnullstartblock(got.br_startblock)); |
5548 | out_error); | ||
5549 | 5536 | ||
5550 | /* | 5537 | /* |
5551 | * If this is the first extent in the file, make sure there's enough | 5538 | * Check for merge if we've got an extent to the left, otherwise make |
5552 | * room at the start of the file and jump right to the shift as there's | 5539 | * sure there's enough room at the start of the file for the shift. |
5553 | * no left extent to merge. | ||
5554 | */ | 5540 | */ |
5555 | if (*current_ext == 0) { | 5541 | if (*current_ext) { |
5556 | if (got.br_startoff < offset_shift_fsb) | 5542 | /* grab the left extent and check for a large enough hole */ |
5557 | return -EINVAL; | 5543 | leftp = xfs_iext_get_ext(ifp, *current_ext - 1); |
5558 | goto shift_extent; | 5544 | xfs_bmbt_get_all(leftp, &left); |
5559 | } | ||
5560 | 5545 | ||
5561 | /* grab the left extent and check for a large enough hole */ | 5546 | if (startoff < left.br_startoff + left.br_blockcount) |
5562 | leftp = xfs_iext_get_ext(ifp, *current_ext - 1); | 5547 | return -EINVAL; |
5563 | xfs_bmbt_get_all(leftp, &left); | ||
5564 | 5548 | ||
5565 | if (startoff < left.br_startoff + left.br_blockcount) | 5549 | /* check whether to merge the extent or shift it down */ |
5550 | if (xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) { | ||
5551 | return xfs_bmse_merge(ip, whichfork, offset_shift_fsb, | ||
5552 | *current_ext, gotp, leftp, cur, | ||
5553 | logflags); | ||
5554 | } | ||
5555 | } else if (got.br_startoff < offset_shift_fsb) | ||
5566 | return -EINVAL; | 5556 | return -EINVAL; |
5567 | 5557 | ||
5568 | /* check whether to merge the extent or shift it down */ | ||
5569 | if (!xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) | ||
5570 | goto shift_extent; | ||
5571 | |||
5572 | return xfs_bmse_merge(ip, whichfork, offset_shift_fsb, *current_ext, | ||
5573 | gotp, leftp, cur, logflags); | ||
5574 | |||
5575 | shift_extent: | ||
5576 | /* | 5558 | /* |
5577 | * Increment the extent index for the next iteration, update the start | 5559 | * Increment the extent index for the next iteration, update the start |
5578 | * offset of the in-core extent and update the btree if applicable. | 5560 | * offset of the in-core extent and update the btree if applicable. |
@@ -5589,18 +5571,11 @@ shift_extent: | |||
5589 | got.br_blockcount, &i); | 5571 | got.br_blockcount, &i); |
5590 | if (error) | 5572 | if (error) |
5591 | return error; | 5573 | return error; |
5592 | XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); | 5574 | XFS_WANT_CORRUPTED_RETURN(i == 1); |
5593 | 5575 | ||
5594 | got.br_startoff = startoff; | 5576 | got.br_startoff = startoff; |
5595 | error = xfs_bmbt_update(cur, got.br_startoff, got.br_startblock, | 5577 | return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock, |
5596 | got.br_blockcount, got.br_state); | 5578 | got.br_blockcount, got.br_state); |
5597 | if (error) | ||
5598 | return error; | ||
5599 | |||
5600 | return 0; | ||
5601 | |||
5602 | out_error: | ||
5603 | return error; | ||
5604 | } | 5579 | } |
5605 | 5580 | ||
5606 | /* | 5581 | /* |
diff --git a/fs/xfs/libxfs/xfs_bmap_btree.c b/fs/xfs/libxfs/xfs_bmap_btree.c index fba753308f31..2c44c8e50782 100644 --- a/fs/xfs/libxfs/xfs_bmap_btree.c +++ b/fs/xfs/libxfs/xfs_bmap_btree.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
29 | #include "xfs_trans.h" | 27 | #include "xfs_trans.h" |
@@ -36,7 +34,6 @@ | |||
36 | #include "xfs_quota.h" | 34 | #include "xfs_quota.h" |
37 | #include "xfs_trace.h" | 35 | #include "xfs_trace.h" |
38 | #include "xfs_cksum.h" | 36 | #include "xfs_cksum.h" |
39 | #include "xfs_dinode.h" | ||
40 | 37 | ||
41 | /* | 38 | /* |
42 | * Determine the extent state. | 39 | * Determine the extent state. |
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index 8fe6a93ff473..81cad433df85 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
29 | #include "xfs_trans.h" | 27 | #include "xfs_trans.h" |
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index fd827530afec..9cb0115c6bd1 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c | |||
@@ -23,8 +23,6 @@ | |||
23 | #include "xfs_log_format.h" | 23 | #include "xfs_log_format.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_bit.h" | 25 | #include "xfs_bit.h" |
26 | #include "xfs_sb.h" | ||
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 27 | #include "xfs_da_format.h" |
30 | #include "xfs_da_btree.h" | 28 | #include "xfs_da_btree.h" |
@@ -514,7 +512,6 @@ xfs_da3_root_split( | |||
514 | struct xfs_buf *bp; | 512 | struct xfs_buf *bp; |
515 | struct xfs_inode *dp; | 513 | struct xfs_inode *dp; |
516 | struct xfs_trans *tp; | 514 | struct xfs_trans *tp; |
517 | struct xfs_mount *mp; | ||
518 | struct xfs_dir2_leaf *leaf; | 515 | struct xfs_dir2_leaf *leaf; |
519 | xfs_dablk_t blkno; | 516 | xfs_dablk_t blkno; |
520 | int level; | 517 | int level; |
@@ -534,7 +531,6 @@ xfs_da3_root_split( | |||
534 | 531 | ||
535 | dp = args->dp; | 532 | dp = args->dp; |
536 | tp = args->trans; | 533 | tp = args->trans; |
537 | mp = state->mp; | ||
538 | error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, args->whichfork); | 534 | error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, args->whichfork); |
539 | if (error) | 535 | if (error) |
540 | return error; | 536 | return error; |
@@ -2342,14 +2338,12 @@ xfs_da_shrink_inode( | |||
2342 | xfs_inode_t *dp; | 2338 | xfs_inode_t *dp; |
2343 | int done, error, w, count; | 2339 | int done, error, w, count; |
2344 | xfs_trans_t *tp; | 2340 | xfs_trans_t *tp; |
2345 | xfs_mount_t *mp; | ||
2346 | 2341 | ||
2347 | trace_xfs_da_shrink_inode(args); | 2342 | trace_xfs_da_shrink_inode(args); |
2348 | 2343 | ||
2349 | dp = args->dp; | 2344 | dp = args->dp; |
2350 | w = args->whichfork; | 2345 | w = args->whichfork; |
2351 | tp = args->trans; | 2346 | tp = args->trans; |
2352 | mp = dp->i_mount; | ||
2353 | count = args->geo->fsbcount; | 2347 | count = args->geo->fsbcount; |
2354 | for (;;) { | 2348 | for (;;) { |
2355 | /* | 2349 | /* |
diff --git a/fs/xfs/libxfs/xfs_da_format.c b/fs/xfs/libxfs/xfs_da_format.c index 7e42fdfd2f1d..9d624a622946 100644 --- a/fs/xfs/libxfs/xfs_da_format.c +++ b/fs/xfs/libxfs/xfs_da_format.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_format.h" | 22 | #include "xfs_format.h" |
23 | #include "xfs_log_format.h" | 23 | #include "xfs_log_format.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_da_format.h" | 26 | #include "xfs_da_format.h" |
29 | #include "xfs_da_btree.h" | 27 | #include "xfs_da_btree.h" |
diff --git a/fs/xfs/libxfs/xfs_dinode.h b/fs/xfs/libxfs/xfs_dinode.h deleted file mode 100644 index 623bbe8fd921..000000000000 --- a/fs/xfs/libxfs/xfs_dinode.h +++ /dev/null | |||
@@ -1,243 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | #ifndef __XFS_DINODE_H__ | ||
19 | #define __XFS_DINODE_H__ | ||
20 | |||
21 | #define XFS_DINODE_MAGIC 0x494e /* 'IN' */ | ||
22 | #define XFS_DINODE_GOOD_VERSION(v) ((v) >= 1 && (v) <= 3) | ||
23 | |||
24 | typedef struct xfs_timestamp { | ||
25 | __be32 t_sec; /* timestamp seconds */ | ||
26 | __be32 t_nsec; /* timestamp nanoseconds */ | ||
27 | } xfs_timestamp_t; | ||
28 | |||
29 | /* | ||
30 | * On-disk inode structure. | ||
31 | * | ||
32 | * This is just the header or "dinode core", the inode is expanded to fill a | ||
33 | * variable size the leftover area split into a data and an attribute fork. | ||
34 | * The format of the data and attribute fork depends on the format of the | ||
35 | * inode as indicated by di_format and di_aformat. To access the data and | ||
36 | * attribute use the XFS_DFORK_DPTR, XFS_DFORK_APTR, and XFS_DFORK_PTR macros | ||
37 | * below. | ||
38 | * | ||
39 | * There is a very similar struct icdinode in xfs_inode which matches the | ||
40 | * layout of the first 96 bytes of this structure, but is kept in native | ||
41 | * format instead of big endian. | ||
42 | * | ||
43 | * Note: di_flushiter is only used by v1/2 inodes - it's effectively a zeroed | ||
44 | * padding field for v3 inodes. | ||
45 | */ | ||
46 | typedef struct xfs_dinode { | ||
47 | __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ | ||
48 | __be16 di_mode; /* mode and type of file */ | ||
49 | __u8 di_version; /* inode version */ | ||
50 | __u8 di_format; /* format of di_c data */ | ||
51 | __be16 di_onlink; /* old number of links to file */ | ||
52 | __be32 di_uid; /* owner's user id */ | ||
53 | __be32 di_gid; /* owner's group id */ | ||
54 | __be32 di_nlink; /* number of links to file */ | ||
55 | __be16 di_projid_lo; /* lower part of owner's project id */ | ||
56 | __be16 di_projid_hi; /* higher part owner's project id */ | ||
57 | __u8 di_pad[6]; /* unused, zeroed space */ | ||
58 | __be16 di_flushiter; /* incremented on flush */ | ||
59 | xfs_timestamp_t di_atime; /* time last accessed */ | ||
60 | xfs_timestamp_t di_mtime; /* time last modified */ | ||
61 | xfs_timestamp_t di_ctime; /* time created/inode modified */ | ||
62 | __be64 di_size; /* number of bytes in file */ | ||
63 | __be64 di_nblocks; /* # of direct & btree blocks used */ | ||
64 | __be32 di_extsize; /* basic/minimum extent size for file */ | ||
65 | __be32 di_nextents; /* number of extents in data fork */ | ||
66 | __be16 di_anextents; /* number of extents in attribute fork*/ | ||
67 | __u8 di_forkoff; /* attr fork offs, <<3 for 64b align */ | ||
68 | __s8 di_aformat; /* format of attr fork's data */ | ||
69 | __be32 di_dmevmask; /* DMIG event mask */ | ||
70 | __be16 di_dmstate; /* DMIG state info */ | ||
71 | __be16 di_flags; /* random flags, XFS_DIFLAG_... */ | ||
72 | __be32 di_gen; /* generation number */ | ||
73 | |||
74 | /* di_next_unlinked is the only non-core field in the old dinode */ | ||
75 | __be32 di_next_unlinked;/* agi unlinked list ptr */ | ||
76 | |||
77 | /* start of the extended dinode, writable fields */ | ||
78 | __le32 di_crc; /* CRC of the inode */ | ||
79 | __be64 di_changecount; /* number of attribute changes */ | ||
80 | __be64 di_lsn; /* flush sequence */ | ||
81 | __be64 di_flags2; /* more random flags */ | ||
82 | __u8 di_pad2[16]; /* more padding for future expansion */ | ||
83 | |||
84 | /* fields only written to during inode creation */ | ||
85 | xfs_timestamp_t di_crtime; /* time created */ | ||
86 | __be64 di_ino; /* inode number */ | ||
87 | uuid_t di_uuid; /* UUID of the filesystem */ | ||
88 | |||
89 | /* structure must be padded to 64 bit alignment */ | ||
90 | } xfs_dinode_t; | ||
91 | |||
92 | #define XFS_DINODE_CRC_OFF offsetof(struct xfs_dinode, di_crc) | ||
93 | |||
94 | #define DI_MAX_FLUSH 0xffff | ||
95 | |||
96 | /* | ||
97 | * Size of the core inode on disk. Version 1 and 2 inodes have | ||
98 | * the same size, but version 3 has grown a few additional fields. | ||
99 | */ | ||
100 | static inline uint xfs_dinode_size(int version) | ||
101 | { | ||
102 | if (version == 3) | ||
103 | return sizeof(struct xfs_dinode); | ||
104 | return offsetof(struct xfs_dinode, di_crc); | ||
105 | } | ||
106 | |||
107 | /* | ||
108 | * The 32 bit link count in the inode theoretically maxes out at UINT_MAX. | ||
109 | * Since the pathconf interface is signed, we use 2^31 - 1 instead. | ||
110 | * The old inode format had a 16 bit link count, so its maximum is USHRT_MAX. | ||
111 | */ | ||
112 | #define XFS_MAXLINK ((1U << 31) - 1U) | ||
113 | #define XFS_MAXLINK_1 65535U | ||
114 | |||
115 | /* | ||
116 | * Values for di_format | ||
117 | */ | ||
118 | typedef enum xfs_dinode_fmt { | ||
119 | XFS_DINODE_FMT_DEV, /* xfs_dev_t */ | ||
120 | XFS_DINODE_FMT_LOCAL, /* bulk data */ | ||
121 | XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */ | ||
122 | XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */ | ||
123 | XFS_DINODE_FMT_UUID /* uuid_t */ | ||
124 | } xfs_dinode_fmt_t; | ||
125 | |||
126 | /* | ||
127 | * Inode minimum and maximum sizes. | ||
128 | */ | ||
129 | #define XFS_DINODE_MIN_LOG 8 | ||
130 | #define XFS_DINODE_MAX_LOG 11 | ||
131 | #define XFS_DINODE_MIN_SIZE (1 << XFS_DINODE_MIN_LOG) | ||
132 | #define XFS_DINODE_MAX_SIZE (1 << XFS_DINODE_MAX_LOG) | ||
133 | |||
134 | /* | ||
135 | * Inode size for given fs. | ||
136 | */ | ||
137 | #define XFS_LITINO(mp, version) \ | ||
138 | ((int)(((mp)->m_sb.sb_inodesize) - xfs_dinode_size(version))) | ||
139 | |||
140 | /* | ||
141 | * Inode data & attribute fork sizes, per inode. | ||
142 | */ | ||
143 | #define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0) | ||
144 | #define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3)) | ||
145 | |||
146 | #define XFS_DFORK_DSIZE(dip,mp) \ | ||
147 | (XFS_DFORK_Q(dip) ? \ | ||
148 | XFS_DFORK_BOFF(dip) : \ | ||
149 | XFS_LITINO(mp, (dip)->di_version)) | ||
150 | #define XFS_DFORK_ASIZE(dip,mp) \ | ||
151 | (XFS_DFORK_Q(dip) ? \ | ||
152 | XFS_LITINO(mp, (dip)->di_version) - XFS_DFORK_BOFF(dip) : \ | ||
153 | 0) | ||
154 | #define XFS_DFORK_SIZE(dip,mp,w) \ | ||
155 | ((w) == XFS_DATA_FORK ? \ | ||
156 | XFS_DFORK_DSIZE(dip, mp) : \ | ||
157 | XFS_DFORK_ASIZE(dip, mp)) | ||
158 | |||
159 | /* | ||
160 | * Return pointers to the data or attribute forks. | ||
161 | */ | ||
162 | #define XFS_DFORK_DPTR(dip) \ | ||
163 | ((char *)dip + xfs_dinode_size(dip->di_version)) | ||
164 | #define XFS_DFORK_APTR(dip) \ | ||
165 | (XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip)) | ||
166 | #define XFS_DFORK_PTR(dip,w) \ | ||
167 | ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) | ||
168 | |||
169 | #define XFS_DFORK_FORMAT(dip,w) \ | ||
170 | ((w) == XFS_DATA_FORK ? \ | ||
171 | (dip)->di_format : \ | ||
172 | (dip)->di_aformat) | ||
173 | #define XFS_DFORK_NEXTENTS(dip,w) \ | ||
174 | ((w) == XFS_DATA_FORK ? \ | ||
175 | be32_to_cpu((dip)->di_nextents) : \ | ||
176 | be16_to_cpu((dip)->di_anextents)) | ||
177 | |||
178 | #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)((bp)->b_addr)) | ||
179 | |||
180 | /* | ||
181 | * For block and character special files the 32bit dev_t is stored at the | ||
182 | * beginning of the data fork. | ||
183 | */ | ||
184 | static inline xfs_dev_t xfs_dinode_get_rdev(struct xfs_dinode *dip) | ||
185 | { | ||
186 | return be32_to_cpu(*(__be32 *)XFS_DFORK_DPTR(dip)); | ||
187 | } | ||
188 | |||
189 | static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) | ||
190 | { | ||
191 | *(__be32 *)XFS_DFORK_DPTR(dip) = cpu_to_be32(rdev); | ||
192 | } | ||
193 | |||
194 | /* | ||
195 | * Values for di_flags | ||
196 | * There should be a one-to-one correspondence between these flags and the | ||
197 | * XFS_XFLAG_s. | ||
198 | */ | ||
199 | #define XFS_DIFLAG_REALTIME_BIT 0 /* file's blocks come from rt area */ | ||
200 | #define XFS_DIFLAG_PREALLOC_BIT 1 /* file space has been preallocated */ | ||
201 | #define XFS_DIFLAG_NEWRTBM_BIT 2 /* for rtbitmap inode, new format */ | ||
202 | #define XFS_DIFLAG_IMMUTABLE_BIT 3 /* inode is immutable */ | ||
203 | #define XFS_DIFLAG_APPEND_BIT 4 /* inode is append-only */ | ||
204 | #define XFS_DIFLAG_SYNC_BIT 5 /* inode is written synchronously */ | ||
205 | #define XFS_DIFLAG_NOATIME_BIT 6 /* do not update atime */ | ||
206 | #define XFS_DIFLAG_NODUMP_BIT 7 /* do not dump */ | ||
207 | #define XFS_DIFLAG_RTINHERIT_BIT 8 /* create with realtime bit set */ | ||
208 | #define XFS_DIFLAG_PROJINHERIT_BIT 9 /* create with parents projid */ | ||
209 | #define XFS_DIFLAG_NOSYMLINKS_BIT 10 /* disallow symlink creation */ | ||
210 | #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */ | ||
211 | #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */ | ||
212 | #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */ | ||
213 | #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */ | ||
214 | #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT) | ||
215 | #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT) | ||
216 | #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT) | ||
217 | #define XFS_DIFLAG_IMMUTABLE (1 << XFS_DIFLAG_IMMUTABLE_BIT) | ||
218 | #define XFS_DIFLAG_APPEND (1 << XFS_DIFLAG_APPEND_BIT) | ||
219 | #define XFS_DIFLAG_SYNC (1 << XFS_DIFLAG_SYNC_BIT) | ||
220 | #define XFS_DIFLAG_NOATIME (1 << XFS_DIFLAG_NOATIME_BIT) | ||
221 | #define XFS_DIFLAG_NODUMP (1 << XFS_DIFLAG_NODUMP_BIT) | ||
222 | #define XFS_DIFLAG_RTINHERIT (1 << XFS_DIFLAG_RTINHERIT_BIT) | ||
223 | #define XFS_DIFLAG_PROJINHERIT (1 << XFS_DIFLAG_PROJINHERIT_BIT) | ||
224 | #define XFS_DIFLAG_NOSYMLINKS (1 << XFS_DIFLAG_NOSYMLINKS_BIT) | ||
225 | #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT) | ||
226 | #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT) | ||
227 | #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT) | ||
228 | #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT) | ||
229 | |||
230 | #ifdef CONFIG_XFS_RT | ||
231 | #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) | ||
232 | #else | ||
233 | #define XFS_IS_REALTIME_INODE(ip) (0) | ||
234 | #endif | ||
235 | |||
236 | #define XFS_DIFLAG_ANY \ | ||
237 | (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \ | ||
238 | XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \ | ||
239 | XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \ | ||
240 | XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \ | ||
241 | XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM) | ||
242 | |||
243 | #endif /* __XFS_DINODE_H__ */ | ||
diff --git a/fs/xfs/libxfs/xfs_dir2.c b/fs/xfs/libxfs/xfs_dir2.c index 7075aaf131f4..a69fb3a1e161 100644 --- a/fs/xfs/libxfs/xfs_dir2.c +++ b/fs/xfs/libxfs/xfs_dir2.c | |||
@@ -20,9 +20,6 @@ | |||
20 | #include "xfs_format.h" | 20 | #include "xfs_format.h" |
21 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
23 | #include "xfs_inum.h" | ||
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 23 | #include "xfs_mount.h" |
27 | #include "xfs_da_format.h" | 24 | #include "xfs_da_format.h" |
28 | #include "xfs_da_btree.h" | 25 | #include "xfs_da_btree.h" |
@@ -34,10 +31,25 @@ | |||
34 | #include "xfs_dir2_priv.h" | 31 | #include "xfs_dir2_priv.h" |
35 | #include "xfs_error.h" | 32 | #include "xfs_error.h" |
36 | #include "xfs_trace.h" | 33 | #include "xfs_trace.h" |
37 | #include "xfs_dinode.h" | ||
38 | 34 | ||
39 | struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR }; | 35 | struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR }; |
40 | 36 | ||
37 | /* | ||
38 | * @mode, if set, indicates that the type field needs to be set up. | ||
39 | * This uses the transformation from file mode to DT_* as defined in linux/fs.h | ||
40 | * for file type specification. This will be propagated into the directory | ||
41 | * structure if appropriate for the given operation and filesystem config. | ||
42 | */ | ||
43 | const unsigned char xfs_mode_to_ftype[S_IFMT >> S_SHIFT] = { | ||
44 | [0] = XFS_DIR3_FT_UNKNOWN, | ||
45 | [S_IFREG >> S_SHIFT] = XFS_DIR3_FT_REG_FILE, | ||
46 | [S_IFDIR >> S_SHIFT] = XFS_DIR3_FT_DIR, | ||
47 | [S_IFCHR >> S_SHIFT] = XFS_DIR3_FT_CHRDEV, | ||
48 | [S_IFBLK >> S_SHIFT] = XFS_DIR3_FT_BLKDEV, | ||
49 | [S_IFIFO >> S_SHIFT] = XFS_DIR3_FT_FIFO, | ||
50 | [S_IFSOCK >> S_SHIFT] = XFS_DIR3_FT_SOCK, | ||
51 | [S_IFLNK >> S_SHIFT] = XFS_DIR3_FT_SYMLINK, | ||
52 | }; | ||
41 | 53 | ||
42 | /* | 54 | /* |
43 | * ASCII case-insensitive (ie. A-Z) support for directories that was | 55 | * ASCII case-insensitive (ie. A-Z) support for directories that was |
diff --git a/fs/xfs/libxfs/xfs_dir2.h b/fs/xfs/libxfs/xfs_dir2.h index 4dff261e6ed5..e55353651f5b 100644 --- a/fs/xfs/libxfs/xfs_dir2.h +++ b/fs/xfs/libxfs/xfs_dir2.h | |||
@@ -32,6 +32,12 @@ struct xfs_dir2_data_unused; | |||
32 | extern struct xfs_name xfs_name_dotdot; | 32 | extern struct xfs_name xfs_name_dotdot; |
33 | 33 | ||
34 | /* | 34 | /* |
35 | * directory filetype conversion tables. | ||
36 | */ | ||
37 | #define S_SHIFT 12 | ||
38 | extern const unsigned char xfs_mode_to_ftype[]; | ||
39 | |||
40 | /* | ||
35 | * directory operations vector for encode/decode routines | 41 | * directory operations vector for encode/decode routines |
36 | */ | 42 | */ |
37 | struct xfs_dir_ops { | 43 | struct xfs_dir_ops { |
@@ -177,4 +183,138 @@ extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops; | |||
177 | extern const struct xfs_buf_ops xfs_dir3_free_buf_ops; | 183 | extern const struct xfs_buf_ops xfs_dir3_free_buf_ops; |
178 | extern const struct xfs_buf_ops xfs_dir3_data_buf_ops; | 184 | extern const struct xfs_buf_ops xfs_dir3_data_buf_ops; |
179 | 185 | ||
186 | /* | ||
187 | * Directory offset/block conversion functions. | ||
188 | * | ||
189 | * DB blocks here are logical directory block numbers, not filesystem blocks. | ||
190 | */ | ||
191 | |||
192 | /* | ||
193 | * Convert dataptr to byte in file space | ||
194 | */ | ||
195 | static inline xfs_dir2_off_t | ||
196 | xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp) | ||
197 | { | ||
198 | return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG; | ||
199 | } | ||
200 | |||
201 | /* | ||
202 | * Convert byte in file space to dataptr. It had better be aligned. | ||
203 | */ | ||
204 | static inline xfs_dir2_dataptr_t | ||
205 | xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by) | ||
206 | { | ||
207 | return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG); | ||
208 | } | ||
209 | |||
210 | /* | ||
211 | * Convert byte in space to (DB) block | ||
212 | */ | ||
213 | static inline xfs_dir2_db_t | ||
214 | xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
215 | { | ||
216 | return (xfs_dir2_db_t)(by >> geo->blklog); | ||
217 | } | ||
218 | |||
219 | /* | ||
220 | * Convert dataptr to a block number | ||
221 | */ | ||
222 | static inline xfs_dir2_db_t | ||
223 | xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) | ||
224 | { | ||
225 | return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp)); | ||
226 | } | ||
227 | |||
228 | /* | ||
229 | * Convert byte in space to offset in a block | ||
230 | */ | ||
231 | static inline xfs_dir2_data_aoff_t | ||
232 | xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
233 | { | ||
234 | return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1)); | ||
235 | } | ||
236 | |||
237 | /* | ||
238 | * Convert dataptr to a byte offset in a block | ||
239 | */ | ||
240 | static inline xfs_dir2_data_aoff_t | ||
241 | xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) | ||
242 | { | ||
243 | return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp)); | ||
244 | } | ||
245 | |||
246 | /* | ||
247 | * Convert block and offset to byte in space | ||
248 | */ | ||
249 | static inline xfs_dir2_off_t | ||
250 | xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db, | ||
251 | xfs_dir2_data_aoff_t o) | ||
252 | { | ||
253 | return ((xfs_dir2_off_t)db << geo->blklog) + o; | ||
254 | } | ||
255 | |||
256 | /* | ||
257 | * Convert block (DB) to block (dablk) | ||
258 | */ | ||
259 | static inline xfs_dablk_t | ||
260 | xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db) | ||
261 | { | ||
262 | return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog)); | ||
263 | } | ||
264 | |||
265 | /* | ||
266 | * Convert byte in space to (DA) block | ||
267 | */ | ||
268 | static inline xfs_dablk_t | ||
269 | xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
270 | { | ||
271 | return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by)); | ||
272 | } | ||
273 | |||
274 | /* | ||
275 | * Convert block and offset to dataptr | ||
276 | */ | ||
277 | static inline xfs_dir2_dataptr_t | ||
278 | xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db, | ||
279 | xfs_dir2_data_aoff_t o) | ||
280 | { | ||
281 | return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o)); | ||
282 | } | ||
283 | |||
284 | /* | ||
285 | * Convert block (dablk) to block (DB) | ||
286 | */ | ||
287 | static inline xfs_dir2_db_t | ||
288 | xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da) | ||
289 | { | ||
290 | return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog)); | ||
291 | } | ||
292 | |||
293 | /* | ||
294 | * Convert block (dablk) to byte offset in space | ||
295 | */ | ||
296 | static inline xfs_dir2_off_t | ||
297 | xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da) | ||
298 | { | ||
299 | return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0); | ||
300 | } | ||
301 | |||
302 | /* | ||
303 | * Directory tail pointer accessor functions. Based on block geometry. | ||
304 | */ | ||
305 | static inline struct xfs_dir2_block_tail * | ||
306 | xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr) | ||
307 | { | ||
308 | return ((struct xfs_dir2_block_tail *) | ||
309 | ((char *)hdr + geo->blksize)) - 1; | ||
310 | } | ||
311 | |||
312 | static inline struct xfs_dir2_leaf_tail * | ||
313 | xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp) | ||
314 | { | ||
315 | return (struct xfs_dir2_leaf_tail *) | ||
316 | ((char *)lp + geo->blksize - | ||
317 | sizeof(struct xfs_dir2_leaf_tail)); | ||
318 | } | ||
319 | |||
180 | #endif /* __XFS_DIR2_H__ */ | 320 | #endif /* __XFS_DIR2_H__ */ |
diff --git a/fs/xfs/libxfs/xfs_dir2_block.c b/fs/xfs/libxfs/xfs_dir2_block.c index 9628ceccfa02..9354e190b82e 100644 --- a/fs/xfs/libxfs/xfs_dir2_block.c +++ b/fs/xfs/libxfs/xfs_dir2_block.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_da_format.h" | 25 | #include "xfs_da_format.h" |
28 | #include "xfs_da_btree.h" | 26 | #include "xfs_da_btree.h" |
@@ -36,7 +34,6 @@ | |||
36 | #include "xfs_error.h" | 34 | #include "xfs_error.h" |
37 | #include "xfs_trace.h" | 35 | #include "xfs_trace.h" |
38 | #include "xfs_cksum.h" | 36 | #include "xfs_cksum.h" |
39 | #include "xfs_dinode.h" | ||
40 | 37 | ||
41 | /* | 38 | /* |
42 | * Local function prototypes. | 39 | * Local function prototypes. |
@@ -353,7 +350,6 @@ xfs_dir2_block_addname( | |||
353 | int low; /* low index for binary srch */ | 350 | int low; /* low index for binary srch */ |
354 | int lowstale; /* low stale index */ | 351 | int lowstale; /* low stale index */ |
355 | int mid=0; /* midpoint for binary srch */ | 352 | int mid=0; /* midpoint for binary srch */ |
356 | xfs_mount_t *mp; /* filesystem mount point */ | ||
357 | int needlog; /* need to log header */ | 353 | int needlog; /* need to log header */ |
358 | int needscan; /* need to rescan freespace */ | 354 | int needscan; /* need to rescan freespace */ |
359 | __be16 *tagp; /* pointer to tag value */ | 355 | __be16 *tagp; /* pointer to tag value */ |
@@ -363,7 +359,6 @@ xfs_dir2_block_addname( | |||
363 | 359 | ||
364 | dp = args->dp; | 360 | dp = args->dp; |
365 | tp = args->trans; | 361 | tp = args->trans; |
366 | mp = dp->i_mount; | ||
367 | 362 | ||
368 | /* Read the (one and only) directory block into bp. */ | 363 | /* Read the (one and only) directory block into bp. */ |
369 | error = xfs_dir3_block_read(tp, dp, &bp); | 364 | error = xfs_dir3_block_read(tp, dp, &bp); |
@@ -618,7 +613,6 @@ xfs_dir2_block_lookup( | |||
618 | xfs_inode_t *dp; /* incore inode */ | 613 | xfs_inode_t *dp; /* incore inode */ |
619 | int ent; /* entry index */ | 614 | int ent; /* entry index */ |
620 | int error; /* error return value */ | 615 | int error; /* error return value */ |
621 | xfs_mount_t *mp; /* filesystem mount point */ | ||
622 | 616 | ||
623 | trace_xfs_dir2_block_lookup(args); | 617 | trace_xfs_dir2_block_lookup(args); |
624 | 618 | ||
@@ -629,7 +623,6 @@ xfs_dir2_block_lookup( | |||
629 | if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent))) | 623 | if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent))) |
630 | return error; | 624 | return error; |
631 | dp = args->dp; | 625 | dp = args->dp; |
632 | mp = dp->i_mount; | ||
633 | hdr = bp->b_addr; | 626 | hdr = bp->b_addr; |
634 | xfs_dir3_data_check(dp, bp); | 627 | xfs_dir3_data_check(dp, bp); |
635 | btp = xfs_dir2_block_tail_p(args->geo, hdr); | 628 | btp = xfs_dir2_block_tail_p(args->geo, hdr); |
@@ -770,7 +763,6 @@ xfs_dir2_block_removename( | |||
770 | xfs_inode_t *dp; /* incore inode */ | 763 | xfs_inode_t *dp; /* incore inode */ |
771 | int ent; /* block leaf entry index */ | 764 | int ent; /* block leaf entry index */ |
772 | int error; /* error return value */ | 765 | int error; /* error return value */ |
773 | xfs_mount_t *mp; /* filesystem mount point */ | ||
774 | int needlog; /* need to log block header */ | 766 | int needlog; /* need to log block header */ |
775 | int needscan; /* need to fixup bestfree */ | 767 | int needscan; /* need to fixup bestfree */ |
776 | xfs_dir2_sf_hdr_t sfh; /* shortform header */ | 768 | xfs_dir2_sf_hdr_t sfh; /* shortform header */ |
@@ -788,7 +780,6 @@ xfs_dir2_block_removename( | |||
788 | } | 780 | } |
789 | dp = args->dp; | 781 | dp = args->dp; |
790 | tp = args->trans; | 782 | tp = args->trans; |
791 | mp = dp->i_mount; | ||
792 | hdr = bp->b_addr; | 783 | hdr = bp->b_addr; |
793 | btp = xfs_dir2_block_tail_p(args->geo, hdr); | 784 | btp = xfs_dir2_block_tail_p(args->geo, hdr); |
794 | blp = xfs_dir2_block_leaf_p(btp); | 785 | blp = xfs_dir2_block_leaf_p(btp); |
@@ -852,7 +843,6 @@ xfs_dir2_block_replace( | |||
852 | xfs_inode_t *dp; /* incore inode */ | 843 | xfs_inode_t *dp; /* incore inode */ |
853 | int ent; /* leaf entry index */ | 844 | int ent; /* leaf entry index */ |
854 | int error; /* error return value */ | 845 | int error; /* error return value */ |
855 | xfs_mount_t *mp; /* filesystem mount point */ | ||
856 | 846 | ||
857 | trace_xfs_dir2_block_replace(args); | 847 | trace_xfs_dir2_block_replace(args); |
858 | 848 | ||
@@ -864,7 +854,6 @@ xfs_dir2_block_replace( | |||
864 | return error; | 854 | return error; |
865 | } | 855 | } |
866 | dp = args->dp; | 856 | dp = args->dp; |
867 | mp = dp->i_mount; | ||
868 | hdr = bp->b_addr; | 857 | hdr = bp->b_addr; |
869 | btp = xfs_dir2_block_tail_p(args->geo, hdr); | 858 | btp = xfs_dir2_block_tail_p(args->geo, hdr); |
870 | blp = xfs_dir2_block_leaf_p(btp); | 859 | blp = xfs_dir2_block_leaf_p(btp); |
diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c index fdd803fecb8e..5ff31be9b1cd 100644 --- a/fs/xfs/libxfs/xfs_dir2_data.c +++ b/fs/xfs/libxfs/xfs_dir2_data.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_da_format.h" | 25 | #include "xfs_da_format.h" |
28 | #include "xfs_da_btree.h" | 26 | #include "xfs_da_btree.h" |
diff --git a/fs/xfs/libxfs/xfs_dir2_leaf.c b/fs/xfs/libxfs/xfs_dir2_leaf.c index a19174eb3cb2..106119955400 100644 --- a/fs/xfs/libxfs/xfs_dir2_leaf.c +++ b/fs/xfs/libxfs/xfs_dir2_leaf.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_da_format.h" | 25 | #include "xfs_da_format.h" |
28 | #include "xfs_da_btree.h" | 26 | #include "xfs_da_btree.h" |
@@ -384,7 +382,6 @@ xfs_dir2_block_to_leaf( | |||
384 | xfs_dir2_db_t ldb; /* leaf block's bno */ | 382 | xfs_dir2_db_t ldb; /* leaf block's bno */ |
385 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 383 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
386 | xfs_dir2_leaf_tail_t *ltp; /* leaf's tail */ | 384 | xfs_dir2_leaf_tail_t *ltp; /* leaf's tail */ |
387 | xfs_mount_t *mp; /* filesystem mount point */ | ||
388 | int needlog; /* need to log block header */ | 385 | int needlog; /* need to log block header */ |
389 | int needscan; /* need to rescan bestfree */ | 386 | int needscan; /* need to rescan bestfree */ |
390 | xfs_trans_t *tp; /* transaction pointer */ | 387 | xfs_trans_t *tp; /* transaction pointer */ |
@@ -395,7 +392,6 @@ xfs_dir2_block_to_leaf( | |||
395 | trace_xfs_dir2_block_to_leaf(args); | 392 | trace_xfs_dir2_block_to_leaf(args); |
396 | 393 | ||
397 | dp = args->dp; | 394 | dp = args->dp; |
398 | mp = dp->i_mount; | ||
399 | tp = args->trans; | 395 | tp = args->trans; |
400 | /* | 396 | /* |
401 | * Add the leaf block to the inode. | 397 | * Add the leaf block to the inode. |
@@ -626,7 +622,6 @@ xfs_dir2_leaf_addname( | |||
626 | int lfloghigh; /* high leaf logging index */ | 622 | int lfloghigh; /* high leaf logging index */ |
627 | int lowstale; /* index of prev stale leaf */ | 623 | int lowstale; /* index of prev stale leaf */ |
628 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail pointer */ | 624 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail pointer */ |
629 | xfs_mount_t *mp; /* filesystem mount point */ | ||
630 | int needbytes; /* leaf block bytes needed */ | 625 | int needbytes; /* leaf block bytes needed */ |
631 | int needlog; /* need to log data header */ | 626 | int needlog; /* need to log data header */ |
632 | int needscan; /* need to rescan data free */ | 627 | int needscan; /* need to rescan data free */ |
@@ -641,7 +636,6 @@ xfs_dir2_leaf_addname( | |||
641 | 636 | ||
642 | dp = args->dp; | 637 | dp = args->dp; |
643 | tp = args->trans; | 638 | tp = args->trans; |
644 | mp = dp->i_mount; | ||
645 | 639 | ||
646 | error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp); | 640 | error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp); |
647 | if (error) | 641 | if (error) |
@@ -1356,11 +1350,9 @@ xfs_dir2_leaf_removename( | |||
1356 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 1350 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
1357 | xfs_dir2_leaf_entry_t *lep; /* leaf entry */ | 1351 | xfs_dir2_leaf_entry_t *lep; /* leaf entry */ |
1358 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ | 1352 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ |
1359 | xfs_mount_t *mp; /* filesystem mount point */ | ||
1360 | int needlog; /* need to log data header */ | 1353 | int needlog; /* need to log data header */ |
1361 | int needscan; /* need to rescan data frees */ | 1354 | int needscan; /* need to rescan data frees */ |
1362 | xfs_dir2_data_off_t oldbest; /* old value of best free */ | 1355 | xfs_dir2_data_off_t oldbest; /* old value of best free */ |
1363 | xfs_trans_t *tp; /* transaction pointer */ | ||
1364 | struct xfs_dir2_data_free *bf; /* bestfree table */ | 1356 | struct xfs_dir2_data_free *bf; /* bestfree table */ |
1365 | struct xfs_dir2_leaf_entry *ents; | 1357 | struct xfs_dir2_leaf_entry *ents; |
1366 | struct xfs_dir3_icleaf_hdr leafhdr; | 1358 | struct xfs_dir3_icleaf_hdr leafhdr; |
@@ -1374,8 +1366,6 @@ xfs_dir2_leaf_removename( | |||
1374 | return error; | 1366 | return error; |
1375 | } | 1367 | } |
1376 | dp = args->dp; | 1368 | dp = args->dp; |
1377 | tp = args->trans; | ||
1378 | mp = dp->i_mount; | ||
1379 | leaf = lbp->b_addr; | 1369 | leaf = lbp->b_addr; |
1380 | hdr = dbp->b_addr; | 1370 | hdr = dbp->b_addr; |
1381 | xfs_dir3_data_check(dp, dbp); | 1371 | xfs_dir3_data_check(dp, dbp); |
@@ -1607,11 +1597,9 @@ xfs_dir2_leaf_trim_data( | |||
1607 | int error; /* error return value */ | 1597 | int error; /* error return value */ |
1608 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 1598 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
1609 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ | 1599 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ |
1610 | xfs_mount_t *mp; /* filesystem mount point */ | ||
1611 | xfs_trans_t *tp; /* transaction pointer */ | 1600 | xfs_trans_t *tp; /* transaction pointer */ |
1612 | 1601 | ||
1613 | dp = args->dp; | 1602 | dp = args->dp; |
1614 | mp = dp->i_mount; | ||
1615 | tp = args->trans; | 1603 | tp = args->trans; |
1616 | /* | 1604 | /* |
1617 | * Read the offending data block. We need its buffer. | 1605 | * Read the offending data block. We need its buffer. |
diff --git a/fs/xfs/libxfs/xfs_dir2_node.c b/fs/xfs/libxfs/xfs_dir2_node.c index 2ae6ac2c11ae..41b80d3d3877 100644 --- a/fs/xfs/libxfs/xfs_dir2_node.c +++ b/fs/xfs/libxfs/xfs_dir2_node.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_da_format.h" | 25 | #include "xfs_da_format.h" |
28 | #include "xfs_da_btree.h" | 26 | #include "xfs_da_btree.h" |
@@ -297,7 +295,6 @@ xfs_dir2_leaf_to_node( | |||
297 | int i; /* leaf freespace index */ | 295 | int i; /* leaf freespace index */ |
298 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 296 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
299 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ | 297 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ |
300 | xfs_mount_t *mp; /* filesystem mount point */ | ||
301 | int n; /* count of live freespc ents */ | 298 | int n; /* count of live freespc ents */ |
302 | xfs_dir2_data_off_t off; /* freespace entry value */ | 299 | xfs_dir2_data_off_t off; /* freespace entry value */ |
303 | __be16 *to; /* pointer to freespace entry */ | 300 | __be16 *to; /* pointer to freespace entry */ |
@@ -307,7 +304,6 @@ xfs_dir2_leaf_to_node( | |||
307 | trace_xfs_dir2_leaf_to_node(args); | 304 | trace_xfs_dir2_leaf_to_node(args); |
308 | 305 | ||
309 | dp = args->dp; | 306 | dp = args->dp; |
310 | mp = dp->i_mount; | ||
311 | tp = args->trans; | 307 | tp = args->trans; |
312 | /* | 308 | /* |
313 | * Add a freespace block to the directory. | 309 | * Add a freespace block to the directory. |
@@ -387,16 +383,12 @@ xfs_dir2_leafn_add( | |||
387 | int lfloghigh; /* high leaf entry logging */ | 383 | int lfloghigh; /* high leaf entry logging */ |
388 | int lfloglow; /* low leaf entry logging */ | 384 | int lfloglow; /* low leaf entry logging */ |
389 | int lowstale; /* previous stale entry */ | 385 | int lowstale; /* previous stale entry */ |
390 | xfs_mount_t *mp; /* filesystem mount point */ | ||
391 | xfs_trans_t *tp; /* transaction pointer */ | ||
392 | struct xfs_dir3_icleaf_hdr leafhdr; | 386 | struct xfs_dir3_icleaf_hdr leafhdr; |
393 | struct xfs_dir2_leaf_entry *ents; | 387 | struct xfs_dir2_leaf_entry *ents; |
394 | 388 | ||
395 | trace_xfs_dir2_leafn_add(args, index); | 389 | trace_xfs_dir2_leafn_add(args, index); |
396 | 390 | ||
397 | dp = args->dp; | 391 | dp = args->dp; |
398 | mp = dp->i_mount; | ||
399 | tp = args->trans; | ||
400 | leaf = bp->b_addr; | 392 | leaf = bp->b_addr; |
401 | dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); | 393 | dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); |
402 | ents = dp->d_ops->leaf_ents_p(leaf); | 394 | ents = dp->d_ops->leaf_ents_p(leaf); |
@@ -1170,7 +1162,6 @@ xfs_dir2_leafn_remove( | |||
1170 | xfs_dir2_leaf_entry_t *lep; /* leaf entry */ | 1162 | xfs_dir2_leaf_entry_t *lep; /* leaf entry */ |
1171 | int longest; /* longest data free entry */ | 1163 | int longest; /* longest data free entry */ |
1172 | int off; /* data block entry offset */ | 1164 | int off; /* data block entry offset */ |
1173 | xfs_mount_t *mp; /* filesystem mount point */ | ||
1174 | int needlog; /* need to log data header */ | 1165 | int needlog; /* need to log data header */ |
1175 | int needscan; /* need to rescan data frees */ | 1166 | int needscan; /* need to rescan data frees */ |
1176 | xfs_trans_t *tp; /* transaction pointer */ | 1167 | xfs_trans_t *tp; /* transaction pointer */ |
@@ -1182,7 +1173,6 @@ xfs_dir2_leafn_remove( | |||
1182 | 1173 | ||
1183 | dp = args->dp; | 1174 | dp = args->dp; |
1184 | tp = args->trans; | 1175 | tp = args->trans; |
1185 | mp = dp->i_mount; | ||
1186 | leaf = bp->b_addr; | 1176 | leaf = bp->b_addr; |
1187 | dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); | 1177 | dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); |
1188 | ents = dp->d_ops->leaf_ents_p(leaf); | 1178 | ents = dp->d_ops->leaf_ents_p(leaf); |
@@ -1323,7 +1313,6 @@ xfs_dir2_leafn_split( | |||
1323 | xfs_da_args_t *args; /* operation arguments */ | 1313 | xfs_da_args_t *args; /* operation arguments */ |
1324 | xfs_dablk_t blkno; /* new leaf block number */ | 1314 | xfs_dablk_t blkno; /* new leaf block number */ |
1325 | int error; /* error return value */ | 1315 | int error; /* error return value */ |
1326 | xfs_mount_t *mp; /* filesystem mount point */ | ||
1327 | struct xfs_inode *dp; | 1316 | struct xfs_inode *dp; |
1328 | 1317 | ||
1329 | /* | 1318 | /* |
@@ -1331,7 +1320,6 @@ xfs_dir2_leafn_split( | |||
1331 | */ | 1320 | */ |
1332 | args = state->args; | 1321 | args = state->args; |
1333 | dp = args->dp; | 1322 | dp = args->dp; |
1334 | mp = dp->i_mount; | ||
1335 | ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC); | 1323 | ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC); |
1336 | error = xfs_da_grow_inode(args, &blkno); | 1324 | error = xfs_da_grow_inode(args, &blkno); |
1337 | if (error) { | 1325 | if (error) { |
@@ -2231,12 +2219,10 @@ xfs_dir2_node_trim_free( | |||
2231 | xfs_inode_t *dp; /* incore directory inode */ | 2219 | xfs_inode_t *dp; /* incore directory inode */ |
2232 | int error; /* error return code */ | 2220 | int error; /* error return code */ |
2233 | xfs_dir2_free_t *free; /* freespace structure */ | 2221 | xfs_dir2_free_t *free; /* freespace structure */ |
2234 | xfs_mount_t *mp; /* filesystem mount point */ | ||
2235 | xfs_trans_t *tp; /* transaction pointer */ | 2222 | xfs_trans_t *tp; /* transaction pointer */ |
2236 | struct xfs_dir3_icfree_hdr freehdr; | 2223 | struct xfs_dir3_icfree_hdr freehdr; |
2237 | 2224 | ||
2238 | dp = args->dp; | 2225 | dp = args->dp; |
2239 | mp = dp->i_mount; | ||
2240 | tp = args->trans; | 2226 | tp = args->trans; |
2241 | /* | 2227 | /* |
2242 | * Read the freespace block. | 2228 | * Read the freespace block. |
diff --git a/fs/xfs/libxfs/xfs_dir2_priv.h b/fs/xfs/libxfs/xfs_dir2_priv.h index 27ce0794d196..ef9f6ead96a4 100644 --- a/fs/xfs/libxfs/xfs_dir2_priv.h +++ b/fs/xfs/libxfs/xfs_dir2_priv.h | |||
@@ -20,140 +20,6 @@ | |||
20 | 20 | ||
21 | struct dir_context; | 21 | struct dir_context; |
22 | 22 | ||
23 | /* | ||
24 | * Directory offset/block conversion functions. | ||
25 | * | ||
26 | * DB blocks here are logical directory block numbers, not filesystem blocks. | ||
27 | */ | ||
28 | |||
29 | /* | ||
30 | * Convert dataptr to byte in file space | ||
31 | */ | ||
32 | static inline xfs_dir2_off_t | ||
33 | xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp) | ||
34 | { | ||
35 | return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG; | ||
36 | } | ||
37 | |||
38 | /* | ||
39 | * Convert byte in file space to dataptr. It had better be aligned. | ||
40 | */ | ||
41 | static inline xfs_dir2_dataptr_t | ||
42 | xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by) | ||
43 | { | ||
44 | return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG); | ||
45 | } | ||
46 | |||
47 | /* | ||
48 | * Convert byte in space to (DB) block | ||
49 | */ | ||
50 | static inline xfs_dir2_db_t | ||
51 | xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
52 | { | ||
53 | return (xfs_dir2_db_t)(by >> geo->blklog); | ||
54 | } | ||
55 | |||
56 | /* | ||
57 | * Convert dataptr to a block number | ||
58 | */ | ||
59 | static inline xfs_dir2_db_t | ||
60 | xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) | ||
61 | { | ||
62 | return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp)); | ||
63 | } | ||
64 | |||
65 | /* | ||
66 | * Convert byte in space to offset in a block | ||
67 | */ | ||
68 | static inline xfs_dir2_data_aoff_t | ||
69 | xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
70 | { | ||
71 | return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1)); | ||
72 | } | ||
73 | |||
74 | /* | ||
75 | * Convert dataptr to a byte offset in a block | ||
76 | */ | ||
77 | static inline xfs_dir2_data_aoff_t | ||
78 | xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) | ||
79 | { | ||
80 | return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp)); | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * Convert block and offset to byte in space | ||
85 | */ | ||
86 | static inline xfs_dir2_off_t | ||
87 | xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db, | ||
88 | xfs_dir2_data_aoff_t o) | ||
89 | { | ||
90 | return ((xfs_dir2_off_t)db << geo->blklog) + o; | ||
91 | } | ||
92 | |||
93 | /* | ||
94 | * Convert block (DB) to block (dablk) | ||
95 | */ | ||
96 | static inline xfs_dablk_t | ||
97 | xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db) | ||
98 | { | ||
99 | return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog)); | ||
100 | } | ||
101 | |||
102 | /* | ||
103 | * Convert byte in space to (DA) block | ||
104 | */ | ||
105 | static inline xfs_dablk_t | ||
106 | xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by) | ||
107 | { | ||
108 | return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by)); | ||
109 | } | ||
110 | |||
111 | /* | ||
112 | * Convert block and offset to dataptr | ||
113 | */ | ||
114 | static inline xfs_dir2_dataptr_t | ||
115 | xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db, | ||
116 | xfs_dir2_data_aoff_t o) | ||
117 | { | ||
118 | return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o)); | ||
119 | } | ||
120 | |||
121 | /* | ||
122 | * Convert block (dablk) to block (DB) | ||
123 | */ | ||
124 | static inline xfs_dir2_db_t | ||
125 | xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da) | ||
126 | { | ||
127 | return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog)); | ||
128 | } | ||
129 | |||
130 | /* | ||
131 | * Convert block (dablk) to byte offset in space | ||
132 | */ | ||
133 | static inline xfs_dir2_off_t | ||
134 | xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da) | ||
135 | { | ||
136 | return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0); | ||
137 | } | ||
138 | |||
139 | /* | ||
140 | * Directory tail pointer accessor functions. Based on block geometry. | ||
141 | */ | ||
142 | static inline struct xfs_dir2_block_tail * | ||
143 | xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr) | ||
144 | { | ||
145 | return ((struct xfs_dir2_block_tail *) | ||
146 | ((char *)hdr + geo->blksize)) - 1; | ||
147 | } | ||
148 | |||
149 | static inline struct xfs_dir2_leaf_tail * | ||
150 | xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp) | ||
151 | { | ||
152 | return (struct xfs_dir2_leaf_tail *) | ||
153 | ((char *)lp + geo->blksize - | ||
154 | sizeof(struct xfs_dir2_leaf_tail)); | ||
155 | } | ||
156 | |||
157 | /* xfs_dir2.c */ | 23 | /* xfs_dir2.c */ |
158 | extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); | 24 | extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); |
159 | extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, | 25 | extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, |
@@ -161,12 +27,6 @@ extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, | |||
161 | extern int xfs_dir_cilookup_result(struct xfs_da_args *args, | 27 | extern int xfs_dir_cilookup_result(struct xfs_da_args *args, |
162 | const unsigned char *name, int len); | 28 | const unsigned char *name, int len); |
163 | 29 | ||
164 | #define S_SHIFT 12 | ||
165 | extern const unsigned char xfs_mode_to_ftype[]; | ||
166 | |||
167 | extern unsigned char xfs_dir3_get_dtype(struct xfs_mount *mp, | ||
168 | __uint8_t filetype); | ||
169 | |||
170 | 30 | ||
171 | /* xfs_dir2_block.c */ | 31 | /* xfs_dir2_block.c */ |
172 | extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp, | 32 | extern int xfs_dir3_block_read(struct xfs_trans *tp, struct xfs_inode *dp, |
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 5079e051ef08..974d62e677f4 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include "xfs_format.h" | 20 | #include "xfs_format.h" |
21 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | 23 | #include "xfs_mount.h" |
26 | #include "xfs_da_format.h" | 24 | #include "xfs_da_format.h" |
27 | #include "xfs_da_btree.h" | 25 | #include "xfs_da_btree.h" |
@@ -32,7 +30,6 @@ | |||
32 | #include "xfs_dir2.h" | 30 | #include "xfs_dir2.h" |
33 | #include "xfs_dir2_priv.h" | 31 | #include "xfs_dir2_priv.h" |
34 | #include "xfs_trace.h" | 32 | #include "xfs_trace.h" |
35 | #include "xfs_dinode.h" | ||
36 | 33 | ||
37 | /* | 34 | /* |
38 | * Prototypes for internal functions. | 35 | * Prototypes for internal functions. |
@@ -455,13 +452,11 @@ xfs_dir2_sf_addname_hard( | |||
455 | xfs_dir2_sf_hdr_t *oldsfp; /* original shortform dir */ | 452 | xfs_dir2_sf_hdr_t *oldsfp; /* original shortform dir */ |
456 | xfs_dir2_sf_entry_t *sfep; /* entry in new dir */ | 453 | xfs_dir2_sf_entry_t *sfep; /* entry in new dir */ |
457 | xfs_dir2_sf_hdr_t *sfp; /* new shortform dir */ | 454 | xfs_dir2_sf_hdr_t *sfp; /* new shortform dir */ |
458 | struct xfs_mount *mp; | ||
459 | 455 | ||
460 | /* | 456 | /* |
461 | * Copy the old directory to the stack buffer. | 457 | * Copy the old directory to the stack buffer. |
462 | */ | 458 | */ |
463 | dp = args->dp; | 459 | dp = args->dp; |
464 | mp = dp->i_mount; | ||
465 | 460 | ||
466 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; | 461 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; |
467 | old_isize = (int)dp->i_d.di_size; | 462 | old_isize = (int)dp->i_d.di_size; |
@@ -542,7 +537,6 @@ xfs_dir2_sf_addname_pick( | |||
542 | xfs_inode_t *dp; /* incore directory inode */ | 537 | xfs_inode_t *dp; /* incore directory inode */ |
543 | int holefit; /* found hole it will fit in */ | 538 | int holefit; /* found hole it will fit in */ |
544 | int i; /* entry number */ | 539 | int i; /* entry number */ |
545 | xfs_mount_t *mp; /* filesystem mount point */ | ||
546 | xfs_dir2_data_aoff_t offset; /* data block offset */ | 540 | xfs_dir2_data_aoff_t offset; /* data block offset */ |
547 | xfs_dir2_sf_entry_t *sfep; /* shortform entry */ | 541 | xfs_dir2_sf_entry_t *sfep; /* shortform entry */ |
548 | xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ | 542 | xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ |
@@ -550,7 +544,6 @@ xfs_dir2_sf_addname_pick( | |||
550 | int used; /* data bytes used */ | 544 | int used; /* data bytes used */ |
551 | 545 | ||
552 | dp = args->dp; | 546 | dp = args->dp; |
553 | mp = dp->i_mount; | ||
554 | 547 | ||
555 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; | 548 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; |
556 | size = dp->d_ops->data_entsize(args->namelen); | 549 | size = dp->d_ops->data_entsize(args->namelen); |
@@ -616,10 +609,8 @@ xfs_dir2_sf_check( | |||
616 | int offset; /* data offset */ | 609 | int offset; /* data offset */ |
617 | xfs_dir2_sf_entry_t *sfep; /* shortform dir entry */ | 610 | xfs_dir2_sf_entry_t *sfep; /* shortform dir entry */ |
618 | xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ | 611 | xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ |
619 | struct xfs_mount *mp; | ||
620 | 612 | ||
621 | dp = args->dp; | 613 | dp = args->dp; |
622 | mp = dp->i_mount; | ||
623 | 614 | ||
624 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; | 615 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; |
625 | offset = dp->d_ops->data_first_offset; | 616 | offset = dp->d_ops->data_first_offset; |
@@ -1016,12 +1007,10 @@ xfs_dir2_sf_toino4( | |||
1016 | int oldsize; /* old inode size */ | 1007 | int oldsize; /* old inode size */ |
1017 | xfs_dir2_sf_entry_t *sfep; /* new sf entry */ | 1008 | xfs_dir2_sf_entry_t *sfep; /* new sf entry */ |
1018 | xfs_dir2_sf_hdr_t *sfp; /* new sf directory */ | 1009 | xfs_dir2_sf_hdr_t *sfp; /* new sf directory */ |
1019 | struct xfs_mount *mp; | ||
1020 | 1010 | ||
1021 | trace_xfs_dir2_sf_toino4(args); | 1011 | trace_xfs_dir2_sf_toino4(args); |
1022 | 1012 | ||
1023 | dp = args->dp; | 1013 | dp = args->dp; |
1024 | mp = dp->i_mount; | ||
1025 | 1014 | ||
1026 | /* | 1015 | /* |
1027 | * Copy the old directory to the buffer. | 1016 | * Copy the old directory to the buffer. |
@@ -1094,12 +1083,10 @@ xfs_dir2_sf_toino8( | |||
1094 | int oldsize; /* old inode size */ | 1083 | int oldsize; /* old inode size */ |
1095 | xfs_dir2_sf_entry_t *sfep; /* new sf entry */ | 1084 | xfs_dir2_sf_entry_t *sfep; /* new sf entry */ |
1096 | xfs_dir2_sf_hdr_t *sfp; /* new sf directory */ | 1085 | xfs_dir2_sf_hdr_t *sfp; /* new sf directory */ |
1097 | struct xfs_mount *mp; | ||
1098 | 1086 | ||
1099 | trace_xfs_dir2_sf_toino8(args); | 1087 | trace_xfs_dir2_sf_toino8(args); |
1100 | 1088 | ||
1101 | dp = args->dp; | 1089 | dp = args->dp; |
1102 | mp = dp->i_mount; | ||
1103 | 1090 | ||
1104 | /* | 1091 | /* |
1105 | * Copy the old directory to the buffer. | 1092 | * Copy the old directory to the buffer. |
diff --git a/fs/xfs/libxfs/xfs_dquot_buf.c b/fs/xfs/libxfs/xfs_dquot_buf.c index bb969337efc8..6fbf2d853a54 100644 --- a/fs/xfs/libxfs/xfs_dquot_buf.c +++ b/fs/xfs/libxfs/xfs_dquot_buf.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_format.h" | 22 | #include "xfs_format.h" |
23 | #include "xfs_log_format.h" | 23 | #include "xfs_log_format.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
29 | #include "xfs_quota.h" | 27 | #include "xfs_quota.h" |
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 7e42bba9a420..fbd6da263571 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h | |||
@@ -34,6 +34,1077 @@ struct xfs_buf; | |||
34 | struct xfs_ifork; | 34 | struct xfs_ifork; |
35 | 35 | ||
36 | /* | 36 | /* |
37 | * Super block | ||
38 | * Fits into a sector-sized buffer at address 0 of each allocation group. | ||
39 | * Only the first of these is ever updated except during growfs. | ||
40 | */ | ||
41 | #define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */ | ||
42 | #define XFS_SB_VERSION_1 1 /* 5.3, 6.0.1, 6.1 */ | ||
43 | #define XFS_SB_VERSION_2 2 /* 6.2 - attributes */ | ||
44 | #define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */ | ||
45 | #define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */ | ||
46 | #define XFS_SB_VERSION_5 5 /* CRC enabled filesystem */ | ||
47 | #define XFS_SB_VERSION_NUMBITS 0x000f | ||
48 | #define XFS_SB_VERSION_ALLFBITS 0xfff0 | ||
49 | #define XFS_SB_VERSION_ATTRBIT 0x0010 | ||
50 | #define XFS_SB_VERSION_NLINKBIT 0x0020 | ||
51 | #define XFS_SB_VERSION_QUOTABIT 0x0040 | ||
52 | #define XFS_SB_VERSION_ALIGNBIT 0x0080 | ||
53 | #define XFS_SB_VERSION_DALIGNBIT 0x0100 | ||
54 | #define XFS_SB_VERSION_SHAREDBIT 0x0200 | ||
55 | #define XFS_SB_VERSION_LOGV2BIT 0x0400 | ||
56 | #define XFS_SB_VERSION_SECTORBIT 0x0800 | ||
57 | #define XFS_SB_VERSION_EXTFLGBIT 0x1000 | ||
58 | #define XFS_SB_VERSION_DIRV2BIT 0x2000 | ||
59 | #define XFS_SB_VERSION_BORGBIT 0x4000 /* ASCII only case-insens. */ | ||
60 | #define XFS_SB_VERSION_MOREBITSBIT 0x8000 | ||
61 | |||
62 | /* | ||
63 | * Supported feature bit list is just all bits in the versionnum field because | ||
64 | * we've used them all up and understand them all. Except, of course, for the | ||
65 | * shared superblock bit, which nobody knows what it does and so is unsupported. | ||
66 | */ | ||
67 | #define XFS_SB_VERSION_OKBITS \ | ||
68 | ((XFS_SB_VERSION_NUMBITS | XFS_SB_VERSION_ALLFBITS) & \ | ||
69 | ~XFS_SB_VERSION_SHAREDBIT) | ||
70 | |||
71 | /* | ||
72 | * There are two words to hold XFS "feature" bits: the original | ||
73 | * word, sb_versionnum, and sb_features2. Whenever a bit is set in | ||
74 | * sb_features2, the feature bit XFS_SB_VERSION_MOREBITSBIT must be set. | ||
75 | * | ||
76 | * These defines represent bits in sb_features2. | ||
77 | */ | ||
78 | #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001 | ||
79 | #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */ | ||
80 | #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 | ||
81 | #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ | ||
82 | #define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */ | ||
83 | #define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32 bit project id */ | ||
84 | #define XFS_SB_VERSION2_CRCBIT 0x00000100 /* metadata CRCs */ | ||
85 | #define XFS_SB_VERSION2_FTYPE 0x00000200 /* inode type in dir */ | ||
86 | |||
87 | #define XFS_SB_VERSION2_OKBITS \ | ||
88 | (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ | ||
89 | XFS_SB_VERSION2_ATTR2BIT | \ | ||
90 | XFS_SB_VERSION2_PROJID32BIT | \ | ||
91 | XFS_SB_VERSION2_FTYPE) | ||
92 | |||
93 | /* | ||
94 | * Superblock - in core version. Must match the ondisk version below. | ||
95 | * Must be padded to 64 bit alignment. | ||
96 | */ | ||
97 | typedef struct xfs_sb { | ||
98 | __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ | ||
99 | __uint32_t sb_blocksize; /* logical block size, bytes */ | ||
100 | xfs_rfsblock_t sb_dblocks; /* number of data blocks */ | ||
101 | xfs_rfsblock_t sb_rblocks; /* number of realtime blocks */ | ||
102 | xfs_rtblock_t sb_rextents; /* number of realtime extents */ | ||
103 | uuid_t sb_uuid; /* file system unique id */ | ||
104 | xfs_fsblock_t sb_logstart; /* starting block of log if internal */ | ||
105 | xfs_ino_t sb_rootino; /* root inode number */ | ||
106 | xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */ | ||
107 | xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */ | ||
108 | xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */ | ||
109 | xfs_agblock_t sb_agblocks; /* size of an allocation group */ | ||
110 | xfs_agnumber_t sb_agcount; /* number of allocation groups */ | ||
111 | xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */ | ||
112 | xfs_extlen_t sb_logblocks; /* number of log blocks */ | ||
113 | __uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */ | ||
114 | __uint16_t sb_sectsize; /* volume sector size, bytes */ | ||
115 | __uint16_t sb_inodesize; /* inode size, bytes */ | ||
116 | __uint16_t sb_inopblock; /* inodes per block */ | ||
117 | char sb_fname[12]; /* file system name */ | ||
118 | __uint8_t sb_blocklog; /* log2 of sb_blocksize */ | ||
119 | __uint8_t sb_sectlog; /* log2 of sb_sectsize */ | ||
120 | __uint8_t sb_inodelog; /* log2 of sb_inodesize */ | ||
121 | __uint8_t sb_inopblog; /* log2 of sb_inopblock */ | ||
122 | __uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */ | ||
123 | __uint8_t sb_rextslog; /* log2 of sb_rextents */ | ||
124 | __uint8_t sb_inprogress; /* mkfs is in progress, don't mount */ | ||
125 | __uint8_t sb_imax_pct; /* max % of fs for inode space */ | ||
126 | /* statistics */ | ||
127 | /* | ||
128 | * These fields must remain contiguous. If you really | ||
129 | * want to change their layout, make sure you fix the | ||
130 | * code in xfs_trans_apply_sb_deltas(). | ||
131 | */ | ||
132 | __uint64_t sb_icount; /* allocated inodes */ | ||
133 | __uint64_t sb_ifree; /* free inodes */ | ||
134 | __uint64_t sb_fdblocks; /* free data blocks */ | ||
135 | __uint64_t sb_frextents; /* free realtime extents */ | ||
136 | /* | ||
137 | * End contiguous fields. | ||
138 | */ | ||
139 | xfs_ino_t sb_uquotino; /* user quota inode */ | ||
140 | xfs_ino_t sb_gquotino; /* group quota inode */ | ||
141 | __uint16_t sb_qflags; /* quota flags */ | ||
142 | __uint8_t sb_flags; /* misc. flags */ | ||
143 | __uint8_t sb_shared_vn; /* shared version number */ | ||
144 | xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */ | ||
145 | __uint32_t sb_unit; /* stripe or raid unit */ | ||
146 | __uint32_t sb_width; /* stripe or raid width */ | ||
147 | __uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */ | ||
148 | __uint8_t sb_logsectlog; /* log2 of the log sector size */ | ||
149 | __uint16_t sb_logsectsize; /* sector size for the log, bytes */ | ||
150 | __uint32_t sb_logsunit; /* stripe unit size for the log */ | ||
151 | __uint32_t sb_features2; /* additional feature bits */ | ||
152 | |||
153 | /* | ||
154 | * bad features2 field as a result of failing to pad the sb | ||
155 | * structure to 64 bits. Some machines will be using this field | ||
156 | * for features2 bits. Easiest just to mark it bad and not use | ||
157 | * it for anything else. | ||
158 | */ | ||
159 | __uint32_t sb_bad_features2; | ||
160 | |||
161 | /* version 5 superblock fields start here */ | ||
162 | |||
163 | /* feature masks */ | ||
164 | __uint32_t sb_features_compat; | ||
165 | __uint32_t sb_features_ro_compat; | ||
166 | __uint32_t sb_features_incompat; | ||
167 | __uint32_t sb_features_log_incompat; | ||
168 | |||
169 | __uint32_t sb_crc; /* superblock crc */ | ||
170 | __uint32_t sb_pad; | ||
171 | |||
172 | xfs_ino_t sb_pquotino; /* project quota inode */ | ||
173 | xfs_lsn_t sb_lsn; /* last write sequence */ | ||
174 | |||
175 | /* must be padded to 64 bit alignment */ | ||
176 | } xfs_sb_t; | ||
177 | |||
178 | #define XFS_SB_CRC_OFF offsetof(struct xfs_sb, sb_crc) | ||
179 | |||
180 | /* | ||
181 | * Superblock - on disk version. Must match the in core version above. | ||
182 | * Must be padded to 64 bit alignment. | ||
183 | */ | ||
184 | typedef struct xfs_dsb { | ||
185 | __be32 sb_magicnum; /* magic number == XFS_SB_MAGIC */ | ||
186 | __be32 sb_blocksize; /* logical block size, bytes */ | ||
187 | __be64 sb_dblocks; /* number of data blocks */ | ||
188 | __be64 sb_rblocks; /* number of realtime blocks */ | ||
189 | __be64 sb_rextents; /* number of realtime extents */ | ||
190 | uuid_t sb_uuid; /* file system unique id */ | ||
191 | __be64 sb_logstart; /* starting block of log if internal */ | ||
192 | __be64 sb_rootino; /* root inode number */ | ||
193 | __be64 sb_rbmino; /* bitmap inode for realtime extents */ | ||
194 | __be64 sb_rsumino; /* summary inode for rt bitmap */ | ||
195 | __be32 sb_rextsize; /* realtime extent size, blocks */ | ||
196 | __be32 sb_agblocks; /* size of an allocation group */ | ||
197 | __be32 sb_agcount; /* number of allocation groups */ | ||
198 | __be32 sb_rbmblocks; /* number of rt bitmap blocks */ | ||
199 | __be32 sb_logblocks; /* number of log blocks */ | ||
200 | __be16 sb_versionnum; /* header version == XFS_SB_VERSION */ | ||
201 | __be16 sb_sectsize; /* volume sector size, bytes */ | ||
202 | __be16 sb_inodesize; /* inode size, bytes */ | ||
203 | __be16 sb_inopblock; /* inodes per block */ | ||
204 | char sb_fname[12]; /* file system name */ | ||
205 | __u8 sb_blocklog; /* log2 of sb_blocksize */ | ||
206 | __u8 sb_sectlog; /* log2 of sb_sectsize */ | ||
207 | __u8 sb_inodelog; /* log2 of sb_inodesize */ | ||
208 | __u8 sb_inopblog; /* log2 of sb_inopblock */ | ||
209 | __u8 sb_agblklog; /* log2 of sb_agblocks (rounded up) */ | ||
210 | __u8 sb_rextslog; /* log2 of sb_rextents */ | ||
211 | __u8 sb_inprogress; /* mkfs is in progress, don't mount */ | ||
212 | __u8 sb_imax_pct; /* max % of fs for inode space */ | ||
213 | /* statistics */ | ||
214 | /* | ||
215 | * These fields must remain contiguous. If you really | ||
216 | * want to change their layout, make sure you fix the | ||
217 | * code in xfs_trans_apply_sb_deltas(). | ||
218 | */ | ||
219 | __be64 sb_icount; /* allocated inodes */ | ||
220 | __be64 sb_ifree; /* free inodes */ | ||
221 | __be64 sb_fdblocks; /* free data blocks */ | ||
222 | __be64 sb_frextents; /* free realtime extents */ | ||
223 | /* | ||
224 | * End contiguous fields. | ||
225 | */ | ||
226 | __be64 sb_uquotino; /* user quota inode */ | ||
227 | __be64 sb_gquotino; /* group quota inode */ | ||
228 | __be16 sb_qflags; /* quota flags */ | ||
229 | __u8 sb_flags; /* misc. flags */ | ||
230 | __u8 sb_shared_vn; /* shared version number */ | ||
231 | __be32 sb_inoalignmt; /* inode chunk alignment, fsblocks */ | ||
232 | __be32 sb_unit; /* stripe or raid unit */ | ||
233 | __be32 sb_width; /* stripe or raid width */ | ||
234 | __u8 sb_dirblklog; /* log2 of dir block size (fsbs) */ | ||
235 | __u8 sb_logsectlog; /* log2 of the log sector size */ | ||
236 | __be16 sb_logsectsize; /* sector size for the log, bytes */ | ||
237 | __be32 sb_logsunit; /* stripe unit size for the log */ | ||
238 | __be32 sb_features2; /* additional feature bits */ | ||
239 | /* | ||
240 | * bad features2 field as a result of failing to pad the sb | ||
241 | * structure to 64 bits. Some machines will be using this field | ||
242 | * for features2 bits. Easiest just to mark it bad and not use | ||
243 | * it for anything else. | ||
244 | */ | ||
245 | __be32 sb_bad_features2; | ||
246 | |||
247 | /* version 5 superblock fields start here */ | ||
248 | |||
249 | /* feature masks */ | ||
250 | __be32 sb_features_compat; | ||
251 | __be32 sb_features_ro_compat; | ||
252 | __be32 sb_features_incompat; | ||
253 | __be32 sb_features_log_incompat; | ||
254 | |||
255 | __le32 sb_crc; /* superblock crc */ | ||
256 | __be32 sb_pad; | ||
257 | |||
258 | __be64 sb_pquotino; /* project quota inode */ | ||
259 | __be64 sb_lsn; /* last write sequence */ | ||
260 | |||
261 | /* must be padded to 64 bit alignment */ | ||
262 | } xfs_dsb_t; | ||
263 | |||
264 | /* | ||
265 | * Sequence number values for the fields. | ||
266 | */ | ||
267 | typedef enum { | ||
268 | XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS, | ||
269 | XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO, | ||
270 | XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS, | ||
271 | XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS, | ||
272 | XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE, | ||
273 | XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG, | ||
274 | XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG, | ||
275 | XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT, | ||
276 | XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO, | ||
277 | XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN, | ||
278 | XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG, | ||
279 | XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT, | ||
280 | XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, XFS_SBS_FEATURES_COMPAT, | ||
281 | XFS_SBS_FEATURES_RO_COMPAT, XFS_SBS_FEATURES_INCOMPAT, | ||
282 | XFS_SBS_FEATURES_LOG_INCOMPAT, XFS_SBS_CRC, XFS_SBS_PAD, | ||
283 | XFS_SBS_PQUOTINO, XFS_SBS_LSN, | ||
284 | XFS_SBS_FIELDCOUNT | ||
285 | } xfs_sb_field_t; | ||
286 | |||
287 | /* | ||
288 | * Mask values, defined based on the xfs_sb_field_t values. | ||
289 | * Only define the ones we're using. | ||
290 | */ | ||
291 | #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x) | ||
292 | #define XFS_SB_UUID XFS_SB_MVAL(UUID) | ||
293 | #define XFS_SB_FNAME XFS_SB_MVAL(FNAME) | ||
294 | #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO) | ||
295 | #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO) | ||
296 | #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO) | ||
297 | #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM) | ||
298 | #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO) | ||
299 | #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO) | ||
300 | #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS) | ||
301 | #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN) | ||
302 | #define XFS_SB_UNIT XFS_SB_MVAL(UNIT) | ||
303 | #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH) | ||
304 | #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT) | ||
305 | #define XFS_SB_IFREE XFS_SB_MVAL(IFREE) | ||
306 | #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) | ||
307 | #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) | ||
308 | #define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2) | ||
309 | #define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT) | ||
310 | #define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT) | ||
311 | #define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT) | ||
312 | #define XFS_SB_FEATURES_LOG_INCOMPAT XFS_SB_MVAL(FEATURES_LOG_INCOMPAT) | ||
313 | #define XFS_SB_CRC XFS_SB_MVAL(CRC) | ||
314 | #define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO) | ||
315 | #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) | ||
316 | #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) | ||
317 | #define XFS_SB_MOD_BITS \ | ||
318 | (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \ | ||
319 | XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ | ||
320 | XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ | ||
321 | XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \ | ||
322 | XFS_SB_BAD_FEATURES2 | XFS_SB_FEATURES_COMPAT | \ | ||
323 | XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | \ | ||
324 | XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO) | ||
325 | |||
326 | |||
327 | /* | ||
328 | * Misc. Flags - warning - these will be cleared by xfs_repair unless | ||
329 | * a feature bit is set when the flag is used. | ||
330 | */ | ||
331 | #define XFS_SBF_NOFLAGS 0x00 /* no flags set */ | ||
332 | #define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */ | ||
333 | |||
334 | /* | ||
335 | * define max. shared version we can interoperate with | ||
336 | */ | ||
337 | #define XFS_SB_MAX_SHARED_VN 0 | ||
338 | |||
339 | #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) | ||
340 | |||
341 | /* | ||
342 | * The first XFS version we support is a v4 superblock with V2 directories. | ||
343 | */ | ||
344 | static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp) | ||
345 | { | ||
346 | if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)) | ||
347 | return false; | ||
348 | |||
349 | /* check for unknown features in the fs */ | ||
350 | if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) || | ||
351 | ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && | ||
352 | (sbp->sb_features2 & ~XFS_SB_VERSION2_OKBITS))) | ||
353 | return false; | ||
354 | |||
355 | return true; | ||
356 | } | ||
357 | |||
358 | static inline bool xfs_sb_good_version(struct xfs_sb *sbp) | ||
359 | { | ||
360 | if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) | ||
361 | return true; | ||
362 | if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) | ||
363 | return xfs_sb_good_v4_features(sbp); | ||
364 | return false; | ||
365 | } | ||
366 | |||
367 | /* | ||
368 | * Detect a mismatched features2 field. Older kernels read/wrote | ||
369 | * this into the wrong slot, so to be safe we keep them in sync. | ||
370 | */ | ||
371 | static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp) | ||
372 | { | ||
373 | return sbp->sb_bad_features2 != sbp->sb_features2; | ||
374 | } | ||
375 | |||
376 | static inline bool xfs_sb_version_hasattr(struct xfs_sb *sbp) | ||
377 | { | ||
378 | return (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT); | ||
379 | } | ||
380 | |||
381 | static inline void xfs_sb_version_addattr(struct xfs_sb *sbp) | ||
382 | { | ||
383 | sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT; | ||
384 | } | ||
385 | |||
386 | static inline bool xfs_sb_version_hasquota(struct xfs_sb *sbp) | ||
387 | { | ||
388 | return (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT); | ||
389 | } | ||
390 | |||
391 | static inline void xfs_sb_version_addquota(struct xfs_sb *sbp) | ||
392 | { | ||
393 | sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT; | ||
394 | } | ||
395 | |||
396 | static inline bool xfs_sb_version_hasalign(struct xfs_sb *sbp) | ||
397 | { | ||
398 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || | ||
399 | (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT)); | ||
400 | } | ||
401 | |||
402 | static inline bool xfs_sb_version_hasdalign(struct xfs_sb *sbp) | ||
403 | { | ||
404 | return (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); | ||
405 | } | ||
406 | |||
407 | static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp) | ||
408 | { | ||
409 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || | ||
410 | (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); | ||
411 | } | ||
412 | |||
413 | static inline bool xfs_sb_version_hasextflgbit(struct xfs_sb *sbp) | ||
414 | { | ||
415 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || | ||
416 | (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); | ||
417 | } | ||
418 | |||
419 | static inline bool xfs_sb_version_hassector(struct xfs_sb *sbp) | ||
420 | { | ||
421 | return (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT); | ||
422 | } | ||
423 | |||
424 | static inline bool xfs_sb_version_hasasciici(struct xfs_sb *sbp) | ||
425 | { | ||
426 | return (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); | ||
427 | } | ||
428 | |||
429 | static inline bool xfs_sb_version_hasmorebits(struct xfs_sb *sbp) | ||
430 | { | ||
431 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || | ||
432 | (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); | ||
433 | } | ||
434 | |||
435 | /* | ||
436 | * sb_features2 bit version macros. | ||
437 | */ | ||
438 | static inline bool xfs_sb_version_haslazysbcount(struct xfs_sb *sbp) | ||
439 | { | ||
440 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || | ||
441 | (xfs_sb_version_hasmorebits(sbp) && | ||
442 | (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT)); | ||
443 | } | ||
444 | |||
445 | static inline bool xfs_sb_version_hasattr2(struct xfs_sb *sbp) | ||
446 | { | ||
447 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || | ||
448 | (xfs_sb_version_hasmorebits(sbp) && | ||
449 | (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT)); | ||
450 | } | ||
451 | |||
452 | static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) | ||
453 | { | ||
454 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; | ||
455 | sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; | ||
456 | sbp->sb_bad_features2 |= XFS_SB_VERSION2_ATTR2BIT; | ||
457 | } | ||
458 | |||
459 | static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp) | ||
460 | { | ||
461 | sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; | ||
462 | sbp->sb_bad_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; | ||
463 | if (!sbp->sb_features2) | ||
464 | sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; | ||
465 | } | ||
466 | |||
467 | static inline bool xfs_sb_version_hasprojid32bit(struct xfs_sb *sbp) | ||
468 | { | ||
469 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || | ||
470 | (xfs_sb_version_hasmorebits(sbp) && | ||
471 | (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT)); | ||
472 | } | ||
473 | |||
474 | static inline void xfs_sb_version_addprojid32bit(struct xfs_sb *sbp) | ||
475 | { | ||
476 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; | ||
477 | sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT; | ||
478 | sbp->sb_bad_features2 |= XFS_SB_VERSION2_PROJID32BIT; | ||
479 | } | ||
480 | |||
481 | /* | ||
482 | * Extended v5 superblock feature masks. These are to be used for new v5 | ||
483 | * superblock features only. | ||
484 | * | ||
485 | * Compat features are new features that old kernels will not notice or affect | ||
486 | * and so can mount read-write without issues. | ||
487 | * | ||
488 | * RO-Compat (read only) are features that old kernels can read but will break | ||
489 | * if they write. Hence only read-only mounts of such filesystems are allowed on | ||
490 | * kernels that don't support the feature bit. | ||
491 | * | ||
492 | * InCompat features are features which old kernels will not understand and so | ||
493 | * must not mount. | ||
494 | * | ||
495 | * Log-InCompat features are for changes to log formats or new transactions that | ||
496 | * can't be replayed on older kernels. The fields are set when the filesystem is | ||
497 | * mounted, and a clean unmount clears the fields. | ||
498 | */ | ||
499 | #define XFS_SB_FEAT_COMPAT_ALL 0 | ||
500 | #define XFS_SB_FEAT_COMPAT_UNKNOWN ~XFS_SB_FEAT_COMPAT_ALL | ||
501 | static inline bool | ||
502 | xfs_sb_has_compat_feature( | ||
503 | struct xfs_sb *sbp, | ||
504 | __uint32_t feature) | ||
505 | { | ||
506 | return (sbp->sb_features_compat & feature) != 0; | ||
507 | } | ||
508 | |||
509 | #define XFS_SB_FEAT_RO_COMPAT_FINOBT (1 << 0) /* free inode btree */ | ||
510 | #define XFS_SB_FEAT_RO_COMPAT_ALL \ | ||
511 | (XFS_SB_FEAT_RO_COMPAT_FINOBT) | ||
512 | #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL | ||
513 | static inline bool | ||
514 | xfs_sb_has_ro_compat_feature( | ||
515 | struct xfs_sb *sbp, | ||
516 | __uint32_t feature) | ||
517 | { | ||
518 | return (sbp->sb_features_ro_compat & feature) != 0; | ||
519 | } | ||
520 | |||
521 | #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ | ||
522 | #define XFS_SB_FEAT_INCOMPAT_ALL \ | ||
523 | (XFS_SB_FEAT_INCOMPAT_FTYPE) | ||
524 | |||
525 | #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL | ||
526 | static inline bool | ||
527 | xfs_sb_has_incompat_feature( | ||
528 | struct xfs_sb *sbp, | ||
529 | __uint32_t feature) | ||
530 | { | ||
531 | return (sbp->sb_features_incompat & feature) != 0; | ||
532 | } | ||
533 | |||
534 | #define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 | ||
535 | #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL | ||
536 | static inline bool | ||
537 | xfs_sb_has_incompat_log_feature( | ||
538 | struct xfs_sb *sbp, | ||
539 | __uint32_t feature) | ||
540 | { | ||
541 | return (sbp->sb_features_log_incompat & feature) != 0; | ||
542 | } | ||
543 | |||
544 | /* | ||
545 | * V5 superblock specific feature checks | ||
546 | */ | ||
547 | static inline int xfs_sb_version_hascrc(struct xfs_sb *sbp) | ||
548 | { | ||
549 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; | ||
550 | } | ||
551 | |||
552 | static inline int xfs_sb_version_has_pquotino(struct xfs_sb *sbp) | ||
553 | { | ||
554 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; | ||
555 | } | ||
556 | |||
557 | static inline int xfs_sb_version_hasftype(struct xfs_sb *sbp) | ||
558 | { | ||
559 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && | ||
560 | xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE)) || | ||
561 | (xfs_sb_version_hasmorebits(sbp) && | ||
562 | (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE)); | ||
563 | } | ||
564 | |||
565 | static inline int xfs_sb_version_hasfinobt(xfs_sb_t *sbp) | ||
566 | { | ||
567 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) && | ||
568 | (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FINOBT); | ||
569 | } | ||
570 | |||
571 | /* | ||
572 | * end of superblock version macros | ||
573 | */ | ||
574 | |||
575 | static inline bool | ||
576 | xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) | ||
577 | { | ||
578 | return (ino == sbp->sb_uquotino || | ||
579 | ino == sbp->sb_gquotino || | ||
580 | ino == sbp->sb_pquotino); | ||
581 | } | ||
582 | |||
583 | #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ | ||
584 | #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) | ||
585 | #define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr)) | ||
586 | |||
587 | #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) | ||
588 | #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ | ||
589 | xfs_daddr_to_agno(mp,d), xfs_daddr_to_agbno(mp,d)) | ||
590 | #define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \ | ||
591 | XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno)) | ||
592 | |||
593 | /* | ||
594 | * File system sector to basic block conversions. | ||
595 | */ | ||
596 | #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log) | ||
597 | |||
598 | /* | ||
599 | * File system block to basic block conversions. | ||
600 | */ | ||
601 | #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log) | ||
602 | #define XFS_BB_TO_FSB(mp,bb) \ | ||
603 | (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log) | ||
604 | #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log) | ||
605 | |||
606 | /* | ||
607 | * File system block to byte conversions. | ||
608 | */ | ||
609 | #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog) | ||
610 | #define XFS_B_TO_FSB(mp,b) \ | ||
611 | ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog) | ||
612 | #define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog) | ||
613 | #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask) | ||
614 | |||
615 | /* | ||
616 | * Allocation group header | ||
617 | * | ||
618 | * This is divided into three structures, placed in sequential 512-byte | ||
619 | * buffers after a copy of the superblock (also in a 512-byte buffer). | ||
620 | */ | ||
621 | #define XFS_AGF_MAGIC 0x58414746 /* 'XAGF' */ | ||
622 | #define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */ | ||
623 | #define XFS_AGFL_MAGIC 0x5841464c /* 'XAFL' */ | ||
624 | #define XFS_AGF_VERSION 1 | ||
625 | #define XFS_AGI_VERSION 1 | ||
626 | |||
627 | #define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION) | ||
628 | #define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION) | ||
629 | |||
630 | /* | ||
631 | * Btree number 0 is bno, 1 is cnt. This value gives the size of the | ||
632 | * arrays below. | ||
633 | */ | ||
634 | #define XFS_BTNUM_AGF ((int)XFS_BTNUM_CNTi + 1) | ||
635 | |||
636 | /* | ||
637 | * The second word of agf_levels in the first a.g. overlaps the EFS | ||
638 | * superblock's magic number. Since the magic numbers valid for EFS | ||
639 | * are > 64k, our value cannot be confused for an EFS superblock's. | ||
640 | */ | ||
641 | |||
642 | typedef struct xfs_agf { | ||
643 | /* | ||
644 | * Common allocation group header information | ||
645 | */ | ||
646 | __be32 agf_magicnum; /* magic number == XFS_AGF_MAGIC */ | ||
647 | __be32 agf_versionnum; /* header version == XFS_AGF_VERSION */ | ||
648 | __be32 agf_seqno; /* sequence # starting from 0 */ | ||
649 | __be32 agf_length; /* size in blocks of a.g. */ | ||
650 | /* | ||
651 | * Freespace information | ||
652 | */ | ||
653 | __be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */ | ||
654 | __be32 agf_spare0; /* spare field */ | ||
655 | __be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */ | ||
656 | __be32 agf_spare1; /* spare field */ | ||
657 | |||
658 | __be32 agf_flfirst; /* first freelist block's index */ | ||
659 | __be32 agf_fllast; /* last freelist block's index */ | ||
660 | __be32 agf_flcount; /* count of blocks in freelist */ | ||
661 | __be32 agf_freeblks; /* total free blocks */ | ||
662 | |||
663 | __be32 agf_longest; /* longest free space */ | ||
664 | __be32 agf_btreeblks; /* # of blocks held in AGF btrees */ | ||
665 | uuid_t agf_uuid; /* uuid of filesystem */ | ||
666 | |||
667 | /* | ||
668 | * reserve some contiguous space for future logged fields before we add | ||
669 | * the unlogged fields. This makes the range logging via flags and | ||
670 | * structure offsets much simpler. | ||
671 | */ | ||
672 | __be64 agf_spare64[16]; | ||
673 | |||
674 | /* unlogged fields, written during buffer writeback. */ | ||
675 | __be64 agf_lsn; /* last write sequence */ | ||
676 | __be32 agf_crc; /* crc of agf sector */ | ||
677 | __be32 agf_spare2; | ||
678 | |||
679 | /* structure must be padded to 64 bit alignment */ | ||
680 | } xfs_agf_t; | ||
681 | |||
682 | #define XFS_AGF_CRC_OFF offsetof(struct xfs_agf, agf_crc) | ||
683 | |||
684 | #define XFS_AGF_MAGICNUM 0x00000001 | ||
685 | #define XFS_AGF_VERSIONNUM 0x00000002 | ||
686 | #define XFS_AGF_SEQNO 0x00000004 | ||
687 | #define XFS_AGF_LENGTH 0x00000008 | ||
688 | #define XFS_AGF_ROOTS 0x00000010 | ||
689 | #define XFS_AGF_LEVELS 0x00000020 | ||
690 | #define XFS_AGF_FLFIRST 0x00000040 | ||
691 | #define XFS_AGF_FLLAST 0x00000080 | ||
692 | #define XFS_AGF_FLCOUNT 0x00000100 | ||
693 | #define XFS_AGF_FREEBLKS 0x00000200 | ||
694 | #define XFS_AGF_LONGEST 0x00000400 | ||
695 | #define XFS_AGF_BTREEBLKS 0x00000800 | ||
696 | #define XFS_AGF_UUID 0x00001000 | ||
697 | #define XFS_AGF_NUM_BITS 13 | ||
698 | #define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) | ||
699 | |||
700 | #define XFS_AGF_FLAGS \ | ||
701 | { XFS_AGF_MAGICNUM, "MAGICNUM" }, \ | ||
702 | { XFS_AGF_VERSIONNUM, "VERSIONNUM" }, \ | ||
703 | { XFS_AGF_SEQNO, "SEQNO" }, \ | ||
704 | { XFS_AGF_LENGTH, "LENGTH" }, \ | ||
705 | { XFS_AGF_ROOTS, "ROOTS" }, \ | ||
706 | { XFS_AGF_LEVELS, "LEVELS" }, \ | ||
707 | { XFS_AGF_FLFIRST, "FLFIRST" }, \ | ||
708 | { XFS_AGF_FLLAST, "FLLAST" }, \ | ||
709 | { XFS_AGF_FLCOUNT, "FLCOUNT" }, \ | ||
710 | { XFS_AGF_FREEBLKS, "FREEBLKS" }, \ | ||
711 | { XFS_AGF_LONGEST, "LONGEST" }, \ | ||
712 | { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \ | ||
713 | { XFS_AGF_UUID, "UUID" } | ||
714 | |||
715 | /* disk block (xfs_daddr_t) in the AG */ | ||
716 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) | ||
717 | #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) | ||
718 | #define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)((bp)->b_addr)) | ||
719 | |||
720 | /* | ||
721 | * Size of the unlinked inode hash table in the agi. | ||
722 | */ | ||
723 | #define XFS_AGI_UNLINKED_BUCKETS 64 | ||
724 | |||
725 | typedef struct xfs_agi { | ||
726 | /* | ||
727 | * Common allocation group header information | ||
728 | */ | ||
729 | __be32 agi_magicnum; /* magic number == XFS_AGI_MAGIC */ | ||
730 | __be32 agi_versionnum; /* header version == XFS_AGI_VERSION */ | ||
731 | __be32 agi_seqno; /* sequence # starting from 0 */ | ||
732 | __be32 agi_length; /* size in blocks of a.g. */ | ||
733 | /* | ||
734 | * Inode information | ||
735 | * Inodes are mapped by interpreting the inode number, so no | ||
736 | * mapping data is needed here. | ||
737 | */ | ||
738 | __be32 agi_count; /* count of allocated inodes */ | ||
739 | __be32 agi_root; /* root of inode btree */ | ||
740 | __be32 agi_level; /* levels in inode btree */ | ||
741 | __be32 agi_freecount; /* number of free inodes */ | ||
742 | |||
743 | __be32 agi_newino; /* new inode just allocated */ | ||
744 | __be32 agi_dirino; /* last directory inode chunk */ | ||
745 | /* | ||
746 | * Hash table of inodes which have been unlinked but are | ||
747 | * still being referenced. | ||
748 | */ | ||
749 | __be32 agi_unlinked[XFS_AGI_UNLINKED_BUCKETS]; | ||
750 | /* | ||
751 | * This marks the end of logging region 1 and start of logging region 2. | ||
752 | */ | ||
753 | uuid_t agi_uuid; /* uuid of filesystem */ | ||
754 | __be32 agi_crc; /* crc of agi sector */ | ||
755 | __be32 agi_pad32; | ||
756 | __be64 agi_lsn; /* last write sequence */ | ||
757 | |||
758 | __be32 agi_free_root; /* root of the free inode btree */ | ||
759 | __be32 agi_free_level;/* levels in free inode btree */ | ||
760 | |||
761 | /* structure must be padded to 64 bit alignment */ | ||
762 | } xfs_agi_t; | ||
763 | |||
764 | #define XFS_AGI_CRC_OFF offsetof(struct xfs_agi, agi_crc) | ||
765 | |||
766 | #define XFS_AGI_MAGICNUM (1 << 0) | ||
767 | #define XFS_AGI_VERSIONNUM (1 << 1) | ||
768 | #define XFS_AGI_SEQNO (1 << 2) | ||
769 | #define XFS_AGI_LENGTH (1 << 3) | ||
770 | #define XFS_AGI_COUNT (1 << 4) | ||
771 | #define XFS_AGI_ROOT (1 << 5) | ||
772 | #define XFS_AGI_LEVEL (1 << 6) | ||
773 | #define XFS_AGI_FREECOUNT (1 << 7) | ||
774 | #define XFS_AGI_NEWINO (1 << 8) | ||
775 | #define XFS_AGI_DIRINO (1 << 9) | ||
776 | #define XFS_AGI_UNLINKED (1 << 10) | ||
777 | #define XFS_AGI_NUM_BITS_R1 11 /* end of the 1st agi logging region */ | ||
778 | #define XFS_AGI_ALL_BITS_R1 ((1 << XFS_AGI_NUM_BITS_R1) - 1) | ||
779 | #define XFS_AGI_FREE_ROOT (1 << 11) | ||
780 | #define XFS_AGI_FREE_LEVEL (1 << 12) | ||
781 | #define XFS_AGI_NUM_BITS_R2 13 | ||
782 | |||
783 | /* disk block (xfs_daddr_t) in the AG */ | ||
784 | #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) | ||
785 | #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) | ||
786 | #define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)((bp)->b_addr)) | ||
787 | |||
788 | /* | ||
789 | * The third a.g. block contains the a.g. freelist, an array | ||
790 | * of block pointers to blocks owned by the allocation btree code. | ||
791 | */ | ||
792 | #define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) | ||
793 | #define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) | ||
794 | #define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)((bp)->b_addr)) | ||
795 | |||
796 | #define XFS_BUF_TO_AGFL_BNO(mp, bp) \ | ||
797 | (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ | ||
798 | &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \ | ||
799 | (__be32 *)(bp)->b_addr) | ||
800 | |||
801 | /* | ||
802 | * Size of the AGFL. For CRC-enabled filesystes we steal a couple of | ||
803 | * slots in the beginning of the block for a proper header with the | ||
804 | * location information and CRC. | ||
805 | */ | ||
806 | #define XFS_AGFL_SIZE(mp) \ | ||
807 | (((mp)->m_sb.sb_sectsize - \ | ||
808 | (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ | ||
809 | sizeof(struct xfs_agfl) : 0)) / \ | ||
810 | sizeof(xfs_agblock_t)) | ||
811 | |||
812 | typedef struct xfs_agfl { | ||
813 | __be32 agfl_magicnum; | ||
814 | __be32 agfl_seqno; | ||
815 | uuid_t agfl_uuid; | ||
816 | __be64 agfl_lsn; | ||
817 | __be32 agfl_crc; | ||
818 | __be32 agfl_bno[]; /* actually XFS_AGFL_SIZE(mp) */ | ||
819 | } xfs_agfl_t; | ||
820 | |||
821 | #define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc) | ||
822 | |||
823 | |||
824 | #define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels) | ||
825 | #define XFS_MIN_FREELIST_RAW(bl,cl,mp) \ | ||
826 | (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + MIN(cl + 1, XFS_AG_MAXLEVELS(mp))) | ||
827 | #define XFS_MIN_FREELIST(a,mp) \ | ||
828 | (XFS_MIN_FREELIST_RAW( \ | ||
829 | be32_to_cpu((a)->agf_levels[XFS_BTNUM_BNOi]), \ | ||
830 | be32_to_cpu((a)->agf_levels[XFS_BTNUM_CNTi]), mp)) | ||
831 | #define XFS_MIN_FREELIST_PAG(pag,mp) \ | ||
832 | (XFS_MIN_FREELIST_RAW( \ | ||
833 | (unsigned int)(pag)->pagf_levels[XFS_BTNUM_BNOi], \ | ||
834 | (unsigned int)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp)) | ||
835 | |||
836 | #define XFS_AGB_TO_FSB(mp,agno,agbno) \ | ||
837 | (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno)) | ||
838 | #define XFS_FSB_TO_AGNO(mp,fsbno) \ | ||
839 | ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog)) | ||
840 | #define XFS_FSB_TO_AGBNO(mp,fsbno) \ | ||
841 | ((xfs_agblock_t)((fsbno) & xfs_mask32lo((mp)->m_sb.sb_agblklog))) | ||
842 | #define XFS_AGB_TO_DADDR(mp,agno,agbno) \ | ||
843 | ((xfs_daddr_t)XFS_FSB_TO_BB(mp, \ | ||
844 | (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno))) | ||
845 | #define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d)) | ||
846 | |||
847 | /* | ||
848 | * For checking for bad ranges of xfs_daddr_t's, covering multiple | ||
849 | * allocation groups or a single xfs_daddr_t that's a superblock copy. | ||
850 | */ | ||
851 | #define XFS_AG_CHECK_DADDR(mp,d,len) \ | ||
852 | ((len) == 1 ? \ | ||
853 | ASSERT((d) == XFS_SB_DADDR || \ | ||
854 | xfs_daddr_to_agbno(mp, d) != XFS_SB_DADDR) : \ | ||
855 | ASSERT(xfs_daddr_to_agno(mp, d) == \ | ||
856 | xfs_daddr_to_agno(mp, (d) + (len) - 1))) | ||
857 | |||
858 | typedef struct xfs_timestamp { | ||
859 | __be32 t_sec; /* timestamp seconds */ | ||
860 | __be32 t_nsec; /* timestamp nanoseconds */ | ||
861 | } xfs_timestamp_t; | ||
862 | |||
863 | /* | ||
864 | * On-disk inode structure. | ||
865 | * | ||
866 | * This is just the header or "dinode core", the inode is expanded to fill a | ||
867 | * variable size the leftover area split into a data and an attribute fork. | ||
868 | * The format of the data and attribute fork depends on the format of the | ||
869 | * inode as indicated by di_format and di_aformat. To access the data and | ||
870 | * attribute use the XFS_DFORK_DPTR, XFS_DFORK_APTR, and XFS_DFORK_PTR macros | ||
871 | * below. | ||
872 | * | ||
873 | * There is a very similar struct icdinode in xfs_inode which matches the | ||
874 | * layout of the first 96 bytes of this structure, but is kept in native | ||
875 | * format instead of big endian. | ||
876 | * | ||
877 | * Note: di_flushiter is only used by v1/2 inodes - it's effectively a zeroed | ||
878 | * padding field for v3 inodes. | ||
879 | */ | ||
880 | #define XFS_DINODE_MAGIC 0x494e /* 'IN' */ | ||
881 | #define XFS_DINODE_GOOD_VERSION(v) ((v) >= 1 && (v) <= 3) | ||
882 | typedef struct xfs_dinode { | ||
883 | __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ | ||
884 | __be16 di_mode; /* mode and type of file */ | ||
885 | __u8 di_version; /* inode version */ | ||
886 | __u8 di_format; /* format of di_c data */ | ||
887 | __be16 di_onlink; /* old number of links to file */ | ||
888 | __be32 di_uid; /* owner's user id */ | ||
889 | __be32 di_gid; /* owner's group id */ | ||
890 | __be32 di_nlink; /* number of links to file */ | ||
891 | __be16 di_projid_lo; /* lower part of owner's project id */ | ||
892 | __be16 di_projid_hi; /* higher part owner's project id */ | ||
893 | __u8 di_pad[6]; /* unused, zeroed space */ | ||
894 | __be16 di_flushiter; /* incremented on flush */ | ||
895 | xfs_timestamp_t di_atime; /* time last accessed */ | ||
896 | xfs_timestamp_t di_mtime; /* time last modified */ | ||
897 | xfs_timestamp_t di_ctime; /* time created/inode modified */ | ||
898 | __be64 di_size; /* number of bytes in file */ | ||
899 | __be64 di_nblocks; /* # of direct & btree blocks used */ | ||
900 | __be32 di_extsize; /* basic/minimum extent size for file */ | ||
901 | __be32 di_nextents; /* number of extents in data fork */ | ||
902 | __be16 di_anextents; /* number of extents in attribute fork*/ | ||
903 | __u8 di_forkoff; /* attr fork offs, <<3 for 64b align */ | ||
904 | __s8 di_aformat; /* format of attr fork's data */ | ||
905 | __be32 di_dmevmask; /* DMIG event mask */ | ||
906 | __be16 di_dmstate; /* DMIG state info */ | ||
907 | __be16 di_flags; /* random flags, XFS_DIFLAG_... */ | ||
908 | __be32 di_gen; /* generation number */ | ||
909 | |||
910 | /* di_next_unlinked is the only non-core field in the old dinode */ | ||
911 | __be32 di_next_unlinked;/* agi unlinked list ptr */ | ||
912 | |||
913 | /* start of the extended dinode, writable fields */ | ||
914 | __le32 di_crc; /* CRC of the inode */ | ||
915 | __be64 di_changecount; /* number of attribute changes */ | ||
916 | __be64 di_lsn; /* flush sequence */ | ||
917 | __be64 di_flags2; /* more random flags */ | ||
918 | __u8 di_pad2[16]; /* more padding for future expansion */ | ||
919 | |||
920 | /* fields only written to during inode creation */ | ||
921 | xfs_timestamp_t di_crtime; /* time created */ | ||
922 | __be64 di_ino; /* inode number */ | ||
923 | uuid_t di_uuid; /* UUID of the filesystem */ | ||
924 | |||
925 | /* structure must be padded to 64 bit alignment */ | ||
926 | } xfs_dinode_t; | ||
927 | |||
928 | #define XFS_DINODE_CRC_OFF offsetof(struct xfs_dinode, di_crc) | ||
929 | |||
930 | #define DI_MAX_FLUSH 0xffff | ||
931 | |||
932 | /* | ||
933 | * Size of the core inode on disk. Version 1 and 2 inodes have | ||
934 | * the same size, but version 3 has grown a few additional fields. | ||
935 | */ | ||
936 | static inline uint xfs_dinode_size(int version) | ||
937 | { | ||
938 | if (version == 3) | ||
939 | return sizeof(struct xfs_dinode); | ||
940 | return offsetof(struct xfs_dinode, di_crc); | ||
941 | } | ||
942 | |||
943 | /* | ||
944 | * The 32 bit link count in the inode theoretically maxes out at UINT_MAX. | ||
945 | * Since the pathconf interface is signed, we use 2^31 - 1 instead. | ||
946 | * The old inode format had a 16 bit link count, so its maximum is USHRT_MAX. | ||
947 | */ | ||
948 | #define XFS_MAXLINK ((1U << 31) - 1U) | ||
949 | #define XFS_MAXLINK_1 65535U | ||
950 | |||
951 | /* | ||
952 | * Values for di_format | ||
953 | */ | ||
954 | typedef enum xfs_dinode_fmt { | ||
955 | XFS_DINODE_FMT_DEV, /* xfs_dev_t */ | ||
956 | XFS_DINODE_FMT_LOCAL, /* bulk data */ | ||
957 | XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */ | ||
958 | XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */ | ||
959 | XFS_DINODE_FMT_UUID /* uuid_t */ | ||
960 | } xfs_dinode_fmt_t; | ||
961 | |||
962 | /* | ||
963 | * Inode minimum and maximum sizes. | ||
964 | */ | ||
965 | #define XFS_DINODE_MIN_LOG 8 | ||
966 | #define XFS_DINODE_MAX_LOG 11 | ||
967 | #define XFS_DINODE_MIN_SIZE (1 << XFS_DINODE_MIN_LOG) | ||
968 | #define XFS_DINODE_MAX_SIZE (1 << XFS_DINODE_MAX_LOG) | ||
969 | |||
970 | /* | ||
971 | * Inode size for given fs. | ||
972 | */ | ||
973 | #define XFS_LITINO(mp, version) \ | ||
974 | ((int)(((mp)->m_sb.sb_inodesize) - xfs_dinode_size(version))) | ||
975 | |||
976 | /* | ||
977 | * Inode data & attribute fork sizes, per inode. | ||
978 | */ | ||
979 | #define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0) | ||
980 | #define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3)) | ||
981 | |||
982 | #define XFS_DFORK_DSIZE(dip,mp) \ | ||
983 | (XFS_DFORK_Q(dip) ? \ | ||
984 | XFS_DFORK_BOFF(dip) : \ | ||
985 | XFS_LITINO(mp, (dip)->di_version)) | ||
986 | #define XFS_DFORK_ASIZE(dip,mp) \ | ||
987 | (XFS_DFORK_Q(dip) ? \ | ||
988 | XFS_LITINO(mp, (dip)->di_version) - XFS_DFORK_BOFF(dip) : \ | ||
989 | 0) | ||
990 | #define XFS_DFORK_SIZE(dip,mp,w) \ | ||
991 | ((w) == XFS_DATA_FORK ? \ | ||
992 | XFS_DFORK_DSIZE(dip, mp) : \ | ||
993 | XFS_DFORK_ASIZE(dip, mp)) | ||
994 | |||
995 | /* | ||
996 | * Return pointers to the data or attribute forks. | ||
997 | */ | ||
998 | #define XFS_DFORK_DPTR(dip) \ | ||
999 | ((char *)dip + xfs_dinode_size(dip->di_version)) | ||
1000 | #define XFS_DFORK_APTR(dip) \ | ||
1001 | (XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip)) | ||
1002 | #define XFS_DFORK_PTR(dip,w) \ | ||
1003 | ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) | ||
1004 | |||
1005 | #define XFS_DFORK_FORMAT(dip,w) \ | ||
1006 | ((w) == XFS_DATA_FORK ? \ | ||
1007 | (dip)->di_format : \ | ||
1008 | (dip)->di_aformat) | ||
1009 | #define XFS_DFORK_NEXTENTS(dip,w) \ | ||
1010 | ((w) == XFS_DATA_FORK ? \ | ||
1011 | be32_to_cpu((dip)->di_nextents) : \ | ||
1012 | be16_to_cpu((dip)->di_anextents)) | ||
1013 | |||
1014 | /* | ||
1015 | * For block and character special files the 32bit dev_t is stored at the | ||
1016 | * beginning of the data fork. | ||
1017 | */ | ||
1018 | static inline xfs_dev_t xfs_dinode_get_rdev(struct xfs_dinode *dip) | ||
1019 | { | ||
1020 | return be32_to_cpu(*(__be32 *)XFS_DFORK_DPTR(dip)); | ||
1021 | } | ||
1022 | |||
1023 | static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) | ||
1024 | { | ||
1025 | *(__be32 *)XFS_DFORK_DPTR(dip) = cpu_to_be32(rdev); | ||
1026 | } | ||
1027 | |||
1028 | /* | ||
1029 | * Values for di_flags | ||
1030 | * There should be a one-to-one correspondence between these flags and the | ||
1031 | * XFS_XFLAG_s. | ||
1032 | */ | ||
1033 | #define XFS_DIFLAG_REALTIME_BIT 0 /* file's blocks come from rt area */ | ||
1034 | #define XFS_DIFLAG_PREALLOC_BIT 1 /* file space has been preallocated */ | ||
1035 | #define XFS_DIFLAG_NEWRTBM_BIT 2 /* for rtbitmap inode, new format */ | ||
1036 | #define XFS_DIFLAG_IMMUTABLE_BIT 3 /* inode is immutable */ | ||
1037 | #define XFS_DIFLAG_APPEND_BIT 4 /* inode is append-only */ | ||
1038 | #define XFS_DIFLAG_SYNC_BIT 5 /* inode is written synchronously */ | ||
1039 | #define XFS_DIFLAG_NOATIME_BIT 6 /* do not update atime */ | ||
1040 | #define XFS_DIFLAG_NODUMP_BIT 7 /* do not dump */ | ||
1041 | #define XFS_DIFLAG_RTINHERIT_BIT 8 /* create with realtime bit set */ | ||
1042 | #define XFS_DIFLAG_PROJINHERIT_BIT 9 /* create with parents projid */ | ||
1043 | #define XFS_DIFLAG_NOSYMLINKS_BIT 10 /* disallow symlink creation */ | ||
1044 | #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */ | ||
1045 | #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */ | ||
1046 | #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */ | ||
1047 | #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */ | ||
1048 | #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT) | ||
1049 | #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT) | ||
1050 | #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT) | ||
1051 | #define XFS_DIFLAG_IMMUTABLE (1 << XFS_DIFLAG_IMMUTABLE_BIT) | ||
1052 | #define XFS_DIFLAG_APPEND (1 << XFS_DIFLAG_APPEND_BIT) | ||
1053 | #define XFS_DIFLAG_SYNC (1 << XFS_DIFLAG_SYNC_BIT) | ||
1054 | #define XFS_DIFLAG_NOATIME (1 << XFS_DIFLAG_NOATIME_BIT) | ||
1055 | #define XFS_DIFLAG_NODUMP (1 << XFS_DIFLAG_NODUMP_BIT) | ||
1056 | #define XFS_DIFLAG_RTINHERIT (1 << XFS_DIFLAG_RTINHERIT_BIT) | ||
1057 | #define XFS_DIFLAG_PROJINHERIT (1 << XFS_DIFLAG_PROJINHERIT_BIT) | ||
1058 | #define XFS_DIFLAG_NOSYMLINKS (1 << XFS_DIFLAG_NOSYMLINKS_BIT) | ||
1059 | #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT) | ||
1060 | #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT) | ||
1061 | #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT) | ||
1062 | #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT) | ||
1063 | |||
1064 | #define XFS_DIFLAG_ANY \ | ||
1065 | (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \ | ||
1066 | XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \ | ||
1067 | XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \ | ||
1068 | XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \ | ||
1069 | XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM) | ||
1070 | |||
1071 | /* | ||
1072 | * Inode number format: | ||
1073 | * low inopblog bits - offset in block | ||
1074 | * next agblklog bits - block number in ag | ||
1075 | * next agno_log bits - ag number | ||
1076 | * high agno_log-agblklog-inopblog bits - 0 | ||
1077 | */ | ||
1078 | #define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1) | ||
1079 | #define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog | ||
1080 | #define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog | ||
1081 | #define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log | ||
1082 | #define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log | ||
1083 | #define XFS_INO_BITS(mp) \ | ||
1084 | XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp) | ||
1085 | #define XFS_INO_TO_AGNO(mp,i) \ | ||
1086 | ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) | ||
1087 | #define XFS_INO_TO_AGINO(mp,i) \ | ||
1088 | ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) | ||
1089 | #define XFS_INO_TO_AGBNO(mp,i) \ | ||
1090 | (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ | ||
1091 | XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) | ||
1092 | #define XFS_INO_TO_OFFSET(mp,i) \ | ||
1093 | ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) | ||
1094 | #define XFS_INO_TO_FSB(mp,i) \ | ||
1095 | XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) | ||
1096 | #define XFS_AGINO_TO_INO(mp,a,i) \ | ||
1097 | (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) | ||
1098 | #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) | ||
1099 | #define XFS_AGINO_TO_OFFSET(mp,i) \ | ||
1100 | ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) | ||
1101 | #define XFS_OFFBNO_TO_AGINO(mp,b,o) \ | ||
1102 | ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) | ||
1103 | |||
1104 | #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) | ||
1105 | #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL)) | ||
1106 | |||
1107 | /* | ||
37 | * RealTime Device format definitions | 1108 | * RealTime Device format definitions |
38 | */ | 1109 | */ |
39 | 1110 | ||
@@ -413,4 +1484,40 @@ struct xfs_btree_block { | |||
413 | #define XFS_BTREE_LBLOCK_CRC_OFF \ | 1484 | #define XFS_BTREE_LBLOCK_CRC_OFF \ |
414 | offsetof(struct xfs_btree_block, bb_u.l.bb_crc) | 1485 | offsetof(struct xfs_btree_block, bb_u.l.bb_crc) |
415 | 1486 | ||
1487 | /* | ||
1488 | * On-disk XFS access control list structure. | ||
1489 | */ | ||
1490 | struct xfs_acl_entry { | ||
1491 | __be32 ae_tag; | ||
1492 | __be32 ae_id; | ||
1493 | __be16 ae_perm; | ||
1494 | __be16 ae_pad; /* fill the implicit hole in the structure */ | ||
1495 | }; | ||
1496 | |||
1497 | struct xfs_acl { | ||
1498 | __be32 acl_cnt; | ||
1499 | struct xfs_acl_entry acl_entry[0]; | ||
1500 | }; | ||
1501 | |||
1502 | /* | ||
1503 | * The number of ACL entries allowed is defined by the on-disk format. | ||
1504 | * For v4 superblocks, that is limited to 25 entries. For v5 superblocks, it is | ||
1505 | * limited only by the maximum size of the xattr that stores the information. | ||
1506 | */ | ||
1507 | #define XFS_ACL_MAX_ENTRIES(mp) \ | ||
1508 | (xfs_sb_version_hascrc(&mp->m_sb) \ | ||
1509 | ? (XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \ | ||
1510 | sizeof(struct xfs_acl_entry) \ | ||
1511 | : 25) | ||
1512 | |||
1513 | #define XFS_ACL_MAX_SIZE(mp) \ | ||
1514 | (sizeof(struct xfs_acl) + \ | ||
1515 | sizeof(struct xfs_acl_entry) * XFS_ACL_MAX_ENTRIES((mp))) | ||
1516 | |||
1517 | /* On-disk XFS extended attribute names */ | ||
1518 | #define SGI_ACL_FILE (unsigned char *)"SGI_ACL_FILE" | ||
1519 | #define SGI_ACL_DEFAULT (unsigned char *)"SGI_ACL_DEFAULT" | ||
1520 | #define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1) | ||
1521 | #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1) | ||
1522 | |||
416 | #endif /* __XFS_FORMAT_H__ */ | 1523 | #endif /* __XFS_FORMAT_H__ */ |
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index 23dcb72fc5e6..116ef1ddb3e3 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c | |||
@@ -22,9 +22,7 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_inum.h" | ||
26 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
29 | #include "xfs_inode.h" | 27 | #include "xfs_inode.h" |
30 | #include "xfs_btree.h" | 28 | #include "xfs_btree.h" |
@@ -39,7 +37,6 @@ | |||
39 | #include "xfs_buf_item.h" | 37 | #include "xfs_buf_item.h" |
40 | #include "xfs_icreate_item.h" | 38 | #include "xfs_icreate_item.h" |
41 | #include "xfs_icache.h" | 39 | #include "xfs_icache.h" |
42 | #include "xfs_dinode.h" | ||
43 | #include "xfs_trace.h" | 40 | #include "xfs_trace.h" |
44 | 41 | ||
45 | 42 | ||
@@ -48,12 +45,12 @@ | |||
48 | */ | 45 | */ |
49 | static inline int | 46 | static inline int |
50 | xfs_ialloc_cluster_alignment( | 47 | xfs_ialloc_cluster_alignment( |
51 | xfs_alloc_arg_t *args) | 48 | struct xfs_mount *mp) |
52 | { | 49 | { |
53 | if (xfs_sb_version_hasalign(&args->mp->m_sb) && | 50 | if (xfs_sb_version_hasalign(&mp->m_sb) && |
54 | args->mp->m_sb.sb_inoalignmt >= | 51 | mp->m_sb.sb_inoalignmt >= |
55 | XFS_B_TO_FSBT(args->mp, args->mp->m_inode_cluster_size)) | 52 | XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size)) |
56 | return args->mp->m_sb.sb_inoalignmt; | 53 | return mp->m_sb.sb_inoalignmt; |
57 | return 1; | 54 | return 1; |
58 | } | 55 | } |
59 | 56 | ||
@@ -412,7 +409,7 @@ xfs_ialloc_ag_alloc( | |||
412 | * but not to use them in the actual exact allocation. | 409 | * but not to use them in the actual exact allocation. |
413 | */ | 410 | */ |
414 | args.alignment = 1; | 411 | args.alignment = 1; |
415 | args.minalignslop = xfs_ialloc_cluster_alignment(&args) - 1; | 412 | args.minalignslop = xfs_ialloc_cluster_alignment(args.mp) - 1; |
416 | 413 | ||
417 | /* Allow space for the inode btree to split. */ | 414 | /* Allow space for the inode btree to split. */ |
418 | args.minleft = args.mp->m_in_maxlevels - 1; | 415 | args.minleft = args.mp->m_in_maxlevels - 1; |
@@ -448,7 +445,7 @@ xfs_ialloc_ag_alloc( | |||
448 | args.alignment = args.mp->m_dalign; | 445 | args.alignment = args.mp->m_dalign; |
449 | isaligned = 1; | 446 | isaligned = 1; |
450 | } else | 447 | } else |
451 | args.alignment = xfs_ialloc_cluster_alignment(&args); | 448 | args.alignment = xfs_ialloc_cluster_alignment(args.mp); |
452 | /* | 449 | /* |
453 | * Need to figure out where to allocate the inode blocks. | 450 | * Need to figure out where to allocate the inode blocks. |
454 | * Ideally they should be spaced out through the a.g. | 451 | * Ideally they should be spaced out through the a.g. |
@@ -477,7 +474,7 @@ xfs_ialloc_ag_alloc( | |||
477 | args.type = XFS_ALLOCTYPE_NEAR_BNO; | 474 | args.type = XFS_ALLOCTYPE_NEAR_BNO; |
478 | args.agbno = be32_to_cpu(agi->agi_root); | 475 | args.agbno = be32_to_cpu(agi->agi_root); |
479 | args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); | 476 | args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); |
480 | args.alignment = xfs_ialloc_cluster_alignment(&args); | 477 | args.alignment = xfs_ialloc_cluster_alignment(args.mp); |
481 | if ((error = xfs_alloc_vextent(&args))) | 478 | if ((error = xfs_alloc_vextent(&args))) |
482 | return error; | 479 | return error; |
483 | } | 480 | } |
@@ -632,10 +629,24 @@ xfs_ialloc_ag_select( | |||
632 | } | 629 | } |
633 | 630 | ||
634 | /* | 631 | /* |
635 | * Is there enough free space for the file plus a block of | 632 | * Check that there is enough free space for the file plus a |
636 | * inodes? (if we need to allocate some)? | 633 | * chunk of inodes if we need to allocate some. If this is the |
634 | * first pass across the AGs, take into account the potential | ||
635 | * space needed for alignment of inode chunks when checking the | ||
636 | * longest contiguous free space in the AG - this prevents us | ||
637 | * from getting ENOSPC because we have free space larger than | ||
638 | * m_ialloc_blks but alignment constraints prevent us from using | ||
639 | * it. | ||
640 | * | ||
641 | * If we can't find an AG with space for full alignment slack to | ||
642 | * be taken into account, we must be near ENOSPC in all AGs. | ||
643 | * Hence we don't include alignment for the second pass and so | ||
644 | * if we fail allocation due to alignment issues then it is most | ||
645 | * likely a real ENOSPC condition. | ||
637 | */ | 646 | */ |
638 | ineed = mp->m_ialloc_blks; | 647 | ineed = mp->m_ialloc_blks; |
648 | if (flags && ineed > 1) | ||
649 | ineed += xfs_ialloc_cluster_alignment(mp); | ||
639 | longest = pag->pagf_longest; | 650 | longest = pag->pagf_longest; |
640 | if (!longest) | 651 | if (!longest) |
641 | longest = pag->pagf_flcount > 0; | 652 | longest = pag->pagf_flcount > 0; |
@@ -1137,11 +1148,7 @@ xfs_dialloc_ag_update_inobt( | |||
1137 | XFS_WANT_CORRUPTED_RETURN((rec.ir_free == frec->ir_free) && | 1148 | XFS_WANT_CORRUPTED_RETURN((rec.ir_free == frec->ir_free) && |
1138 | (rec.ir_freecount == frec->ir_freecount)); | 1149 | (rec.ir_freecount == frec->ir_freecount)); |
1139 | 1150 | ||
1140 | error = xfs_inobt_update(cur, &rec); | 1151 | return xfs_inobt_update(cur, &rec); |
1141 | if (error) | ||
1142 | return error; | ||
1143 | |||
1144 | return 0; | ||
1145 | } | 1152 | } |
1146 | 1153 | ||
1147 | /* | 1154 | /* |
diff --git a/fs/xfs/libxfs/xfs_ialloc.h b/fs/xfs/libxfs/xfs_ialloc.h index 95ad1c002d60..100007d56449 100644 --- a/fs/xfs/libxfs/xfs_ialloc.h +++ b/fs/xfs/libxfs/xfs_ialloc.h | |||
@@ -160,4 +160,8 @@ int xfs_ialloc_inode_init(struct xfs_mount *mp, struct xfs_trans *tp, | |||
160 | xfs_agnumber_t agno, xfs_agblock_t agbno, | 160 | xfs_agnumber_t agno, xfs_agblock_t agbno, |
161 | xfs_agblock_t length, unsigned int gen); | 161 | xfs_agblock_t length, unsigned int gen); |
162 | 162 | ||
163 | int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, | ||
164 | xfs_agnumber_t agno, struct xfs_buf **bpp); | ||
165 | |||
166 | |||
163 | #endif /* __XFS_IALLOC_H__ */ | 167 | #endif /* __XFS_IALLOC_H__ */ |
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c index c9b06f30fe86..964c465ca69c 100644 --- a/fs/xfs/libxfs/xfs_ialloc_btree.c +++ b/fs/xfs/libxfs/xfs_ialloc_btree.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
29 | #include "xfs_btree.h" | 27 | #include "xfs_btree.h" |
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c index f18fd2da49f7..002b6b3a1988 100644 --- a/fs/xfs/libxfs/xfs_inode_buf.c +++ b/fs/xfs/libxfs/xfs_inode_buf.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
28 | #include "xfs_error.h" | 26 | #include "xfs_error.h" |
@@ -30,7 +28,6 @@ | |||
30 | #include "xfs_icache.h" | 28 | #include "xfs_icache.h" |
31 | #include "xfs_trans.h" | 29 | #include "xfs_trans.h" |
32 | #include "xfs_ialloc.h" | 30 | #include "xfs_ialloc.h" |
33 | #include "xfs_dinode.h" | ||
34 | 31 | ||
35 | /* | 32 | /* |
36 | * Check that none of the inode's in the buffer have a next | 33 | * Check that none of the inode's in the buffer have a next |
diff --git a/fs/xfs/libxfs/xfs_inode_fork.c b/fs/xfs/libxfs/xfs_inode_fork.c index 6a00f7fed69d..0defbd02f62d 100644 --- a/fs/xfs/libxfs/xfs_inode_fork.c +++ b/fs/xfs/libxfs/xfs_inode_fork.c | |||
@@ -22,9 +22,6 @@ | |||
22 | #include "xfs_format.h" | 22 | #include "xfs_format.h" |
23 | #include "xfs_log_format.h" | 23 | #include "xfs_log_format.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_inum.h" | ||
26 | #include "xfs_sb.h" | ||
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
29 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
30 | #include "xfs_trans.h" | 27 | #include "xfs_trans.h" |
@@ -34,7 +31,6 @@ | |||
34 | #include "xfs_error.h" | 31 | #include "xfs_error.h" |
35 | #include "xfs_trace.h" | 32 | #include "xfs_trace.h" |
36 | #include "xfs_attr_sf.h" | 33 | #include "xfs_attr_sf.h" |
37 | #include "xfs_dinode.h" | ||
38 | 34 | ||
39 | kmem_zone_t *xfs_ifork_zone; | 35 | kmem_zone_t *xfs_ifork_zone; |
40 | 36 | ||
diff --git a/fs/xfs/libxfs/xfs_inum.h b/fs/xfs/libxfs/xfs_inum.h deleted file mode 100644 index 4ff2278e147a..000000000000 --- a/fs/xfs/libxfs/xfs_inum.h +++ /dev/null | |||
@@ -1,60 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. | ||
3 | * All Rights Reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope that it would be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write the Free Software Foundation, | ||
16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
17 | */ | ||
18 | #ifndef __XFS_INUM_H__ | ||
19 | #define __XFS_INUM_H__ | ||
20 | |||
21 | /* | ||
22 | * Inode number format: | ||
23 | * low inopblog bits - offset in block | ||
24 | * next agblklog bits - block number in ag | ||
25 | * next agno_log bits - ag number | ||
26 | * high agno_log-agblklog-inopblog bits - 0 | ||
27 | */ | ||
28 | |||
29 | struct xfs_mount; | ||
30 | |||
31 | #define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1) | ||
32 | #define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog | ||
33 | #define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog | ||
34 | #define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log | ||
35 | #define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log | ||
36 | #define XFS_INO_BITS(mp) \ | ||
37 | XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp) | ||
38 | #define XFS_INO_TO_AGNO(mp,i) \ | ||
39 | ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) | ||
40 | #define XFS_INO_TO_AGINO(mp,i) \ | ||
41 | ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) | ||
42 | #define XFS_INO_TO_AGBNO(mp,i) \ | ||
43 | (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ | ||
44 | XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) | ||
45 | #define XFS_INO_TO_OFFSET(mp,i) \ | ||
46 | ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) | ||
47 | #define XFS_INO_TO_FSB(mp,i) \ | ||
48 | XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) | ||
49 | #define XFS_AGINO_TO_INO(mp,a,i) \ | ||
50 | (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) | ||
51 | #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) | ||
52 | #define XFS_AGINO_TO_OFFSET(mp,i) \ | ||
53 | ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) | ||
54 | #define XFS_OFFBNO_TO_AGINO(mp,b,o) \ | ||
55 | ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) | ||
56 | |||
57 | #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) | ||
58 | #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL)) | ||
59 | |||
60 | #endif /* __XFS_INUM_H__ */ | ||
diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index aff12f2d4428..265314690415 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h | |||
@@ -361,7 +361,7 @@ typedef struct xfs_ictimestamp { | |||
361 | 361 | ||
362 | /* | 362 | /* |
363 | * NOTE: This structure must be kept identical to struct xfs_dinode | 363 | * NOTE: This structure must be kept identical to struct xfs_dinode |
364 | * in xfs_dinode.h except for the endianness annotations. | 364 | * except for the endianness annotations. |
365 | */ | 365 | */ |
366 | typedef struct xfs_icdinode { | 366 | typedef struct xfs_icdinode { |
367 | __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ | 367 | __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */ |
diff --git a/fs/xfs/libxfs/xfs_log_rlimit.c b/fs/xfs/libxfs/xfs_log_rlimit.c index ee7e0e80246b..c10597973333 100644 --- a/fs/xfs/libxfs/xfs_log_rlimit.c +++ b/fs/xfs/libxfs/xfs_log_rlimit.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_da_format.h" | 25 | #include "xfs_da_format.h" |
28 | #include "xfs_trans_space.h" | 26 | #include "xfs_trans_space.h" |
diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c index 7c818f1e4484..9b59ffa1fc19 100644 --- a/fs/xfs/libxfs/xfs_rtbitmap.c +++ b/fs/xfs/libxfs/xfs_rtbitmap.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
29 | #include "xfs_bmap.h" | 27 | #include "xfs_bmap.h" |
@@ -36,7 +34,6 @@ | |||
36 | #include "xfs_trace.h" | 34 | #include "xfs_trace.h" |
37 | #include "xfs_buf.h" | 35 | #include "xfs_buf.h" |
38 | #include "xfs_icache.h" | 36 | #include "xfs_icache.h" |
39 | #include "xfs_dinode.h" | ||
40 | #include "xfs_rtalloc.h" | 37 | #include "xfs_rtalloc.h" |
41 | 38 | ||
42 | 39 | ||
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 5f902fa7913f..752915fa775a 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 27 | #include "xfs_inode.h" |
29 | #include "xfs_ialloc.h" | 28 | #include "xfs_ialloc.h" |
@@ -33,7 +32,6 @@ | |||
33 | #include "xfs_cksum.h" | 32 | #include "xfs_cksum.h" |
34 | #include "xfs_trans.h" | 33 | #include "xfs_trans.h" |
35 | #include "xfs_buf_item.h" | 34 | #include "xfs_buf_item.h" |
36 | #include "xfs_dinode.h" | ||
37 | #include "xfs_bmap_btree.h" | 35 | #include "xfs_bmap_btree.h" |
38 | #include "xfs_alloc_btree.h" | 36 | #include "xfs_alloc_btree.h" |
39 | #include "xfs_ialloc_btree.h" | 37 | #include "xfs_ialloc_btree.h" |
diff --git a/fs/xfs/libxfs/xfs_sb.h b/fs/xfs/libxfs/xfs_sb.h index 2e739708afd3..8eb1c54bafbf 100644 --- a/fs/xfs/libxfs/xfs_sb.h +++ b/fs/xfs/libxfs/xfs_sb.h | |||
@@ -19,590 +19,6 @@ | |||
19 | #define __XFS_SB_H__ | 19 | #define __XFS_SB_H__ |
20 | 20 | ||
21 | /* | 21 | /* |
22 | * Super block | ||
23 | * Fits into a sector-sized buffer at address 0 of each allocation group. | ||
24 | * Only the first of these is ever updated except during growfs. | ||
25 | */ | ||
26 | |||
27 | struct xfs_buf; | ||
28 | struct xfs_mount; | ||
29 | struct xfs_trans; | ||
30 | |||
31 | #define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */ | ||
32 | #define XFS_SB_VERSION_1 1 /* 5.3, 6.0.1, 6.1 */ | ||
33 | #define XFS_SB_VERSION_2 2 /* 6.2 - attributes */ | ||
34 | #define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */ | ||
35 | #define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */ | ||
36 | #define XFS_SB_VERSION_5 5 /* CRC enabled filesystem */ | ||
37 | #define XFS_SB_VERSION_NUMBITS 0x000f | ||
38 | #define XFS_SB_VERSION_ALLFBITS 0xfff0 | ||
39 | #define XFS_SB_VERSION_ATTRBIT 0x0010 | ||
40 | #define XFS_SB_VERSION_NLINKBIT 0x0020 | ||
41 | #define XFS_SB_VERSION_QUOTABIT 0x0040 | ||
42 | #define XFS_SB_VERSION_ALIGNBIT 0x0080 | ||
43 | #define XFS_SB_VERSION_DALIGNBIT 0x0100 | ||
44 | #define XFS_SB_VERSION_SHAREDBIT 0x0200 | ||
45 | #define XFS_SB_VERSION_LOGV2BIT 0x0400 | ||
46 | #define XFS_SB_VERSION_SECTORBIT 0x0800 | ||
47 | #define XFS_SB_VERSION_EXTFLGBIT 0x1000 | ||
48 | #define XFS_SB_VERSION_DIRV2BIT 0x2000 | ||
49 | #define XFS_SB_VERSION_BORGBIT 0x4000 /* ASCII only case-insens. */ | ||
50 | #define XFS_SB_VERSION_MOREBITSBIT 0x8000 | ||
51 | |||
52 | /* | ||
53 | * Supported feature bit list is just all bits in the versionnum field because | ||
54 | * we've used them all up and understand them all. Except, of course, for the | ||
55 | * shared superblock bit, which nobody knows what it does and so is unsupported. | ||
56 | */ | ||
57 | #define XFS_SB_VERSION_OKBITS \ | ||
58 | ((XFS_SB_VERSION_NUMBITS | XFS_SB_VERSION_ALLFBITS) & \ | ||
59 | ~XFS_SB_VERSION_SHAREDBIT) | ||
60 | |||
61 | /* | ||
62 | * There are two words to hold XFS "feature" bits: the original | ||
63 | * word, sb_versionnum, and sb_features2. Whenever a bit is set in | ||
64 | * sb_features2, the feature bit XFS_SB_VERSION_MOREBITSBIT must be set. | ||
65 | * | ||
66 | * These defines represent bits in sb_features2. | ||
67 | */ | ||
68 | #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001 | ||
69 | #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */ | ||
70 | #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 | ||
71 | #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ | ||
72 | #define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */ | ||
73 | #define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32 bit project id */ | ||
74 | #define XFS_SB_VERSION2_CRCBIT 0x00000100 /* metadata CRCs */ | ||
75 | #define XFS_SB_VERSION2_FTYPE 0x00000200 /* inode type in dir */ | ||
76 | |||
77 | #define XFS_SB_VERSION2_OKBITS \ | ||
78 | (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ | ||
79 | XFS_SB_VERSION2_ATTR2BIT | \ | ||
80 | XFS_SB_VERSION2_PROJID32BIT | \ | ||
81 | XFS_SB_VERSION2_FTYPE) | ||
82 | |||
83 | /* | ||
84 | * Superblock - in core version. Must match the ondisk version below. | ||
85 | * Must be padded to 64 bit alignment. | ||
86 | */ | ||
87 | typedef struct xfs_sb { | ||
88 | __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ | ||
89 | __uint32_t sb_blocksize; /* logical block size, bytes */ | ||
90 | xfs_rfsblock_t sb_dblocks; /* number of data blocks */ | ||
91 | xfs_rfsblock_t sb_rblocks; /* number of realtime blocks */ | ||
92 | xfs_rtblock_t sb_rextents; /* number of realtime extents */ | ||
93 | uuid_t sb_uuid; /* file system unique id */ | ||
94 | xfs_fsblock_t sb_logstart; /* starting block of log if internal */ | ||
95 | xfs_ino_t sb_rootino; /* root inode number */ | ||
96 | xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */ | ||
97 | xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */ | ||
98 | xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */ | ||
99 | xfs_agblock_t sb_agblocks; /* size of an allocation group */ | ||
100 | xfs_agnumber_t sb_agcount; /* number of allocation groups */ | ||
101 | xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */ | ||
102 | xfs_extlen_t sb_logblocks; /* number of log blocks */ | ||
103 | __uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */ | ||
104 | __uint16_t sb_sectsize; /* volume sector size, bytes */ | ||
105 | __uint16_t sb_inodesize; /* inode size, bytes */ | ||
106 | __uint16_t sb_inopblock; /* inodes per block */ | ||
107 | char sb_fname[12]; /* file system name */ | ||
108 | __uint8_t sb_blocklog; /* log2 of sb_blocksize */ | ||
109 | __uint8_t sb_sectlog; /* log2 of sb_sectsize */ | ||
110 | __uint8_t sb_inodelog; /* log2 of sb_inodesize */ | ||
111 | __uint8_t sb_inopblog; /* log2 of sb_inopblock */ | ||
112 | __uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */ | ||
113 | __uint8_t sb_rextslog; /* log2 of sb_rextents */ | ||
114 | __uint8_t sb_inprogress; /* mkfs is in progress, don't mount */ | ||
115 | __uint8_t sb_imax_pct; /* max % of fs for inode space */ | ||
116 | /* statistics */ | ||
117 | /* | ||
118 | * These fields must remain contiguous. If you really | ||
119 | * want to change their layout, make sure you fix the | ||
120 | * code in xfs_trans_apply_sb_deltas(). | ||
121 | */ | ||
122 | __uint64_t sb_icount; /* allocated inodes */ | ||
123 | __uint64_t sb_ifree; /* free inodes */ | ||
124 | __uint64_t sb_fdblocks; /* free data blocks */ | ||
125 | __uint64_t sb_frextents; /* free realtime extents */ | ||
126 | /* | ||
127 | * End contiguous fields. | ||
128 | */ | ||
129 | xfs_ino_t sb_uquotino; /* user quota inode */ | ||
130 | xfs_ino_t sb_gquotino; /* group quota inode */ | ||
131 | __uint16_t sb_qflags; /* quota flags */ | ||
132 | __uint8_t sb_flags; /* misc. flags */ | ||
133 | __uint8_t sb_shared_vn; /* shared version number */ | ||
134 | xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */ | ||
135 | __uint32_t sb_unit; /* stripe or raid unit */ | ||
136 | __uint32_t sb_width; /* stripe or raid width */ | ||
137 | __uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */ | ||
138 | __uint8_t sb_logsectlog; /* log2 of the log sector size */ | ||
139 | __uint16_t sb_logsectsize; /* sector size for the log, bytes */ | ||
140 | __uint32_t sb_logsunit; /* stripe unit size for the log */ | ||
141 | __uint32_t sb_features2; /* additional feature bits */ | ||
142 | |||
143 | /* | ||
144 | * bad features2 field as a result of failing to pad the sb | ||
145 | * structure to 64 bits. Some machines will be using this field | ||
146 | * for features2 bits. Easiest just to mark it bad and not use | ||
147 | * it for anything else. | ||
148 | */ | ||
149 | __uint32_t sb_bad_features2; | ||
150 | |||
151 | /* version 5 superblock fields start here */ | ||
152 | |||
153 | /* feature masks */ | ||
154 | __uint32_t sb_features_compat; | ||
155 | __uint32_t sb_features_ro_compat; | ||
156 | __uint32_t sb_features_incompat; | ||
157 | __uint32_t sb_features_log_incompat; | ||
158 | |||
159 | __uint32_t sb_crc; /* superblock crc */ | ||
160 | __uint32_t sb_pad; | ||
161 | |||
162 | xfs_ino_t sb_pquotino; /* project quota inode */ | ||
163 | xfs_lsn_t sb_lsn; /* last write sequence */ | ||
164 | |||
165 | /* must be padded to 64 bit alignment */ | ||
166 | } xfs_sb_t; | ||
167 | |||
168 | #define XFS_SB_CRC_OFF offsetof(struct xfs_sb, sb_crc) | ||
169 | |||
170 | /* | ||
171 | * Superblock - on disk version. Must match the in core version above. | ||
172 | * Must be padded to 64 bit alignment. | ||
173 | */ | ||
174 | typedef struct xfs_dsb { | ||
175 | __be32 sb_magicnum; /* magic number == XFS_SB_MAGIC */ | ||
176 | __be32 sb_blocksize; /* logical block size, bytes */ | ||
177 | __be64 sb_dblocks; /* number of data blocks */ | ||
178 | __be64 sb_rblocks; /* number of realtime blocks */ | ||
179 | __be64 sb_rextents; /* number of realtime extents */ | ||
180 | uuid_t sb_uuid; /* file system unique id */ | ||
181 | __be64 sb_logstart; /* starting block of log if internal */ | ||
182 | __be64 sb_rootino; /* root inode number */ | ||
183 | __be64 sb_rbmino; /* bitmap inode for realtime extents */ | ||
184 | __be64 sb_rsumino; /* summary inode for rt bitmap */ | ||
185 | __be32 sb_rextsize; /* realtime extent size, blocks */ | ||
186 | __be32 sb_agblocks; /* size of an allocation group */ | ||
187 | __be32 sb_agcount; /* number of allocation groups */ | ||
188 | __be32 sb_rbmblocks; /* number of rt bitmap blocks */ | ||
189 | __be32 sb_logblocks; /* number of log blocks */ | ||
190 | __be16 sb_versionnum; /* header version == XFS_SB_VERSION */ | ||
191 | __be16 sb_sectsize; /* volume sector size, bytes */ | ||
192 | __be16 sb_inodesize; /* inode size, bytes */ | ||
193 | __be16 sb_inopblock; /* inodes per block */ | ||
194 | char sb_fname[12]; /* file system name */ | ||
195 | __u8 sb_blocklog; /* log2 of sb_blocksize */ | ||
196 | __u8 sb_sectlog; /* log2 of sb_sectsize */ | ||
197 | __u8 sb_inodelog; /* log2 of sb_inodesize */ | ||
198 | __u8 sb_inopblog; /* log2 of sb_inopblock */ | ||
199 | __u8 sb_agblklog; /* log2 of sb_agblocks (rounded up) */ | ||
200 | __u8 sb_rextslog; /* log2 of sb_rextents */ | ||
201 | __u8 sb_inprogress; /* mkfs is in progress, don't mount */ | ||
202 | __u8 sb_imax_pct; /* max % of fs for inode space */ | ||
203 | /* statistics */ | ||
204 | /* | ||
205 | * These fields must remain contiguous. If you really | ||
206 | * want to change their layout, make sure you fix the | ||
207 | * code in xfs_trans_apply_sb_deltas(). | ||
208 | */ | ||
209 | __be64 sb_icount; /* allocated inodes */ | ||
210 | __be64 sb_ifree; /* free inodes */ | ||
211 | __be64 sb_fdblocks; /* free data blocks */ | ||
212 | __be64 sb_frextents; /* free realtime extents */ | ||
213 | /* | ||
214 | * End contiguous fields. | ||
215 | */ | ||
216 | __be64 sb_uquotino; /* user quota inode */ | ||
217 | __be64 sb_gquotino; /* group quota inode */ | ||
218 | __be16 sb_qflags; /* quota flags */ | ||
219 | __u8 sb_flags; /* misc. flags */ | ||
220 | __u8 sb_shared_vn; /* shared version number */ | ||
221 | __be32 sb_inoalignmt; /* inode chunk alignment, fsblocks */ | ||
222 | __be32 sb_unit; /* stripe or raid unit */ | ||
223 | __be32 sb_width; /* stripe or raid width */ | ||
224 | __u8 sb_dirblklog; /* log2 of dir block size (fsbs) */ | ||
225 | __u8 sb_logsectlog; /* log2 of the log sector size */ | ||
226 | __be16 sb_logsectsize; /* sector size for the log, bytes */ | ||
227 | __be32 sb_logsunit; /* stripe unit size for the log */ | ||
228 | __be32 sb_features2; /* additional feature bits */ | ||
229 | /* | ||
230 | * bad features2 field as a result of failing to pad the sb | ||
231 | * structure to 64 bits. Some machines will be using this field | ||
232 | * for features2 bits. Easiest just to mark it bad and not use | ||
233 | * it for anything else. | ||
234 | */ | ||
235 | __be32 sb_bad_features2; | ||
236 | |||
237 | /* version 5 superblock fields start here */ | ||
238 | |||
239 | /* feature masks */ | ||
240 | __be32 sb_features_compat; | ||
241 | __be32 sb_features_ro_compat; | ||
242 | __be32 sb_features_incompat; | ||
243 | __be32 sb_features_log_incompat; | ||
244 | |||
245 | __le32 sb_crc; /* superblock crc */ | ||
246 | __be32 sb_pad; | ||
247 | |||
248 | __be64 sb_pquotino; /* project quota inode */ | ||
249 | __be64 sb_lsn; /* last write sequence */ | ||
250 | |||
251 | /* must be padded to 64 bit alignment */ | ||
252 | } xfs_dsb_t; | ||
253 | |||
254 | /* | ||
255 | * Sequence number values for the fields. | ||
256 | */ | ||
257 | typedef enum { | ||
258 | XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS, | ||
259 | XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO, | ||
260 | XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS, | ||
261 | XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS, | ||
262 | XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE, | ||
263 | XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG, | ||
264 | XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG, | ||
265 | XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT, | ||
266 | XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO, | ||
267 | XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN, | ||
268 | XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG, | ||
269 | XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT, | ||
270 | XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, XFS_SBS_FEATURES_COMPAT, | ||
271 | XFS_SBS_FEATURES_RO_COMPAT, XFS_SBS_FEATURES_INCOMPAT, | ||
272 | XFS_SBS_FEATURES_LOG_INCOMPAT, XFS_SBS_CRC, XFS_SBS_PAD, | ||
273 | XFS_SBS_PQUOTINO, XFS_SBS_LSN, | ||
274 | XFS_SBS_FIELDCOUNT | ||
275 | } xfs_sb_field_t; | ||
276 | |||
277 | /* | ||
278 | * Mask values, defined based on the xfs_sb_field_t values. | ||
279 | * Only define the ones we're using. | ||
280 | */ | ||
281 | #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x) | ||
282 | #define XFS_SB_UUID XFS_SB_MVAL(UUID) | ||
283 | #define XFS_SB_FNAME XFS_SB_MVAL(FNAME) | ||
284 | #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO) | ||
285 | #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO) | ||
286 | #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO) | ||
287 | #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM) | ||
288 | #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO) | ||
289 | #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO) | ||
290 | #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS) | ||
291 | #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN) | ||
292 | #define XFS_SB_UNIT XFS_SB_MVAL(UNIT) | ||
293 | #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH) | ||
294 | #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT) | ||
295 | #define XFS_SB_IFREE XFS_SB_MVAL(IFREE) | ||
296 | #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) | ||
297 | #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) | ||
298 | #define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2) | ||
299 | #define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT) | ||
300 | #define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT) | ||
301 | #define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT) | ||
302 | #define XFS_SB_FEATURES_LOG_INCOMPAT XFS_SB_MVAL(FEATURES_LOG_INCOMPAT) | ||
303 | #define XFS_SB_CRC XFS_SB_MVAL(CRC) | ||
304 | #define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO) | ||
305 | #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) | ||
306 | #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) | ||
307 | #define XFS_SB_MOD_BITS \ | ||
308 | (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \ | ||
309 | XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ | ||
310 | XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ | ||
311 | XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \ | ||
312 | XFS_SB_BAD_FEATURES2 | XFS_SB_FEATURES_COMPAT | \ | ||
313 | XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | \ | ||
314 | XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO) | ||
315 | |||
316 | |||
317 | /* | ||
318 | * Misc. Flags - warning - these will be cleared by xfs_repair unless | ||
319 | * a feature bit is set when the flag is used. | ||
320 | */ | ||
321 | #define XFS_SBF_NOFLAGS 0x00 /* no flags set */ | ||
322 | #define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */ | ||
323 | |||
324 | /* | ||
325 | * define max. shared version we can interoperate with | ||
326 | */ | ||
327 | #define XFS_SB_MAX_SHARED_VN 0 | ||
328 | |||
329 | #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) | ||
330 | |||
331 | /* | ||
332 | * The first XFS version we support is a v4 superblock with V2 directories. | ||
333 | */ | ||
334 | static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp) | ||
335 | { | ||
336 | if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)) | ||
337 | return false; | ||
338 | |||
339 | /* check for unknown features in the fs */ | ||
340 | if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) || | ||
341 | ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && | ||
342 | (sbp->sb_features2 & ~XFS_SB_VERSION2_OKBITS))) | ||
343 | return false; | ||
344 | |||
345 | return true; | ||
346 | } | ||
347 | |||
348 | static inline bool xfs_sb_good_version(struct xfs_sb *sbp) | ||
349 | { | ||
350 | if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) | ||
351 | return true; | ||
352 | if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) | ||
353 | return xfs_sb_good_v4_features(sbp); | ||
354 | return false; | ||
355 | } | ||
356 | |||
357 | /* | ||
358 | * Detect a mismatched features2 field. Older kernels read/wrote | ||
359 | * this into the wrong slot, so to be safe we keep them in sync. | ||
360 | */ | ||
361 | static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp) | ||
362 | { | ||
363 | return sbp->sb_bad_features2 != sbp->sb_features2; | ||
364 | } | ||
365 | |||
366 | static inline bool xfs_sb_version_hasattr(struct xfs_sb *sbp) | ||
367 | { | ||
368 | return (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT); | ||
369 | } | ||
370 | |||
371 | static inline void xfs_sb_version_addattr(struct xfs_sb *sbp) | ||
372 | { | ||
373 | sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT; | ||
374 | } | ||
375 | |||
376 | static inline bool xfs_sb_version_hasquota(struct xfs_sb *sbp) | ||
377 | { | ||
378 | return (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT); | ||
379 | } | ||
380 | |||
381 | static inline void xfs_sb_version_addquota(struct xfs_sb *sbp) | ||
382 | { | ||
383 | sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT; | ||
384 | } | ||
385 | |||
386 | static inline bool xfs_sb_version_hasalign(struct xfs_sb *sbp) | ||
387 | { | ||
388 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || | ||
389 | (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT)); | ||
390 | } | ||
391 | |||
392 | static inline bool xfs_sb_version_hasdalign(struct xfs_sb *sbp) | ||
393 | { | ||
394 | return (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); | ||
395 | } | ||
396 | |||
397 | static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp) | ||
398 | { | ||
399 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || | ||
400 | (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); | ||
401 | } | ||
402 | |||
403 | static inline bool xfs_sb_version_hasextflgbit(struct xfs_sb *sbp) | ||
404 | { | ||
405 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || | ||
406 | (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); | ||
407 | } | ||
408 | |||
409 | static inline bool xfs_sb_version_hassector(struct xfs_sb *sbp) | ||
410 | { | ||
411 | return (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT); | ||
412 | } | ||
413 | |||
414 | static inline bool xfs_sb_version_hasasciici(struct xfs_sb *sbp) | ||
415 | { | ||
416 | return (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); | ||
417 | } | ||
418 | |||
419 | static inline bool xfs_sb_version_hasmorebits(struct xfs_sb *sbp) | ||
420 | { | ||
421 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || | ||
422 | (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); | ||
423 | } | ||
424 | |||
425 | /* | ||
426 | * sb_features2 bit version macros. | ||
427 | */ | ||
428 | static inline bool xfs_sb_version_haslazysbcount(struct xfs_sb *sbp) | ||
429 | { | ||
430 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || | ||
431 | (xfs_sb_version_hasmorebits(sbp) && | ||
432 | (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT)); | ||
433 | } | ||
434 | |||
435 | static inline bool xfs_sb_version_hasattr2(struct xfs_sb *sbp) | ||
436 | { | ||
437 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || | ||
438 | (xfs_sb_version_hasmorebits(sbp) && | ||
439 | (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT)); | ||
440 | } | ||
441 | |||
442 | static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) | ||
443 | { | ||
444 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; | ||
445 | sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; | ||
446 | sbp->sb_bad_features2 |= XFS_SB_VERSION2_ATTR2BIT; | ||
447 | } | ||
448 | |||
449 | static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp) | ||
450 | { | ||
451 | sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; | ||
452 | sbp->sb_bad_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; | ||
453 | if (!sbp->sb_features2) | ||
454 | sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; | ||
455 | } | ||
456 | |||
457 | static inline bool xfs_sb_version_hasprojid32bit(struct xfs_sb *sbp) | ||
458 | { | ||
459 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || | ||
460 | (xfs_sb_version_hasmorebits(sbp) && | ||
461 | (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT)); | ||
462 | } | ||
463 | |||
464 | static inline void xfs_sb_version_addprojid32bit(struct xfs_sb *sbp) | ||
465 | { | ||
466 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; | ||
467 | sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT; | ||
468 | sbp->sb_bad_features2 |= XFS_SB_VERSION2_PROJID32BIT; | ||
469 | } | ||
470 | |||
471 | /* | ||
472 | * Extended v5 superblock feature masks. These are to be used for new v5 | ||
473 | * superblock features only. | ||
474 | * | ||
475 | * Compat features are new features that old kernels will not notice or affect | ||
476 | * and so can mount read-write without issues. | ||
477 | * | ||
478 | * RO-Compat (read only) are features that old kernels can read but will break | ||
479 | * if they write. Hence only read-only mounts of such filesystems are allowed on | ||
480 | * kernels that don't support the feature bit. | ||
481 | * | ||
482 | * InCompat features are features which old kernels will not understand and so | ||
483 | * must not mount. | ||
484 | * | ||
485 | * Log-InCompat features are for changes to log formats or new transactions that | ||
486 | * can't be replayed on older kernels. The fields are set when the filesystem is | ||
487 | * mounted, and a clean unmount clears the fields. | ||
488 | */ | ||
489 | #define XFS_SB_FEAT_COMPAT_ALL 0 | ||
490 | #define XFS_SB_FEAT_COMPAT_UNKNOWN ~XFS_SB_FEAT_COMPAT_ALL | ||
491 | static inline bool | ||
492 | xfs_sb_has_compat_feature( | ||
493 | struct xfs_sb *sbp, | ||
494 | __uint32_t feature) | ||
495 | { | ||
496 | return (sbp->sb_features_compat & feature) != 0; | ||
497 | } | ||
498 | |||
499 | #define XFS_SB_FEAT_RO_COMPAT_FINOBT (1 << 0) /* free inode btree */ | ||
500 | #define XFS_SB_FEAT_RO_COMPAT_ALL \ | ||
501 | (XFS_SB_FEAT_RO_COMPAT_FINOBT) | ||
502 | #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL | ||
503 | static inline bool | ||
504 | xfs_sb_has_ro_compat_feature( | ||
505 | struct xfs_sb *sbp, | ||
506 | __uint32_t feature) | ||
507 | { | ||
508 | return (sbp->sb_features_ro_compat & feature) != 0; | ||
509 | } | ||
510 | |||
511 | #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ | ||
512 | #define XFS_SB_FEAT_INCOMPAT_ALL \ | ||
513 | (XFS_SB_FEAT_INCOMPAT_FTYPE) | ||
514 | |||
515 | #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL | ||
516 | static inline bool | ||
517 | xfs_sb_has_incompat_feature( | ||
518 | struct xfs_sb *sbp, | ||
519 | __uint32_t feature) | ||
520 | { | ||
521 | return (sbp->sb_features_incompat & feature) != 0; | ||
522 | } | ||
523 | |||
524 | #define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 | ||
525 | #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL | ||
526 | static inline bool | ||
527 | xfs_sb_has_incompat_log_feature( | ||
528 | struct xfs_sb *sbp, | ||
529 | __uint32_t feature) | ||
530 | { | ||
531 | return (sbp->sb_features_log_incompat & feature) != 0; | ||
532 | } | ||
533 | |||
534 | /* | ||
535 | * V5 superblock specific feature checks | ||
536 | */ | ||
537 | static inline int xfs_sb_version_hascrc(struct xfs_sb *sbp) | ||
538 | { | ||
539 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; | ||
540 | } | ||
541 | |||
542 | static inline int xfs_sb_version_has_pquotino(struct xfs_sb *sbp) | ||
543 | { | ||
544 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; | ||
545 | } | ||
546 | |||
547 | static inline int xfs_sb_version_hasftype(struct xfs_sb *sbp) | ||
548 | { | ||
549 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && | ||
550 | xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE)) || | ||
551 | (xfs_sb_version_hasmorebits(sbp) && | ||
552 | (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE)); | ||
553 | } | ||
554 | |||
555 | static inline int xfs_sb_version_hasfinobt(xfs_sb_t *sbp) | ||
556 | { | ||
557 | return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) && | ||
558 | (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FINOBT); | ||
559 | } | ||
560 | |||
561 | /* | ||
562 | * end of superblock version macros | ||
563 | */ | ||
564 | |||
565 | static inline bool | ||
566 | xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) | ||
567 | { | ||
568 | return (ino == sbp->sb_uquotino || | ||
569 | ino == sbp->sb_gquotino || | ||
570 | ino == sbp->sb_pquotino); | ||
571 | } | ||
572 | |||
573 | #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ | ||
574 | #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) | ||
575 | #define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr)) | ||
576 | |||
577 | #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) | ||
578 | #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ | ||
579 | xfs_daddr_to_agno(mp,d), xfs_daddr_to_agbno(mp,d)) | ||
580 | #define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \ | ||
581 | XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno)) | ||
582 | |||
583 | /* | ||
584 | * File system sector to basic block conversions. | ||
585 | */ | ||
586 | #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log) | ||
587 | |||
588 | /* | ||
589 | * File system block to basic block conversions. | ||
590 | */ | ||
591 | #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log) | ||
592 | #define XFS_BB_TO_FSB(mp,bb) \ | ||
593 | (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log) | ||
594 | #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log) | ||
595 | |||
596 | /* | ||
597 | * File system block to byte conversions. | ||
598 | */ | ||
599 | #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog) | ||
600 | #define XFS_B_TO_FSB(mp,b) \ | ||
601 | ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog) | ||
602 | #define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog) | ||
603 | #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask) | ||
604 | |||
605 | /* | ||
606 | * perag get/put wrappers for ref counting | 22 | * perag get/put wrappers for ref counting |
607 | */ | 23 | */ |
608 | extern struct xfs_perag *xfs_perag_get(struct xfs_mount *, xfs_agnumber_t); | 24 | extern struct xfs_perag *xfs_perag_get(struct xfs_mount *, xfs_agnumber_t); |
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c index 5782f037eab4..c80c5236c3da 100644 --- a/fs/xfs/libxfs/xfs_symlink_remote.c +++ b/fs/xfs/libxfs/xfs_symlink_remote.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_shared.h" | 23 | #include "xfs_shared.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_sb.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_bmap_btree.h" | 26 | #include "xfs_bmap_btree.h" |
29 | #include "xfs_inode.h" | 27 | #include "xfs_inode.h" |
diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index f2bda7c76b8a..6c1330f29050 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_format.h" | 22 | #include "xfs_format.h" |
23 | #include "xfs_log_format.h" | 23 | #include "xfs_log_format.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_da_format.h" | 26 | #include "xfs_da_format.h" |
29 | #include "xfs_da_btree.h" | 27 | #include "xfs_da_btree.h" |
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c index a65fa5dde6e9..4b641676f258 100644 --- a/fs/xfs/xfs_acl.c +++ b/fs/xfs/xfs_acl.c | |||
@@ -19,8 +19,6 @@ | |||
19 | #include "xfs_format.h" | 19 | #include "xfs_format.h" |
20 | #include "xfs_log_format.h" | 20 | #include "xfs_log_format.h" |
21 | #include "xfs_trans_resv.h" | 21 | #include "xfs_trans_resv.h" |
22 | #include "xfs_ag.h" | ||
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_mount.h" | 22 | #include "xfs_mount.h" |
25 | #include "xfs_inode.h" | 23 | #include "xfs_inode.h" |
26 | #include "xfs_acl.h" | 24 | #include "xfs_acl.h" |
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h index 5dc163744511..3841b07f27bf 100644 --- a/fs/xfs/xfs_acl.h +++ b/fs/xfs/xfs_acl.h | |||
@@ -22,42 +22,6 @@ struct inode; | |||
22 | struct posix_acl; | 22 | struct posix_acl; |
23 | struct xfs_inode; | 23 | struct xfs_inode; |
24 | 24 | ||
25 | #define XFS_ACL_NOT_PRESENT (-1) | ||
26 | |||
27 | /* On-disk XFS access control list structure */ | ||
28 | struct xfs_acl_entry { | ||
29 | __be32 ae_tag; | ||
30 | __be32 ae_id; | ||
31 | __be16 ae_perm; | ||
32 | __be16 ae_pad; /* fill the implicit hole in the structure */ | ||
33 | }; | ||
34 | |||
35 | struct xfs_acl { | ||
36 | __be32 acl_cnt; | ||
37 | struct xfs_acl_entry acl_entry[0]; | ||
38 | }; | ||
39 | |||
40 | /* | ||
41 | * The number of ACL entries allowed is defined by the on-disk format. | ||
42 | * For v4 superblocks, that is limited to 25 entries. For v5 superblocks, it is | ||
43 | * limited only by the maximum size of the xattr that stores the information. | ||
44 | */ | ||
45 | #define XFS_ACL_MAX_ENTRIES(mp) \ | ||
46 | (xfs_sb_version_hascrc(&mp->m_sb) \ | ||
47 | ? (XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \ | ||
48 | sizeof(struct xfs_acl_entry) \ | ||
49 | : 25) | ||
50 | |||
51 | #define XFS_ACL_MAX_SIZE(mp) \ | ||
52 | (sizeof(struct xfs_acl) + \ | ||
53 | sizeof(struct xfs_acl_entry) * XFS_ACL_MAX_ENTRIES((mp))) | ||
54 | |||
55 | /* On-disk XFS extended attribute names */ | ||
56 | #define SGI_ACL_FILE (unsigned char *)"SGI_ACL_FILE" | ||
57 | #define SGI_ACL_DEFAULT (unsigned char *)"SGI_ACL_DEFAULT" | ||
58 | #define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1) | ||
59 | #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1) | ||
60 | |||
61 | #ifdef CONFIG_XFS_POSIX_ACL | 25 | #ifdef CONFIG_XFS_POSIX_ACL |
62 | extern struct posix_acl *xfs_get_acl(struct inode *inode, int type); | 26 | extern struct posix_acl *xfs_get_acl(struct inode *inode, int type); |
63 | extern int xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); | 27 | extern int xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type); |
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c index f5b2453a43b2..18e2f3bbae5e 100644 --- a/fs/xfs/xfs_aops.c +++ b/fs/xfs/xfs_aops.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include "xfs_format.h" | 20 | #include "xfs_format.h" |
21 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | 23 | #include "xfs_mount.h" |
26 | #include "xfs_inode.h" | 24 | #include "xfs_inode.h" |
27 | #include "xfs_trans.h" | 25 | #include "xfs_trans.h" |
@@ -33,7 +31,6 @@ | |||
33 | #include "xfs_bmap.h" | 31 | #include "xfs_bmap.h" |
34 | #include "xfs_bmap_util.h" | 32 | #include "xfs_bmap_util.h" |
35 | #include "xfs_bmap_btree.h" | 33 | #include "xfs_bmap_btree.h" |
36 | #include "xfs_dinode.h" | ||
37 | #include <linux/aio.h> | 34 | #include <linux/aio.h> |
38 | #include <linux/gfp.h> | 35 | #include <linux/gfp.h> |
39 | #include <linux/mpage.h> | 36 | #include <linux/mpage.h> |
diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c index aa2a8b1838a2..83af4c149635 100644 --- a/fs/xfs/xfs_attr_inactive.c +++ b/fs/xfs/xfs_attr_inactive.c | |||
@@ -23,8 +23,6 @@ | |||
23 | #include "xfs_log_format.h" | 23 | #include "xfs_log_format.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_bit.h" | 25 | #include "xfs_bit.h" |
26 | #include "xfs_sb.h" | ||
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 27 | #include "xfs_da_format.h" |
30 | #include "xfs_da_btree.h" | 28 | #include "xfs_da_btree.h" |
@@ -39,7 +37,6 @@ | |||
39 | #include "xfs_error.h" | 37 | #include "xfs_error.h" |
40 | #include "xfs_quota.h" | 38 | #include "xfs_quota.h" |
41 | #include "xfs_trace.h" | 39 | #include "xfs_trace.h" |
42 | #include "xfs_dinode.h" | ||
43 | #include "xfs_dir2.h" | 40 | #include "xfs_dir2.h" |
44 | 41 | ||
45 | /* | 42 | /* |
diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c index 62db83ab6cbc..a43d370d2c58 100644 --- a/fs/xfs/xfs_attr_list.c +++ b/fs/xfs/xfs_attr_list.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_da_format.h" | 26 | #include "xfs_da_format.h" |
29 | #include "xfs_da_btree.h" | 27 | #include "xfs_da_btree.h" |
@@ -39,7 +37,6 @@ | |||
39 | #include "xfs_trace.h" | 37 | #include "xfs_trace.h" |
40 | #include "xfs_buf_item.h" | 38 | #include "xfs_buf_item.h" |
41 | #include "xfs_cksum.h" | 39 | #include "xfs_cksum.h" |
42 | #include "xfs_dinode.h" | ||
43 | #include "xfs_dir2.h" | 40 | #include "xfs_dir2.h" |
44 | 41 | ||
45 | STATIC int | 42 | STATIC int |
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 281002689d64..22a5dcb70b32 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c | |||
@@ -23,8 +23,6 @@ | |||
23 | #include "xfs_log_format.h" | 23 | #include "xfs_log_format.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_bit.h" | 25 | #include "xfs_bit.h" |
26 | #include "xfs_sb.h" | ||
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 27 | #include "xfs_da_format.h" |
30 | #include "xfs_inode.h" | 28 | #include "xfs_inode.h" |
@@ -42,7 +40,6 @@ | |||
42 | #include "xfs_trace.h" | 40 | #include "xfs_trace.h" |
43 | #include "xfs_icache.h" | 41 | #include "xfs_icache.h" |
44 | #include "xfs_log.h" | 42 | #include "xfs_log.h" |
45 | #include "xfs_dinode.h" | ||
46 | 43 | ||
47 | /* Kernel only BMAP related definitions and functions */ | 44 | /* Kernel only BMAP related definitions and functions */ |
48 | 45 | ||
diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c index 24b4ebea0d4d..bb502a391792 100644 --- a/fs/xfs/xfs_buf.c +++ b/fs/xfs/xfs_buf.c | |||
@@ -34,18 +34,16 @@ | |||
34 | #include <linux/backing-dev.h> | 34 | #include <linux/backing-dev.h> |
35 | #include <linux/freezer.h> | 35 | #include <linux/freezer.h> |
36 | 36 | ||
37 | #include "xfs_format.h" | ||
37 | #include "xfs_log_format.h" | 38 | #include "xfs_log_format.h" |
38 | #include "xfs_trans_resv.h" | 39 | #include "xfs_trans_resv.h" |
39 | #include "xfs_sb.h" | 40 | #include "xfs_sb.h" |
40 | #include "xfs_ag.h" | ||
41 | #include "xfs_mount.h" | 41 | #include "xfs_mount.h" |
42 | #include "xfs_trace.h" | 42 | #include "xfs_trace.h" |
43 | #include "xfs_log.h" | 43 | #include "xfs_log.h" |
44 | 44 | ||
45 | static kmem_zone_t *xfs_buf_zone; | 45 | static kmem_zone_t *xfs_buf_zone; |
46 | 46 | ||
47 | static struct workqueue_struct *xfslogd_workqueue; | ||
48 | |||
49 | #ifdef XFS_BUF_LOCK_TRACKING | 47 | #ifdef XFS_BUF_LOCK_TRACKING |
50 | # define XB_SET_OWNER(bp) ((bp)->b_last_holder = current->pid) | 48 | # define XB_SET_OWNER(bp) ((bp)->b_last_holder = current->pid) |
51 | # define XB_CLEAR_OWNER(bp) ((bp)->b_last_holder = -1) | 49 | # define XB_CLEAR_OWNER(bp) ((bp)->b_last_holder = -1) |
@@ -463,7 +461,7 @@ _xfs_buf_find( | |||
463 | * have to check that the buffer falls within the filesystem bounds. | 461 | * have to check that the buffer falls within the filesystem bounds. |
464 | */ | 462 | */ |
465 | eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks); | 463 | eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks); |
466 | if (blkno >= eofs) { | 464 | if (blkno < 0 || blkno >= eofs) { |
467 | /* | 465 | /* |
468 | * XXX (dgc): we should really be returning -EFSCORRUPTED here, | 466 | * XXX (dgc): we should really be returning -EFSCORRUPTED here, |
469 | * but none of the higher level infrastructure supports | 467 | * but none of the higher level infrastructure supports |
@@ -1043,7 +1041,7 @@ xfs_buf_ioend_work( | |||
1043 | struct work_struct *work) | 1041 | struct work_struct *work) |
1044 | { | 1042 | { |
1045 | struct xfs_buf *bp = | 1043 | struct xfs_buf *bp = |
1046 | container_of(work, xfs_buf_t, b_iodone_work); | 1044 | container_of(work, xfs_buf_t, b_ioend_work); |
1047 | 1045 | ||
1048 | xfs_buf_ioend(bp); | 1046 | xfs_buf_ioend(bp); |
1049 | } | 1047 | } |
@@ -1052,8 +1050,8 @@ void | |||
1052 | xfs_buf_ioend_async( | 1050 | xfs_buf_ioend_async( |
1053 | struct xfs_buf *bp) | 1051 | struct xfs_buf *bp) |
1054 | { | 1052 | { |
1055 | INIT_WORK(&bp->b_iodone_work, xfs_buf_ioend_work); | 1053 | INIT_WORK(&bp->b_ioend_work, xfs_buf_ioend_work); |
1056 | queue_work(xfslogd_workqueue, &bp->b_iodone_work); | 1054 | queue_work(bp->b_ioend_wq, &bp->b_ioend_work); |
1057 | } | 1055 | } |
1058 | 1056 | ||
1059 | void | 1057 | void |
@@ -1222,6 +1220,13 @@ _xfs_buf_ioapply( | |||
1222 | */ | 1220 | */ |
1223 | bp->b_error = 0; | 1221 | bp->b_error = 0; |
1224 | 1222 | ||
1223 | /* | ||
1224 | * Initialize the I/O completion workqueue if we haven't yet or the | ||
1225 | * submitter has not opted to specify a custom one. | ||
1226 | */ | ||
1227 | if (!bp->b_ioend_wq) | ||
1228 | bp->b_ioend_wq = bp->b_target->bt_mount->m_buf_workqueue; | ||
1229 | |||
1225 | if (bp->b_flags & XBF_WRITE) { | 1230 | if (bp->b_flags & XBF_WRITE) { |
1226 | if (bp->b_flags & XBF_SYNCIO) | 1231 | if (bp->b_flags & XBF_SYNCIO) |
1227 | rw = WRITE_SYNC; | 1232 | rw = WRITE_SYNC; |
@@ -1882,15 +1887,8 @@ xfs_buf_init(void) | |||
1882 | if (!xfs_buf_zone) | 1887 | if (!xfs_buf_zone) |
1883 | goto out; | 1888 | goto out; |
1884 | 1889 | ||
1885 | xfslogd_workqueue = alloc_workqueue("xfslogd", | ||
1886 | WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_FREEZABLE, 1); | ||
1887 | if (!xfslogd_workqueue) | ||
1888 | goto out_free_buf_zone; | ||
1889 | |||
1890 | return 0; | 1890 | return 0; |
1891 | 1891 | ||
1892 | out_free_buf_zone: | ||
1893 | kmem_zone_destroy(xfs_buf_zone); | ||
1894 | out: | 1892 | out: |
1895 | return -ENOMEM; | 1893 | return -ENOMEM; |
1896 | } | 1894 | } |
@@ -1898,6 +1896,5 @@ xfs_buf_init(void) | |||
1898 | void | 1896 | void |
1899 | xfs_buf_terminate(void) | 1897 | xfs_buf_terminate(void) |
1900 | { | 1898 | { |
1901 | destroy_workqueue(xfslogd_workqueue); | ||
1902 | kmem_zone_destroy(xfs_buf_zone); | 1899 | kmem_zone_destroy(xfs_buf_zone); |
1903 | } | 1900 | } |
diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h index 82002c00af90..75ff5d5a7d2e 100644 --- a/fs/xfs/xfs_buf.h +++ b/fs/xfs/xfs_buf.h | |||
@@ -164,7 +164,8 @@ typedef struct xfs_buf { | |||
164 | struct xfs_perag *b_pag; /* contains rbtree root */ | 164 | struct xfs_perag *b_pag; /* contains rbtree root */ |
165 | xfs_buftarg_t *b_target; /* buffer target (device) */ | 165 | xfs_buftarg_t *b_target; /* buffer target (device) */ |
166 | void *b_addr; /* virtual address of buffer */ | 166 | void *b_addr; /* virtual address of buffer */ |
167 | struct work_struct b_iodone_work; | 167 | struct work_struct b_ioend_work; |
168 | struct workqueue_struct *b_ioend_wq; /* I/O completion wq */ | ||
168 | xfs_buf_iodone_t b_iodone; /* I/O completion function */ | 169 | xfs_buf_iodone_t b_iodone; /* I/O completion function */ |
169 | struct completion b_iowait; /* queue for I/O waiters */ | 170 | struct completion b_iowait; /* queue for I/O waiters */ |
170 | void *b_fspriv; | 171 | void *b_fspriv; |
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c index f15969543326..3f9bd58edec7 100644 --- a/fs/xfs/xfs_buf_item.c +++ b/fs/xfs/xfs_buf_item.c | |||
@@ -17,11 +17,11 @@ | |||
17 | */ | 17 | */ |
18 | #include "xfs.h" | 18 | #include "xfs.h" |
19 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
20 | #include "xfs_format.h" | ||
20 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
21 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
22 | #include "xfs_bit.h" | 23 | #include "xfs_bit.h" |
23 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
26 | #include "xfs_trans.h" | 26 | #include "xfs_trans.h" |
27 | #include "xfs_buf_item.h" | 27 | #include "xfs_buf_item.h" |
diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c index f1b69edcdf31..098cd78fe708 100644 --- a/fs/xfs/xfs_dir2_readdir.c +++ b/fs/xfs/xfs_dir2_readdir.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_da_format.h" | 26 | #include "xfs_da_format.h" |
29 | #include "xfs_da_btree.h" | 27 | #include "xfs_da_btree.h" |
@@ -34,7 +32,6 @@ | |||
34 | #include "xfs_trace.h" | 32 | #include "xfs_trace.h" |
35 | #include "xfs_bmap.h" | 33 | #include "xfs_bmap.h" |
36 | #include "xfs_trans.h" | 34 | #include "xfs_trans.h" |
37 | #include "xfs_dinode.h" | ||
38 | 35 | ||
39 | /* | 36 | /* |
40 | * Directory file type support functions | 37 | * Directory file type support functions |
@@ -44,7 +41,7 @@ static unsigned char xfs_dir3_filetype_table[] = { | |||
44 | DT_FIFO, DT_SOCK, DT_LNK, DT_WHT, | 41 | DT_FIFO, DT_SOCK, DT_LNK, DT_WHT, |
45 | }; | 42 | }; |
46 | 43 | ||
47 | unsigned char | 44 | static unsigned char |
48 | xfs_dir3_get_dtype( | 45 | xfs_dir3_get_dtype( |
49 | struct xfs_mount *mp, | 46 | struct xfs_mount *mp, |
50 | __uint8_t filetype) | 47 | __uint8_t filetype) |
@@ -57,22 +54,6 @@ xfs_dir3_get_dtype( | |||
57 | 54 | ||
58 | return xfs_dir3_filetype_table[filetype]; | 55 | return xfs_dir3_filetype_table[filetype]; |
59 | } | 56 | } |
60 | /* | ||
61 | * @mode, if set, indicates that the type field needs to be set up. | ||
62 | * This uses the transformation from file mode to DT_* as defined in linux/fs.h | ||
63 | * for file type specification. This will be propagated into the directory | ||
64 | * structure if appropriate for the given operation and filesystem config. | ||
65 | */ | ||
66 | const unsigned char xfs_mode_to_ftype[S_IFMT >> S_SHIFT] = { | ||
67 | [0] = XFS_DIR3_FT_UNKNOWN, | ||
68 | [S_IFREG >> S_SHIFT] = XFS_DIR3_FT_REG_FILE, | ||
69 | [S_IFDIR >> S_SHIFT] = XFS_DIR3_FT_DIR, | ||
70 | [S_IFCHR >> S_SHIFT] = XFS_DIR3_FT_CHRDEV, | ||
71 | [S_IFBLK >> S_SHIFT] = XFS_DIR3_FT_BLKDEV, | ||
72 | [S_IFIFO >> S_SHIFT] = XFS_DIR3_FT_FIFO, | ||
73 | [S_IFSOCK >> S_SHIFT] = XFS_DIR3_FT_SOCK, | ||
74 | [S_IFLNK >> S_SHIFT] = XFS_DIR3_FT_SYMLINK, | ||
75 | }; | ||
76 | 57 | ||
77 | STATIC int | 58 | STATIC int |
78 | xfs_dir2_sf_getdents( | 59 | xfs_dir2_sf_getdents( |
diff --git a/fs/xfs/xfs_discard.c b/fs/xfs/xfs_discard.c index 13d08a1b390e..799e5a2d334d 100644 --- a/fs/xfs/xfs_discard.c +++ b/fs/xfs/xfs_discard.c | |||
@@ -20,7 +20,6 @@ | |||
20 | #include "xfs_log_format.h" | 20 | #include "xfs_log_format.h" |
21 | #include "xfs_trans_resv.h" | 21 | #include "xfs_trans_resv.h" |
22 | #include "xfs_sb.h" | 22 | #include "xfs_sb.h" |
23 | #include "xfs_ag.h" | ||
24 | #include "xfs_mount.h" | 23 | #include "xfs_mount.h" |
25 | #include "xfs_quota.h" | 24 | #include "xfs_quota.h" |
26 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 63c2de49f61d..02c01bbbc789 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_shared.h" | 22 | #include "xfs_shared.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
29 | #include "xfs_bmap.h" | 27 | #include "xfs_bmap.h" |
diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c index f33fbaaa4d8a..814cff94e78f 100644 --- a/fs/xfs/xfs_dquot_item.c +++ b/fs/xfs/xfs_dquot_item.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include "xfs_format.h" | 20 | #include "xfs_format.h" |
21 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | 23 | #include "xfs_mount.h" |
26 | #include "xfs_inode.h" | 24 | #include "xfs_inode.h" |
27 | #include "xfs_quota.h" | 25 | #include "xfs_quota.h" |
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index b92fd7bc49e3..3ee186ac1093 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include "xfs_fs.h" | 20 | #include "xfs_fs.h" |
21 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | 23 | #include "xfs_mount.h" |
26 | #include "xfs_error.h" | 24 | #include "xfs_error.h" |
27 | 25 | ||
diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c index 5a6bd5d8779a..5eb4a14e0a0f 100644 --- a/fs/xfs/xfs_export.c +++ b/fs/xfs/xfs_export.c | |||
@@ -19,10 +19,9 @@ | |||
19 | #include "xfs_format.h" | 19 | #include "xfs_format.h" |
20 | #include "xfs_log_format.h" | 20 | #include "xfs_log_format.h" |
21 | #include "xfs_trans_resv.h" | 21 | #include "xfs_trans_resv.h" |
22 | #include "xfs_sb.h" | ||
23 | #include "xfs_ag.h" | ||
24 | #include "xfs_mount.h" | 22 | #include "xfs_mount.h" |
25 | #include "xfs_da_format.h" | 23 | #include "xfs_da_format.h" |
24 | #include "xfs_da_btree.h" | ||
26 | #include "xfs_dir2.h" | 25 | #include "xfs_dir2.h" |
27 | #include "xfs_export.h" | 26 | #include "xfs_export.h" |
28 | #include "xfs_inode.h" | 27 | #include "xfs_inode.h" |
diff --git a/fs/xfs/xfs_extent_busy.c b/fs/xfs/xfs_extent_busy.c index fd22f69049d4..c263e079273e 100644 --- a/fs/xfs/xfs_extent_busy.c +++ b/fs/xfs/xfs_extent_busy.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include "xfs_shared.h" | 24 | #include "xfs_shared.h" |
25 | #include "xfs_trans_resv.h" | 25 | #include "xfs_trans_resv.h" |
26 | #include "xfs_sb.h" | 26 | #include "xfs_sb.h" |
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 27 | #include "xfs_mount.h" |
29 | #include "xfs_alloc.h" | 28 | #include "xfs_alloc.h" |
30 | #include "xfs_extent_busy.h" | 29 | #include "xfs_extent_busy.h" |
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c index c4327419dc5c..cb7fe64cdbfa 100644 --- a/fs/xfs/xfs_extfree_item.c +++ b/fs/xfs/xfs_extfree_item.c | |||
@@ -17,10 +17,9 @@ | |||
17 | */ | 17 | */ |
18 | #include "xfs.h" | 18 | #include "xfs.h" |
19 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
20 | #include "xfs_format.h" | ||
20 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
21 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
22 | #include "xfs_sb.h" | ||
23 | #include "xfs_ag.h" | ||
24 | #include "xfs_mount.h" | 23 | #include "xfs_mount.h" |
25 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
26 | #include "xfs_trans_priv.h" | 25 | #include "xfs_trans_priv.h" |
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index eb596b419942..13e974e6a889 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_da_format.h" | 25 | #include "xfs_da_format.h" |
28 | #include "xfs_da_btree.h" | 26 | #include "xfs_da_btree.h" |
@@ -37,7 +35,6 @@ | |||
37 | #include "xfs_ioctl.h" | 35 | #include "xfs_ioctl.h" |
38 | #include "xfs_trace.h" | 36 | #include "xfs_trace.h" |
39 | #include "xfs_log.h" | 37 | #include "xfs_log.h" |
40 | #include "xfs_dinode.h" | ||
41 | #include "xfs_icache.h" | 38 | #include "xfs_icache.h" |
42 | 39 | ||
43 | #include <linux/aio.h> | 40 | #include <linux/aio.h> |
@@ -933,7 +930,6 @@ xfs_file_readdir( | |||
933 | { | 930 | { |
934 | struct inode *inode = file_inode(file); | 931 | struct inode *inode = file_inode(file); |
935 | xfs_inode_t *ip = XFS_I(inode); | 932 | xfs_inode_t *ip = XFS_I(inode); |
936 | int error; | ||
937 | size_t bufsize; | 933 | size_t bufsize; |
938 | 934 | ||
939 | /* | 935 | /* |
@@ -950,10 +946,7 @@ xfs_file_readdir( | |||
950 | */ | 946 | */ |
951 | bufsize = (size_t)min_t(loff_t, 32768, ip->i_d.di_size); | 947 | bufsize = (size_t)min_t(loff_t, 32768, ip->i_d.di_size); |
952 | 948 | ||
953 | error = xfs_readdir(ip, ctx, bufsize); | 949 | return xfs_readdir(ip, ctx, bufsize); |
954 | if (error) | ||
955 | return error; | ||
956 | return 0; | ||
957 | } | 950 | } |
958 | 951 | ||
959 | STATIC int | 952 | STATIC int |
diff --git a/fs/xfs/xfs_filestream.c b/fs/xfs/xfs_filestream.c index e92730c1d3ca..a2e86e8a0fea 100644 --- a/fs/xfs/xfs_filestream.c +++ b/fs/xfs/xfs_filestream.c | |||
@@ -20,16 +20,13 @@ | |||
20 | #include "xfs_format.h" | 20 | #include "xfs_format.h" |
21 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
23 | #include "xfs_ag.h" | ||
24 | #include "xfs_sb.h" | 23 | #include "xfs_sb.h" |
25 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
26 | #include "xfs_inum.h" | ||
27 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
28 | #include "xfs_bmap.h" | 26 | #include "xfs_bmap.h" |
29 | #include "xfs_bmap_util.h" | 27 | #include "xfs_bmap_util.h" |
30 | #include "xfs_alloc.h" | 28 | #include "xfs_alloc.h" |
31 | #include "xfs_mru_cache.h" | 29 | #include "xfs_mru_cache.h" |
32 | #include "xfs_dinode.h" | ||
33 | #include "xfs_filestream.h" | 30 | #include "xfs_filestream.h" |
34 | #include "xfs_trace.h" | 31 | #include "xfs_trace.h" |
35 | 32 | ||
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index c05ac8b70fa9..fdc64220fcb0 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c | |||
@@ -22,7 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
27 | #include "xfs_da_format.h" | 26 | #include "xfs_da_format.h" |
28 | #include "xfs_da_btree.h" | 27 | #include "xfs_da_btree.h" |
@@ -40,7 +39,6 @@ | |||
40 | #include "xfs_rtalloc.h" | 39 | #include "xfs_rtalloc.h" |
41 | #include "xfs_trace.h" | 40 | #include "xfs_trace.h" |
42 | #include "xfs_log.h" | 41 | #include "xfs_log.h" |
43 | #include "xfs_dinode.h" | ||
44 | #include "xfs_filestream.h" | 42 | #include "xfs_filestream.h" |
45 | 43 | ||
46 | /* | 44 | /* |
diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index b45f7b27b5df..9771b7ef62ed 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c | |||
@@ -20,9 +20,7 @@ | |||
20 | #include "xfs_format.h" | 20 | #include "xfs_format.h" |
21 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
23 | #include "xfs_inum.h" | ||
24 | #include "xfs_sb.h" | 23 | #include "xfs_sb.h" |
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
28 | #include "xfs_error.h" | 26 | #include "xfs_error.h" |
@@ -65,6 +63,7 @@ xfs_inode_alloc( | |||
65 | return NULL; | 63 | return NULL; |
66 | } | 64 | } |
67 | 65 | ||
66 | XFS_STATS_INC(vn_active); | ||
68 | ASSERT(atomic_read(&ip->i_pincount) == 0); | 67 | ASSERT(atomic_read(&ip->i_pincount) == 0); |
69 | ASSERT(!spin_is_locked(&ip->i_flags_lock)); | 68 | ASSERT(!spin_is_locked(&ip->i_flags_lock)); |
70 | ASSERT(!xfs_isiflocked(ip)); | 69 | ASSERT(!xfs_isiflocked(ip)); |
@@ -130,6 +129,7 @@ xfs_inode_free( | |||
130 | /* asserts to verify all state is correct here */ | 129 | /* asserts to verify all state is correct here */ |
131 | ASSERT(atomic_read(&ip->i_pincount) == 0); | 130 | ASSERT(atomic_read(&ip->i_pincount) == 0); |
132 | ASSERT(!xfs_isiflocked(ip)); | 131 | ASSERT(!xfs_isiflocked(ip)); |
132 | XFS_STATS_DEC(vn_active); | ||
133 | 133 | ||
134 | call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback); | 134 | call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback); |
135 | } | 135 | } |
diff --git a/fs/xfs/xfs_icache.h b/fs/xfs/xfs_icache.h index 46748b86b12f..62f1f91c32cb 100644 --- a/fs/xfs/xfs_icache.h +++ b/fs/xfs/xfs_icache.h | |||
@@ -34,6 +34,14 @@ struct xfs_eofblocks { | |||
34 | #define SYNC_TRYLOCK 0x0002 /* only try to lock inodes */ | 34 | #define SYNC_TRYLOCK 0x0002 /* only try to lock inodes */ |
35 | 35 | ||
36 | /* | 36 | /* |
37 | * tags for inode radix tree | ||
38 | */ | ||
39 | #define XFS_ICI_NO_TAG (-1) /* special flag for an untagged lookup | ||
40 | in xfs_inode_ag_iterator */ | ||
41 | #define XFS_ICI_RECLAIM_TAG 0 /* inode is to be reclaimed */ | ||
42 | #define XFS_ICI_EOFBLOCKS_TAG 1 /* inode has blocks beyond EOF */ | ||
43 | |||
44 | /* | ||
37 | * Flags for xfs_iget() | 45 | * Flags for xfs_iget() |
38 | */ | 46 | */ |
39 | #define XFS_IGET_CREATE 0x1 | 47 | #define XFS_IGET_CREATE 0x1 |
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c index 7e4549233251..d45ca72af6fb 100644 --- a/fs/xfs/xfs_icreate_item.c +++ b/fs/xfs/xfs_icreate_item.c | |||
@@ -18,11 +18,10 @@ | |||
18 | #include "xfs.h" | 18 | #include "xfs.h" |
19 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
20 | #include "xfs_shared.h" | 20 | #include "xfs_shared.h" |
21 | #include "xfs_format.h" | ||
21 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
23 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
27 | #include "xfs_trans.h" | 26 | #include "xfs_trans.h" |
28 | #include "xfs_trans_priv.h" | 27 | #include "xfs_trans_priv.h" |
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 8ed049d1e332..41f804e740d7 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c | |||
@@ -23,9 +23,7 @@ | |||
23 | #include "xfs_format.h" | 23 | #include "xfs_format.h" |
24 | #include "xfs_log_format.h" | 24 | #include "xfs_log_format.h" |
25 | #include "xfs_trans_resv.h" | 25 | #include "xfs_trans_resv.h" |
26 | #include "xfs_inum.h" | ||
27 | #include "xfs_sb.h" | 26 | #include "xfs_sb.h" |
28 | #include "xfs_ag.h" | ||
29 | #include "xfs_mount.h" | 27 | #include "xfs_mount.h" |
30 | #include "xfs_inode.h" | 28 | #include "xfs_inode.h" |
31 | #include "xfs_da_format.h" | 29 | #include "xfs_da_format.h" |
@@ -1082,7 +1080,7 @@ xfs_create( | |||
1082 | struct xfs_dquot *udqp = NULL; | 1080 | struct xfs_dquot *udqp = NULL; |
1083 | struct xfs_dquot *gdqp = NULL; | 1081 | struct xfs_dquot *gdqp = NULL; |
1084 | struct xfs_dquot *pdqp = NULL; | 1082 | struct xfs_dquot *pdqp = NULL; |
1085 | struct xfs_trans_res tres; | 1083 | struct xfs_trans_res *tres; |
1086 | uint resblks; | 1084 | uint resblks; |
1087 | 1085 | ||
1088 | trace_xfs_create(dp, name); | 1086 | trace_xfs_create(dp, name); |
@@ -1105,13 +1103,11 @@ xfs_create( | |||
1105 | if (is_dir) { | 1103 | if (is_dir) { |
1106 | rdev = 0; | 1104 | rdev = 0; |
1107 | resblks = XFS_MKDIR_SPACE_RES(mp, name->len); | 1105 | resblks = XFS_MKDIR_SPACE_RES(mp, name->len); |
1108 | tres.tr_logres = M_RES(mp)->tr_mkdir.tr_logres; | 1106 | tres = &M_RES(mp)->tr_mkdir; |
1109 | tres.tr_logcount = XFS_MKDIR_LOG_COUNT; | ||
1110 | tp = xfs_trans_alloc(mp, XFS_TRANS_MKDIR); | 1107 | tp = xfs_trans_alloc(mp, XFS_TRANS_MKDIR); |
1111 | } else { | 1108 | } else { |
1112 | resblks = XFS_CREATE_SPACE_RES(mp, name->len); | 1109 | resblks = XFS_CREATE_SPACE_RES(mp, name->len); |
1113 | tres.tr_logres = M_RES(mp)->tr_create.tr_logres; | 1110 | tres = &M_RES(mp)->tr_create; |
1114 | tres.tr_logcount = XFS_CREATE_LOG_COUNT; | ||
1115 | tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE); | 1111 | tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE); |
1116 | } | 1112 | } |
1117 | 1113 | ||
@@ -1123,17 +1119,16 @@ xfs_create( | |||
1123 | * the case we'll drop the one we have and get a more | 1119 | * the case we'll drop the one we have and get a more |
1124 | * appropriate transaction later. | 1120 | * appropriate transaction later. |
1125 | */ | 1121 | */ |
1126 | tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; | 1122 | error = xfs_trans_reserve(tp, tres, resblks, 0); |
1127 | error = xfs_trans_reserve(tp, &tres, resblks, 0); | ||
1128 | if (error == -ENOSPC) { | 1123 | if (error == -ENOSPC) { |
1129 | /* flush outstanding delalloc blocks and retry */ | 1124 | /* flush outstanding delalloc blocks and retry */ |
1130 | xfs_flush_inodes(mp); | 1125 | xfs_flush_inodes(mp); |
1131 | error = xfs_trans_reserve(tp, &tres, resblks, 0); | 1126 | error = xfs_trans_reserve(tp, tres, resblks, 0); |
1132 | } | 1127 | } |
1133 | if (error == -ENOSPC) { | 1128 | if (error == -ENOSPC) { |
1134 | /* No space at all so try a "no-allocation" reservation */ | 1129 | /* No space at all so try a "no-allocation" reservation */ |
1135 | resblks = 0; | 1130 | resblks = 0; |
1136 | error = xfs_trans_reserve(tp, &tres, 0, 0); | 1131 | error = xfs_trans_reserve(tp, tres, 0, 0); |
1137 | } | 1132 | } |
1138 | if (error) { | 1133 | if (error) { |
1139 | cancel_flags = 0; | 1134 | cancel_flags = 0; |
@@ -2488,9 +2483,7 @@ xfs_remove( | |||
2488 | xfs_fsblock_t first_block; | 2483 | xfs_fsblock_t first_block; |
2489 | int cancel_flags; | 2484 | int cancel_flags; |
2490 | int committed; | 2485 | int committed; |
2491 | int link_zero; | ||
2492 | uint resblks; | 2486 | uint resblks; |
2493 | uint log_count; | ||
2494 | 2487 | ||
2495 | trace_xfs_remove(dp, name); | 2488 | trace_xfs_remove(dp, name); |
2496 | 2489 | ||
@@ -2505,13 +2498,10 @@ xfs_remove( | |||
2505 | if (error) | 2498 | if (error) |
2506 | goto std_return; | 2499 | goto std_return; |
2507 | 2500 | ||
2508 | if (is_dir) { | 2501 | if (is_dir) |
2509 | tp = xfs_trans_alloc(mp, XFS_TRANS_RMDIR); | 2502 | tp = xfs_trans_alloc(mp, XFS_TRANS_RMDIR); |
2510 | log_count = XFS_DEFAULT_LOG_COUNT; | 2503 | else |
2511 | } else { | ||
2512 | tp = xfs_trans_alloc(mp, XFS_TRANS_REMOVE); | 2504 | tp = xfs_trans_alloc(mp, XFS_TRANS_REMOVE); |
2513 | log_count = XFS_REMOVE_LOG_COUNT; | ||
2514 | } | ||
2515 | cancel_flags = XFS_TRANS_RELEASE_LOG_RES; | 2505 | cancel_flags = XFS_TRANS_RELEASE_LOG_RES; |
2516 | 2506 | ||
2517 | /* | 2507 | /* |
@@ -2579,9 +2569,6 @@ xfs_remove( | |||
2579 | if (error) | 2569 | if (error) |
2580 | goto out_trans_cancel; | 2570 | goto out_trans_cancel; |
2581 | 2571 | ||
2582 | /* Determine if this is the last link while the inode is locked */ | ||
2583 | link_zero = (ip->i_d.di_nlink == 0); | ||
2584 | |||
2585 | xfs_bmap_init(&free_list, &first_block); | 2572 | xfs_bmap_init(&free_list, &first_block); |
2586 | error = xfs_dir_removename(tp, dp, name, ip->i_ino, | 2573 | error = xfs_dir_removename(tp, dp, name, ip->i_ino, |
2587 | &first_block, &free_list, resblks); | 2574 | &first_block, &free_list, resblks); |
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h index 9af2882e1f4c..4ed2ba9342dc 100644 --- a/fs/xfs/xfs_inode.h +++ b/fs/xfs/xfs_inode.h | |||
@@ -20,7 +20,6 @@ | |||
20 | 20 | ||
21 | #include "xfs_inode_buf.h" | 21 | #include "xfs_inode_buf.h" |
22 | #include "xfs_inode_fork.h" | 22 | #include "xfs_inode_fork.h" |
23 | #include "xfs_dinode.h" | ||
24 | 23 | ||
25 | /* | 24 | /* |
26 | * Kernel only inode definitions | 25 | * Kernel only inode definitions |
@@ -324,7 +323,6 @@ static inline int xfs_isiflocked(struct xfs_inode *ip) | |||
324 | (((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \ | 323 | (((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \ |
325 | ((pip)->i_d.di_mode & S_ISGID)) | 324 | ((pip)->i_d.di_mode & S_ISGID)) |
326 | 325 | ||
327 | |||
328 | int xfs_release(struct xfs_inode *ip); | 326 | int xfs_release(struct xfs_inode *ip); |
329 | void xfs_inactive(struct xfs_inode *ip); | 327 | void xfs_inactive(struct xfs_inode *ip); |
330 | int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name, | 328 | int xfs_lookup(struct xfs_inode *dp, struct xfs_name *name, |
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c index 63de0b0acc32..bf13a5a7e2f4 100644 --- a/fs/xfs/xfs_inode_item.c +++ b/fs/xfs/xfs_inode_item.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include "xfs_format.h" | 20 | #include "xfs_format.h" |
21 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | 23 | #include "xfs_mount.h" |
26 | #include "xfs_inode.h" | 24 | #include "xfs_inode.h" |
27 | #include "xfs_trans.h" | 25 | #include "xfs_trans.h" |
@@ -29,7 +27,6 @@ | |||
29 | #include "xfs_error.h" | 27 | #include "xfs_error.h" |
30 | #include "xfs_trace.h" | 28 | #include "xfs_trace.h" |
31 | #include "xfs_trans_priv.h" | 29 | #include "xfs_trans_priv.h" |
32 | #include "xfs_dinode.h" | ||
33 | #include "xfs_log.h" | 30 | #include "xfs_log.h" |
34 | 31 | ||
35 | 32 | ||
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c index 24c926b6fe85..a1831980a68e 100644 --- a/fs/xfs/xfs_ioctl.c +++ b/fs/xfs/xfs_ioctl.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
28 | #include "xfs_ioctl.h" | 26 | #include "xfs_ioctl.h" |
@@ -40,7 +38,6 @@ | |||
40 | #include "xfs_trace.h" | 38 | #include "xfs_trace.h" |
41 | #include "xfs_icache.h" | 39 | #include "xfs_icache.h" |
42 | #include "xfs_symlink.h" | 40 | #include "xfs_symlink.h" |
43 | #include "xfs_dinode.h" | ||
44 | #include "xfs_trans.h" | 41 | #include "xfs_trans.h" |
45 | 42 | ||
46 | #include <linux/capability.h> | 43 | #include <linux/capability.h> |
diff --git a/fs/xfs/xfs_ioctl32.c b/fs/xfs/xfs_ioctl32.c index 94ce027e28e3..ec6772866f3d 100644 --- a/fs/xfs/xfs_ioctl32.c +++ b/fs/xfs/xfs_ioctl32.c | |||
@@ -25,8 +25,6 @@ | |||
25 | #include "xfs_format.h" | 25 | #include "xfs_format.h" |
26 | #include "xfs_log_format.h" | 26 | #include "xfs_log_format.h" |
27 | #include "xfs_trans_resv.h" | 27 | #include "xfs_trans_resv.h" |
28 | #include "xfs_sb.h" | ||
29 | #include "xfs_ag.h" | ||
30 | #include "xfs_mount.h" | 28 | #include "xfs_mount.h" |
31 | #include "xfs_inode.h" | 29 | #include "xfs_inode.h" |
32 | #include "xfs_itable.h" | 30 | #include "xfs_itable.h" |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index afcf3c926565..c980e2a5086b 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
28 | #include "xfs_btree.h" | 26 | #include "xfs_btree.h" |
@@ -38,7 +36,6 @@ | |||
38 | #include "xfs_quota.h" | 36 | #include "xfs_quota.h" |
39 | #include "xfs_dquot_item.h" | 37 | #include "xfs_dquot_item.h" |
40 | #include "xfs_dquot.h" | 38 | #include "xfs_dquot.h" |
41 | #include "xfs_dinode.h" | ||
42 | 39 | ||
43 | 40 | ||
44 | #define XFS_WRITEIO_ALIGN(mp,off) (((off) >> mp->m_writeio_log) \ | 41 | #define XFS_WRITEIO_ALIGN(mp,off) (((off) >> mp->m_writeio_log) \ |
@@ -52,7 +49,6 @@ xfs_iomap_eof_align_last_fsb( | |||
52 | xfs_extlen_t extsize, | 49 | xfs_extlen_t extsize, |
53 | xfs_fileoff_t *last_fsb) | 50 | xfs_fileoff_t *last_fsb) |
54 | { | 51 | { |
55 | xfs_fileoff_t new_last_fsb = 0; | ||
56 | xfs_extlen_t align = 0; | 52 | xfs_extlen_t align = 0; |
57 | int eof, error; | 53 | int eof, error; |
58 | 54 | ||
@@ -70,8 +66,8 @@ xfs_iomap_eof_align_last_fsb( | |||
70 | else if (mp->m_dalign) | 66 | else if (mp->m_dalign) |
71 | align = mp->m_dalign; | 67 | align = mp->m_dalign; |
72 | 68 | ||
73 | if (align && XFS_ISIZE(ip) >= XFS_FSB_TO_B(mp, align)) | 69 | if (align && XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, align)) |
74 | new_last_fsb = roundup_64(*last_fsb, align); | 70 | align = 0; |
75 | } | 71 | } |
76 | 72 | ||
77 | /* | 73 | /* |
@@ -79,14 +75,14 @@ xfs_iomap_eof_align_last_fsb( | |||
79 | * (when file on a real-time subvolume or has di_extsize hint). | 75 | * (when file on a real-time subvolume or has di_extsize hint). |
80 | */ | 76 | */ |
81 | if (extsize) { | 77 | if (extsize) { |
82 | if (new_last_fsb) | 78 | if (align) |
83 | align = roundup_64(new_last_fsb, extsize); | 79 | align = roundup_64(align, extsize); |
84 | else | 80 | else |
85 | align = extsize; | 81 | align = extsize; |
86 | new_last_fsb = roundup_64(*last_fsb, align); | ||
87 | } | 82 | } |
88 | 83 | ||
89 | if (new_last_fsb) { | 84 | if (align) { |
85 | xfs_fileoff_t new_last_fsb = roundup_64(*last_fsb, align); | ||
90 | error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof); | 86 | error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof); |
91 | if (error) | 87 | if (error) |
92 | return error; | 88 | return error; |
@@ -264,7 +260,6 @@ xfs_iomap_eof_want_preallocate( | |||
264 | { | 260 | { |
265 | xfs_fileoff_t start_fsb; | 261 | xfs_fileoff_t start_fsb; |
266 | xfs_filblks_t count_fsb; | 262 | xfs_filblks_t count_fsb; |
267 | xfs_fsblock_t firstblock; | ||
268 | int n, error, imaps; | 263 | int n, error, imaps; |
269 | int found_delalloc = 0; | 264 | int found_delalloc = 0; |
270 | 265 | ||
@@ -289,7 +284,6 @@ xfs_iomap_eof_want_preallocate( | |||
289 | count_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); | 284 | count_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); |
290 | while (count_fsb > 0) { | 285 | while (count_fsb > 0) { |
291 | imaps = nimaps; | 286 | imaps = nimaps; |
292 | firstblock = NULLFSBLOCK; | ||
293 | error = xfs_bmapi_read(ip, start_fsb, count_fsb, imap, &imaps, | 287 | error = xfs_bmapi_read(ip, start_fsb, count_fsb, imap, &imaps, |
294 | 0); | 288 | 0); |
295 | if (error) | 289 | if (error) |
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index ec6dcdc181ee..c50311cae1b1 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_da_format.h" | 25 | #include "xfs_da_format.h" |
28 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
@@ -37,8 +35,7 @@ | |||
37 | #include "xfs_icache.h" | 35 | #include "xfs_icache.h" |
38 | #include "xfs_symlink.h" | 36 | #include "xfs_symlink.h" |
39 | #include "xfs_da_btree.h" | 37 | #include "xfs_da_btree.h" |
40 | #include "xfs_dir2_priv.h" | 38 | #include "xfs_dir2.h" |
41 | #include "xfs_dinode.h" | ||
42 | #include "xfs_trans_space.h" | 39 | #include "xfs_trans_space.h" |
43 | 40 | ||
44 | #include <linux/capability.h> | 41 | #include <linux/capability.h> |
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c index 894924a5129b..82e314258f73 100644 --- a/fs/xfs/xfs_itable.c +++ b/fs/xfs/xfs_itable.c | |||
@@ -21,9 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_inum.h" | ||
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
29 | #include "xfs_btree.h" | 26 | #include "xfs_btree.h" |
@@ -33,7 +30,6 @@ | |||
33 | #include "xfs_error.h" | 30 | #include "xfs_error.h" |
34 | #include "xfs_trace.h" | 31 | #include "xfs_trace.h" |
35 | #include "xfs_icache.h" | 32 | #include "xfs_icache.h" |
36 | #include "xfs_dinode.h" | ||
37 | 33 | ||
38 | STATIC int | 34 | STATIC int |
39 | xfs_internal_inum( | 35 | xfs_internal_inum( |
@@ -352,7 +348,6 @@ xfs_bulkstat( | |||
352 | int *done) /* 1 if there are more stats to get */ | 348 | int *done) /* 1 if there are more stats to get */ |
353 | { | 349 | { |
354 | xfs_buf_t *agbp; /* agi header buffer */ | 350 | xfs_buf_t *agbp; /* agi header buffer */ |
355 | xfs_agi_t *agi; /* agi header data */ | ||
356 | xfs_agino_t agino; /* inode # in allocation group */ | 351 | xfs_agino_t agino; /* inode # in allocation group */ |
357 | xfs_agnumber_t agno; /* allocation group number */ | 352 | xfs_agnumber_t agno; /* allocation group number */ |
358 | xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */ | 353 | xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */ |
@@ -403,7 +398,6 @@ xfs_bulkstat( | |||
403 | error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); | 398 | error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); |
404 | if (error) | 399 | if (error) |
405 | break; | 400 | break; |
406 | agi = XFS_BUF_TO_AGI(agbp); | ||
407 | /* | 401 | /* |
408 | * Allocate and initialize a btree cursor for ialloc btree. | 402 | * Allocate and initialize a btree cursor for ialloc btree. |
409 | */ | 403 | */ |
diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h index 6a51619d8690..c31d2c2eadc4 100644 --- a/fs/xfs/xfs_linux.h +++ b/fs/xfs/xfs_linux.h | |||
@@ -384,4 +384,10 @@ static inline __uint64_t howmany_64(__uint64_t x, __uint32_t y) | |||
384 | #endif /* XFS_WARN */ | 384 | #endif /* XFS_WARN */ |
385 | #endif /* DEBUG */ | 385 | #endif /* DEBUG */ |
386 | 386 | ||
387 | #ifdef CONFIG_XFS_RT | ||
388 | #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) | ||
389 | #else | ||
390 | #define XFS_IS_REALTIME_INODE(ip) (0) | ||
391 | #endif | ||
392 | |||
387 | #endif /* __XFS_LINUX__ */ | 393 | #endif /* __XFS_LINUX__ */ |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index fe88ef67f93a..e408bf5a3ff7 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_error.h" | 25 | #include "xfs_error.h" |
28 | #include "xfs_trans.h" | 26 | #include "xfs_trans.h" |
@@ -1031,7 +1029,7 @@ xfs_log_need_covered(xfs_mount_t *mp) | |||
1031 | struct xlog *log = mp->m_log; | 1029 | struct xlog *log = mp->m_log; |
1032 | int needed = 0; | 1030 | int needed = 0; |
1033 | 1031 | ||
1034 | if (!xfs_fs_writable(mp)) | 1032 | if (!xfs_fs_writable(mp, SB_FREEZE_WRITE)) |
1035 | return 0; | 1033 | return 0; |
1036 | 1034 | ||
1037 | if (!xlog_cil_empty(log)) | 1035 | if (!xlog_cil_empty(log)) |
@@ -1808,6 +1806,8 @@ xlog_sync( | |||
1808 | XFS_BUF_ZEROFLAGS(bp); | 1806 | XFS_BUF_ZEROFLAGS(bp); |
1809 | XFS_BUF_ASYNC(bp); | 1807 | XFS_BUF_ASYNC(bp); |
1810 | bp->b_flags |= XBF_SYNCIO; | 1808 | bp->b_flags |= XBF_SYNCIO; |
1809 | /* use high priority completion wq */ | ||
1810 | bp->b_ioend_wq = log->l_mp->m_log_workqueue; | ||
1811 | 1811 | ||
1812 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) { | 1812 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) { |
1813 | bp->b_flags |= XBF_FUA; | 1813 | bp->b_flags |= XBF_FUA; |
@@ -1856,6 +1856,8 @@ xlog_sync( | |||
1856 | bp->b_flags |= XBF_SYNCIO; | 1856 | bp->b_flags |= XBF_SYNCIO; |
1857 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) | 1857 | if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) |
1858 | bp->b_flags |= XBF_FUA; | 1858 | bp->b_flags |= XBF_FUA; |
1859 | /* use high priority completion wq */ | ||
1860 | bp->b_ioend_wq = log->l_mp->m_log_workqueue; | ||
1859 | 1861 | ||
1860 | ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1); | 1862 | ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1); |
1861 | ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize); | 1863 | ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize); |
diff --git a/fs/xfs/xfs_log_cil.c b/fs/xfs/xfs_log_cil.c index f506c457011e..45cc0ce18adf 100644 --- a/fs/xfs/xfs_log_cil.c +++ b/fs/xfs/xfs_log_cil.c | |||
@@ -17,11 +17,10 @@ | |||
17 | 17 | ||
18 | #include "xfs.h" | 18 | #include "xfs.h" |
19 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
20 | #include "xfs_format.h" | ||
20 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
21 | #include "xfs_shared.h" | 22 | #include "xfs_shared.h" |
22 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
26 | #include "xfs_error.h" | 25 | #include "xfs_error.h" |
27 | #include "xfs_alloc.h" | 26 | #include "xfs_alloc.h" |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 00cd7f3a8f59..a5a945fc3bdc 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -22,11 +22,10 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_inum.h" | ||
26 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 27 | #include "xfs_da_format.h" |
28 | #include "xfs_da_btree.h" | ||
30 | #include "xfs_inode.h" | 29 | #include "xfs_inode.h" |
31 | #include "xfs_trans.h" | 30 | #include "xfs_trans.h" |
32 | #include "xfs_log.h" | 31 | #include "xfs_log.h" |
@@ -42,7 +41,6 @@ | |||
42 | #include "xfs_trace.h" | 41 | #include "xfs_trace.h" |
43 | #include "xfs_icache.h" | 42 | #include "xfs_icache.h" |
44 | #include "xfs_bmap_btree.h" | 43 | #include "xfs_bmap_btree.h" |
45 | #include "xfs_dinode.h" | ||
46 | #include "xfs_error.h" | 44 | #include "xfs_error.h" |
47 | #include "xfs_dir2.h" | 45 | #include "xfs_dir2.h" |
48 | 46 | ||
diff --git a/fs/xfs/xfs_message.c b/fs/xfs/xfs_message.c index 63ca2f0420b1..d8b67547ab34 100644 --- a/fs/xfs/xfs_message.c +++ b/fs/xfs/xfs_message.c | |||
@@ -17,10 +17,9 @@ | |||
17 | 17 | ||
18 | #include "xfs.h" | 18 | #include "xfs.h" |
19 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
20 | #include "xfs_format.h" | ||
20 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
21 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
22 | #include "xfs_sb.h" | ||
23 | #include "xfs_ag.h" | ||
24 | #include "xfs_mount.h" | 23 | #include "xfs_mount.h" |
25 | 24 | ||
26 | /* | 25 | /* |
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 51435dbce9c4..d3d38836f87f 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c | |||
@@ -22,11 +22,10 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_inum.h" | ||
26 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 27 | #include "xfs_da_format.h" |
28 | #include "xfs_da_btree.h" | ||
30 | #include "xfs_inode.h" | 29 | #include "xfs_inode.h" |
31 | #include "xfs_dir2.h" | 30 | #include "xfs_dir2.h" |
32 | #include "xfs_ialloc.h" | 31 | #include "xfs_ialloc.h" |
@@ -41,7 +40,6 @@ | |||
41 | #include "xfs_fsops.h" | 40 | #include "xfs_fsops.h" |
42 | #include "xfs_trace.h" | 41 | #include "xfs_trace.h" |
43 | #include "xfs_icache.h" | 42 | #include "xfs_icache.h" |
44 | #include "xfs_dinode.h" | ||
45 | #include "xfs_sysfs.h" | 43 | #include "xfs_sysfs.h" |
46 | 44 | ||
47 | 45 | ||
@@ -1074,11 +1072,23 @@ xfs_unmountfs( | |||
1074 | xfs_sysfs_del(&mp->m_kobj); | 1072 | xfs_sysfs_del(&mp->m_kobj); |
1075 | } | 1073 | } |
1076 | 1074 | ||
1077 | int | 1075 | /* |
1078 | xfs_fs_writable(xfs_mount_t *mp) | 1076 | * Determine whether modifications can proceed. The caller specifies the minimum |
1077 | * freeze level for which modifications should not be allowed. This allows | ||
1078 | * certain operations to proceed while the freeze sequence is in progress, if | ||
1079 | * necessary. | ||
1080 | */ | ||
1081 | bool | ||
1082 | xfs_fs_writable( | ||
1083 | struct xfs_mount *mp, | ||
1084 | int level) | ||
1079 | { | 1085 | { |
1080 | return !(mp->m_super->s_writers.frozen || XFS_FORCED_SHUTDOWN(mp) || | 1086 | ASSERT(level > SB_UNFROZEN); |
1081 | (mp->m_flags & XFS_MOUNT_RDONLY)); | 1087 | if ((mp->m_super->s_writers.frozen >= level) || |
1088 | XFS_FORCED_SHUTDOWN(mp) || (mp->m_flags & XFS_MOUNT_RDONLY)) | ||
1089 | return false; | ||
1090 | |||
1091 | return true; | ||
1082 | } | 1092 | } |
1083 | 1093 | ||
1084 | /* | 1094 | /* |
@@ -1086,9 +1096,9 @@ xfs_fs_writable(xfs_mount_t *mp) | |||
1086 | * | 1096 | * |
1087 | * Sync the superblock counters to disk. | 1097 | * Sync the superblock counters to disk. |
1088 | * | 1098 | * |
1089 | * Note this code can be called during the process of freezing, so | 1099 | * Note this code can be called during the process of freezing, so we use the |
1090 | * we may need to use the transaction allocator which does not | 1100 | * transaction allocator that does not block when the transaction subsystem is |
1091 | * block when the transaction subsystem is in its frozen state. | 1101 | * in its frozen state. |
1092 | */ | 1102 | */ |
1093 | int | 1103 | int |
1094 | xfs_log_sbcount(xfs_mount_t *mp) | 1104 | xfs_log_sbcount(xfs_mount_t *mp) |
@@ -1096,7 +1106,8 @@ xfs_log_sbcount(xfs_mount_t *mp) | |||
1096 | xfs_trans_t *tp; | 1106 | xfs_trans_t *tp; |
1097 | int error; | 1107 | int error; |
1098 | 1108 | ||
1099 | if (!xfs_fs_writable(mp)) | 1109 | /* allow this to proceed during the freeze sequence... */ |
1110 | if (!xfs_fs_writable(mp, SB_FREEZE_COMPLETE)) | ||
1100 | return 0; | 1111 | return 0; |
1101 | 1112 | ||
1102 | xfs_icsb_sync_counters(mp, 0); | 1113 | xfs_icsb_sync_counters(mp, 0); |
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index b0447c86e7e2..22ccf69d4d3c 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h | |||
@@ -168,6 +168,7 @@ typedef struct xfs_mount { | |||
168 | /* low free space thresholds */ | 168 | /* low free space thresholds */ |
169 | struct xfs_kobj m_kobj; | 169 | struct xfs_kobj m_kobj; |
170 | 170 | ||
171 | struct workqueue_struct *m_buf_workqueue; | ||
171 | struct workqueue_struct *m_data_workqueue; | 172 | struct workqueue_struct *m_data_workqueue; |
172 | struct workqueue_struct *m_unwritten_workqueue; | 173 | struct workqueue_struct *m_unwritten_workqueue; |
173 | struct workqueue_struct *m_cil_workqueue; | 174 | struct workqueue_struct *m_cil_workqueue; |
@@ -320,10 +321,7 @@ typedef struct xfs_mod_sb { | |||
320 | 321 | ||
321 | /* | 322 | /* |
322 | * Per-ag incore structure, copies of information in agf and agi, to improve the | 323 | * Per-ag incore structure, copies of information in agf and agi, to improve the |
323 | * performance of allocation group selection. This is defined for the kernel | 324 | * performance of allocation group selection. |
324 | * only, and hence is defined here instead of in xfs_ag.h. You need the struct | ||
325 | * xfs_mount to be defined to look up a xfs_perag anyway (via mp->m_perag_tree), | ||
326 | * so this doesn't introduce any strange header file dependencies. | ||
327 | */ | 325 | */ |
328 | typedef struct xfs_perag { | 326 | typedef struct xfs_perag { |
329 | struct xfs_mount *pag_mount; /* owner filesystem */ | 327 | struct xfs_mount *pag_mount; /* owner filesystem */ |
@@ -384,7 +382,7 @@ extern int xfs_mount_log_sb(xfs_mount_t *, __int64_t); | |||
384 | extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); | 382 | extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); |
385 | extern int xfs_readsb(xfs_mount_t *, int); | 383 | extern int xfs_readsb(xfs_mount_t *, int); |
386 | extern void xfs_freesb(xfs_mount_t *); | 384 | extern void xfs_freesb(xfs_mount_t *); |
387 | extern int xfs_fs_writable(xfs_mount_t *); | 385 | extern bool xfs_fs_writable(struct xfs_mount *mp, int level); |
388 | extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t); | 386 | extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t); |
389 | 387 | ||
390 | extern int xfs_dev_is_read_only(struct xfs_mount *, char *); | 388 | extern int xfs_dev_is_read_only(struct xfs_mount *, char *); |
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index d68f23021af3..79fb19dd9c83 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c | |||
@@ -23,7 +23,6 @@ | |||
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 27 | #include "xfs_inode.h" |
29 | #include "xfs_ialloc.h" | 28 | #include "xfs_ialloc.h" |
@@ -38,7 +37,6 @@ | |||
38 | #include "xfs_trace.h" | 37 | #include "xfs_trace.h" |
39 | #include "xfs_icache.h" | 38 | #include "xfs_icache.h" |
40 | #include "xfs_cksum.h" | 39 | #include "xfs_cksum.h" |
41 | #include "xfs_dinode.h" | ||
42 | 40 | ||
43 | /* | 41 | /* |
44 | * The global quota manager. There is only one of these for the entire | 42 | * The global quota manager. There is only one of these for the entire |
@@ -1749,23 +1747,21 @@ xfs_qm_vop_dqalloc( | |||
1749 | xfs_iunlock(ip, lockflags); | 1747 | xfs_iunlock(ip, lockflags); |
1750 | if (O_udqpp) | 1748 | if (O_udqpp) |
1751 | *O_udqpp = uq; | 1749 | *O_udqpp = uq; |
1752 | else if (uq) | 1750 | else |
1753 | xfs_qm_dqrele(uq); | 1751 | xfs_qm_dqrele(uq); |
1754 | if (O_gdqpp) | 1752 | if (O_gdqpp) |
1755 | *O_gdqpp = gq; | 1753 | *O_gdqpp = gq; |
1756 | else if (gq) | 1754 | else |
1757 | xfs_qm_dqrele(gq); | 1755 | xfs_qm_dqrele(gq); |
1758 | if (O_pdqpp) | 1756 | if (O_pdqpp) |
1759 | *O_pdqpp = pq; | 1757 | *O_pdqpp = pq; |
1760 | else if (pq) | 1758 | else |
1761 | xfs_qm_dqrele(pq); | 1759 | xfs_qm_dqrele(pq); |
1762 | return 0; | 1760 | return 0; |
1763 | 1761 | ||
1764 | error_rele: | 1762 | error_rele: |
1765 | if (gq) | 1763 | xfs_qm_dqrele(gq); |
1766 | xfs_qm_dqrele(gq); | 1764 | xfs_qm_dqrele(uq); |
1767 | if (uq) | ||
1768 | xfs_qm_dqrele(uq); | ||
1769 | return error; | 1765 | return error; |
1770 | } | 1766 | } |
1771 | 1767 | ||
diff --git a/fs/xfs/xfs_qm_bhv.c b/fs/xfs/xfs_qm_bhv.c index 2c61e61b0205..3e52d5de7ae1 100644 --- a/fs/xfs/xfs_qm_bhv.c +++ b/fs/xfs/xfs_qm_bhv.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include "xfs_format.h" | 20 | #include "xfs_format.h" |
21 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_quota.h" | 23 | #include "xfs_quota.h" |
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c index 80f2d77d929a..74fca68e43b6 100644 --- a/fs/xfs/xfs_qm_syscalls.c +++ b/fs/xfs/xfs_qm_syscalls.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "xfs_trans_resv.h" | 26 | #include "xfs_trans_resv.h" |
27 | #include "xfs_bit.h" | 27 | #include "xfs_bit.h" |
28 | #include "xfs_sb.h" | 28 | #include "xfs_sb.h" |
29 | #include "xfs_ag.h" | ||
30 | #include "xfs_mount.h" | 29 | #include "xfs_mount.h" |
31 | #include "xfs_inode.h" | 30 | #include "xfs_inode.h" |
32 | #include "xfs_trans.h" | 31 | #include "xfs_trans.h" |
@@ -784,19 +783,21 @@ xfs_qm_log_quotaoff( | |||
784 | { | 783 | { |
785 | xfs_trans_t *tp; | 784 | xfs_trans_t *tp; |
786 | int error; | 785 | int error; |
787 | xfs_qoff_logitem_t *qoffi=NULL; | 786 | xfs_qoff_logitem_t *qoffi; |
788 | uint oldsbqflag=0; | 787 | |
788 | *qoffstartp = NULL; | ||
789 | 789 | ||
790 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF); | 790 | tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF); |
791 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_quotaoff, 0, 0); | 791 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_quotaoff, 0, 0); |
792 | if (error) | 792 | if (error) { |
793 | goto error0; | 793 | xfs_trans_cancel(tp, 0); |
794 | goto out; | ||
795 | } | ||
794 | 796 | ||
795 | qoffi = xfs_trans_get_qoff_item(tp, NULL, flags & XFS_ALL_QUOTA_ACCT); | 797 | qoffi = xfs_trans_get_qoff_item(tp, NULL, flags & XFS_ALL_QUOTA_ACCT); |
796 | xfs_trans_log_quotaoff_item(tp, qoffi); | 798 | xfs_trans_log_quotaoff_item(tp, qoffi); |
797 | 799 | ||
798 | spin_lock(&mp->m_sb_lock); | 800 | spin_lock(&mp->m_sb_lock); |
799 | oldsbqflag = mp->m_sb.sb_qflags; | ||
800 | mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL; | 801 | mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL; |
801 | spin_unlock(&mp->m_sb_lock); | 802 | spin_unlock(&mp->m_sb_lock); |
802 | 803 | ||
@@ -809,19 +810,11 @@ xfs_qm_log_quotaoff( | |||
809 | */ | 810 | */ |
810 | xfs_trans_set_sync(tp); | 811 | xfs_trans_set_sync(tp); |
811 | error = xfs_trans_commit(tp, 0); | 812 | error = xfs_trans_commit(tp, 0); |
813 | if (error) | ||
814 | goto out; | ||
812 | 815 | ||
813 | error0: | ||
814 | if (error) { | ||
815 | xfs_trans_cancel(tp, 0); | ||
816 | /* | ||
817 | * No one else is modifying sb_qflags, so this is OK. | ||
818 | * We still hold the quotaofflock. | ||
819 | */ | ||
820 | spin_lock(&mp->m_sb_lock); | ||
821 | mp->m_sb.sb_qflags = oldsbqflag; | ||
822 | spin_unlock(&mp->m_sb_lock); | ||
823 | } | ||
824 | *qoffstartp = qoffi; | 816 | *qoffstartp = qoffi; |
817 | out: | ||
825 | return error; | 818 | return error; |
826 | } | 819 | } |
827 | 820 | ||
diff --git a/fs/xfs/xfs_quotaops.c b/fs/xfs/xfs_quotaops.c index b238027df987..7542bbeca6a1 100644 --- a/fs/xfs/xfs_quotaops.c +++ b/fs/xfs/xfs_quotaops.c | |||
@@ -19,8 +19,6 @@ | |||
19 | #include "xfs_format.h" | 19 | #include "xfs_format.h" |
20 | #include "xfs_log_format.h" | 20 | #include "xfs_log_format.h" |
21 | #include "xfs_trans_resv.h" | 21 | #include "xfs_trans_resv.h" |
22 | #include "xfs_sb.h" | ||
23 | #include "xfs_ag.h" | ||
24 | #include "xfs_mount.h" | 22 | #include "xfs_mount.h" |
25 | #include "xfs_inode.h" | 23 | #include "xfs_inode.h" |
26 | #include "xfs_quota.h" | 24 | #include "xfs_quota.h" |
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index e1175ea9b551..f2079b6911cc 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_bit.h" | 24 | #include "xfs_bit.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
29 | #include "xfs_bmap.h" | 27 | #include "xfs_bmap.h" |
@@ -36,7 +34,6 @@ | |||
36 | #include "xfs_trace.h" | 34 | #include "xfs_trace.h" |
37 | #include "xfs_buf.h" | 35 | #include "xfs_buf.h" |
38 | #include "xfs_icache.h" | 36 | #include "xfs_icache.h" |
39 | #include "xfs_dinode.h" | ||
40 | #include "xfs_rtalloc.h" | 37 | #include "xfs_rtalloc.h" |
41 | 38 | ||
42 | 39 | ||
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 206b97fd1d8a..19cbda196369 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c | |||
@@ -21,9 +21,7 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_inum.h" | ||
25 | #include "xfs_sb.h" | 24 | #include "xfs_sb.h" |
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_da_format.h" | 26 | #include "xfs_da_format.h" |
29 | #include "xfs_inode.h" | 27 | #include "xfs_inode.h" |
@@ -44,7 +42,6 @@ | |||
44 | #include "xfs_icache.h" | 42 | #include "xfs_icache.h" |
45 | #include "xfs_trace.h" | 43 | #include "xfs_trace.h" |
46 | #include "xfs_icreate_item.h" | 44 | #include "xfs_icreate_item.h" |
47 | #include "xfs_dinode.h" | ||
48 | #include "xfs_filestream.h" | 45 | #include "xfs_filestream.h" |
49 | #include "xfs_quota.h" | 46 | #include "xfs_quota.h" |
50 | #include "xfs_sysfs.h" | 47 | #include "xfs_sysfs.h" |
@@ -796,8 +793,7 @@ xfs_open_devices( | |||
796 | out_free_ddev_targ: | 793 | out_free_ddev_targ: |
797 | xfs_free_buftarg(mp, mp->m_ddev_targp); | 794 | xfs_free_buftarg(mp, mp->m_ddev_targp); |
798 | out_close_rtdev: | 795 | out_close_rtdev: |
799 | if (rtdev) | 796 | xfs_blkdev_put(rtdev); |
800 | xfs_blkdev_put(rtdev); | ||
801 | out_close_logdev: | 797 | out_close_logdev: |
802 | if (logdev && logdev != ddev) | 798 | if (logdev && logdev != ddev) |
803 | xfs_blkdev_put(logdev); | 799 | xfs_blkdev_put(logdev); |
@@ -842,10 +838,15 @@ STATIC int | |||
842 | xfs_init_mount_workqueues( | 838 | xfs_init_mount_workqueues( |
843 | struct xfs_mount *mp) | 839 | struct xfs_mount *mp) |
844 | { | 840 | { |
841 | mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s", | ||
842 | WQ_MEM_RECLAIM|WQ_FREEZABLE, 1, mp->m_fsname); | ||
843 | if (!mp->m_buf_workqueue) | ||
844 | goto out; | ||
845 | |||
845 | mp->m_data_workqueue = alloc_workqueue("xfs-data/%s", | 846 | mp->m_data_workqueue = alloc_workqueue("xfs-data/%s", |
846 | WQ_MEM_RECLAIM|WQ_FREEZABLE, 0, mp->m_fsname); | 847 | WQ_MEM_RECLAIM|WQ_FREEZABLE, 0, mp->m_fsname); |
847 | if (!mp->m_data_workqueue) | 848 | if (!mp->m_data_workqueue) |
848 | goto out; | 849 | goto out_destroy_buf; |
849 | 850 | ||
850 | mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s", | 851 | mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s", |
851 | WQ_MEM_RECLAIM|WQ_FREEZABLE, 0, mp->m_fsname); | 852 | WQ_MEM_RECLAIM|WQ_FREEZABLE, 0, mp->m_fsname); |
@@ -863,7 +864,7 @@ xfs_init_mount_workqueues( | |||
863 | goto out_destroy_cil; | 864 | goto out_destroy_cil; |
864 | 865 | ||
865 | mp->m_log_workqueue = alloc_workqueue("xfs-log/%s", | 866 | mp->m_log_workqueue = alloc_workqueue("xfs-log/%s", |
866 | WQ_FREEZABLE, 0, mp->m_fsname); | 867 | WQ_FREEZABLE|WQ_HIGHPRI, 0, mp->m_fsname); |
867 | if (!mp->m_log_workqueue) | 868 | if (!mp->m_log_workqueue) |
868 | goto out_destroy_reclaim; | 869 | goto out_destroy_reclaim; |
869 | 870 | ||
@@ -884,6 +885,8 @@ out_destroy_unwritten: | |||
884 | destroy_workqueue(mp->m_unwritten_workqueue); | 885 | destroy_workqueue(mp->m_unwritten_workqueue); |
885 | out_destroy_data_iodone_queue: | 886 | out_destroy_data_iodone_queue: |
886 | destroy_workqueue(mp->m_data_workqueue); | 887 | destroy_workqueue(mp->m_data_workqueue); |
888 | out_destroy_buf: | ||
889 | destroy_workqueue(mp->m_buf_workqueue); | ||
887 | out: | 890 | out: |
888 | return -ENOMEM; | 891 | return -ENOMEM; |
889 | } | 892 | } |
@@ -898,6 +901,7 @@ xfs_destroy_mount_workqueues( | |||
898 | destroy_workqueue(mp->m_cil_workqueue); | 901 | destroy_workqueue(mp->m_cil_workqueue); |
899 | destroy_workqueue(mp->m_data_workqueue); | 902 | destroy_workqueue(mp->m_data_workqueue); |
900 | destroy_workqueue(mp->m_unwritten_workqueue); | 903 | destroy_workqueue(mp->m_unwritten_workqueue); |
904 | destroy_workqueue(mp->m_buf_workqueue); | ||
901 | } | 905 | } |
902 | 906 | ||
903 | /* | 907 | /* |
@@ -1000,7 +1004,6 @@ xfs_fs_evict_inode( | |||
1000 | clear_inode(inode); | 1004 | clear_inode(inode); |
1001 | XFS_STATS_INC(vn_rele); | 1005 | XFS_STATS_INC(vn_rele); |
1002 | XFS_STATS_INC(vn_remove); | 1006 | XFS_STATS_INC(vn_remove); |
1003 | XFS_STATS_DEC(vn_active); | ||
1004 | 1007 | ||
1005 | xfs_inactive(ip); | 1008 | xfs_inactive(ip); |
1006 | } | 1009 | } |
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c index 02ae62a998e0..25791df6f638 100644 --- a/fs/xfs/xfs_symlink.c +++ b/fs/xfs/xfs_symlink.c | |||
@@ -23,8 +23,6 @@ | |||
23 | #include "xfs_log_format.h" | 23 | #include "xfs_log_format.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_bit.h" | 25 | #include "xfs_bit.h" |
26 | #include "xfs_sb.h" | ||
27 | #include "xfs_ag.h" | ||
28 | #include "xfs_mount.h" | 26 | #include "xfs_mount.h" |
29 | #include "xfs_da_format.h" | 27 | #include "xfs_da_format.h" |
30 | #include "xfs_da_btree.h" | 28 | #include "xfs_da_btree.h" |
@@ -42,7 +40,6 @@ | |||
42 | #include "xfs_symlink.h" | 40 | #include "xfs_symlink.h" |
43 | #include "xfs_trans.h" | 41 | #include "xfs_trans.h" |
44 | #include "xfs_log.h" | 42 | #include "xfs_log.h" |
45 | #include "xfs_dinode.h" | ||
46 | 43 | ||
47 | /* ----- Kernel only functions below ----- */ | 44 | /* ----- Kernel only functions below ----- */ |
48 | STATIC int | 45 | STATIC int |
diff --git a/fs/xfs/xfs_trace.c b/fs/xfs/xfs_trace.c index 1e85bcd0e418..13a029806805 100644 --- a/fs/xfs/xfs_trace.c +++ b/fs/xfs/xfs_trace.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_da_format.h" | 25 | #include "xfs_da_format.h" |
28 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c index 30e8e3410955..fa3135b9bf04 100644 --- a/fs/xfs/xfs_trans.c +++ b/fs/xfs/xfs_trans.c | |||
@@ -22,8 +22,6 @@ | |||
22 | #include "xfs_format.h" | 22 | #include "xfs_format.h" |
23 | #include "xfs_log_format.h" | 23 | #include "xfs_log_format.h" |
24 | #include "xfs_trans_resv.h" | 24 | #include "xfs_trans_resv.h" |
25 | #include "xfs_sb.h" | ||
26 | #include "xfs_ag.h" | ||
27 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
28 | #include "xfs_inode.h" | 26 | #include "xfs_inode.h" |
29 | #include "xfs_extent_busy.h" | 27 | #include "xfs_extent_busy.h" |
diff --git a/fs/xfs/xfs_trans_ail.c b/fs/xfs/xfs_trans_ail.c index 859482f53b5a..573aefb5a573 100644 --- a/fs/xfs/xfs_trans_ail.c +++ b/fs/xfs/xfs_trans_ail.c | |||
@@ -18,10 +18,9 @@ | |||
18 | */ | 18 | */ |
19 | #include "xfs.h" | 19 | #include "xfs.h" |
20 | #include "xfs_fs.h" | 20 | #include "xfs_fs.h" |
21 | #include "xfs_format.h" | ||
21 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
26 | #include "xfs_trans.h" | 25 | #include "xfs_trans.h" |
27 | #include "xfs_trans_priv.h" | 26 | #include "xfs_trans_priv.h" |
diff --git a/fs/xfs/xfs_trans_buf.c b/fs/xfs/xfs_trans_buf.c index e2b2216b1635..0a4d4ab6d9a9 100644 --- a/fs/xfs/xfs_trans_buf.c +++ b/fs/xfs/xfs_trans_buf.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
28 | #include "xfs_trans.h" | 26 | #include "xfs_trans.h" |
@@ -229,13 +227,6 @@ xfs_trans_getsb(xfs_trans_t *tp, | |||
229 | return bp; | 227 | return bp; |
230 | } | 228 | } |
231 | 229 | ||
232 | #ifdef DEBUG | ||
233 | xfs_buftarg_t *xfs_error_target; | ||
234 | int xfs_do_error; | ||
235 | int xfs_req_num; | ||
236 | int xfs_error_mod = 33; | ||
237 | #endif | ||
238 | |||
239 | /* | 230 | /* |
240 | * Get and lock the buffer for the caller if it is not already | 231 | * Get and lock the buffer for the caller if it is not already |
241 | * locked within the given transaction. If it has not yet been | 232 | * locked within the given transaction. If it has not yet been |
@@ -257,46 +248,11 @@ xfs_trans_read_buf_map( | |||
257 | struct xfs_buf **bpp, | 248 | struct xfs_buf **bpp, |
258 | const struct xfs_buf_ops *ops) | 249 | const struct xfs_buf_ops *ops) |
259 | { | 250 | { |
260 | xfs_buf_t *bp; | 251 | struct xfs_buf *bp = NULL; |
261 | xfs_buf_log_item_t *bip; | 252 | struct xfs_buf_log_item *bip; |
262 | int error; | 253 | int error; |
263 | 254 | ||
264 | *bpp = NULL; | 255 | *bpp = NULL; |
265 | if (!tp) { | ||
266 | bp = xfs_buf_read_map(target, map, nmaps, flags, ops); | ||
267 | if (!bp) | ||
268 | return (flags & XBF_TRYLOCK) ? | ||
269 | -EAGAIN : -ENOMEM; | ||
270 | |||
271 | if (bp->b_error) { | ||
272 | error = bp->b_error; | ||
273 | xfs_buf_ioerror_alert(bp, __func__); | ||
274 | XFS_BUF_UNDONE(bp); | ||
275 | xfs_buf_stale(bp); | ||
276 | xfs_buf_relse(bp); | ||
277 | |||
278 | /* bad CRC means corrupted metadata */ | ||
279 | if (error == -EFSBADCRC) | ||
280 | error = -EFSCORRUPTED; | ||
281 | return error; | ||
282 | } | ||
283 | #ifdef DEBUG | ||
284 | if (xfs_do_error) { | ||
285 | if (xfs_error_target == target) { | ||
286 | if (((xfs_req_num++) % xfs_error_mod) == 0) { | ||
287 | xfs_buf_relse(bp); | ||
288 | xfs_debug(mp, "Returning error!"); | ||
289 | return -EIO; | ||
290 | } | ||
291 | } | ||
292 | } | ||
293 | #endif | ||
294 | if (XFS_FORCED_SHUTDOWN(mp)) | ||
295 | goto shutdown_abort; | ||
296 | *bpp = bp; | ||
297 | return 0; | ||
298 | } | ||
299 | |||
300 | /* | 256 | /* |
301 | * If we find the buffer in the cache with this transaction | 257 | * If we find the buffer in the cache with this transaction |
302 | * pointer in its b_fsprivate2 field, then we know we already | 258 | * pointer in its b_fsprivate2 field, then we know we already |
@@ -305,49 +261,24 @@ xfs_trans_read_buf_map( | |||
305 | * If the buffer is not yet read in, then we read it in, increment | 261 | * If the buffer is not yet read in, then we read it in, increment |
306 | * the lock recursion count, and return it to the caller. | 262 | * the lock recursion count, and return it to the caller. |
307 | */ | 263 | */ |
308 | bp = xfs_trans_buf_item_match(tp, target, map, nmaps); | 264 | if (tp) |
309 | if (bp != NULL) { | 265 | bp = xfs_trans_buf_item_match(tp, target, map, nmaps); |
266 | if (bp) { | ||
310 | ASSERT(xfs_buf_islocked(bp)); | 267 | ASSERT(xfs_buf_islocked(bp)); |
311 | ASSERT(bp->b_transp == tp); | 268 | ASSERT(bp->b_transp == tp); |
312 | ASSERT(bp->b_fspriv != NULL); | 269 | ASSERT(bp->b_fspriv != NULL); |
313 | ASSERT(!bp->b_error); | 270 | ASSERT(!bp->b_error); |
314 | if (!(XFS_BUF_ISDONE(bp))) { | 271 | ASSERT(bp->b_flags & XBF_DONE); |
315 | trace_xfs_trans_read_buf_io(bp, _RET_IP_); | 272 | |
316 | ASSERT(!XFS_BUF_ISASYNC(bp)); | ||
317 | ASSERT(bp->b_iodone == NULL); | ||
318 | XFS_BUF_READ(bp); | ||
319 | bp->b_ops = ops; | ||
320 | |||
321 | error = xfs_buf_submit_wait(bp); | ||
322 | if (error) { | ||
323 | if (!XFS_FORCED_SHUTDOWN(mp)) | ||
324 | xfs_buf_ioerror_alert(bp, __func__); | ||
325 | xfs_buf_relse(bp); | ||
326 | /* | ||
327 | * We can gracefully recover from most read | ||
328 | * errors. Ones we can't are those that happen | ||
329 | * after the transaction's already dirty. | ||
330 | */ | ||
331 | if (tp->t_flags & XFS_TRANS_DIRTY) | ||
332 | xfs_force_shutdown(tp->t_mountp, | ||
333 | SHUTDOWN_META_IO_ERROR); | ||
334 | /* bad CRC means corrupted metadata */ | ||
335 | if (error == -EFSBADCRC) | ||
336 | error = -EFSCORRUPTED; | ||
337 | return error; | ||
338 | } | ||
339 | } | ||
340 | /* | 273 | /* |
341 | * We never locked this buf ourselves, so we shouldn't | 274 | * We never locked this buf ourselves, so we shouldn't |
342 | * brelse it either. Just get out. | 275 | * brelse it either. Just get out. |
343 | */ | 276 | */ |
344 | if (XFS_FORCED_SHUTDOWN(mp)) { | 277 | if (XFS_FORCED_SHUTDOWN(mp)) { |
345 | trace_xfs_trans_read_buf_shut(bp, _RET_IP_); | 278 | trace_xfs_trans_read_buf_shut(bp, _RET_IP_); |
346 | *bpp = NULL; | ||
347 | return -EIO; | 279 | return -EIO; |
348 | } | 280 | } |
349 | 281 | ||
350 | |||
351 | bip = bp->b_fspriv; | 282 | bip = bp->b_fspriv; |
352 | bip->bli_recur++; | 283 | bip->bli_recur++; |
353 | 284 | ||
@@ -358,17 +289,29 @@ xfs_trans_read_buf_map( | |||
358 | } | 289 | } |
359 | 290 | ||
360 | bp = xfs_buf_read_map(target, map, nmaps, flags, ops); | 291 | bp = xfs_buf_read_map(target, map, nmaps, flags, ops); |
361 | if (bp == NULL) { | 292 | if (!bp) { |
362 | *bpp = NULL; | 293 | if (!(flags & XBF_TRYLOCK)) |
363 | return (flags & XBF_TRYLOCK) ? | 294 | return -ENOMEM; |
364 | 0 : -ENOMEM; | 295 | return tp ? 0 : -EAGAIN; |
365 | } | 296 | } |
297 | |||
298 | /* | ||
299 | * If we've had a read error, then the contents of the buffer are | ||
300 | * invalid and should not be used. To ensure that a followup read tries | ||
301 | * to pull the buffer from disk again, we clear the XBF_DONE flag and | ||
302 | * mark the buffer stale. This ensures that anyone who has a current | ||
303 | * reference to the buffer will interpret it's contents correctly and | ||
304 | * future cache lookups will also treat it as an empty, uninitialised | ||
305 | * buffer. | ||
306 | */ | ||
366 | if (bp->b_error) { | 307 | if (bp->b_error) { |
367 | error = bp->b_error; | 308 | error = bp->b_error; |
309 | if (!XFS_FORCED_SHUTDOWN(mp)) | ||
310 | xfs_buf_ioerror_alert(bp, __func__); | ||
311 | bp->b_flags &= ~XBF_DONE; | ||
368 | xfs_buf_stale(bp); | 312 | xfs_buf_stale(bp); |
369 | XFS_BUF_DONE(bp); | 313 | |
370 | xfs_buf_ioerror_alert(bp, __func__); | 314 | if (tp && (tp->t_flags & XFS_TRANS_DIRTY)) |
371 | if (tp->t_flags & XFS_TRANS_DIRTY) | ||
372 | xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR); | 315 | xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR); |
373 | xfs_buf_relse(bp); | 316 | xfs_buf_relse(bp); |
374 | 317 | ||
@@ -377,33 +320,19 @@ xfs_trans_read_buf_map( | |||
377 | error = -EFSCORRUPTED; | 320 | error = -EFSCORRUPTED; |
378 | return error; | 321 | return error; |
379 | } | 322 | } |
380 | #ifdef DEBUG | 323 | |
381 | if (xfs_do_error && !(tp->t_flags & XFS_TRANS_DIRTY)) { | 324 | if (XFS_FORCED_SHUTDOWN(mp)) { |
382 | if (xfs_error_target == target) { | 325 | xfs_buf_relse(bp); |
383 | if (((xfs_req_num++) % xfs_error_mod) == 0) { | 326 | trace_xfs_trans_read_buf_shut(bp, _RET_IP_); |
384 | xfs_force_shutdown(tp->t_mountp, | 327 | return -EIO; |
385 | SHUTDOWN_META_IO_ERROR); | ||
386 | xfs_buf_relse(bp); | ||
387 | xfs_debug(mp, "Returning trans error!"); | ||
388 | return -EIO; | ||
389 | } | ||
390 | } | ||
391 | } | 328 | } |
392 | #endif | ||
393 | if (XFS_FORCED_SHUTDOWN(mp)) | ||
394 | goto shutdown_abort; | ||
395 | 329 | ||
396 | _xfs_trans_bjoin(tp, bp, 1); | 330 | if (tp) |
331 | _xfs_trans_bjoin(tp, bp, 1); | ||
397 | trace_xfs_trans_read_buf(bp->b_fspriv); | 332 | trace_xfs_trans_read_buf(bp->b_fspriv); |
398 | |||
399 | *bpp = bp; | 333 | *bpp = bp; |
400 | return 0; | 334 | return 0; |
401 | 335 | ||
402 | shutdown_abort: | ||
403 | trace_xfs_trans_read_buf_shut(bp, _RET_IP_); | ||
404 | xfs_buf_relse(bp); | ||
405 | *bpp = NULL; | ||
406 | return -EIO; | ||
407 | } | 336 | } |
408 | 337 | ||
409 | /* | 338 | /* |
diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index 846e061c2e98..76a16df55ef7 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
28 | #include "xfs_error.h" | 26 | #include "xfs_error.h" |
diff --git a/fs/xfs/xfs_trans_extfree.c b/fs/xfs/xfs_trans_extfree.c index 47978ba89dae..284397dd7990 100644 --- a/fs/xfs/xfs_trans_extfree.c +++ b/fs/xfs/xfs_trans_extfree.c | |||
@@ -18,10 +18,9 @@ | |||
18 | #include "xfs.h" | 18 | #include "xfs.h" |
19 | #include "xfs_fs.h" | 19 | #include "xfs_fs.h" |
20 | #include "xfs_shared.h" | 20 | #include "xfs_shared.h" |
21 | #include "xfs_format.h" | ||
21 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
26 | #include "xfs_trans.h" | 25 | #include "xfs_trans.h" |
27 | #include "xfs_trans_priv.h" | 26 | #include "xfs_trans_priv.h" |
diff --git a/fs/xfs/xfs_trans_inode.c b/fs/xfs/xfs_trans_inode.c index cdb4d86520e1..17280cd71934 100644 --- a/fs/xfs/xfs_trans_inode.c +++ b/fs/xfs/xfs_trans_inode.c | |||
@@ -21,8 +21,6 @@ | |||
21 | #include "xfs_format.h" | 21 | #include "xfs_format.h" |
22 | #include "xfs_log_format.h" | 22 | #include "xfs_log_format.h" |
23 | #include "xfs_trans_resv.h" | 23 | #include "xfs_trans_resv.h" |
24 | #include "xfs_sb.h" | ||
25 | #include "xfs_ag.h" | ||
26 | #include "xfs_mount.h" | 24 | #include "xfs_mount.h" |
27 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |
28 | #include "xfs_trans.h" | 26 | #include "xfs_trans.h" |
diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 93455b998041..69f6e475de97 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c | |||
@@ -20,8 +20,6 @@ | |||
20 | #include "xfs_format.h" | 20 | #include "xfs_format.h" |
21 | #include "xfs_log_format.h" | 21 | #include "xfs_log_format.h" |
22 | #include "xfs_trans_resv.h" | 22 | #include "xfs_trans_resv.h" |
23 | #include "xfs_sb.h" | ||
24 | #include "xfs_ag.h" | ||
25 | #include "xfs_mount.h" | 23 | #include "xfs_mount.h" |
26 | #include "xfs_da_format.h" | 24 | #include "xfs_da_format.h" |
27 | #include "xfs_inode.h" | 25 | #include "xfs_inode.h" |