Merge of master-melb:xfs-cmds:24318a by kenmcd.
# 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; \
/*
* 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?
{
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 */
}
/*
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;
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);
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;
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;