diff options
author | Christoph Hellwig <hch@lst.de> | 2013-04-03 01:11:17 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-04-21 16:03:33 -0400 |
commit | 93848a999cf9b9e4f4f77dba843a48c393f33c59 (patch) | |
tree | 92c2fb4e741a8d70e70f9d31df308d1a30ecaef6 /fs/xfs/xfs_ialloc.c | |
parent | 3fe58f30b4fc3f8a9084b035a02bc0c67bee8d00 (diff) |
xfs: add version 3 inode format with CRCs
Add a new inode version with a larger core. The primary objective is
to allow for a crc of the inode, and location information (uuid and ino)
to verify it was written in the right place. We also extend it by:
a creation time (for Samba);
a changecount (for NFSv4);
a flush sequence (in LSN format for recovery);
an additional inode flags field; and
some additional padding.
These additional fields are not implemented yet, but already laid
out in the structure.
[dchinner@redhat.com] Added LSN and flags field, some factoring and rework to
capture all the necessary information in the crc calculation.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_ialloc.c')
-rw-r--r-- | fs/xfs/xfs_ialloc.c | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/fs/xfs/xfs_ialloc.c b/fs/xfs/xfs_ialloc.c index 6d0a4954aa8c..3039f829c96a 100644 --- a/fs/xfs/xfs_ialloc.c +++ b/fs/xfs/xfs_ialloc.c | |||
@@ -167,6 +167,7 @@ xfs_ialloc_inode_init( | |||
167 | int version; | 167 | int version; |
168 | int i, j; | 168 | int i, j; |
169 | xfs_daddr_t d; | 169 | xfs_daddr_t d; |
170 | xfs_ino_t ino = 0; | ||
170 | 171 | ||
171 | /* | 172 | /* |
172 | * Loop over the new block(s), filling in the inodes. | 173 | * Loop over the new block(s), filling in the inodes. |
@@ -185,13 +186,29 @@ xfs_ialloc_inode_init( | |||
185 | } | 186 | } |
186 | 187 | ||
187 | /* | 188 | /* |
188 | * Figure out what version number to use in the inodes we create. | 189 | * Figure out what version number to use in the inodes we create. If |
189 | * If the superblock version has caught up to the one that supports | 190 | * the superblock version has caught up to the one that supports the new |
190 | * the new inode format, then use the new inode version. Otherwise | 191 | * inode format, then use the new inode version. Otherwise use the old |
191 | * use the old version so that old kernels will continue to be | 192 | * version so that old kernels will continue to be able to use the file |
192 | * able to use the file system. | 193 | * system. |
194 | * | ||
195 | * For v3 inodes, we also need to write the inode number into the inode, | ||
196 | * so calculate the first inode number of the chunk here as | ||
197 | * XFS_OFFBNO_TO_AGINO() only works within a filesystem block, not | ||
198 | * across multiple filesystem blocks (such as a cluster) and so cannot | ||
199 | * be used in the cluster buffer loop below. | ||
200 | * | ||
201 | * Further, because we are writing the inode directly into the buffer | ||
202 | * and calculating a CRC on the entire inode, we have ot log the entire | ||
203 | * inode so that the entire range the CRC covers is present in the log. | ||
204 | * That means for v3 inode we log the entire buffer rather than just the | ||
205 | * inode cores. | ||
193 | */ | 206 | */ |
194 | if (xfs_sb_version_hasnlink(&mp->m_sb)) | 207 | if (xfs_sb_version_hascrc(&mp->m_sb)) { |
208 | version = 3; | ||
209 | ino = XFS_AGINO_TO_INO(mp, agno, | ||
210 | XFS_OFFBNO_TO_AGINO(mp, agbno, 0)); | ||
211 | } else if (xfs_sb_version_hasnlink(&mp->m_sb)) | ||
195 | version = 2; | 212 | version = 2; |
196 | else | 213 | else |
197 | version = 1; | 214 | version = 1; |
@@ -214,17 +231,32 @@ xfs_ialloc_inode_init( | |||
214 | * individual transactions causing a lot of log traffic. | 231 | * individual transactions causing a lot of log traffic. |
215 | */ | 232 | */ |
216 | fbuf->b_ops = &xfs_inode_buf_ops; | 233 | fbuf->b_ops = &xfs_inode_buf_ops; |
217 | xfs_buf_zero(fbuf, 0, ninodes << mp->m_sb.sb_inodelog); | 234 | xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length)); |
218 | for (i = 0; i < ninodes; i++) { | 235 | for (i = 0; i < ninodes; i++) { |
219 | int ioffset = i << mp->m_sb.sb_inodelog; | 236 | int ioffset = i << mp->m_sb.sb_inodelog; |
220 | uint isize = sizeof(struct xfs_dinode); | 237 | uint isize = xfs_dinode_size(version); |
221 | 238 | ||
222 | free = xfs_make_iptr(mp, fbuf, i); | 239 | free = xfs_make_iptr(mp, fbuf, i); |
223 | free->di_magic = cpu_to_be16(XFS_DINODE_MAGIC); | 240 | free->di_magic = cpu_to_be16(XFS_DINODE_MAGIC); |
224 | free->di_version = version; | 241 | free->di_version = version; |
225 | free->di_gen = cpu_to_be32(gen); | 242 | free->di_gen = cpu_to_be32(gen); |
226 | free->di_next_unlinked = cpu_to_be32(NULLAGINO); | 243 | free->di_next_unlinked = cpu_to_be32(NULLAGINO); |
227 | xfs_trans_log_buf(tp, fbuf, ioffset, ioffset + isize - 1); | 244 | |
245 | if (version == 3) { | ||
246 | free->di_ino = cpu_to_be64(ino); | ||
247 | ino++; | ||
248 | uuid_copy(&free->di_uuid, &mp->m_sb.sb_uuid); | ||
249 | xfs_dinode_calc_crc(mp, free); | ||
250 | } else { | ||
251 | /* just log the inode core */ | ||
252 | xfs_trans_log_buf(tp, fbuf, ioffset, | ||
253 | ioffset + isize - 1); | ||
254 | } | ||
255 | } | ||
256 | if (version == 3) { | ||
257 | /* need to log the entire buffer */ | ||
258 | xfs_trans_log_buf(tp, fbuf, 0, | ||
259 | BBTOB(fbuf->b_length) - 1); | ||
228 | } | 260 | } |
229 | xfs_trans_inode_alloc_buf(tp, fbuf); | 261 | xfs_trans_inode_alloc_buf(tp, fbuf); |
230 | } | 262 | } |