diff options
Diffstat (limited to 'fs/xfs/xfs_da_btree.c')
-rw-r--r-- | fs/xfs/xfs_da_btree.c | 101 |
1 files changed, 24 insertions, 77 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 8b792ddf2164..473671fa5c13 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -1,41 +1,26 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved. | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
3 | * All Rights Reserved. | ||
3 | * | 4 | * |
4 | * This program is free software; you can redistribute it and/or modify it | 5 | * This program is free software; you can redistribute it and/or |
5 | * under the terms of version 2 of the GNU General Public License as | 6 | * modify it under the terms of the GNU General Public License as |
6 | * published by the Free Software Foundation. | 7 | * published by the Free Software Foundation. |
7 | * | 8 | * |
8 | * This program is distributed in the hope that it would be useful, but | 9 | * This program is distributed in the hope that it would be useful, |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. | ||
11 | * | 13 | * |
12 | * Further, this software is distributed without any warranty that it is | 14 | * You should have received a copy of the GNU General Public License |
13 | * free of the rightful claim of any third person regarding infringement | 15 | * along with this program; if not, write the Free Software Foundation, |
14 | * or the like. Any license provided herein, whether implied or | 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
15 | * otherwise, applies only to this software file. Patent licenses, if | ||
16 | * any, provided herein do not apply to combinations of this program with | ||
17 | * other software, or any other product whatsoever. | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License along | ||
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | ||
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | ||
22 | * | ||
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | ||
24 | * Mountain View, CA 94043, or: | ||
25 | * | ||
26 | * http://www.sgi.com | ||
27 | * | ||
28 | * For further information regarding this notice, see: | ||
29 | * | ||
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | ||
31 | */ | 17 | */ |
32 | |||
33 | #include "xfs.h" | 18 | #include "xfs.h" |
34 | 19 | #include "xfs_fs.h" | |
35 | #include "xfs_macros.h" | ||
36 | #include "xfs_types.h" | 20 | #include "xfs_types.h" |
37 | #include "xfs_inum.h" | 21 | #include "xfs_bit.h" |
38 | #include "xfs_log.h" | 22 | #include "xfs_log.h" |
23 | #include "xfs_inum.h" | ||
39 | #include "xfs_trans.h" | 24 | #include "xfs_trans.h" |
40 | #include "xfs_sb.h" | 25 | #include "xfs_sb.h" |
41 | #include "xfs_ag.h" | 26 | #include "xfs_ag.h" |
@@ -43,19 +28,19 @@ | |||
43 | #include "xfs_dir2.h" | 28 | #include "xfs_dir2.h" |
44 | #include "xfs_dmapi.h" | 29 | #include "xfs_dmapi.h" |
45 | #include "xfs_mount.h" | 30 | #include "xfs_mount.h" |
46 | #include "xfs_alloc_btree.h" | 31 | #include "xfs_da_btree.h" |
47 | #include "xfs_bmap_btree.h" | 32 | #include "xfs_bmap_btree.h" |
33 | #include "xfs_alloc_btree.h" | ||
48 | #include "xfs_ialloc_btree.h" | 34 | #include "xfs_ialloc_btree.h" |
49 | #include "xfs_alloc.h" | ||
50 | #include "xfs_btree.h" | ||
51 | #include "xfs_attr_sf.h" | ||
52 | #include "xfs_dir_sf.h" | 35 | #include "xfs_dir_sf.h" |
53 | #include "xfs_dir2_sf.h" | 36 | #include "xfs_dir2_sf.h" |
37 | #include "xfs_attr_sf.h" | ||
54 | #include "xfs_dinode.h" | 38 | #include "xfs_dinode.h" |
55 | #include "xfs_inode_item.h" | ||
56 | #include "xfs_inode.h" | 39 | #include "xfs_inode.h" |
40 | #include "xfs_inode_item.h" | ||
41 | #include "xfs_alloc.h" | ||
42 | #include "xfs_btree.h" | ||
57 | #include "xfs_bmap.h" | 43 | #include "xfs_bmap.h" |
58 | #include "xfs_da_btree.h" | ||
59 | #include "xfs_attr.h" | 44 | #include "xfs_attr.h" |
60 | #include "xfs_attr_leaf.h" | 45 | #include "xfs_attr_leaf.h" |
61 | #include "xfs_dir_leaf.h" | 46 | #include "xfs_dir_leaf.h" |
@@ -64,7 +49,6 @@ | |||
64 | #include "xfs_dir2_block.h" | 49 | #include "xfs_dir2_block.h" |
65 | #include "xfs_dir2_node.h" | 50 | #include "xfs_dir2_node.h" |
66 | #include "xfs_error.h" | 51 | #include "xfs_error.h" |
67 | #include "xfs_bit.h" | ||
68 | 52 | ||
69 | /* | 53 | /* |
70 | * xfs_da_btree.c | 54 | * xfs_da_btree.c |
@@ -190,9 +174,6 @@ xfs_da_split(xfs_da_state_t *state) | |||
190 | */ | 174 | */ |
191 | switch (oldblk->magic) { | 175 | switch (oldblk->magic) { |
192 | case XFS_ATTR_LEAF_MAGIC: | 176 | case XFS_ATTR_LEAF_MAGIC: |
193 | #ifndef __KERNEL__ | ||
194 | return(ENOTTY); | ||
195 | #else | ||
196 | error = xfs_attr_leaf_split(state, oldblk, newblk); | 177 | error = xfs_attr_leaf_split(state, oldblk, newblk); |
197 | if ((error != 0) && (error != ENOSPC)) { | 178 | if ((error != 0) && (error != ENOSPC)) { |
198 | return(error); /* GROT: attr is inconsistent */ | 179 | return(error); /* GROT: attr is inconsistent */ |
@@ -218,7 +199,6 @@ xfs_da_split(xfs_da_state_t *state) | |||
218 | return(error); /* GROT: attr inconsistent */ | 199 | return(error); /* GROT: attr inconsistent */ |
219 | addblk = newblk; | 200 | addblk = newblk; |
220 | break; | 201 | break; |
221 | #endif | ||
222 | case XFS_DIR_LEAF_MAGIC: | 202 | case XFS_DIR_LEAF_MAGIC: |
223 | ASSERT(XFS_DIR_IS_V1(state->mp)); | 203 | ASSERT(XFS_DIR_IS_V1(state->mp)); |
224 | error = xfs_dir_leaf_split(state, oldblk, newblk); | 204 | error = xfs_dir_leaf_split(state, oldblk, newblk); |
@@ -449,7 +429,8 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
449 | /* | 429 | /* |
450 | * With V2 the extra block is data or freespace. | 430 | * With V2 the extra block is data or freespace. |
451 | */ | 431 | */ |
452 | useextra = state->extravalid && XFS_DIR_IS_V1(state->mp); | 432 | useextra = state->extravalid && (XFS_DIR_IS_V1(state->mp) || |
433 | state->args->whichfork == XFS_ATTR_FORK); | ||
453 | newcount = 1 + useextra; | 434 | newcount = 1 + useextra; |
454 | /* | 435 | /* |
455 | * Do we have to split the node? | 436 | * Do we have to split the node? |
@@ -706,18 +687,12 @@ xfs_da_join(xfs_da_state_t *state) | |||
706 | */ | 687 | */ |
707 | switch (drop_blk->magic) { | 688 | switch (drop_blk->magic) { |
708 | case XFS_ATTR_LEAF_MAGIC: | 689 | case XFS_ATTR_LEAF_MAGIC: |
709 | #ifndef __KERNEL__ | ||
710 | error = ENOTTY; | ||
711 | #else | ||
712 | error = xfs_attr_leaf_toosmall(state, &action); | 690 | error = xfs_attr_leaf_toosmall(state, &action); |
713 | #endif | ||
714 | if (error) | 691 | if (error) |
715 | return(error); | 692 | return(error); |
716 | if (action == 0) | 693 | if (action == 0) |
717 | return(0); | 694 | return(0); |
718 | #ifdef __KERNEL__ | ||
719 | xfs_attr_leaf_unbalance(state, drop_blk, save_blk); | 695 | xfs_attr_leaf_unbalance(state, drop_blk, save_blk); |
720 | #endif | ||
721 | break; | 696 | break; |
722 | case XFS_DIR_LEAF_MAGIC: | 697 | case XFS_DIR_LEAF_MAGIC: |
723 | ASSERT(XFS_DIR_IS_V1(state->mp)); | 698 | ASSERT(XFS_DIR_IS_V1(state->mp)); |
@@ -973,13 +948,11 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path) | |||
973 | level = path->active-1; | 948 | level = path->active-1; |
974 | blk = &path->blk[ level ]; | 949 | blk = &path->blk[ level ]; |
975 | switch (blk->magic) { | 950 | switch (blk->magic) { |
976 | #ifdef __KERNEL__ | ||
977 | case XFS_ATTR_LEAF_MAGIC: | 951 | case XFS_ATTR_LEAF_MAGIC: |
978 | lasthash = xfs_attr_leaf_lasthash(blk->bp, &count); | 952 | lasthash = xfs_attr_leaf_lasthash(blk->bp, &count); |
979 | if (count == 0) | 953 | if (count == 0) |
980 | return; | 954 | return; |
981 | break; | 955 | break; |
982 | #endif | ||
983 | case XFS_DIR_LEAF_MAGIC: | 956 | case XFS_DIR_LEAF_MAGIC: |
984 | ASSERT(XFS_DIR_IS_V1(state->mp)); | 957 | ASSERT(XFS_DIR_IS_V1(state->mp)); |
985 | lasthash = xfs_dir_leaf_lasthash(blk->bp, &count); | 958 | lasthash = xfs_dir_leaf_lasthash(blk->bp, &count); |
@@ -1220,12 +1193,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1220 | blkno = INT_GET(btree->before, ARCH_CONVERT); | 1193 | blkno = INT_GET(btree->before, ARCH_CONVERT); |
1221 | } | 1194 | } |
1222 | } | 1195 | } |
1223 | #ifdef __KERNEL__ | ||
1224 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { | 1196 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { |
1225 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); | 1197 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); |
1226 | break; | 1198 | break; |
1227 | } | 1199 | } |
1228 | #endif | ||
1229 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { | 1200 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { |
1230 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); | 1201 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); |
1231 | break; | 1202 | break; |
@@ -1252,13 +1223,11 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1252 | retval = xfs_dir2_leafn_lookup_int(blk->bp, args, | 1223 | retval = xfs_dir2_leafn_lookup_int(blk->bp, args, |
1253 | &blk->index, state); | 1224 | &blk->index, state); |
1254 | } | 1225 | } |
1255 | #ifdef __KERNEL__ | ||
1256 | else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { | 1226 | else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { |
1257 | retval = xfs_attr_leaf_lookup_int(blk->bp, args); | 1227 | retval = xfs_attr_leaf_lookup_int(blk->bp, args); |
1258 | blk->index = args->index; | 1228 | blk->index = args->index; |
1259 | args->blkno = blk->blkno; | 1229 | args->blkno = blk->blkno; |
1260 | } | 1230 | } |
1261 | #endif | ||
1262 | if (((retval == ENOENT) || (retval == ENOATTR)) && | 1231 | if (((retval == ENOENT) || (retval == ENOATTR)) && |
1263 | (blk->hashval == args->hashval)) { | 1232 | (blk->hashval == args->hashval)) { |
1264 | error = xfs_da_path_shift(state, &state->path, 1, 1, | 1233 | error = xfs_da_path_shift(state, &state->path, 1, 1, |
@@ -1268,12 +1237,10 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1268 | if (retval == 0) { | 1237 | if (retval == 0) { |
1269 | continue; | 1238 | continue; |
1270 | } | 1239 | } |
1271 | #ifdef __KERNEL__ | ||
1272 | else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { | 1240 | else if (blk->magic == XFS_ATTR_LEAF_MAGIC) { |
1273 | /* path_shift() gives ENOENT */ | 1241 | /* path_shift() gives ENOENT */ |
1274 | retval = XFS_ERROR(ENOATTR); | 1242 | retval = XFS_ERROR(ENOATTR); |
1275 | } | 1243 | } |
1276 | #endif | ||
1277 | } | 1244 | } |
1278 | break; | 1245 | break; |
1279 | } | 1246 | } |
@@ -1312,11 +1279,9 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, | |||
1312 | ASSERT(old_blk->magic == new_blk->magic); | 1279 | ASSERT(old_blk->magic == new_blk->magic); |
1313 | 1280 | ||
1314 | switch (old_blk->magic) { | 1281 | switch (old_blk->magic) { |
1315 | #ifdef __KERNEL__ | ||
1316 | case XFS_ATTR_LEAF_MAGIC: | 1282 | case XFS_ATTR_LEAF_MAGIC: |
1317 | before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); | 1283 | before = xfs_attr_leaf_order(old_blk->bp, new_blk->bp); |
1318 | break; | 1284 | break; |
1319 | #endif | ||
1320 | case XFS_DIR_LEAF_MAGIC: | 1285 | case XFS_DIR_LEAF_MAGIC: |
1321 | ASSERT(XFS_DIR_IS_V1(state->mp)); | 1286 | ASSERT(XFS_DIR_IS_V1(state->mp)); |
1322 | before = xfs_dir_leaf_order(old_blk->bp, new_blk->bp); | 1287 | before = xfs_dir_leaf_order(old_blk->bp, new_blk->bp); |
@@ -1587,12 +1552,10 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, | |||
1587 | ASSERT(level == path->active-1); | 1552 | ASSERT(level == path->active-1); |
1588 | blk->index = 0; | 1553 | blk->index = 0; |
1589 | switch(blk->magic) { | 1554 | switch(blk->magic) { |
1590 | #ifdef __KERNEL__ | ||
1591 | case XFS_ATTR_LEAF_MAGIC: | 1555 | case XFS_ATTR_LEAF_MAGIC: |
1592 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, | 1556 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, |
1593 | NULL); | 1557 | NULL); |
1594 | break; | 1558 | break; |
1595 | #endif | ||
1596 | case XFS_DIR_LEAF_MAGIC: | 1559 | case XFS_DIR_LEAF_MAGIC: |
1597 | ASSERT(XFS_DIR_IS_V1(state->mp)); | 1560 | ASSERT(XFS_DIR_IS_V1(state->mp)); |
1598 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, | 1561 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, |
@@ -1626,19 +1589,10 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, | |||
1626 | * This is implemented with some source-level loop unrolling. | 1589 | * This is implemented with some source-level loop unrolling. |
1627 | */ | 1590 | */ |
1628 | xfs_dahash_t | 1591 | xfs_dahash_t |
1629 | xfs_da_hashname(uchar_t *name, int namelen) | 1592 | xfs_da_hashname(const uchar_t *name, int namelen) |
1630 | { | 1593 | { |
1631 | xfs_dahash_t hash; | 1594 | xfs_dahash_t hash; |
1632 | 1595 | ||
1633 | #ifdef SLOWVERSION | ||
1634 | /* | ||
1635 | * This is the old one-byte-at-a-time version. | ||
1636 | */ | ||
1637 | for (hash = 0; namelen > 0; namelen--) | ||
1638 | hash = *name++ ^ rol32(hash, 7); | ||
1639 | |||
1640 | return(hash); | ||
1641 | #else | ||
1642 | /* | 1596 | /* |
1643 | * Do four characters at a time as long as we can. | 1597 | * Do four characters at a time as long as we can. |
1644 | */ | 1598 | */ |
@@ -1657,12 +1611,9 @@ xfs_da_hashname(uchar_t *name, int namelen) | |||
1657 | return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2); | 1611 | return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2); |
1658 | case 1: | 1612 | case 1: |
1659 | return (name[0] << 0) ^ rol32(hash, 7 * 1); | 1613 | return (name[0] << 0) ^ rol32(hash, 7 * 1); |
1660 | case 0: | 1614 | default: /* case 0: */ |
1661 | return hash; | 1615 | return hash; |
1662 | } | 1616 | } |
1663 | /* NOTREACHED */ | ||
1664 | #endif | ||
1665 | return 0; /* keep gcc happy */ | ||
1666 | } | 1617 | } |
1667 | 1618 | ||
1668 | /* | 1619 | /* |
@@ -2200,20 +2151,16 @@ xfs_da_do_buf( | |||
2200 | error = bp ? XFS_BUF_GETERROR(bp) : XFS_ERROR(EIO); | 2151 | error = bp ? XFS_BUF_GETERROR(bp) : XFS_ERROR(EIO); |
2201 | break; | 2152 | break; |
2202 | case 1: | 2153 | case 1: |
2203 | #ifndef __KERNEL__ | ||
2204 | case 2: | 2154 | case 2: |
2205 | #endif | ||
2206 | bp = NULL; | 2155 | bp = NULL; |
2207 | error = xfs_trans_read_buf(mp, trans, mp->m_ddev_targp, | 2156 | error = xfs_trans_read_buf(mp, trans, mp->m_ddev_targp, |
2208 | mappedbno, nmapped, 0, &bp); | 2157 | mappedbno, nmapped, 0, &bp); |
2209 | break; | 2158 | break; |
2210 | #ifdef __KERNEL__ | ||
2211 | case 3: | 2159 | case 3: |
2212 | xfs_baread(mp->m_ddev_targp, mappedbno, nmapped); | 2160 | xfs_baread(mp->m_ddev_targp, mappedbno, nmapped); |
2213 | error = 0; | 2161 | error = 0; |
2214 | bp = NULL; | 2162 | bp = NULL; |
2215 | break; | 2163 | break; |
2216 | #endif | ||
2217 | } | 2164 | } |
2218 | if (error) { | 2165 | if (error) { |
2219 | if (bp) | 2166 | if (bp) |