From f9c48a873e130ab6cccd039cf5f045342b48a209 Mon Sep 17 00:00:00 2001 From: Nathan Scott Date: Tue, 8 Nov 2005 14:07:59 +0000 Subject: [PATCH] Merge back kernel fixes/code updates in xfs. Merge of master-melb:xfs-cmds:24318a by kenmcd. --- libxfs/xfs.h | 1 + libxfs/xfs_da_btree.c | 31 +++++++++---------------------- libxfs/xfs_dir2_sf.c | 6 +++--- libxfs/xfs_dir_leaf.c | 2 +- libxfs/xfs_mount.c | 2 +- 5 files changed, 15 insertions(+), 27 deletions(-) diff --git a/libxfs/xfs.h b/libxfs/xfs.h index 80ed1d036..63d69e2c0 100644 --- a/libxfs/xfs.h +++ b/libxfs/xfs.h @@ -342,6 +342,7 @@ typedef struct { dev_t dev; } xfs_buftarg_t; # define printk(...) ( fprintf(stderr, __VA_ARGS__) ) #endif +#define rol32(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) #define do_mod(a, b) ((a) % (b)) #define do_div(n,base) ({ \ int __res; \ diff --git a/libxfs/xfs_da_btree.c b/libxfs/xfs_da_btree.c index 4585cf12f..30a90993d 100644 --- a/libxfs/xfs_da_btree.c +++ b/libxfs/xfs_da_btree.c @@ -367,7 +367,8 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, /* * With V2 the extra block is data or freespace. */ - useextra = state->extravalid && XFS_DIR_IS_V1(state->mp); + useextra = state->extravalid && (XFS_DIR_IS_V1(state->mp) || + state->args->whichfork == XFS_ATTR_FORK); newcount = 1 + useextra; /* * Do we have to split the node? @@ -1530,41 +1531,27 @@ xfs_da_hashname(const uchar_t *name, int namelen) { xfs_dahash_t hash; -#define ROTL(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) -#ifdef SLOWVERSION - /* - * This is the old one-byte-at-a-time version. - */ - for (hash = 0; namelen > 0; namelen--) { - hash = *name++ ^ ROTL(hash, 7); - } - return(hash); -#else /* * Do four characters at a time as long as we can. */ - for (hash = 0; namelen >= 4; namelen -= 4, name += 4) { + for (hash = 0; namelen >= 4; namelen -= 4, name += 4) hash = (name[0] << 21) ^ (name[1] << 14) ^ (name[2] << 7) ^ - (name[3] << 0) ^ ROTL(hash, 7 * 4); - } + (name[3] << 0) ^ rol32(hash, 7 * 4); + /* * Now do the rest of the characters. */ switch (namelen) { case 3: return (name[0] << 14) ^ (name[1] << 7) ^ (name[2] << 0) ^ - ROTL(hash, 7 * 3); + rol32(hash, 7 * 3); case 2: - return (name[0] << 7) ^ (name[1] << 0) ^ ROTL(hash, 7 * 2); + return (name[0] << 7) ^ (name[1] << 0) ^ rol32(hash, 7 * 2); case 1: - return (name[0] << 0) ^ ROTL(hash, 7 * 1); - case 0: + return (name[0] << 0) ^ rol32(hash, 7 * 1); + default: /* case 0: */ return hash; } - /* NOTREACHED */ -#endif -#undef ROTL - return 0; /* keep gcc happy */ } /* diff --git a/libxfs/xfs_dir2_sf.c b/libxfs/xfs_dir2_sf.c index 220494756..df66d314d 100644 --- a/libxfs/xfs_dir2_sf.c +++ b/libxfs/xfs_dir2_sf.c @@ -61,7 +61,7 @@ xfs_dir2_block_sfsize( int isdotdot; /* entry is ".." */ xfs_mount_t *mp; /* mount structure pointer */ int namelen; /* total name bytes */ - xfs_ino_t parent; /* parent inode number */ + xfs_ino_t parent = 0; /* parent inode number */ int size=0; /* total computed size */ mp = dp->i_mount; @@ -252,11 +252,11 @@ xfs_dir2_sf_addname( int incr_isize; /* total change in size */ int new_isize; /* di_size after adding name */ int objchange; /* changing to 8-byte inodes */ - xfs_dir2_data_aoff_t offset; /* offset for new entry */ + xfs_dir2_data_aoff_t offset = 0; /* offset for new entry */ int old_isize; /* di_size before adding name */ int pick; /* which algorithm to use */ xfs_dir2_sf_t *sfp; /* shortform structure */ - xfs_dir2_sf_entry_t *sfep; /* shortform entry */ + xfs_dir2_sf_entry_t *sfep = NULL; /* shortform entry */ xfs_dir2_trace_args("sf_addname", args); ASSERT(xfs_dir2_sf_lookup(args) == ENOENT); diff --git a/libxfs/xfs_dir_leaf.c b/libxfs/xfs_dir_leaf.c index 94f6cf112..635578ebf 100644 --- a/libxfs/xfs_dir_leaf.c +++ b/libxfs/xfs_dir_leaf.c @@ -405,7 +405,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) xfs_dir_leaf_name_t *namest; xfs_da_args_t args; xfs_inode_t *dp; - xfs_ino_t parent; + xfs_ino_t parent = 0; char *tmpbuffer; int retval, i; xfs_dabuf_t *bp; diff --git a/libxfs/xfs_mount.c b/libxfs/xfs_mount.c index 2279aab9c..c9d8cc457 100644 --- a/libxfs/xfs_mount.c +++ b/libxfs/xfs_mount.c @@ -260,7 +260,7 @@ xfs_initialize_perag(xfs_mount_t *mp, xfs_agnumber_t agcount) icount = sbp->sb_dblocks * sbp->sb_imax_pct; do_div(icount, 100); icount += sbp->sb_agblocks - 1; - do_div(icount, mp->m_ialloc_blks); + do_div(icount, sbp->sb_agblocks); max_metadata = icount; } else { max_metadata = agcount; -- 2.47.2