.. | .. |
---|
1 | | -// SPDX-License-Identifier: GPL-2.0 |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 */ |
---|
2 | 2 | /* |
---|
3 | 3 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
---|
4 | 4 | * All Rights Reserved. |
---|
.. | .. |
---|
287 | 287 | { |
---|
288 | 288 | if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)) |
---|
289 | 289 | return false; |
---|
| 290 | + if (!(sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT)) |
---|
| 291 | + return false; |
---|
290 | 292 | |
---|
291 | 293 | /* check for unknown features in the fs */ |
---|
292 | 294 | if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) || |
---|
.. | .. |
---|
355 | 357 | { |
---|
356 | 358 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || |
---|
357 | 359 | (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); |
---|
358 | | -} |
---|
359 | | - |
---|
360 | | -static inline bool xfs_sb_version_hasextflgbit(struct xfs_sb *sbp) |
---|
361 | | -{ |
---|
362 | | - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || |
---|
363 | | - (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); |
---|
364 | 360 | } |
---|
365 | 361 | |
---|
366 | 362 | static inline bool xfs_sb_version_hassector(struct xfs_sb *sbp) |
---|
.. | .. |
---|
453 | 449 | #define XFS_SB_FEAT_RO_COMPAT_FINOBT (1 << 0) /* free inode btree */ |
---|
454 | 450 | #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ |
---|
455 | 451 | #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ |
---|
| 452 | +#define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ |
---|
456 | 453 | #define XFS_SB_FEAT_RO_COMPAT_ALL \ |
---|
457 | 454 | (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ |
---|
458 | 455 | XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ |
---|
459 | | - XFS_SB_FEAT_RO_COMPAT_REFLINK) |
---|
| 456 | + XFS_SB_FEAT_RO_COMPAT_REFLINK| \ |
---|
| 457 | + XFS_SB_FEAT_RO_COMPAT_INOBTCNT) |
---|
460 | 458 | #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL |
---|
461 | 459 | static inline bool |
---|
462 | 460 | xfs_sb_has_ro_compat_feature( |
---|
.. | .. |
---|
469 | 467 | #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ |
---|
470 | 468 | #define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */ |
---|
471 | 469 | #define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */ |
---|
| 470 | +#define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */ |
---|
472 | 471 | #define XFS_SB_FEAT_INCOMPAT_ALL \ |
---|
473 | 472 | (XFS_SB_FEAT_INCOMPAT_FTYPE| \ |
---|
474 | 473 | XFS_SB_FEAT_INCOMPAT_SPINODES| \ |
---|
475 | | - XFS_SB_FEAT_INCOMPAT_META_UUID) |
---|
| 474 | + XFS_SB_FEAT_INCOMPAT_META_UUID| \ |
---|
| 475 | + XFS_SB_FEAT_INCOMPAT_BIGTIME) |
---|
476 | 476 | |
---|
477 | 477 | #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL |
---|
478 | 478 | static inline bool |
---|
.. | .. |
---|
499 | 499 | static inline bool xfs_sb_version_hascrc(struct xfs_sb *sbp) |
---|
500 | 500 | { |
---|
501 | 501 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; |
---|
| 502 | +} |
---|
| 503 | + |
---|
| 504 | +/* |
---|
| 505 | + * v5 file systems support V3 inodes only, earlier file systems support |
---|
| 506 | + * v2 and v1 inodes. |
---|
| 507 | + */ |
---|
| 508 | +static inline bool xfs_sb_version_has_v3inode(struct xfs_sb *sbp) |
---|
| 509 | +{ |
---|
| 510 | + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; |
---|
| 511 | +} |
---|
| 512 | + |
---|
| 513 | +static inline bool xfs_dinode_good_version(struct xfs_sb *sbp, |
---|
| 514 | + uint8_t version) |
---|
| 515 | +{ |
---|
| 516 | + if (xfs_sb_version_has_v3inode(sbp)) |
---|
| 517 | + return version == 3; |
---|
| 518 | + return version == 1 || version == 2; |
---|
502 | 519 | } |
---|
503 | 520 | |
---|
504 | 521 | static inline bool xfs_sb_version_has_pquotino(struct xfs_sb *sbp) |
---|
.. | .. |
---|
550 | 567 | (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_REFLINK); |
---|
551 | 568 | } |
---|
552 | 569 | |
---|
| 570 | +static inline bool xfs_sb_version_hasbigtime(struct xfs_sb *sbp) |
---|
| 571 | +{ |
---|
| 572 | + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && |
---|
| 573 | + (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_BIGTIME); |
---|
| 574 | +} |
---|
| 575 | + |
---|
| 576 | +/* |
---|
| 577 | + * Inode btree block counter. We record the number of inobt and finobt blocks |
---|
| 578 | + * in the AGI header so that we can skip the finobt walk at mount time when |
---|
| 579 | + * setting up per-AG reservations. |
---|
| 580 | + */ |
---|
| 581 | +static inline bool xfs_sb_version_hasinobtcounts(struct xfs_sb *sbp) |
---|
| 582 | +{ |
---|
| 583 | + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && |
---|
| 584 | + (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_INOBTCNT); |
---|
| 585 | +} |
---|
| 586 | + |
---|
553 | 587 | /* |
---|
554 | 588 | * end of superblock version macros |
---|
555 | 589 | */ |
---|
.. | .. |
---|
564 | 598 | |
---|
565 | 599 | #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ |
---|
566 | 600 | #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) |
---|
567 | | -#define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr)) |
---|
568 | 601 | |
---|
569 | 602 | #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) |
---|
570 | 603 | #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ |
---|
.. | .. |
---|
711 | 744 | /* disk block (xfs_daddr_t) in the AG */ |
---|
712 | 745 | #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) |
---|
713 | 746 | #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) |
---|
714 | | -#define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)((bp)->b_addr)) |
---|
715 | 747 | |
---|
716 | 748 | /* |
---|
717 | 749 | * Size of the unlinked inode hash table in the agi. |
---|
.. | .. |
---|
754 | 786 | __be32 agi_free_root; /* root of the free inode btree */ |
---|
755 | 787 | __be32 agi_free_level;/* levels in free inode btree */ |
---|
756 | 788 | |
---|
| 789 | + __be32 agi_iblocks; /* inobt blocks used */ |
---|
| 790 | + __be32 agi_fblocks; /* finobt blocks used */ |
---|
| 791 | + |
---|
757 | 792 | /* structure must be padded to 64 bit alignment */ |
---|
758 | 793 | } xfs_agi_t; |
---|
759 | 794 | |
---|
.. | .. |
---|
774 | 809 | #define XFS_AGI_ALL_BITS_R1 ((1 << XFS_AGI_NUM_BITS_R1) - 1) |
---|
775 | 810 | #define XFS_AGI_FREE_ROOT (1 << 11) |
---|
776 | 811 | #define XFS_AGI_FREE_LEVEL (1 << 12) |
---|
777 | | -#define XFS_AGI_NUM_BITS_R2 13 |
---|
| 812 | +#define XFS_AGI_IBLOCKS (1 << 13) /* both inobt/finobt block counters */ |
---|
| 813 | +#define XFS_AGI_NUM_BITS_R2 14 |
---|
778 | 814 | |
---|
779 | 815 | /* disk block (xfs_daddr_t) in the AG */ |
---|
780 | 816 | #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) |
---|
781 | 817 | #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) |
---|
782 | | -#define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)((bp)->b_addr)) |
---|
783 | 818 | |
---|
784 | 819 | /* |
---|
785 | 820 | * The third a.g. block contains the a.g. freelist, an array |
---|
.. | .. |
---|
787 | 822 | */ |
---|
788 | 823 | #define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) |
---|
789 | 824 | #define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) |
---|
790 | | -#define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)((bp)->b_addr)) |
---|
| 825 | +#define XFS_BUF_TO_AGFL(bp) ((struct xfs_agfl *)((bp)->b_addr)) |
---|
791 | 826 | |
---|
792 | | -#define XFS_BUF_TO_AGFL_BNO(mp, bp) \ |
---|
793 | | - (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ |
---|
794 | | - &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \ |
---|
795 | | - (__be32 *)(bp)->b_addr) |
---|
796 | | - |
---|
797 | | -typedef struct xfs_agfl { |
---|
| 827 | +struct xfs_agfl { |
---|
798 | 828 | __be32 agfl_magicnum; |
---|
799 | 829 | __be32 agfl_seqno; |
---|
800 | 830 | uuid_t agfl_uuid; |
---|
801 | 831 | __be64 agfl_lsn; |
---|
802 | 832 | __be32 agfl_crc; |
---|
803 | | - __be32 agfl_bno[]; /* actually xfs_agfl_size(mp) */ |
---|
804 | | -} __attribute__((packed)) xfs_agfl_t; |
---|
| 833 | +} __attribute__((packed)); |
---|
805 | 834 | |
---|
806 | 835 | #define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc) |
---|
807 | 836 | |
---|
.. | .. |
---|
827 | 856 | ASSERT(xfs_daddr_to_agno(mp, d) == \ |
---|
828 | 857 | xfs_daddr_to_agno(mp, (d) + (len) - 1))) |
---|
829 | 858 | |
---|
830 | | -typedef struct xfs_timestamp { |
---|
| 859 | +/* |
---|
| 860 | + * XFS Timestamps |
---|
| 861 | + * ============== |
---|
| 862 | + * |
---|
| 863 | + * Traditional ondisk inode timestamps consist of signed 32-bit counters for |
---|
| 864 | + * seconds and nanoseconds; time zero is the Unix epoch, Jan 1 00:00:00 UTC |
---|
| 865 | + * 1970, which means that the timestamp epoch is the same as the Unix epoch. |
---|
| 866 | + * Therefore, the ondisk min and max defined here can be used directly to |
---|
| 867 | + * constrain the incore timestamps on a Unix system. Note that we actually |
---|
| 868 | + * encode a __be64 value on disk. |
---|
| 869 | + * |
---|
| 870 | + * When the bigtime feature is enabled, ondisk inode timestamps become an |
---|
| 871 | + * unsigned 64-bit nanoseconds counter. This means that the bigtime inode |
---|
| 872 | + * timestamp epoch is the start of the classic timestamp range, which is |
---|
| 873 | + * Dec 31 20:45:52 UTC 1901. Because the epochs are not the same, callers |
---|
| 874 | + * /must/ use the bigtime conversion functions when encoding and decoding raw |
---|
| 875 | + * timestamps. |
---|
| 876 | + */ |
---|
| 877 | +typedef __be64 xfs_timestamp_t; |
---|
| 878 | + |
---|
| 879 | +/* Legacy timestamp encoding format. */ |
---|
| 880 | +struct xfs_legacy_timestamp { |
---|
831 | 881 | __be32 t_sec; /* timestamp seconds */ |
---|
832 | 882 | __be32 t_nsec; /* timestamp nanoseconds */ |
---|
833 | | -} xfs_timestamp_t; |
---|
| 883 | +}; |
---|
| 884 | + |
---|
| 885 | +/* |
---|
| 886 | + * Smallest possible ondisk seconds value with traditional timestamps. This |
---|
| 887 | + * corresponds exactly with the incore timestamp Dec 13 20:45:52 UTC 1901. |
---|
| 888 | + */ |
---|
| 889 | +#define XFS_LEGACY_TIME_MIN ((int64_t)S32_MIN) |
---|
| 890 | + |
---|
| 891 | +/* |
---|
| 892 | + * Largest possible ondisk seconds value with traditional timestamps. This |
---|
| 893 | + * corresponds exactly with the incore timestamp Jan 19 03:14:07 UTC 2038. |
---|
| 894 | + */ |
---|
| 895 | +#define XFS_LEGACY_TIME_MAX ((int64_t)S32_MAX) |
---|
| 896 | + |
---|
| 897 | +/* |
---|
| 898 | + * Smallest possible ondisk seconds value with bigtime timestamps. This |
---|
| 899 | + * corresponds (after conversion to a Unix timestamp) with the traditional |
---|
| 900 | + * minimum timestamp of Dec 13 20:45:52 UTC 1901. |
---|
| 901 | + */ |
---|
| 902 | +#define XFS_BIGTIME_TIME_MIN ((int64_t)0) |
---|
| 903 | + |
---|
| 904 | +/* |
---|
| 905 | + * Largest supported ondisk seconds value with bigtime timestamps. This |
---|
| 906 | + * corresponds (after conversion to a Unix timestamp) with an incore timestamp |
---|
| 907 | + * of Jul 2 20:20:24 UTC 2486. |
---|
| 908 | + * |
---|
| 909 | + * We round down the ondisk limit so that the bigtime quota and inode max |
---|
| 910 | + * timestamps will be the same. |
---|
| 911 | + */ |
---|
| 912 | +#define XFS_BIGTIME_TIME_MAX ((int64_t)((-1ULL / NSEC_PER_SEC) & ~0x3ULL)) |
---|
| 913 | + |
---|
| 914 | +/* |
---|
| 915 | + * Bigtime epoch is set exactly to the minimum time value that a traditional |
---|
| 916 | + * 32-bit timestamp can represent when using the Unix epoch as a reference. |
---|
| 917 | + * Hence the Unix epoch is at a fixed offset into the supported bigtime |
---|
| 918 | + * timestamp range. |
---|
| 919 | + * |
---|
| 920 | + * The bigtime epoch also matches the minimum value an on-disk 32-bit XFS |
---|
| 921 | + * timestamp can represent so we will not lose any fidelity in converting |
---|
| 922 | + * to/from unix and bigtime timestamps. |
---|
| 923 | + * |
---|
| 924 | + * The following conversion factor converts a seconds counter from the Unix |
---|
| 925 | + * epoch to the bigtime epoch. |
---|
| 926 | + */ |
---|
| 927 | +#define XFS_BIGTIME_EPOCH_OFFSET (-(int64_t)S32_MIN) |
---|
| 928 | + |
---|
| 929 | +/* Convert a timestamp from the Unix epoch to the bigtime epoch. */ |
---|
| 930 | +static inline uint64_t xfs_unix_to_bigtime(time64_t unix_seconds) |
---|
| 931 | +{ |
---|
| 932 | + return (uint64_t)unix_seconds + XFS_BIGTIME_EPOCH_OFFSET; |
---|
| 933 | +} |
---|
| 934 | + |
---|
| 935 | +/* Convert a timestamp from the bigtime epoch to the Unix epoch. */ |
---|
| 936 | +static inline time64_t xfs_bigtime_to_unix(uint64_t ondisk_seconds) |
---|
| 937 | +{ |
---|
| 938 | + return (time64_t)ondisk_seconds - XFS_BIGTIME_EPOCH_OFFSET; |
---|
| 939 | +} |
---|
834 | 940 | |
---|
835 | 941 | /* |
---|
836 | 942 | * On-disk inode structure. |
---|
.. | .. |
---|
920 | 1026 | |
---|
921 | 1027 | /* |
---|
922 | 1028 | * Values for di_format |
---|
| 1029 | + * |
---|
| 1030 | + * This enum is used in string mapping in xfs_trace.h; please keep the |
---|
| 1031 | + * TRACE_DEFINE_ENUMs for it up to date. |
---|
923 | 1032 | */ |
---|
924 | | -typedef enum xfs_dinode_fmt { |
---|
| 1033 | +enum xfs_dinode_fmt { |
---|
925 | 1034 | XFS_DINODE_FMT_DEV, /* xfs_dev_t */ |
---|
926 | 1035 | XFS_DINODE_FMT_LOCAL, /* bulk data */ |
---|
927 | 1036 | XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */ |
---|
928 | 1037 | XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */ |
---|
929 | 1038 | XFS_DINODE_FMT_UUID /* added long ago, but never used */ |
---|
930 | | -} xfs_dinode_fmt_t; |
---|
| 1039 | +}; |
---|
| 1040 | + |
---|
| 1041 | +#define XFS_INODE_FORMAT_STR \ |
---|
| 1042 | + { XFS_DINODE_FMT_DEV, "dev" }, \ |
---|
| 1043 | + { XFS_DINODE_FMT_LOCAL, "local" }, \ |
---|
| 1044 | + { XFS_DINODE_FMT_EXTENTS, "extent" }, \ |
---|
| 1045 | + { XFS_DINODE_FMT_BTREE, "btree" }, \ |
---|
| 1046 | + { XFS_DINODE_FMT_UUID, "uuid" } |
---|
931 | 1047 | |
---|
932 | 1048 | /* |
---|
933 | 1049 | * Inode minimum and maximum sizes. |
---|
.. | .. |
---|
940 | 1056 | /* |
---|
941 | 1057 | * Inode size for given fs. |
---|
942 | 1058 | */ |
---|
943 | | -#define XFS_LITINO(mp, version) \ |
---|
944 | | - ((int)(((mp)->m_sb.sb_inodesize) - xfs_dinode_size(version))) |
---|
| 1059 | +#define XFS_DINODE_SIZE(sbp) \ |
---|
| 1060 | + (xfs_sb_version_has_v3inode(sbp) ? \ |
---|
| 1061 | + sizeof(struct xfs_dinode) : \ |
---|
| 1062 | + offsetof(struct xfs_dinode, di_crc)) |
---|
| 1063 | +#define XFS_LITINO(mp) \ |
---|
| 1064 | + ((mp)->m_sb.sb_inodesize - XFS_DINODE_SIZE(&(mp)->m_sb)) |
---|
945 | 1065 | |
---|
946 | 1066 | /* |
---|
947 | 1067 | * Inode data & attribute fork sizes, per inode. |
---|
948 | 1068 | */ |
---|
949 | | -#define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0) |
---|
950 | 1069 | #define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3)) |
---|
951 | 1070 | |
---|
952 | 1071 | #define XFS_DFORK_DSIZE(dip,mp) \ |
---|
953 | | - (XFS_DFORK_Q(dip) ? \ |
---|
954 | | - XFS_DFORK_BOFF(dip) : \ |
---|
955 | | - XFS_LITINO(mp, (dip)->di_version)) |
---|
| 1072 | + ((dip)->di_forkoff ? XFS_DFORK_BOFF(dip) : XFS_LITINO(mp)) |
---|
956 | 1073 | #define XFS_DFORK_ASIZE(dip,mp) \ |
---|
957 | | - (XFS_DFORK_Q(dip) ? \ |
---|
958 | | - XFS_LITINO(mp, (dip)->di_version) - XFS_DFORK_BOFF(dip) : \ |
---|
959 | | - 0) |
---|
| 1074 | + ((dip)->di_forkoff ? XFS_LITINO(mp) - XFS_DFORK_BOFF(dip) : 0) |
---|
960 | 1075 | #define XFS_DFORK_SIZE(dip,mp,w) \ |
---|
961 | 1076 | ((w) == XFS_DATA_FORK ? \ |
---|
962 | 1077 | XFS_DFORK_DSIZE(dip, mp) : \ |
---|
.. | .. |
---|
1048 | 1163 | #define XFS_DIFLAG2_DAX_BIT 0 /* use DAX for this inode */ |
---|
1049 | 1164 | #define XFS_DIFLAG2_REFLINK_BIT 1 /* file's blocks may be shared */ |
---|
1050 | 1165 | #define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ |
---|
| 1166 | +#define XFS_DIFLAG2_BIGTIME_BIT 3 /* big timestamps */ |
---|
| 1167 | + |
---|
1051 | 1168 | #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) |
---|
1052 | 1169 | #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT) |
---|
1053 | 1170 | #define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT) |
---|
| 1171 | +#define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_BIT) |
---|
1054 | 1172 | |
---|
1055 | 1173 | #define XFS_DIFLAG2_ANY \ |
---|
1056 | | - (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE) |
---|
| 1174 | + (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ |
---|
| 1175 | + XFS_DIFLAG2_BIGTIME) |
---|
| 1176 | + |
---|
| 1177 | +static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) |
---|
| 1178 | +{ |
---|
| 1179 | + return dip->di_version >= 3 && |
---|
| 1180 | + (dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_BIGTIME)); |
---|
| 1181 | +} |
---|
1057 | 1182 | |
---|
1058 | 1183 | /* |
---|
1059 | 1184 | * Inode number format: |
---|
.. | .. |
---|
1065 | 1190 | #define XFS_INO_MASK(k) (uint32_t)((1ULL << (k)) - 1) |
---|
1066 | 1191 | #define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog |
---|
1067 | 1192 | #define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog |
---|
1068 | | -#define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log |
---|
| 1193 | +#define XFS_INO_AGINO_BITS(mp) ((mp)->m_ino_geo.agino_log) |
---|
1069 | 1194 | #define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log |
---|
1070 | 1195 | #define XFS_INO_BITS(mp) \ |
---|
1071 | 1196 | XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp) |
---|
.. | .. |
---|
1087 | 1212 | ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) |
---|
1088 | 1213 | #define XFS_OFFBNO_TO_AGINO(mp,b,o) \ |
---|
1089 | 1214 | ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) |
---|
| 1215 | +#define XFS_FSB_TO_INO(mp, b) ((xfs_ino_t)((b) << XFS_INO_OFFSET_BITS(mp))) |
---|
| 1216 | +#define XFS_AGB_TO_AGINO(mp, b) ((xfs_agino_t)((b) << XFS_INO_OFFSET_BITS(mp))) |
---|
1090 | 1217 | |
---|
1091 | 1218 | #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) |
---|
1092 | 1219 | #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL)) |
---|
.. | .. |
---|
1134 | 1261 | #define XFS_DQUOT_MAGIC 0x4451 /* 'DQ' */ |
---|
1135 | 1262 | #define XFS_DQUOT_VERSION (uint8_t)0x01 /* latest version number */ |
---|
1136 | 1263 | |
---|
| 1264 | +#define XFS_DQTYPE_USER 0x01 /* user dquot record */ |
---|
| 1265 | +#define XFS_DQTYPE_PROJ 0x02 /* project dquot record */ |
---|
| 1266 | +#define XFS_DQTYPE_GROUP 0x04 /* group dquot record */ |
---|
| 1267 | +#define XFS_DQTYPE_BIGTIME 0x80 /* large expiry timestamps */ |
---|
| 1268 | + |
---|
| 1269 | +/* bitmask to determine if this is a user/group/project dquot */ |
---|
| 1270 | +#define XFS_DQTYPE_REC_MASK (XFS_DQTYPE_USER | \ |
---|
| 1271 | + XFS_DQTYPE_PROJ | \ |
---|
| 1272 | + XFS_DQTYPE_GROUP) |
---|
| 1273 | + |
---|
| 1274 | +#define XFS_DQTYPE_ANY (XFS_DQTYPE_REC_MASK | \ |
---|
| 1275 | + XFS_DQTYPE_BIGTIME) |
---|
| 1276 | + |
---|
1137 | 1277 | /* |
---|
1138 | | - * This is the main portion of the on-disk representation of quota |
---|
1139 | | - * information for a user. This is the q_core of the xfs_dquot_t that |
---|
1140 | | - * is kept in kernel memory. We pad this with some more expansion room |
---|
1141 | | - * to construct the on disk structure. |
---|
| 1278 | + * XFS Quota Timers |
---|
| 1279 | + * ================ |
---|
| 1280 | + * |
---|
| 1281 | + * Traditional quota grace period expiration timers are an unsigned 32-bit |
---|
| 1282 | + * seconds counter; time zero is the Unix epoch, Jan 1 00:00:01 UTC 1970. |
---|
| 1283 | + * Note that an expiration value of zero means that the quota limit has not |
---|
| 1284 | + * been reached, and therefore no expiration has been set. Therefore, the |
---|
| 1285 | + * ondisk min and max defined here can be used directly to constrain the incore |
---|
| 1286 | + * quota expiration timestamps on a Unix system. |
---|
| 1287 | + * |
---|
| 1288 | + * When bigtime is enabled, we trade two bits of precision to expand the |
---|
| 1289 | + * expiration timeout range to match that of big inode timestamps. The min and |
---|
| 1290 | + * max recorded here are the on-disk limits, not a Unix timestamp. |
---|
| 1291 | + * |
---|
| 1292 | + * The grace period for each quota type is stored in the root dquot (id = 0) |
---|
| 1293 | + * and is applied to a non-root dquot when it exceeds the soft or hard limits. |
---|
| 1294 | + * The length of quota grace periods are unsigned 32-bit quantities measured in |
---|
| 1295 | + * units of seconds. A value of zero means to use the default period. |
---|
1142 | 1296 | */ |
---|
1143 | | -typedef struct xfs_disk_dquot { |
---|
| 1297 | + |
---|
| 1298 | +/* |
---|
| 1299 | + * Smallest possible ondisk quota expiration value with traditional timestamps. |
---|
| 1300 | + * This corresponds exactly with the incore expiration Jan 1 00:00:01 UTC 1970. |
---|
| 1301 | + */ |
---|
| 1302 | +#define XFS_DQ_LEGACY_EXPIRY_MIN ((int64_t)1) |
---|
| 1303 | + |
---|
| 1304 | +/* |
---|
| 1305 | + * Largest possible ondisk quota expiration value with traditional timestamps. |
---|
| 1306 | + * This corresponds exactly with the incore expiration Feb 7 06:28:15 UTC 2106. |
---|
| 1307 | + */ |
---|
| 1308 | +#define XFS_DQ_LEGACY_EXPIRY_MAX ((int64_t)U32_MAX) |
---|
| 1309 | + |
---|
| 1310 | +/* |
---|
| 1311 | + * Smallest possible ondisk quota expiration value with bigtime timestamps. |
---|
| 1312 | + * This corresponds (after conversion to a Unix timestamp) with the incore |
---|
| 1313 | + * expiration of Jan 1 00:00:04 UTC 1970. |
---|
| 1314 | + */ |
---|
| 1315 | +#define XFS_DQ_BIGTIME_EXPIRY_MIN (XFS_DQ_LEGACY_EXPIRY_MIN) |
---|
| 1316 | + |
---|
| 1317 | +/* |
---|
| 1318 | + * Largest supported ondisk quota expiration value with bigtime timestamps. |
---|
| 1319 | + * This corresponds (after conversion to a Unix timestamp) with an incore |
---|
| 1320 | + * expiration of Jul 2 20:20:24 UTC 2486. |
---|
| 1321 | + * |
---|
| 1322 | + * The ondisk field supports values up to -1U, which corresponds to an incore |
---|
| 1323 | + * expiration in 2514. This is beyond the maximum the bigtime inode timestamp, |
---|
| 1324 | + * so we cap the maximum bigtime quota expiration to the max inode timestamp. |
---|
| 1325 | + */ |
---|
| 1326 | +#define XFS_DQ_BIGTIME_EXPIRY_MAX ((int64_t)4074815106U) |
---|
| 1327 | + |
---|
| 1328 | +/* |
---|
| 1329 | + * The following conversion factors assist in converting a quota expiration |
---|
| 1330 | + * timestamp between the incore and ondisk formats. |
---|
| 1331 | + */ |
---|
| 1332 | +#define XFS_DQ_BIGTIME_SHIFT (2) |
---|
| 1333 | +#define XFS_DQ_BIGTIME_SLACK ((int64_t)(1ULL << XFS_DQ_BIGTIME_SHIFT) - 1) |
---|
| 1334 | + |
---|
| 1335 | +/* Convert an incore quota expiration timestamp to an ondisk bigtime value. */ |
---|
| 1336 | +static inline uint32_t xfs_dq_unix_to_bigtime(time64_t unix_seconds) |
---|
| 1337 | +{ |
---|
| 1338 | + /* |
---|
| 1339 | + * Round the expiration timestamp up to the nearest bigtime timestamp |
---|
| 1340 | + * that we can store, to give users the most time to fix problems. |
---|
| 1341 | + */ |
---|
| 1342 | + return ((uint64_t)unix_seconds + XFS_DQ_BIGTIME_SLACK) >> |
---|
| 1343 | + XFS_DQ_BIGTIME_SHIFT; |
---|
| 1344 | +} |
---|
| 1345 | + |
---|
| 1346 | +/* Convert an ondisk bigtime quota expiration value to an incore timestamp. */ |
---|
| 1347 | +static inline time64_t xfs_dq_bigtime_to_unix(uint32_t ondisk_seconds) |
---|
| 1348 | +{ |
---|
| 1349 | + return (time64_t)ondisk_seconds << XFS_DQ_BIGTIME_SHIFT; |
---|
| 1350 | +} |
---|
| 1351 | + |
---|
| 1352 | +/* |
---|
| 1353 | + * Default quota grace periods, ranging from zero (use the compiled defaults) |
---|
| 1354 | + * to ~136 years. These are applied to a non-root dquot that has exceeded |
---|
| 1355 | + * either limit. |
---|
| 1356 | + */ |
---|
| 1357 | +#define XFS_DQ_GRACE_MIN ((int64_t)0) |
---|
| 1358 | +#define XFS_DQ_GRACE_MAX ((int64_t)U32_MAX) |
---|
| 1359 | + |
---|
| 1360 | +/* |
---|
| 1361 | + * This is the main portion of the on-disk representation of quota information |
---|
| 1362 | + * for a user. We pad this with some more expansion room to construct the on |
---|
| 1363 | + * disk structure. |
---|
| 1364 | + */ |
---|
| 1365 | +struct xfs_disk_dquot { |
---|
1144 | 1366 | __be16 d_magic; /* dquot magic = XFS_DQUOT_MAGIC */ |
---|
1145 | 1367 | __u8 d_version; /* dquot version */ |
---|
1146 | | - __u8 d_flags; /* XFS_DQ_USER/PROJ/GROUP */ |
---|
| 1368 | + __u8 d_type; /* XFS_DQTYPE_USER/PROJ/GROUP */ |
---|
1147 | 1369 | __be32 d_id; /* user,project,group id */ |
---|
1148 | 1370 | __be64 d_blk_hardlimit;/* absolute limit on disk blks */ |
---|
1149 | 1371 | __be64 d_blk_softlimit;/* preferred limit on disk blks */ |
---|
.. | .. |
---|
1163 | 1385 | __be32 d_rtbtimer; /* similar to above; for RT disk blocks */ |
---|
1164 | 1386 | __be16 d_rtbwarns; /* warnings issued wrt RT disk blocks */ |
---|
1165 | 1387 | __be16 d_pad; |
---|
1166 | | -} xfs_disk_dquot_t; |
---|
| 1388 | +}; |
---|
1167 | 1389 | |
---|
1168 | 1390 | /* |
---|
1169 | 1391 | * This is what goes on disk. This is separated from the xfs_disk_dquot because |
---|
1170 | 1392 | * carrying the unnecessary padding would be a waste of memory. |
---|
1171 | 1393 | */ |
---|
1172 | 1394 | typedef struct xfs_dqblk { |
---|
1173 | | - xfs_disk_dquot_t dd_diskdq; /* portion that lives incore as well */ |
---|
1174 | | - char dd_fill[4]; /* filling for posterity */ |
---|
| 1395 | + struct xfs_disk_dquot dd_diskdq; /* portion living incore as well */ |
---|
| 1396 | + char dd_fill[4];/* filling for posterity */ |
---|
1175 | 1397 | |
---|
1176 | 1398 | /* |
---|
1177 | 1399 | * These two are only present on filesystems with the CRC bits set. |
---|
.. | .. |
---|
1182 | 1404 | } xfs_dqblk_t; |
---|
1183 | 1405 | |
---|
1184 | 1406 | #define XFS_DQUOT_CRC_OFF offsetof(struct xfs_dqblk, dd_crc) |
---|
| 1407 | + |
---|
| 1408 | +/* |
---|
| 1409 | + * This defines the unit of allocation of dquots. |
---|
| 1410 | + * |
---|
| 1411 | + * Currently, it is just one file system block, and a 4K blk contains 30 |
---|
| 1412 | + * (136 * 30 = 4080) dquots. It's probably not worth trying to make |
---|
| 1413 | + * this more dynamic. |
---|
| 1414 | + * |
---|
| 1415 | + * However, if this number is changed, we have to make sure that we don't |
---|
| 1416 | + * implicitly assume that we do allocations in chunks of a single filesystem |
---|
| 1417 | + * block in the dquot/xqm code. |
---|
| 1418 | + * |
---|
| 1419 | + * This is part of the ondisk format because the structure size is not a power |
---|
| 1420 | + * of two, which leaves slack at the end of the disk block. |
---|
| 1421 | + */ |
---|
| 1422 | +#define XFS_DQUOT_CLUSTER_SIZE_FSB (xfs_filblks_t)1 |
---|
1185 | 1423 | |
---|
1186 | 1424 | /* |
---|
1187 | 1425 | * Remote symlink format and access functions. |
---|
.. | .. |
---|
1532 | 1770 | #define BMBT_BLOCKCOUNT_BITLEN 21 |
---|
1533 | 1771 | |
---|
1534 | 1772 | #define BMBT_STARTOFF_MASK ((1ULL << BMBT_STARTOFF_BITLEN) - 1) |
---|
| 1773 | +#define BMBT_BLOCKCOUNT_MASK ((1ULL << BMBT_BLOCKCOUNT_BITLEN) - 1) |
---|
| 1774 | + |
---|
| 1775 | +/* |
---|
| 1776 | + * bmbt records have a file offset (block) field that is 54 bits wide, so this |
---|
| 1777 | + * is the largest xfs_fileoff_t that we ever expect to see. |
---|
| 1778 | + */ |
---|
| 1779 | +#define XFS_MAX_FILEOFF (BMBT_STARTOFF_MASK + BMBT_BLOCKCOUNT_MASK) |
---|
1535 | 1780 | |
---|
1536 | 1781 | typedef struct xfs_bmbt_rec { |
---|
1537 | 1782 | __be64 l0, l1; |
---|
.. | .. |
---|
1658 | 1903 | |
---|
1659 | 1904 | struct xfs_acl { |
---|
1660 | 1905 | __be32 acl_cnt; |
---|
1661 | | - struct xfs_acl_entry acl_entry[0]; |
---|
| 1906 | + struct xfs_acl_entry acl_entry[]; |
---|
1662 | 1907 | }; |
---|
1663 | 1908 | |
---|
1664 | 1909 | /* |
---|