hc
2024-09-20 a36159eec6ca17402b0e146b86efaf76568dc353
kernel/fs/xfs/libxfs/xfs_log_format.h
....@@ -368,10 +368,13 @@
368368 * directly mirrors the xfs_dinode structure as it must contain all the same
369369 * information.
370370 */
371
-typedef struct xfs_ictimestamp {
371
+typedef uint64_t xfs_ictimestamp_t;
372
+
373
+/* Legacy timestamp encoding format. */
374
+struct xfs_legacy_ictimestamp {
372375 int32_t t_sec; /* timestamp seconds */
373376 int32_t t_nsec; /* timestamp nanoseconds */
374
-} xfs_ictimestamp_t;
377
+};
375378
376379 /*
377380 * Define the format of the inode core that is logged. This structure must be
....@@ -411,7 +414,16 @@
411414 /* start of the extended dinode, writable fields */
412415 uint32_t di_crc; /* CRC of the inode */
413416 uint64_t di_changecount; /* number of attribute changes */
414
- xfs_lsn_t di_lsn; /* flush sequence */
417
+
418
+ /*
419
+ * The LSN we write to this field during formatting is not a reflection
420
+ * of the current on-disk LSN. It should never be used for recovery
421
+ * sequencing, nor should it be recovered into the on-disk inode at all.
422
+ * See xlog_recover_inode_commit_pass2() and xfs_log_dinode_to_disk()
423
+ * for details.
424
+ */
425
+ xfs_lsn_t di_lsn;
426
+
415427 uint64_t di_flags2; /* more random flags */
416428 uint32_t di_cowextsize; /* basic cow extent size for file */
417429 uint8_t di_pad2[12]; /* more padding for future expansion */
....@@ -424,17 +436,15 @@
424436 /* structure must be padded to 64 bit alignment */
425437 };
426438
427
-static inline uint xfs_log_dinode_size(int version)
428
-{
429
- if (version == 3)
430
- return sizeof(struct xfs_log_dinode);
431
- return offsetof(struct xfs_log_dinode, di_next_unlinked);
432
-}
439
+#define xfs_log_dinode_size(mp) \
440
+ (xfs_sb_version_has_v3inode(&(mp)->m_sb) ? \
441
+ sizeof(struct xfs_log_dinode) : \
442
+ offsetof(struct xfs_log_dinode, di_next_unlinked))
433443
434444 /*
435
- * Buffer Log Format defintions
445
+ * Buffer Log Format definitions
436446 *
437
- * These are the physical dirty bitmap defintions for the log format structure.
447
+ * These are the physical dirty bitmap definitions for the log format structure.
438448 */
439449 #define XFS_BLF_CHUNK 128
440450 #define XFS_BLF_SHIFT 7
....@@ -462,11 +472,20 @@
462472 #define XFS_BLF_GDQUOT_BUF (1<<4)
463473
464474 /*
465
- * This is the structure used to lay out a buf log item in the
466
- * log. The data map describes which 128 byte chunks of the buffer
467
- * have been logged.
475
+ * This is the structure used to lay out a buf log item in the log. The data
476
+ * map describes which 128 byte chunks of the buffer have been logged.
477
+ *
478
+ * The placement of blf_map_size causes blf_data_map to start at an odd
479
+ * multiple of sizeof(unsigned int) offset within the struct. Because the data
480
+ * bitmap size will always be an even number, the end of the data_map (and
481
+ * therefore the structure) will also be at an odd multiple of sizeof(unsigned
482
+ * int). Some 64-bit compilers will insert padding at the end of the struct to
483
+ * ensure 64-bit alignment of blf_blkno, but 32-bit ones will not. Therefore,
484
+ * XFS_BLF_DATAMAP_SIZE must be an odd number to make the padding explicit and
485
+ * keep the structure size consistent between 32-bit and 64-bit platforms.
468486 */
469
-#define XFS_BLF_DATAMAP_SIZE ((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / NBWORD)
487
+#define __XFS_BLF_DATAMAP_SIZE ((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / NBWORD)
488
+#define XFS_BLF_DATAMAP_SIZE (__XFS_BLF_DATAMAP_SIZE + 1)
470489
471490 typedef struct xfs_buf_log_format {
472491 unsigned short blf_type; /* buf log item type indicator */