Commit 81591fe2db19d0fc1ec2aaaa6a790a5ab97ac3ab

Authored by Christoph Hellwig
Committed by Niv Sardi
1 parent d42f08f61c

[XFS] kill xfs_dinode_core_t

Now that we have a separate xfs_icdinode_t for the in-core inode which
gets logged there is no need anymore for the xfs_dinode vs xfs_dinode_core
split - the fact that part of the structure gets logged through the inode
log item and a small part not can better be described in a comment.

All sizeof operations on the dinode_core either really wanted the
icdinode and are switched to that one, or had already added the size
of the agi unlinked list pointer.  Later both will be replaced with
helpers once we get the larger CRC-enabled dinode.

Removing the data and attribute fork unions also has the advantage that
xfs_dinode.h doesn't need to pull in every header under the sun.

While we're at it also add some more comments describing the dinode
structure.

(First sent on October 7th)

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Niv Sardi <xaiki@sgi.com>

Showing 9 changed files with 124 additions and 141 deletions Side-by-side Diff

... ... @@ -18,32 +18,32 @@
18 18 #ifndef __XFS_DINODE_H__
19 19 #define __XFS_DINODE_H__
20 20  
21   -struct xfs_buf;
22   -struct xfs_mount;
23   -
24 21 #define XFS_DINODE_VERSION_1 1
25 22 #define XFS_DINODE_VERSION_2 2
26 23 #define XFS_DINODE_GOOD_VERSION(v) \
27 24 (((v) == XFS_DINODE_VERSION_1 || (v) == XFS_DINODE_VERSION_2))
28 25 #define XFS_DINODE_MAGIC 0x494e /* 'IN' */
29 26  
30   -/*
31   - * Disk inode structure.
32   - * This is just the header; the inode is expanded to fill a variable size
33   - * with the last field expanding. It is split into the core and "other"
34   - * because we only need the core part in the in-core inode.
35   - */
36 27 typedef struct xfs_timestamp {
37 28 __be32 t_sec; /* timestamp seconds */
38 29 __be32 t_nsec; /* timestamp nanoseconds */
39 30 } xfs_timestamp_t;
40 31  
41 32 /*
42   - * Note: Coordinate changes to this structure with the XFS_DI_* #defines
43   - * below, the offsets table in xfs_ialloc_log_di() and struct xfs_icdinode
44   - * in xfs_inode.h.
  33 + * On-disk inode structure.
  34 + *
  35 + * This is just the header or "dinode core", the inode is expanded to fill a
  36 + * variable size the leftover area split into a data and an attribute fork.
  37 + * The format of the data and attribute fork depends on the format of the
  38 + * inode as indicated by di_format and di_aformat. To access the data and
  39 + * attribute use the XFS_DFORK_PTR, XFS_DFORK_DPTR, and XFS_DFORK_PTR macros
  40 + * below.
  41 + *
  42 + * There is a very similar struct icdinode in xfs_inode which matches the
  43 + * layout of the first 96 bytes of this structure, but is kept in native
  44 + * format instead of big endian.
45 45 */
46   -typedef struct xfs_dinode_core {
  46 +typedef struct xfs_dinode {
47 47 __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */
48 48 __be16 di_mode; /* mode and type of file */
49 49 __u8 di_version; /* inode version */
50 50  
51 51  
... ... @@ -69,34 +69,13 @@
69 69 __be16 di_dmstate; /* DMIG state info */
70 70 __be16 di_flags; /* random flags, XFS_DIFLAG_... */
71 71 __be32 di_gen; /* generation number */
72   -} xfs_dinode_core_t;
73 72  
  73 + /* di_next_unlinked is the only non-core field in the old dinode */
  74 + __be32 di_next_unlinked;/* agi unlinked list ptr */
  75 +} __attribute__((packed)) xfs_dinode_t;
  76 +
74 77 #define DI_MAX_FLUSH 0xffff
75 78  
76   -typedef struct xfs_dinode
77   -{
78   - xfs_dinode_core_t di_core;
79   - /*
80   - * In adding anything between the core and the union, be
81   - * sure to update the macros like XFS_LITINO below.
82   - */
83   - __be32 di_next_unlinked;/* agi unlinked list ptr */
84   - union {
85   - xfs_bmdr_block_t di_bmbt; /* btree root block */
86   - xfs_bmbt_rec_32_t di_bmx[1]; /* extent list */
87   - xfs_dir2_sf_t di_dir2sf; /* shortform directory v2 */
88   - char di_c[1]; /* local contents */
89   - __be32 di_dev; /* device for S_IFCHR/S_IFBLK */
90   - uuid_t di_muuid; /* mount point value */
91   - char di_symlink[1]; /* local symbolic link */
92   - } di_u;
93   - union {
94   - xfs_bmdr_block_t di_abmbt; /* btree root block */
95   - xfs_bmbt_rec_32_t di_abmx[1]; /* extent list */
96   - xfs_attr_shortform_t di_attrsf; /* shortform attribute list */
97   - } di_a;
98   -} xfs_dinode_t;
99   -
100 79 /*
101 80 * The 32 bit link count in the inode theoretically maxes out at UINT_MAX.
102 81 * Since the pathconf interface is signed, we use 2^31 - 1 instead.
... ... @@ -108,14 +87,12 @@
108 87 /*
109 88 * Values for di_format
110 89 */
111   -typedef enum xfs_dinode_fmt
112   -{
113   - XFS_DINODE_FMT_DEV, /* CHR, BLK: di_dev */
114   - XFS_DINODE_FMT_LOCAL, /* DIR, REG: di_c */
115   - /* LNK: di_symlink */
116   - XFS_DINODE_FMT_EXTENTS, /* DIR, REG, LNK: di_bmx */
117   - XFS_DINODE_FMT_BTREE, /* DIR, REG, LNK: di_bmbt */
118   - XFS_DINODE_FMT_UUID /* MNT: di_uuid */
  90 +typedef enum xfs_dinode_fmt {
  91 + XFS_DINODE_FMT_DEV, /* xfs_dev_t */
  92 + XFS_DINODE_FMT_LOCAL, /* bulk data */
  93 + XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */
  94 + XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */
  95 + XFS_DINODE_FMT_UUID /* uuid_t */
119 96 } xfs_dinode_fmt_t;
120 97  
121 98 /*
... ... @@ -136,8 +113,8 @@
136 113 /*
137 114 * Inode data & attribute fork sizes, per inode.
138 115 */
139   -#define XFS_DFORK_Q(dip) ((dip)->di_core.di_forkoff != 0)
140   -#define XFS_DFORK_BOFF(dip) ((int)((dip)->di_core.di_forkoff << 3))
  116 +#define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0)
  117 +#define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3))
141 118  
142 119 #define XFS_DFORK_DSIZE(dip,mp) \
143 120 (XFS_DFORK_Q(dip) ? \
144 121  
145 122  
146 123  
147 124  
148 125  
... ... @@ -152,21 +129,40 @@
152 129 XFS_DFORK_DSIZE(dip, mp) : \
153 130 XFS_DFORK_ASIZE(dip, mp))
154 131  
155   -#define XFS_DFORK_DPTR(dip) ((dip)->di_u.di_c)
  132 +/*
  133 + * Return pointers to the data or attribute forks.
  134 + */
  135 +#define XFS_DFORK_DPTR(dip) \
  136 + ((char *)(dip) + sizeof(struct xfs_dinode))
156 137 #define XFS_DFORK_APTR(dip) \
157   - ((dip)->di_u.di_c + XFS_DFORK_BOFF(dip))
  138 + (XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip))
158 139 #define XFS_DFORK_PTR(dip,w) \
159 140 ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip))
  141 +
160 142 #define XFS_DFORK_FORMAT(dip,w) \
161 143 ((w) == XFS_DATA_FORK ? \
162   - (dip)->di_core.di_format : \
163   - (dip)->di_core.di_aformat)
  144 + (dip)->di_format : \
  145 + (dip)->di_aformat)
164 146 #define XFS_DFORK_NEXTENTS(dip,w) \
165 147 ((w) == XFS_DATA_FORK ? \
166   - be32_to_cpu((dip)->di_core.di_nextents) : \
167   - be16_to_cpu((dip)->di_core.di_anextents))
  148 + be32_to_cpu((dip)->di_nextents) : \
  149 + be16_to_cpu((dip)->di_anextents))
168 150  
169 151 #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)XFS_BUF_PTR(bp))
  152 +
  153 +/*
  154 + * For block and character special files the 32bit dev_t is stored at the
  155 + * beginning of the data fork.
  156 + */
  157 +static inline xfs_dev_t xfs_dinode_get_rdev(struct xfs_dinode *dip)
  158 +{
  159 + return be32_to_cpu(*(__be32 *)XFS_DFORK_DPTR(dip));
  160 +}
  161 +
  162 +static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev)
  163 +{
  164 + *(__be32 *)XFS_DFORK_DPTR(dip) = cpu_to_be32(rdev);
  165 +}
170 166  
171 167 /*
172 168 * Values for di_flags
fs/xfs/xfs_dir2_sf.h
... ... @@ -34,13 +34,6 @@
34 34 struct xfs_trans;
35 35  
36 36 /*
37   - * Maximum size of a shortform directory.
38   - */
39   -#define XFS_DIR2_SF_MAX_SIZE \
40   - (XFS_DINODE_MAX_SIZE - (uint)sizeof(xfs_dinode_core_t) - \
41   - (uint)sizeof(xfs_agino_t))
42   -
43   -/*
44 37 * Inode number stored as 8 8-bit values.
45 38 */
46 39 typedef struct { __uint8_t i[8]; } xfs_dir2_ino8_t;
... ... @@ -355,12 +355,12 @@
355 355 xfs_biozero(fbuf, 0, ninodes << args.mp->m_sb.sb_inodelog);
356 356 for (i = 0; i < ninodes; i++) {
357 357 int ioffset = i << args.mp->m_sb.sb_inodelog;
358   - uint isize = sizeof(xfs_dinode_t) + sizeof(__be32);
  358 + uint isize = sizeof(struct xfs_dinode);
359 359  
360 360 free = XFS_MAKE_IPTR(args.mp, fbuf, i);
361   - free->di_core.di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
362   - free->di_core.di_version = version;
363   - free->di_core.di_gen = cpu_to_be32(gen);
  361 + free->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
  362 + free->di_version = version;
  363 + free->di_gen = cpu_to_be32(gen);
364 364 free->di_next_unlinked = cpu_to_be32(NULLAGINO);
365 365 xfs_trans_log_buf(tp, fbuf, ioffset, ioffset + isize - 1);
366 366 }
... ... @@ -174,8 +174,8 @@
174 174  
175 175 dip = (xfs_dinode_t *)xfs_buf_offset(bp,
176 176 (i << mp->m_sb.sb_inodelog));
177   - di_ok = be16_to_cpu(dip->di_core.di_magic) == XFS_DINODE_MAGIC &&
178   - XFS_DINODE_GOOD_VERSION(dip->di_core.di_version);
  177 + di_ok = be16_to_cpu(dip->di_magic) == XFS_DINODE_MAGIC &&
  178 + XFS_DINODE_GOOD_VERSION(dip->di_version);
179 179 if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
180 180 XFS_ERRTAG_ITOBP_INOTOBP,
181 181 XFS_RANDOM_ITOBP_INOTOBP))) {
... ... @@ -191,7 +191,7 @@
191 191 "daddr %lld #%d (magic=%x)",
192 192 XFS_BUFTARG_NAME(mp->m_ddev_targp),
193 193 (unsigned long long)imap->im_blkno, i,
194   - be16_to_cpu(dip->di_core.di_magic));
  194 + be16_to_cpu(dip->di_magic));
195 195 #endif
196 196 xfs_trans_brelse(tp, bp);
197 197 return XFS_ERROR(EFSCORRUPTED);
198 198  
199 199  
200 200  
201 201  
... ... @@ -350,26 +350,26 @@
350 350 XFS_IFORK_DSIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
351 351 error = 0;
352 352  
353   - if (unlikely(be32_to_cpu(dip->di_core.di_nextents) +
354   - be16_to_cpu(dip->di_core.di_anextents) >
355   - be64_to_cpu(dip->di_core.di_nblocks))) {
  353 + if (unlikely(be32_to_cpu(dip->di_nextents) +
  354 + be16_to_cpu(dip->di_anextents) >
  355 + be64_to_cpu(dip->di_nblocks))) {
356 356 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
357 357 "corrupt dinode %Lu, extent total = %d, nblocks = %Lu.",
358 358 (unsigned long long)ip->i_ino,
359   - (int)(be32_to_cpu(dip->di_core.di_nextents) +
360   - be16_to_cpu(dip->di_core.di_anextents)),
  359 + (int)(be32_to_cpu(dip->di_nextents) +
  360 + be16_to_cpu(dip->di_anextents)),
361 361 (unsigned long long)
362   - be64_to_cpu(dip->di_core.di_nblocks));
  362 + be64_to_cpu(dip->di_nblocks));
363 363 XFS_CORRUPTION_ERROR("xfs_iformat(1)", XFS_ERRLEVEL_LOW,
364 364 ip->i_mount, dip);
365 365 return XFS_ERROR(EFSCORRUPTED);
366 366 }
367 367  
368   - if (unlikely(dip->di_core.di_forkoff > ip->i_mount->m_sb.sb_inodesize)) {
  368 + if (unlikely(dip->di_forkoff > ip->i_mount->m_sb.sb_inodesize)) {
369 369 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
370 370 "corrupt dinode %Lu, forkoff = 0x%x.",
371 371 (unsigned long long)ip->i_ino,
372   - dip->di_core.di_forkoff);
  372 + dip->di_forkoff);
373 373 XFS_CORRUPTION_ERROR("xfs_iformat(2)", XFS_ERRLEVEL_LOW,
374 374 ip->i_mount, dip);
375 375 return XFS_ERROR(EFSCORRUPTED);
376 376  
377 377  
378 378  
... ... @@ -380,25 +380,25 @@
380 380 case S_IFCHR:
381 381 case S_IFBLK:
382 382 case S_IFSOCK:
383   - if (unlikely(dip->di_core.di_format != XFS_DINODE_FMT_DEV)) {
  383 + if (unlikely(dip->di_format != XFS_DINODE_FMT_DEV)) {
384 384 XFS_CORRUPTION_ERROR("xfs_iformat(3)", XFS_ERRLEVEL_LOW,
385 385 ip->i_mount, dip);
386 386 return XFS_ERROR(EFSCORRUPTED);
387 387 }
388 388 ip->i_d.di_size = 0;
389 389 ip->i_size = 0;
390   - ip->i_df.if_u2.if_rdev = be32_to_cpu(dip->di_u.di_dev);
  390 + ip->i_df.if_u2.if_rdev = xfs_dinode_get_rdev(dip);
391 391 break;
392 392  
393 393 case S_IFREG:
394 394 case S_IFLNK:
395 395 case S_IFDIR:
396   - switch (dip->di_core.di_format) {
  396 + switch (dip->di_format) {
397 397 case XFS_DINODE_FMT_LOCAL:
398 398 /*
399 399 * no local regular files yet
400 400 */
401   - if (unlikely((be16_to_cpu(dip->di_core.di_mode) & S_IFMT) == S_IFREG)) {
  401 + if (unlikely((be16_to_cpu(dip->di_mode) & S_IFMT) == S_IFREG)) {
402 402 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
403 403 "corrupt inode %Lu "
404 404 "(local format for regular file).",
... ... @@ -409,7 +409,7 @@
409 409 return XFS_ERROR(EFSCORRUPTED);
410 410 }
411 411  
412   - di_size = be64_to_cpu(dip->di_core.di_size);
  412 + di_size = be64_to_cpu(dip->di_size);
413 413 if (unlikely(di_size > XFS_DFORK_DSIZE(dip, ip->i_mount))) {
414 414 xfs_fs_repair_cmn_err(CE_WARN, ip->i_mount,
415 415 "corrupt inode %Lu "
... ... @@ -451,7 +451,7 @@
451 451 ip->i_afp = kmem_zone_zalloc(xfs_ifork_zone, KM_SLEEP);
452 452 ip->i_afp->if_ext_max =
453 453 XFS_IFORK_ASIZE(ip) / (uint)sizeof(xfs_bmbt_rec_t);
454   - switch (dip->di_core.di_aformat) {
  454 + switch (dip->di_aformat) {
455 455 case XFS_DINODE_FMT_LOCAL:
456 456 atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip);
457 457 size = be16_to_cpu(atp->hdr.totsize);
... ... @@ -663,7 +663,7 @@
663 663 void
664 664 xfs_dinode_from_disk(
665 665 xfs_icdinode_t *to,
666   - xfs_dinode_core_t *from)
  666 + xfs_dinode_t *from)
667 667 {
668 668 to->di_magic = be16_to_cpu(from->di_magic);
669 669 to->di_mode = be16_to_cpu(from->di_mode);
... ... @@ -697,7 +697,7 @@
697 697  
698 698 void
699 699 xfs_dinode_to_disk(
700   - xfs_dinode_core_t *to,
  700 + xfs_dinode_t *to,
701 701 xfs_icdinode_t *from)
702 702 {
703 703 to->di_magic = cpu_to_be16(from->di_magic);
... ... @@ -784,9 +784,7 @@
784 784 xfs_dic2xflags(
785 785 xfs_dinode_t *dip)
786 786 {
787   - xfs_dinode_core_t *dic = &dip->di_core;
788   -
789   - return _xfs_dic2xflags(be16_to_cpu(dic->di_flags)) |
  787 + return _xfs_dic2xflags(be16_to_cpu(dip->di_flags)) |
790 788 (XFS_DFORK_Q(dip) ? XFS_XFLAG_HASATTR : 0);
791 789 }
792 790  
793 791  
794 792  
... ... @@ -905,12 +903,12 @@
905 903 * If we got something that isn't an inode it means someone
906 904 * (nfs or dmi) has a stale handle.
907 905 */
908   - if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC) {
  906 + if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC) {
909 907 #ifdef DEBUG
910 908 xfs_fs_cmn_err(CE_ALERT, mp, "xfs_iread: "
911   - "dip->di_core.di_magic (0x%x) != "
  909 + "dip->di_magic (0x%x) != "
912 910 "XFS_DINODE_MAGIC (0x%x)",
913   - be16_to_cpu(dip->di_core.di_magic),
  911 + be16_to_cpu(dip->di_magic),
914 912 XFS_DINODE_MAGIC);
915 913 #endif /* DEBUG */
916 914 error = XFS_ERROR(EINVAL);
... ... @@ -924,8 +922,8 @@
924 922 * specific information.
925 923 * Otherwise, just get the truly permanent information.
926 924 */
927   - if (dip->di_core.di_mode) {
928   - xfs_dinode_from_disk(&ip->i_d, &dip->di_core);
  925 + if (dip->di_mode) {
  926 + xfs_dinode_from_disk(&ip->i_d, dip);
929 927 error = xfs_iformat(ip, dip);
930 928 if (error) {
931 929 #ifdef DEBUG
... ... @@ -936,10 +934,10 @@
936 934 goto out_brelse;
937 935 }
938 936 } else {
939   - ip->i_d.di_magic = be16_to_cpu(dip->di_core.di_magic);
940   - ip->i_d.di_version = dip->di_core.di_version;
941   - ip->i_d.di_gen = be32_to_cpu(dip->di_core.di_gen);
942   - ip->i_d.di_flushiter = be16_to_cpu(dip->di_core.di_flushiter);
  937 + ip->i_d.di_magic = be16_to_cpu(dip->di_magic);
  938 + ip->i_d.di_version = dip->di_version;
  939 + ip->i_d.di_gen = be32_to_cpu(dip->di_gen);
  940 + ip->i_d.di_flushiter = be16_to_cpu(dip->di_flushiter);
943 941 /*
944 942 * Make sure to pull in the mode here as well in
945 943 * case the inode is released without being used.
... ... @@ -2295,7 +2293,7 @@
2295 2293 * This is a temporary hack that would require a proper fix
2296 2294 * in the future.
2297 2295 */
2298   - dip->di_core.di_mode = 0;
  2296 + dip->di_mode = 0;
2299 2297  
2300 2298 if (delete) {
2301 2299 xfs_ifree_cluster(ip, tp, first_ino);
2302 2300  
... ... @@ -2909,15 +2907,16 @@
2909 2907 case XFS_DINODE_FMT_DEV:
2910 2908 if (iip->ili_format.ilf_fields & XFS_ILOG_DEV) {
2911 2909 ASSERT(whichfork == XFS_DATA_FORK);
2912   - dip->di_u.di_dev = cpu_to_be32(ip->i_df.if_u2.if_rdev);
  2910 + xfs_dinode_put_rdev(dip, ip->i_df.if_u2.if_rdev);
2913 2911 }
2914 2912 break;
2915 2913  
2916 2914 case XFS_DINODE_FMT_UUID:
2917 2915 if (iip->ili_format.ilf_fields & XFS_ILOG_UUID) {
2918 2916 ASSERT(whichfork == XFS_DATA_FORK);
2919   - memcpy(&dip->di_u.di_muuid, &ip->i_df.if_u2.if_uuid,
2920   - sizeof(uuid_t));
  2917 + memcpy(XFS_DFORK_DPTR(dip),
  2918 + &ip->i_df.if_u2.if_uuid,
  2919 + sizeof(uuid_t));
2921 2920 }
2922 2921 break;
2923 2922  
2924 2923  
... ... @@ -3295,11 +3294,11 @@
3295 3294 */
3296 3295 xfs_synchronize_atime(ip);
3297 3296  
3298   - if (XFS_TEST_ERROR(be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC,
  3297 + if (XFS_TEST_ERROR(be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC,
3299 3298 mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) {
3300 3299 xfs_cmn_err(XFS_PTAG_IFLUSH, CE_ALERT, mp,
3301 3300 "xfs_iflush: Bad inode %Lu magic number 0x%x, ptr 0x%p",
3302   - ip->i_ino, be16_to_cpu(dip->di_core.di_magic), dip);
  3301 + ip->i_ino, be16_to_cpu(dip->di_magic), dip);
3303 3302 goto corrupt_out;
3304 3303 }
3305 3304 if (XFS_TEST_ERROR(ip->i_d.di_magic != XFS_DINODE_MAGIC,
... ... @@ -3362,7 +3361,7 @@
3362 3361 * because if the inode is dirty at all the core must
3363 3362 * be.
3364 3363 */
3365   - xfs_dinode_to_disk(&dip->di_core, &ip->i_d);
  3364 + xfs_dinode_to_disk(dip, &ip->i_d);
3366 3365  
3367 3366 /* Wrap, we never let the log put out DI_MAX_FLUSH */
3368 3367 if (ip->i_d.di_flushiter == DI_MAX_FLUSH)
... ... @@ -3382,7 +3381,7 @@
3382 3381 * Convert it back.
3383 3382 */
3384 3383 ASSERT(ip->i_d.di_nlink <= XFS_MAXLINK_1);
3385   - dip->di_core.di_onlink = cpu_to_be16(ip->i_d.di_nlink);
  3384 + dip->di_onlink = cpu_to_be16(ip->i_d.di_nlink);
3386 3385 } else {
3387 3386 /*
3388 3387 * The superblock version has already been bumped,
3389 3388  
3390 3389  
... ... @@ -3390,12 +3389,12 @@
3390 3389 * format permanent.
3391 3390 */
3392 3391 ip->i_d.di_version = XFS_DINODE_VERSION_2;
3393   - dip->di_core.di_version = XFS_DINODE_VERSION_2;
  3392 + dip->di_version = XFS_DINODE_VERSION_2;
3394 3393 ip->i_d.di_onlink = 0;
3395   - dip->di_core.di_onlink = 0;
  3394 + dip->di_onlink = 0;
3396 3395 memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
3397   - memset(&(dip->di_core.di_pad[0]), 0,
3398   - sizeof(dip->di_core.di_pad));
  3396 + memset(&(dip->di_pad[0]), 0,
  3397 + sizeof(dip->di_pad));
3399 3398 ASSERT(ip->i_d.di_projid == 0);
3400 3399 }
3401 3400 }
... ... @@ -19,7 +19,6 @@
19 19 #define __XFS_INODE_H__
20 20  
21 21 struct xfs_dinode;
22   -struct xfs_dinode_core;
23 22 struct xfs_inode;
24 23  
25 24 /*
... ... @@ -112,7 +111,7 @@
112 111 } xfs_ictimestamp_t;
113 112  
114 113 /*
115   - * NOTE: This structure must be kept identical to struct xfs_dinode_core
  114 + * NOTE: This structure must be kept identical to struct xfs_dinode
116 115 * in xfs_dinode.h except for the endianess annotations.
117 116 */
118 117 typedef struct xfs_icdinode {
... ... @@ -553,8 +552,8 @@
553 552 struct xfs_inode *, struct xfs_dinode **,
554 553 struct xfs_buf **, xfs_daddr_t, uint, uint);
555 554 void xfs_dinode_from_disk(struct xfs_icdinode *,
556   - struct xfs_dinode_core *);
557   -void xfs_dinode_to_disk(struct xfs_dinode_core *,
  555 + struct xfs_dinode *);
  556 +void xfs_dinode_to_disk(struct xfs_dinode *,
558 557 struct xfs_icdinode *);
559 558 void xfs_idestroy_fork(struct xfs_inode *, int);
560 559 void xfs_idata_realloc(struct xfs_inode *, int, int);
fs/xfs/xfs_inode_item.c
... ... @@ -281,7 +281,7 @@
281 281 xfs_mark_inode_dirty_sync(ip);
282 282  
283 283 vecp->i_addr = (xfs_caddr_t)&ip->i_d;
284   - vecp->i_len = sizeof(xfs_dinode_core_t);
  284 + vecp->i_len = sizeof(struct xfs_icdinode);
285 285 XLOG_VEC_SET_TYPE(vecp, XLOG_REG_TYPE_ICORE);
286 286 vecp++;
287 287 nvecs++;
... ... @@ -125,13 +125,9 @@
125 125 xfs_bulkstat_one_dinode(
126 126 xfs_mount_t *mp, /* mount point for filesystem */
127 127 xfs_ino_t ino, /* inode number to get data for */
128   - xfs_dinode_t *dip, /* dinode inode pointer */
  128 + xfs_dinode_t *dic, /* dinode inode pointer */
129 129 xfs_bstat_t *buf) /* return buffer */
130 130 {
131   - xfs_dinode_core_t *dic; /* dinode core info pointer */
132   -
133   - dic = &dip->di_core;
134   -
135 131 /*
136 132 * The inode format changed when we moved the link count and
137 133 * made it 32 bits long. If this is an old format inode,
... ... @@ -162,7 +158,7 @@
162 158 buf->bs_mtime.tv_nsec = be32_to_cpu(dic->di_mtime.t_nsec);
163 159 buf->bs_ctime.tv_sec = be32_to_cpu(dic->di_ctime.t_sec);
164 160 buf->bs_ctime.tv_nsec = be32_to_cpu(dic->di_ctime.t_nsec);
165   - buf->bs_xflags = xfs_dic2xflags(dip);
  161 + buf->bs_xflags = xfs_dic2xflags(dic);
166 162 buf->bs_extsize = be32_to_cpu(dic->di_extsize) << mp->m_sb.sb_blocklog;
167 163 buf->bs_extents = be32_to_cpu(dic->di_nextents);
168 164 buf->bs_gen = be32_to_cpu(dic->di_gen);
... ... @@ -173,7 +169,7 @@
173 169  
174 170 switch (dic->di_format) {
175 171 case XFS_DINODE_FMT_DEV:
176   - buf->bs_rdev = be32_to_cpu(dip->di_u.di_dev);
  172 + buf->bs_rdev = xfs_dinode_get_rdev(dic);
177 173 buf->bs_blksize = BLKDEV_IOSIZE;
178 174 buf->bs_blocks = 0;
179 175 break;
180 176  
181 177  
... ... @@ -287,19 +283,19 @@
287 283 * to disk yet. This is a temporary hack that would require a proper
288 284 * fix in the future.
289 285 */
290   - if (be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC ||
291   - !XFS_DINODE_GOOD_VERSION(dip->di_core.di_version) ||
292   - !dip->di_core.di_mode)
  286 + if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC ||
  287 + !XFS_DINODE_GOOD_VERSION(dip->di_version) ||
  288 + !dip->di_mode)
293 289 return 0;
294 290 if (flags & BULKSTAT_FG_QUICK) {
295 291 *dipp = dip;
296 292 return 1;
297 293 }
298 294 /* BULKSTAT_FG_INLINE: if attr fork is local, or not there, use it */
299   - aformat = dip->di_core.di_aformat;
  295 + aformat = dip->di_aformat;
300 296 if ((XFS_DFORK_Q(dip) == 0) ||
301 297 (aformat == XFS_DINODE_FMT_LOCAL) ||
302   - (aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_core.di_anextents)) {
  298 + (aformat == XFS_DINODE_FMT_EXTENTS && !dip->di_anextents)) {
303 299 *dipp = dip;
304 300 return 1;
305 301 }
fs/xfs/xfs_log_recover.c
... ... @@ -2320,7 +2320,7 @@
2320 2320 * Make sure the place we're flushing out to really looks
2321 2321 * like an inode!
2322 2322 */
2323   - if (unlikely(be16_to_cpu(dip->di_core.di_magic) != XFS_DINODE_MAGIC)) {
  2323 + if (unlikely(be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC)) {
2324 2324 xfs_buf_relse(bp);
2325 2325 xfs_fs_cmn_err(CE_ALERT, mp,
2326 2326 "xfs_inode_recover: Bad inode magic number, dino ptr = 0x%p, dino bp = 0x%p, ino = %Ld",
2327 2327  
... ... @@ -2343,12 +2343,12 @@
2343 2343 }
2344 2344  
2345 2345 /* Skip replay when the on disk inode is newer than the log one */
2346   - if (dicp->di_flushiter < be16_to_cpu(dip->di_core.di_flushiter)) {
  2346 + if (dicp->di_flushiter < be16_to_cpu(dip->di_flushiter)) {
2347 2347 /*
2348 2348 * Deal with the wrap case, DI_MAX_FLUSH is less
2349 2349 * than smaller numbers
2350 2350 */
2351   - if (be16_to_cpu(dip->di_core.di_flushiter) == DI_MAX_FLUSH &&
  2351 + if (be16_to_cpu(dip->di_flushiter) == DI_MAX_FLUSH &&
2352 2352 dicp->di_flushiter < (DI_MAX_FLUSH >> 1)) {
2353 2353 /* do nothing */
2354 2354 } else {
... ... @@ -2408,7 +2408,7 @@
2408 2408 error = EFSCORRUPTED;
2409 2409 goto error;
2410 2410 }
2411   - if (unlikely(item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t))) {
  2411 + if (unlikely(item->ri_buf[1].i_len > sizeof(struct xfs_icdinode))) {
2412 2412 XFS_CORRUPTION_ERROR("xlog_recover_do_inode_trans(7)",
2413 2413 XFS_ERRLEVEL_LOW, mp, dicp);
2414 2414 xfs_buf_relse(bp);
2415 2415  
2416 2416  
2417 2417  
... ... @@ -2420,23 +2420,24 @@
2420 2420 }
2421 2421  
2422 2422 /* The core is in in-core format */
2423   - xfs_dinode_to_disk(&dip->di_core,
2424   - (xfs_icdinode_t *)item->ri_buf[1].i_addr);
  2423 + xfs_dinode_to_disk(dip, (xfs_icdinode_t *)item->ri_buf[1].i_addr);
2425 2424  
2426 2425 /* the rest is in on-disk format */
2427   - if (item->ri_buf[1].i_len > sizeof(xfs_dinode_core_t)) {
2428   - memcpy((xfs_caddr_t) dip + sizeof(xfs_dinode_core_t),
2429   - item->ri_buf[1].i_addr + sizeof(xfs_dinode_core_t),
2430   - item->ri_buf[1].i_len - sizeof(xfs_dinode_core_t));
  2426 + if (item->ri_buf[1].i_len > sizeof(struct xfs_icdinode)) {
  2427 + memcpy((xfs_caddr_t) dip + sizeof(struct xfs_icdinode),
  2428 + item->ri_buf[1].i_addr + sizeof(struct xfs_icdinode),
  2429 + item->ri_buf[1].i_len - sizeof(struct xfs_icdinode));
2431 2430 }
2432 2431  
2433 2432 fields = in_f->ilf_fields;
2434 2433 switch (fields & (XFS_ILOG_DEV | XFS_ILOG_UUID)) {
2435 2434 case XFS_ILOG_DEV:
2436   - dip->di_u.di_dev = cpu_to_be32(in_f->ilf_u.ilfu_rdev);
  2435 + xfs_dinode_put_rdev(dip, in_f->ilf_u.ilfu_rdev);
2437 2436 break;
2438 2437 case XFS_ILOG_UUID:
2439   - dip->di_u.di_muuid = in_f->ilf_u.ilfu_uuid;
  2438 + memcpy(XFS_DFORK_DPTR(dip),
  2439 + &in_f->ilf_u.ilfu_uuid,
  2440 + sizeof(uuid_t));
2440 2441 break;
2441 2442 }
2442 2443  
2443 2444  
... ... @@ -2452,12 +2453,12 @@
2452 2453 switch (fields & XFS_ILOG_DFORK) {
2453 2454 case XFS_ILOG_DDATA:
2454 2455 case XFS_ILOG_DEXT:
2455   - memcpy(&dip->di_u, src, len);
  2456 + memcpy(XFS_DFORK_DPTR(dip), src, len);
2456 2457 break;
2457 2458  
2458 2459 case XFS_ILOG_DBROOT:
2459 2460 xfs_bmbt_to_bmdr(mp, (struct xfs_btree_block *)src, len,
2460   - &dip->di_u.di_bmbt,
  2461 + (xfs_bmdr_block_t *)XFS_DFORK_DPTR(dip),
2461 2462 XFS_DFORK_DSIZE(dip, mp));
2462 2463 break;
2463 2464  
... ... @@ -575,8 +575,7 @@
575 575 mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT;
576 576 mp->m_agno_log = xfs_highbit32(sbp->sb_agcount - 1) + 1;
577 577 mp->m_agino_log = sbp->sb_inopblog + sbp->sb_agblklog;
578   - mp->m_litino = sbp->sb_inodesize -
579   - ((uint)sizeof(xfs_dinode_core_t) + (uint)sizeof(xfs_agino_t));
  578 + mp->m_litino = sbp->sb_inodesize - sizeof(struct xfs_dinode);
580 579 mp->m_blockmask = sbp->sb_blocksize - 1;
581 580 mp->m_blockwsize = sbp->sb_blocksize >> XFS_WORDLOG;
582 581 mp->m_blockwmask = mp->m_blockwsize - 1;