diff options
Diffstat (limited to 'fs/xfs/xfs_attr.c')
-rw-r--r-- | fs/xfs/xfs_attr.c | 125 |
1 files changed, 69 insertions, 56 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index 7afef2810e41..e70687541592 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
@@ -819,7 +819,7 @@ xfs_attr_inactive(xfs_inode_t *dp) | |||
819 | error = 0; | 819 | error = 0; |
820 | goto out; | 820 | goto out; |
821 | } | 821 | } |
822 | error = xfs_attr_root_inactive(&trans, dp); | 822 | error = xfs_attr3_root_inactive(&trans, dp); |
823 | if (error) | 823 | if (error) |
824 | goto out; | 824 | goto out; |
825 | 825 | ||
@@ -905,7 +905,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) | |||
905 | */ | 905 | */ |
906 | dp = args->dp; | 906 | dp = args->dp; |
907 | args->blkno = 0; | 907 | args->blkno = 0; |
908 | error = xfs_attr_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); | 908 | error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); |
909 | if (error) | 909 | if (error) |
910 | return error; | 910 | return error; |
911 | 911 | ||
@@ -913,14 +913,14 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) | |||
913 | * Look up the given attribute in the leaf block. Figure out if | 913 | * Look up the given attribute in the leaf block. Figure out if |
914 | * the given flags produce an error or call for an atomic rename. | 914 | * the given flags produce an error or call for an atomic rename. |
915 | */ | 915 | */ |
916 | retval = xfs_attr_leaf_lookup_int(bp, args); | 916 | retval = xfs_attr3_leaf_lookup_int(bp, args); |
917 | if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { | 917 | if ((args->flags & ATTR_REPLACE) && (retval == ENOATTR)) { |
918 | xfs_trans_brelse(args->trans, bp); | 918 | xfs_trans_brelse(args->trans, bp); |
919 | return(retval); | 919 | return retval; |
920 | } else if (retval == EEXIST) { | 920 | } else if (retval == EEXIST) { |
921 | if (args->flags & ATTR_CREATE) { /* pure create op */ | 921 | if (args->flags & ATTR_CREATE) { /* pure create op */ |
922 | xfs_trans_brelse(args->trans, bp); | 922 | xfs_trans_brelse(args->trans, bp); |
923 | return(retval); | 923 | return retval; |
924 | } | 924 | } |
925 | 925 | ||
926 | trace_xfs_attr_leaf_replace(args); | 926 | trace_xfs_attr_leaf_replace(args); |
@@ -936,7 +936,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) | |||
936 | * Add the attribute to the leaf block, transitioning to a Btree | 936 | * Add the attribute to the leaf block, transitioning to a Btree |
937 | * if required. | 937 | * if required. |
938 | */ | 938 | */ |
939 | retval = xfs_attr_leaf_add(bp, args); | 939 | retval = xfs_attr3_leaf_add(bp, args); |
940 | if (retval == ENOSPC) { | 940 | if (retval == ENOSPC) { |
941 | /* | 941 | /* |
942 | * Promote the attribute list to the Btree format, then | 942 | * Promote the attribute list to the Btree format, then |
@@ -944,7 +944,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) | |||
944 | * can manage its own transactions. | 944 | * can manage its own transactions. |
945 | */ | 945 | */ |
946 | xfs_bmap_init(args->flist, args->firstblock); | 946 | xfs_bmap_init(args->flist, args->firstblock); |
947 | error = xfs_attr_leaf_to_node(args); | 947 | error = xfs_attr3_leaf_to_node(args); |
948 | if (!error) { | 948 | if (!error) { |
949 | error = xfs_bmap_finish(&args->trans, args->flist, | 949 | error = xfs_bmap_finish(&args->trans, args->flist, |
950 | &committed); | 950 | &committed); |
@@ -1009,7 +1009,7 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) | |||
1009 | * In a separate transaction, set the incomplete flag on the | 1009 | * In a separate transaction, set the incomplete flag on the |
1010 | * "old" attr and clear the incomplete flag on the "new" attr. | 1010 | * "old" attr and clear the incomplete flag on the "new" attr. |
1011 | */ | 1011 | */ |
1012 | error = xfs_attr_leaf_flipflags(args); | 1012 | error = xfs_attr3_leaf_flipflags(args); |
1013 | if (error) | 1013 | if (error) |
1014 | return(error); | 1014 | return(error); |
1015 | 1015 | ||
@@ -1031,19 +1031,19 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) | |||
1031 | * Read in the block containing the "old" attr, then | 1031 | * Read in the block containing the "old" attr, then |
1032 | * remove the "old" attr from that block (neat, huh!) | 1032 | * remove the "old" attr from that block (neat, huh!) |
1033 | */ | 1033 | */ |
1034 | error = xfs_attr_leaf_read(args->trans, args->dp, args->blkno, | 1034 | error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, |
1035 | -1, &bp); | 1035 | -1, &bp); |
1036 | if (error) | 1036 | if (error) |
1037 | return error; | 1037 | return error; |
1038 | 1038 | ||
1039 | xfs_attr_leaf_remove(bp, args); | 1039 | xfs_attr3_leaf_remove(bp, args); |
1040 | 1040 | ||
1041 | /* | 1041 | /* |
1042 | * If the result is small enough, shrink it all into the inode. | 1042 | * If the result is small enough, shrink it all into the inode. |
1043 | */ | 1043 | */ |
1044 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { | 1044 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { |
1045 | xfs_bmap_init(args->flist, args->firstblock); | 1045 | xfs_bmap_init(args->flist, args->firstblock); |
1046 | error = xfs_attr_leaf_to_shortform(bp, args, forkoff); | 1046 | error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); |
1047 | /* bp is gone due to xfs_da_shrink_inode */ | 1047 | /* bp is gone due to xfs_da_shrink_inode */ |
1048 | if (!error) { | 1048 | if (!error) { |
1049 | error = xfs_bmap_finish(&args->trans, | 1049 | error = xfs_bmap_finish(&args->trans, |
@@ -1075,9 +1075,9 @@ xfs_attr_leaf_addname(xfs_da_args_t *args) | |||
1075 | /* | 1075 | /* |
1076 | * Added a "remote" value, just clear the incomplete flag. | 1076 | * Added a "remote" value, just clear the incomplete flag. |
1077 | */ | 1077 | */ |
1078 | error = xfs_attr_leaf_clearflag(args); | 1078 | error = xfs_attr3_leaf_clearflag(args); |
1079 | } | 1079 | } |
1080 | return(error); | 1080 | return error; |
1081 | } | 1081 | } |
1082 | 1082 | ||
1083 | /* | 1083 | /* |
@@ -1100,24 +1100,24 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) | |||
1100 | */ | 1100 | */ |
1101 | dp = args->dp; | 1101 | dp = args->dp; |
1102 | args->blkno = 0; | 1102 | args->blkno = 0; |
1103 | error = xfs_attr_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); | 1103 | error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); |
1104 | if (error) | 1104 | if (error) |
1105 | return error; | 1105 | return error; |
1106 | 1106 | ||
1107 | error = xfs_attr_leaf_lookup_int(bp, args); | 1107 | error = xfs_attr3_leaf_lookup_int(bp, args); |
1108 | if (error == ENOATTR) { | 1108 | if (error == ENOATTR) { |
1109 | xfs_trans_brelse(args->trans, bp); | 1109 | xfs_trans_brelse(args->trans, bp); |
1110 | return(error); | 1110 | return error; |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | xfs_attr_leaf_remove(bp, args); | 1113 | xfs_attr3_leaf_remove(bp, args); |
1114 | 1114 | ||
1115 | /* | 1115 | /* |
1116 | * If the result is small enough, shrink it all into the inode. | 1116 | * If the result is small enough, shrink it all into the inode. |
1117 | */ | 1117 | */ |
1118 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { | 1118 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { |
1119 | xfs_bmap_init(args->flist, args->firstblock); | 1119 | xfs_bmap_init(args->flist, args->firstblock); |
1120 | error = xfs_attr_leaf_to_shortform(bp, args, forkoff); | 1120 | error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); |
1121 | /* bp is gone due to xfs_da_shrink_inode */ | 1121 | /* bp is gone due to xfs_da_shrink_inode */ |
1122 | if (!error) { | 1122 | if (!error) { |
1123 | error = xfs_bmap_finish(&args->trans, args->flist, | 1123 | error = xfs_bmap_finish(&args->trans, args->flist, |
@@ -1127,7 +1127,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) | |||
1127 | ASSERT(committed); | 1127 | ASSERT(committed); |
1128 | args->trans = NULL; | 1128 | args->trans = NULL; |
1129 | xfs_bmap_cancel(args->flist); | 1129 | xfs_bmap_cancel(args->flist); |
1130 | return(error); | 1130 | return error; |
1131 | } | 1131 | } |
1132 | 1132 | ||
1133 | /* | 1133 | /* |
@@ -1137,7 +1137,7 @@ xfs_attr_leaf_removename(xfs_da_args_t *args) | |||
1137 | if (committed) | 1137 | if (committed) |
1138 | xfs_trans_ijoin(args->trans, dp, 0); | 1138 | xfs_trans_ijoin(args->trans, dp, 0); |
1139 | } | 1139 | } |
1140 | return(0); | 1140 | return 0; |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | /* | 1143 | /* |
@@ -1155,21 +1155,21 @@ xfs_attr_leaf_get(xfs_da_args_t *args) | |||
1155 | trace_xfs_attr_leaf_get(args); | 1155 | trace_xfs_attr_leaf_get(args); |
1156 | 1156 | ||
1157 | args->blkno = 0; | 1157 | args->blkno = 0; |
1158 | error = xfs_attr_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); | 1158 | error = xfs_attr3_leaf_read(args->trans, args->dp, args->blkno, -1, &bp); |
1159 | if (error) | 1159 | if (error) |
1160 | return error; | 1160 | return error; |
1161 | 1161 | ||
1162 | error = xfs_attr_leaf_lookup_int(bp, args); | 1162 | error = xfs_attr3_leaf_lookup_int(bp, args); |
1163 | if (error != EEXIST) { | 1163 | if (error != EEXIST) { |
1164 | xfs_trans_brelse(args->trans, bp); | 1164 | xfs_trans_brelse(args->trans, bp); |
1165 | return(error); | 1165 | return error; |
1166 | } | 1166 | } |
1167 | error = xfs_attr_leaf_getvalue(bp, args); | 1167 | error = xfs_attr3_leaf_getvalue(bp, args); |
1168 | xfs_trans_brelse(args->trans, bp); | 1168 | xfs_trans_brelse(args->trans, bp); |
1169 | if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) { | 1169 | if (!error && (args->rmtblkno > 0) && !(args->flags & ATTR_KERNOVAL)) { |
1170 | error = xfs_attr_rmtval_get(args); | 1170 | error = xfs_attr_rmtval_get(args); |
1171 | } | 1171 | } |
1172 | return(error); | 1172 | return error; |
1173 | } | 1173 | } |
1174 | 1174 | ||
1175 | /* | 1175 | /* |
@@ -1184,11 +1184,11 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context) | |||
1184 | trace_xfs_attr_leaf_list(context); | 1184 | trace_xfs_attr_leaf_list(context); |
1185 | 1185 | ||
1186 | context->cursor->blkno = 0; | 1186 | context->cursor->blkno = 0; |
1187 | error = xfs_attr_leaf_read(NULL, context->dp, 0, -1, &bp); | 1187 | error = xfs_attr3_leaf_read(NULL, context->dp, 0, -1, &bp); |
1188 | if (error) | 1188 | if (error) |
1189 | return XFS_ERROR(error); | 1189 | return XFS_ERROR(error); |
1190 | 1190 | ||
1191 | error = xfs_attr_leaf_list_int(bp, context); | 1191 | error = xfs_attr3_leaf_list_int(bp, context); |
1192 | xfs_trans_brelse(NULL, bp); | 1192 | xfs_trans_brelse(NULL, bp); |
1193 | return XFS_ERROR(error); | 1193 | return XFS_ERROR(error); |
1194 | } | 1194 | } |
@@ -1257,7 +1257,7 @@ restart: | |||
1257 | args->rmtblkcnt = 0; | 1257 | args->rmtblkcnt = 0; |
1258 | } | 1258 | } |
1259 | 1259 | ||
1260 | retval = xfs_attr_leaf_add(blk->bp, state->args); | 1260 | retval = xfs_attr3_leaf_add(blk->bp, state->args); |
1261 | if (retval == ENOSPC) { | 1261 | if (retval == ENOSPC) { |
1262 | if (state->path.active == 1) { | 1262 | if (state->path.active == 1) { |
1263 | /* | 1263 | /* |
@@ -1267,7 +1267,7 @@ restart: | |||
1267 | */ | 1267 | */ |
1268 | xfs_da_state_free(state); | 1268 | xfs_da_state_free(state); |
1269 | xfs_bmap_init(args->flist, args->firstblock); | 1269 | xfs_bmap_init(args->flist, args->firstblock); |
1270 | error = xfs_attr_leaf_to_node(args); | 1270 | error = xfs_attr3_leaf_to_node(args); |
1271 | if (!error) { | 1271 | if (!error) { |
1272 | error = xfs_bmap_finish(&args->trans, | 1272 | error = xfs_bmap_finish(&args->trans, |
1273 | args->flist, | 1273 | args->flist, |
@@ -1369,7 +1369,7 @@ restart: | |||
1369 | * In a separate transaction, set the incomplete flag on the | 1369 | * In a separate transaction, set the incomplete flag on the |
1370 | * "old" attr and clear the incomplete flag on the "new" attr. | 1370 | * "old" attr and clear the incomplete flag on the "new" attr. |
1371 | */ | 1371 | */ |
1372 | error = xfs_attr_leaf_flipflags(args); | 1372 | error = xfs_attr3_leaf_flipflags(args); |
1373 | if (error) | 1373 | if (error) |
1374 | goto out; | 1374 | goto out; |
1375 | 1375 | ||
@@ -1408,7 +1408,7 @@ restart: | |||
1408 | */ | 1408 | */ |
1409 | blk = &state->path.blk[ state->path.active-1 ]; | 1409 | blk = &state->path.blk[ state->path.active-1 ]; |
1410 | ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); | 1410 | ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); |
1411 | error = xfs_attr_leaf_remove(blk->bp, args); | 1411 | error = xfs_attr3_leaf_remove(blk->bp, args); |
1412 | xfs_da3_fixhashpath(state, &state->path); | 1412 | xfs_da3_fixhashpath(state, &state->path); |
1413 | 1413 | ||
1414 | /* | 1414 | /* |
@@ -1449,7 +1449,7 @@ restart: | |||
1449 | /* | 1449 | /* |
1450 | * Added a "remote" value, just clear the incomplete flag. | 1450 | * Added a "remote" value, just clear the incomplete flag. |
1451 | */ | 1451 | */ |
1452 | error = xfs_attr_leaf_clearflag(args); | 1452 | error = xfs_attr3_leaf_clearflag(args); |
1453 | if (error) | 1453 | if (error) |
1454 | goto out; | 1454 | goto out; |
1455 | } | 1455 | } |
@@ -1523,7 +1523,7 @@ xfs_attr_node_removename(xfs_da_args_t *args) | |||
1523 | * Mark the attribute as INCOMPLETE, then bunmapi() the | 1523 | * Mark the attribute as INCOMPLETE, then bunmapi() the |
1524 | * remote value. | 1524 | * remote value. |
1525 | */ | 1525 | */ |
1526 | error = xfs_attr_leaf_setflag(args); | 1526 | error = xfs_attr3_leaf_setflag(args); |
1527 | if (error) | 1527 | if (error) |
1528 | goto out; | 1528 | goto out; |
1529 | error = xfs_attr_rmtval_remove(args); | 1529 | error = xfs_attr_rmtval_remove(args); |
@@ -1544,7 +1544,7 @@ xfs_attr_node_removename(xfs_da_args_t *args) | |||
1544 | */ | 1544 | */ |
1545 | blk = &state->path.blk[ state->path.active-1 ]; | 1545 | blk = &state->path.blk[ state->path.active-1 ]; |
1546 | ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); | 1546 | ASSERT(blk->magic == XFS_ATTR_LEAF_MAGIC); |
1547 | retval = xfs_attr_leaf_remove(blk->bp, args); | 1547 | retval = xfs_attr3_leaf_remove(blk->bp, args); |
1548 | xfs_da3_fixhashpath(state, &state->path); | 1548 | xfs_da3_fixhashpath(state, &state->path); |
1549 | 1549 | ||
1550 | /* | 1550 | /* |
@@ -1590,13 +1590,13 @@ xfs_attr_node_removename(xfs_da_args_t *args) | |||
1590 | ASSERT(state->path.blk[0].bp); | 1590 | ASSERT(state->path.blk[0].bp); |
1591 | state->path.blk[0].bp = NULL; | 1591 | state->path.blk[0].bp = NULL; |
1592 | 1592 | ||
1593 | error = xfs_attr_leaf_read(args->trans, args->dp, 0, -1, &bp); | 1593 | error = xfs_attr3_leaf_read(args->trans, args->dp, 0, -1, &bp); |
1594 | if (error) | 1594 | if (error) |
1595 | goto out; | 1595 | goto out; |
1596 | 1596 | ||
1597 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { | 1597 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { |
1598 | xfs_bmap_init(args->flist, args->firstblock); | 1598 | xfs_bmap_init(args->flist, args->firstblock); |
1599 | error = xfs_attr_leaf_to_shortform(bp, args, forkoff); | 1599 | error = xfs_attr3_leaf_to_shortform(bp, args, forkoff); |
1600 | /* bp is gone due to xfs_da_shrink_inode */ | 1600 | /* bp is gone due to xfs_da_shrink_inode */ |
1601 | if (!error) { | 1601 | if (!error) { |
1602 | error = xfs_bmap_finish(&args->trans, | 1602 | error = xfs_bmap_finish(&args->trans, |
@@ -1768,7 +1768,7 @@ xfs_attr_node_get(xfs_da_args_t *args) | |||
1768 | /* | 1768 | /* |
1769 | * Get the value, local or "remote" | 1769 | * Get the value, local or "remote" |
1770 | */ | 1770 | */ |
1771 | retval = xfs_attr_leaf_getvalue(blk->bp, args); | 1771 | retval = xfs_attr3_leaf_getvalue(blk->bp, args); |
1772 | if (!retval && (args->rmtblkno > 0) | 1772 | if (!retval && (args->rmtblkno > 0) |
1773 | && !(args->flags & ATTR_KERNOVAL)) { | 1773 | && !(args->flags & ATTR_KERNOVAL)) { |
1774 | retval = xfs_attr_rmtval_get(args); | 1774 | retval = xfs_attr_rmtval_get(args); |
@@ -1793,7 +1793,9 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1793 | attrlist_cursor_kern_t *cursor; | 1793 | attrlist_cursor_kern_t *cursor; |
1794 | xfs_attr_leafblock_t *leaf; | 1794 | xfs_attr_leafblock_t *leaf; |
1795 | xfs_da_intnode_t *node; | 1795 | xfs_da_intnode_t *node; |
1796 | xfs_da_node_entry_t *btree; | 1796 | struct xfs_attr3_icleaf_hdr leafhdr; |
1797 | struct xfs_da3_icnode_hdr nodehdr; | ||
1798 | struct xfs_da_node_entry *btree; | ||
1797 | int error, i; | 1799 | int error, i; |
1798 | struct xfs_buf *bp; | 1800 | struct xfs_buf *bp; |
1799 | 1801 | ||
@@ -1814,22 +1816,28 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1814 | if ((error != 0) && (error != EFSCORRUPTED)) | 1816 | if ((error != 0) && (error != EFSCORRUPTED)) |
1815 | return(error); | 1817 | return(error); |
1816 | if (bp) { | 1818 | if (bp) { |
1819 | struct xfs_attr_leaf_entry *entries; | ||
1820 | |||
1817 | node = bp->b_addr; | 1821 | node = bp->b_addr; |
1818 | switch (be16_to_cpu(node->hdr.info.magic)) { | 1822 | switch (be16_to_cpu(node->hdr.info.magic)) { |
1819 | case XFS_DA_NODE_MAGIC: | 1823 | case XFS_DA_NODE_MAGIC: |
1824 | case XFS_DA3_NODE_MAGIC: | ||
1820 | trace_xfs_attr_list_wrong_blk(context); | 1825 | trace_xfs_attr_list_wrong_blk(context); |
1821 | xfs_trans_brelse(NULL, bp); | 1826 | xfs_trans_brelse(NULL, bp); |
1822 | bp = NULL; | 1827 | bp = NULL; |
1823 | break; | 1828 | break; |
1824 | case XFS_ATTR_LEAF_MAGIC: | 1829 | case XFS_ATTR_LEAF_MAGIC: |
1830 | case XFS_ATTR3_LEAF_MAGIC: | ||
1825 | leaf = bp->b_addr; | 1831 | leaf = bp->b_addr; |
1826 | if (cursor->hashval > be32_to_cpu(leaf->entries[ | 1832 | xfs_attr3_leaf_hdr_from_disk(&leafhdr, leaf); |
1827 | be16_to_cpu(leaf->hdr.count)-1].hashval)) { | 1833 | entries = xfs_attr3_leaf_entryp(leaf); |
1834 | if (cursor->hashval > be32_to_cpu( | ||
1835 | entries[leafhdr.count - 1].hashval)) { | ||
1828 | trace_xfs_attr_list_wrong_blk(context); | 1836 | trace_xfs_attr_list_wrong_blk(context); |
1829 | xfs_trans_brelse(NULL, bp); | 1837 | xfs_trans_brelse(NULL, bp); |
1830 | bp = NULL; | 1838 | bp = NULL; |
1831 | } else if (cursor->hashval <= | 1839 | } else if (cursor->hashval <= be32_to_cpu( |
1832 | be32_to_cpu(leaf->entries[0].hashval)) { | 1840 | entries[0].hashval)) { |
1833 | trace_xfs_attr_list_wrong_blk(context); | 1841 | trace_xfs_attr_list_wrong_blk(context); |
1834 | xfs_trans_brelse(NULL, bp); | 1842 | xfs_trans_brelse(NULL, bp); |
1835 | bp = NULL; | 1843 | bp = NULL; |
@@ -1851,27 +1859,31 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1851 | if (bp == NULL) { | 1859 | if (bp == NULL) { |
1852 | cursor->blkno = 0; | 1860 | cursor->blkno = 0; |
1853 | for (;;) { | 1861 | for (;;) { |
1862 | __uint16_t magic; | ||
1863 | |||
1854 | error = xfs_da3_node_read(NULL, context->dp, | 1864 | error = xfs_da3_node_read(NULL, context->dp, |
1855 | cursor->blkno, -1, &bp, | 1865 | cursor->blkno, -1, &bp, |
1856 | XFS_ATTR_FORK); | 1866 | XFS_ATTR_FORK); |
1857 | if (error) | 1867 | if (error) |
1858 | return(error); | 1868 | return(error); |
1859 | node = bp->b_addr; | 1869 | node = bp->b_addr; |
1860 | if (node->hdr.info.magic == | 1870 | magic = be16_to_cpu(node->hdr.info.magic); |
1861 | cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) | 1871 | if (magic == XFS_ATTR_LEAF_MAGIC || |
1872 | magic == XFS_ATTR3_LEAF_MAGIC) | ||
1862 | break; | 1873 | break; |
1863 | if (unlikely(node->hdr.info.magic != | 1874 | if (magic != XFS_DA_NODE_MAGIC && |
1864 | cpu_to_be16(XFS_DA_NODE_MAGIC))) { | 1875 | magic != XFS_DA3_NODE_MAGIC) { |
1865 | XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)", | 1876 | XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)", |
1866 | XFS_ERRLEVEL_LOW, | 1877 | XFS_ERRLEVEL_LOW, |
1867 | context->dp->i_mount, | 1878 | context->dp->i_mount, |
1868 | node); | 1879 | node); |
1869 | xfs_trans_brelse(NULL, bp); | 1880 | xfs_trans_brelse(NULL, bp); |
1870 | return(XFS_ERROR(EFSCORRUPTED)); | 1881 | return XFS_ERROR(EFSCORRUPTED); |
1871 | } | 1882 | } |
1883 | |||
1884 | xfs_da3_node_hdr_from_disk(&nodehdr, node); | ||
1872 | btree = xfs_da3_node_tree_p(node); | 1885 | btree = xfs_da3_node_tree_p(node); |
1873 | for (i = 0; i < be16_to_cpu(node->hdr.count); | 1886 | for (i = 0; i < nodehdr.count; btree++, i++) { |
1874 | btree++, i++) { | ||
1875 | if (cursor->hashval | 1887 | if (cursor->hashval |
1876 | <= be32_to_cpu(btree->hashval)) { | 1888 | <= be32_to_cpu(btree->hashval)) { |
1877 | cursor->blkno = be32_to_cpu(btree->before); | 1889 | cursor->blkno = be32_to_cpu(btree->before); |
@@ -1880,9 +1892,9 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1880 | break; | 1892 | break; |
1881 | } | 1893 | } |
1882 | } | 1894 | } |
1883 | if (i == be16_to_cpu(node->hdr.count)) { | 1895 | if (i == nodehdr.count) { |
1884 | xfs_trans_brelse(NULL, bp); | 1896 | xfs_trans_brelse(NULL, bp); |
1885 | return(0); | 1897 | return 0; |
1886 | } | 1898 | } |
1887 | xfs_trans_brelse(NULL, bp); | 1899 | xfs_trans_brelse(NULL, bp); |
1888 | } | 1900 | } |
@@ -1896,22 +1908,23 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1896 | */ | 1908 | */ |
1897 | for (;;) { | 1909 | for (;;) { |
1898 | leaf = bp->b_addr; | 1910 | leaf = bp->b_addr; |
1899 | error = xfs_attr_leaf_list_int(bp, context); | 1911 | error = xfs_attr3_leaf_list_int(bp, context); |
1900 | if (error) { | 1912 | if (error) { |
1901 | xfs_trans_brelse(NULL, bp); | 1913 | xfs_trans_brelse(NULL, bp); |
1902 | return error; | 1914 | return error; |
1903 | } | 1915 | } |
1904 | if (context->seen_enough || leaf->hdr.info.forw == 0) | 1916 | xfs_attr3_leaf_hdr_from_disk(&leafhdr, leaf); |
1917 | if (context->seen_enough || leafhdr.forw == 0) | ||
1905 | break; | 1918 | break; |
1906 | cursor->blkno = be32_to_cpu(leaf->hdr.info.forw); | 1919 | cursor->blkno = leafhdr.forw; |
1907 | xfs_trans_brelse(NULL, bp); | 1920 | xfs_trans_brelse(NULL, bp); |
1908 | error = xfs_attr_leaf_read(NULL, context->dp, cursor->blkno, -1, | 1921 | error = xfs_attr3_leaf_read(NULL, context->dp, cursor->blkno, -1, |
1909 | &bp); | 1922 | &bp); |
1910 | if (error) | 1923 | if (error) |
1911 | return error; | 1924 | return error; |
1912 | } | 1925 | } |
1913 | xfs_trans_brelse(NULL, bp); | 1926 | xfs_trans_brelse(NULL, bp); |
1914 | return(0); | 1927 | return 0; |
1915 | } | 1928 | } |
1916 | 1929 | ||
1917 | 1930 | ||