diff options
Diffstat (limited to 'fs/xfs/libxfs/xfs_dir2_sf.c')
-rw-r--r-- | fs/xfs/libxfs/xfs_dir2_sf.c | 45 |
1 files changed, 8 insertions, 37 deletions
diff --git a/fs/xfs/libxfs/xfs_dir2_sf.c b/fs/xfs/libxfs/xfs_dir2_sf.c index 8f4f26af35e1..5079e051ef08 100644 --- a/fs/xfs/libxfs/xfs_dir2_sf.c +++ b/fs/xfs/libxfs/xfs_dir2_sf.c | |||
@@ -51,10 +51,9 @@ static void xfs_dir2_sf_check(xfs_da_args_t *args); | |||
51 | #else | 51 | #else |
52 | #define xfs_dir2_sf_check(args) | 52 | #define xfs_dir2_sf_check(args) |
53 | #endif /* DEBUG */ | 53 | #endif /* DEBUG */ |
54 | #if XFS_BIG_INUMS | 54 | |
55 | static void xfs_dir2_sf_toino4(xfs_da_args_t *args); | 55 | static void xfs_dir2_sf_toino4(xfs_da_args_t *args); |
56 | static void xfs_dir2_sf_toino8(xfs_da_args_t *args); | 56 | static void xfs_dir2_sf_toino8(xfs_da_args_t *args); |
57 | #endif /* XFS_BIG_INUMS */ | ||
58 | 57 | ||
59 | /* | 58 | /* |
60 | * Given a block directory (dp/block), calculate its size as a shortform (sf) | 59 | * Given a block directory (dp/block), calculate its size as a shortform (sf) |
@@ -117,10 +116,10 @@ xfs_dir2_block_sfsize( | |||
117 | isdotdot = | 116 | isdotdot = |
118 | dep->namelen == 2 && | 117 | dep->namelen == 2 && |
119 | dep->name[0] == '.' && dep->name[1] == '.'; | 118 | dep->name[0] == '.' && dep->name[1] == '.'; |
120 | #if XFS_BIG_INUMS | 119 | |
121 | if (!isdot) | 120 | if (!isdot) |
122 | i8count += be64_to_cpu(dep->inumber) > XFS_DIR2_MAX_SHORT_INUM; | 121 | i8count += be64_to_cpu(dep->inumber) > XFS_DIR2_MAX_SHORT_INUM; |
123 | #endif | 122 | |
124 | /* take into account the file type field */ | 123 | /* take into account the file type field */ |
125 | if (!isdot && !isdotdot) { | 124 | if (!isdot && !isdotdot) { |
126 | count++; | 125 | count++; |
@@ -318,7 +317,7 @@ xfs_dir2_sf_addname( | |||
318 | */ | 317 | */ |
319 | incr_isize = dp->d_ops->sf_entsize(sfp, args->namelen); | 318 | incr_isize = dp->d_ops->sf_entsize(sfp, args->namelen); |
320 | objchange = 0; | 319 | objchange = 0; |
321 | #if XFS_BIG_INUMS | 320 | |
322 | /* | 321 | /* |
323 | * Do we have to change to 8 byte inodes? | 322 | * Do we have to change to 8 byte inodes? |
324 | */ | 323 | */ |
@@ -332,7 +331,7 @@ xfs_dir2_sf_addname( | |||
332 | (uint)sizeof(xfs_dir2_ino4_t)); | 331 | (uint)sizeof(xfs_dir2_ino4_t)); |
333 | objchange = 1; | 332 | objchange = 1; |
334 | } | 333 | } |
335 | #endif | 334 | |
336 | new_isize = (int)dp->i_d.di_size + incr_isize; | 335 | new_isize = (int)dp->i_d.di_size + incr_isize; |
337 | /* | 336 | /* |
338 | * Won't fit as shortform any more (due to size), | 337 | * Won't fit as shortform any more (due to size), |
@@ -370,10 +369,8 @@ xfs_dir2_sf_addname( | |||
370 | */ | 369 | */ |
371 | else { | 370 | else { |
372 | ASSERT(pick == 2); | 371 | ASSERT(pick == 2); |
373 | #if XFS_BIG_INUMS | ||
374 | if (objchange) | 372 | if (objchange) |
375 | xfs_dir2_sf_toino8(args); | 373 | xfs_dir2_sf_toino8(args); |
376 | #endif | ||
377 | xfs_dir2_sf_addname_hard(args, objchange, new_isize); | 374 | xfs_dir2_sf_addname_hard(args, objchange, new_isize); |
378 | } | 375 | } |
379 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); | 376 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); |
@@ -425,10 +422,8 @@ xfs_dir2_sf_addname_easy( | |||
425 | * Update the header and inode. | 422 | * Update the header and inode. |
426 | */ | 423 | */ |
427 | sfp->count++; | 424 | sfp->count++; |
428 | #if XFS_BIG_INUMS | ||
429 | if (args->inumber > XFS_DIR2_MAX_SHORT_INUM) | 425 | if (args->inumber > XFS_DIR2_MAX_SHORT_INUM) |
430 | sfp->i8count++; | 426 | sfp->i8count++; |
431 | #endif | ||
432 | dp->i_d.di_size = new_isize; | 427 | dp->i_d.di_size = new_isize; |
433 | xfs_dir2_sf_check(args); | 428 | xfs_dir2_sf_check(args); |
434 | } | 429 | } |
@@ -516,10 +511,8 @@ xfs_dir2_sf_addname_hard( | |||
516 | dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); | 511 | dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); |
517 | dp->d_ops->sf_put_ftype(sfep, args->filetype); | 512 | dp->d_ops->sf_put_ftype(sfep, args->filetype); |
518 | sfp->count++; | 513 | sfp->count++; |
519 | #if XFS_BIG_INUMS | ||
520 | if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange) | 514 | if (args->inumber > XFS_DIR2_MAX_SHORT_INUM && !objchange) |
521 | sfp->i8count++; | 515 | sfp->i8count++; |
522 | #endif | ||
523 | /* | 516 | /* |
524 | * If there's more left to copy, do that. | 517 | * If there's more left to copy, do that. |
525 | */ | 518 | */ |
@@ -593,13 +586,8 @@ xfs_dir2_sf_addname_pick( | |||
593 | /* | 586 | /* |
594 | * If changing the inode number size, do it the hard way. | 587 | * If changing the inode number size, do it the hard way. |
595 | */ | 588 | */ |
596 | #if XFS_BIG_INUMS | 589 | if (objchange) |
597 | if (objchange) { | ||
598 | return 2; | 590 | return 2; |
599 | } | ||
600 | #else | ||
601 | ASSERT(objchange == 0); | ||
602 | #endif | ||
603 | /* | 591 | /* |
604 | * If it won't fit at the end then do it the hard way (use the hole). | 592 | * If it won't fit at the end then do it the hard way (use the hole). |
605 | */ | 593 | */ |
@@ -650,7 +638,6 @@ xfs_dir2_sf_check( | |||
650 | ASSERT(dp->d_ops->sf_get_ftype(sfep) < XFS_DIR3_FT_MAX); | 638 | ASSERT(dp->d_ops->sf_get_ftype(sfep) < XFS_DIR3_FT_MAX); |
651 | } | 639 | } |
652 | ASSERT(i8count == sfp->i8count); | 640 | ASSERT(i8count == sfp->i8count); |
653 | ASSERT(XFS_BIG_INUMS || i8count == 0); | ||
654 | ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size); | 641 | ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size); |
655 | ASSERT(offset + | 642 | ASSERT(offset + |
656 | (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) + | 643 | (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) + |
@@ -870,7 +857,6 @@ xfs_dir2_sf_removename( | |||
870 | */ | 857 | */ |
871 | xfs_idata_realloc(dp, newsize - oldsize, XFS_DATA_FORK); | 858 | xfs_idata_realloc(dp, newsize - oldsize, XFS_DATA_FORK); |
872 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; | 859 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; |
873 | #if XFS_BIG_INUMS | ||
874 | /* | 860 | /* |
875 | * Are we changing inode number size? | 861 | * Are we changing inode number size? |
876 | */ | 862 | */ |
@@ -880,7 +866,6 @@ xfs_dir2_sf_removename( | |||
880 | else | 866 | else |
881 | sfp->i8count--; | 867 | sfp->i8count--; |
882 | } | 868 | } |
883 | #endif | ||
884 | xfs_dir2_sf_check(args); | 869 | xfs_dir2_sf_check(args); |
885 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); | 870 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); |
886 | return 0; | 871 | return 0; |
@@ -895,12 +880,8 @@ xfs_dir2_sf_replace( | |||
895 | { | 880 | { |
896 | xfs_inode_t *dp; /* incore directory inode */ | 881 | xfs_inode_t *dp; /* incore directory inode */ |
897 | int i; /* entry index */ | 882 | int i; /* entry index */ |
898 | #if XFS_BIG_INUMS || defined(DEBUG) | ||
899 | xfs_ino_t ino=0; /* entry old inode number */ | 883 | xfs_ino_t ino=0; /* entry old inode number */ |
900 | #endif | ||
901 | #if XFS_BIG_INUMS | ||
902 | int i8elevated; /* sf_toino8 set i8count=1 */ | 884 | int i8elevated; /* sf_toino8 set i8count=1 */ |
903 | #endif | ||
904 | xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ | 885 | xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ |
905 | xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ | 886 | xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ |
906 | 887 | ||
@@ -920,7 +901,7 @@ xfs_dir2_sf_replace( | |||
920 | ASSERT(dp->i_df.if_u1.if_data != NULL); | 901 | ASSERT(dp->i_df.if_u1.if_data != NULL); |
921 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; | 902 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; |
922 | ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count)); | 903 | ASSERT(dp->i_d.di_size >= xfs_dir2_sf_hdr_size(sfp->i8count)); |
923 | #if XFS_BIG_INUMS | 904 | |
924 | /* | 905 | /* |
925 | * New inode number is large, and need to convert to 8-byte inodes. | 906 | * New inode number is large, and need to convert to 8-byte inodes. |
926 | */ | 907 | */ |
@@ -951,17 +932,15 @@ xfs_dir2_sf_replace( | |||
951 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; | 932 | sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; |
952 | } else | 933 | } else |
953 | i8elevated = 0; | 934 | i8elevated = 0; |
954 | #endif | 935 | |
955 | ASSERT(args->namelen != 1 || args->name[0] != '.'); | 936 | ASSERT(args->namelen != 1 || args->name[0] != '.'); |
956 | /* | 937 | /* |
957 | * Replace ..'s entry. | 938 | * Replace ..'s entry. |
958 | */ | 939 | */ |
959 | if (args->namelen == 2 && | 940 | if (args->namelen == 2 && |
960 | args->name[0] == '.' && args->name[1] == '.') { | 941 | args->name[0] == '.' && args->name[1] == '.') { |
961 | #if XFS_BIG_INUMS || defined(DEBUG) | ||
962 | ino = dp->d_ops->sf_get_parent_ino(sfp); | 942 | ino = dp->d_ops->sf_get_parent_ino(sfp); |
963 | ASSERT(args->inumber != ino); | 943 | ASSERT(args->inumber != ino); |
964 | #endif | ||
965 | dp->d_ops->sf_put_parent_ino(sfp, args->inumber); | 944 | dp->d_ops->sf_put_parent_ino(sfp, args->inumber); |
966 | } | 945 | } |
967 | /* | 946 | /* |
@@ -972,10 +951,8 @@ xfs_dir2_sf_replace( | |||
972 | i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep)) { | 951 | i++, sfep = dp->d_ops->sf_nextentry(sfp, sfep)) { |
973 | if (xfs_da_compname(args, sfep->name, sfep->namelen) == | 952 | if (xfs_da_compname(args, sfep->name, sfep->namelen) == |
974 | XFS_CMP_EXACT) { | 953 | XFS_CMP_EXACT) { |
975 | #if XFS_BIG_INUMS || defined(DEBUG) | ||
976 | ino = dp->d_ops->sf_get_ino(sfp, sfep); | 954 | ino = dp->d_ops->sf_get_ino(sfp, sfep); |
977 | ASSERT(args->inumber != ino); | 955 | ASSERT(args->inumber != ino); |
978 | #endif | ||
979 | dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); | 956 | dp->d_ops->sf_put_ino(sfp, sfep, args->inumber); |
980 | dp->d_ops->sf_put_ftype(sfep, args->filetype); | 957 | dp->d_ops->sf_put_ftype(sfep, args->filetype); |
981 | break; | 958 | break; |
@@ -986,14 +963,11 @@ xfs_dir2_sf_replace( | |||
986 | */ | 963 | */ |
987 | if (i == sfp->count) { | 964 | if (i == sfp->count) { |
988 | ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); | 965 | ASSERT(args->op_flags & XFS_DA_OP_OKNOENT); |
989 | #if XFS_BIG_INUMS | ||
990 | if (i8elevated) | 966 | if (i8elevated) |
991 | xfs_dir2_sf_toino4(args); | 967 | xfs_dir2_sf_toino4(args); |
992 | #endif | ||
993 | return -ENOENT; | 968 | return -ENOENT; |
994 | } | 969 | } |
995 | } | 970 | } |
996 | #if XFS_BIG_INUMS | ||
997 | /* | 971 | /* |
998 | * See if the old number was large, the new number is small. | 972 | * See if the old number was large, the new number is small. |
999 | */ | 973 | */ |
@@ -1020,13 +994,11 @@ xfs_dir2_sf_replace( | |||
1020 | if (!i8elevated) | 994 | if (!i8elevated) |
1021 | sfp->i8count++; | 995 | sfp->i8count++; |
1022 | } | 996 | } |
1023 | #endif | ||
1024 | xfs_dir2_sf_check(args); | 997 | xfs_dir2_sf_check(args); |
1025 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_DDATA); | 998 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_DDATA); |
1026 | return 0; | 999 | return 0; |
1027 | } | 1000 | } |
1028 | 1001 | ||
1029 | #if XFS_BIG_INUMS | ||
1030 | /* | 1002 | /* |
1031 | * Convert from 8-byte inode numbers to 4-byte inode numbers. | 1003 | * Convert from 8-byte inode numbers to 4-byte inode numbers. |
1032 | * The last 8-byte inode number is gone, but the count is still 1. | 1004 | * The last 8-byte inode number is gone, but the count is still 1. |
@@ -1181,4 +1153,3 @@ xfs_dir2_sf_toino8( | |||
1181 | dp->i_d.di_size = newsize; | 1153 | dp->i_d.di_size = newsize; |
1182 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); | 1154 | xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_DDATA); |
1183 | } | 1155 | } |
1184 | #endif /* XFS_BIG_INUMS */ | ||