aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_attr_leaf.c
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2005-11-01 18:33:33 -0500
committerNathan Scott <nathans@sgi.com>2005-11-01 18:33:33 -0500
commitaa82daa06198b27963fe3d6ee8035855b29f6524 (patch)
tree7c618d365997e8a9a326739f0579b3cc1272e62e /fs/xfs/xfs_attr_leaf.c
parente8c8b3a79d85c22d3665b97dde843dc4d8d7ae37 (diff)
[XFS] Move some code around to prepare for the upcoming extended
attributes format change (attr2). SGI-PV: 941645 SGI-Modid: xfs-linux:xfs-kern:23833a Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_attr_leaf.c')
-rw-r--r--fs/xfs/xfs_attr_leaf.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 1cdd574c63a9..e13eaa521436 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved. 2 * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify it 4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as 5 * under the terms of version 2 of the GNU General Public License as
@@ -898,7 +898,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
898 ASSERT((args->index >= 0) 898 ASSERT((args->index >= 0)
899 && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); 899 && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
900 hdr = &leaf->hdr; 900 hdr = &leaf->hdr;
901 entsize = xfs_attr_leaf_newentsize(args, 901 entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
902 args->trans->t_mountp->m_sb.sb_blocksize, NULL); 902 args->trans->t_mountp->m_sb.sb_blocksize, NULL);
903 903
904 /* 904 /*
@@ -995,13 +995,14 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
995 mp = args->trans->t_mountp; 995 mp = args->trans->t_mountp;
996 ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp)); 996 ASSERT(INT_GET(map->base, ARCH_CONVERT) < XFS_LBSIZE(mp));
997 ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0); 997 ASSERT((INT_GET(map->base, ARCH_CONVERT) & 0x3) == 0);
998 ASSERT(INT_GET(map->size, ARCH_CONVERT) 998 ASSERT(INT_GET(map->size, ARCH_CONVERT) >=
999 >= xfs_attr_leaf_newentsize(args, 999 xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
1000 mp->m_sb.sb_blocksize, NULL)); 1000 mp->m_sb.sb_blocksize, NULL));
1001 ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp)); 1001 ASSERT(INT_GET(map->size, ARCH_CONVERT) < XFS_LBSIZE(mp));
1002 ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0); 1002 ASSERT((INT_GET(map->size, ARCH_CONVERT) & 0x3) == 0);
1003 INT_MOD(map->size, ARCH_CONVERT, 1003 INT_MOD(map->size, ARCH_CONVERT,
1004 -xfs_attr_leaf_newentsize(args, mp->m_sb.sb_blocksize, &tmp)); 1004 -xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
1005 mp->m_sb.sb_blocksize, &tmp));
1005 INT_SET(entry->nameidx, ARCH_CONVERT, 1006 INT_SET(entry->nameidx, ARCH_CONVERT,
1006 INT_GET(map->base, ARCH_CONVERT) 1007 INT_GET(map->base, ARCH_CONVERT)
1007 + INT_GET(map->size, ARCH_CONVERT)); 1008 + INT_GET(map->size, ARCH_CONVERT));
@@ -1357,8 +1358,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
1357 half = (max+1) * sizeof(*entry); 1358 half = (max+1) * sizeof(*entry);
1358 half += INT_GET(hdr1->usedbytes, ARCH_CONVERT) 1359 half += INT_GET(hdr1->usedbytes, ARCH_CONVERT)
1359 + INT_GET(hdr2->usedbytes, ARCH_CONVERT) 1360 + INT_GET(hdr2->usedbytes, ARCH_CONVERT)
1360 + xfs_attr_leaf_newentsize(state->args, 1361 + xfs_attr_leaf_newentsize(
1361 state->blocksize, NULL); 1362 state->args->namelen,
1363 state->args->valuelen,
1364 state->blocksize, NULL);
1362 half /= 2; 1365 half /= 2;
1363 lastdelta = state->blocksize; 1366 lastdelta = state->blocksize;
1364 entry = &leaf1->entries[0]; 1367 entry = &leaf1->entries[0];
@@ -1370,9 +1373,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
1370 */ 1373 */
1371 if (count == blk1->index) { 1374 if (count == blk1->index) {
1372 tmp = totallen + sizeof(*entry) + 1375 tmp = totallen + sizeof(*entry) +
1373 xfs_attr_leaf_newentsize(state->args, 1376 xfs_attr_leaf_newentsize(
1374 state->blocksize, 1377 state->args->namelen,
1375 NULL); 1378 state->args->valuelen,
1379 state->blocksize, NULL);
1376 if (XFS_ATTR_ABS(half - tmp) > lastdelta) 1380 if (XFS_ATTR_ABS(half - tmp) > lastdelta)
1377 break; 1381 break;
1378 lastdelta = XFS_ATTR_ABS(half - tmp); 1382 lastdelta = XFS_ATTR_ABS(half - tmp);
@@ -1408,9 +1412,10 @@ xfs_attr_leaf_figure_balance(xfs_da_state_t *state,
1408 totallen -= count * sizeof(*entry); 1412 totallen -= count * sizeof(*entry);
1409 if (foundit) { 1413 if (foundit) {
1410 totallen -= sizeof(*entry) + 1414 totallen -= sizeof(*entry) +
1411 xfs_attr_leaf_newentsize(state->args, 1415 xfs_attr_leaf_newentsize(
1412 state->blocksize, 1416 state->args->namelen,
1413 NULL); 1417 state->args->valuelen,
1418 state->blocksize, NULL);
1414 } 1419 }
1415 1420
1416 *countarg = count; 1421 *countarg = count;
@@ -2253,17 +2258,17 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
2253 * a "local" or a "remote" attribute. 2258 * a "local" or a "remote" attribute.
2254 */ 2259 */
2255int 2260int
2256xfs_attr_leaf_newentsize(xfs_da_args_t *args, int blocksize, int *local) 2261xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, int *local)
2257{ 2262{
2258 int size; 2263 int size;
2259 2264
2260 size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(args->namelen, args->valuelen); 2265 size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(namelen, valuelen);
2261 if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) { 2266 if (size < XFS_ATTR_LEAF_ENTSIZE_LOCAL_MAX(blocksize)) {
2262 if (local) { 2267 if (local) {
2263 *local = 1; 2268 *local = 1;
2264 } 2269 }
2265 } else { 2270 } else {
2266 size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(args->namelen); 2271 size = XFS_ATTR_LEAF_ENTSIZE_REMOTE(namelen);
2267 if (local) { 2272 if (local) {
2268 *local = 0; 2273 *local = 0;
2269 } 2274 }