From: Steve Lord Date: Fri, 24 May 2002 15:34:31 +0000 (+0000) Subject: sync up user space with the kernel X-Git-Tag: v2.1.0~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d663096d04d530536819e1ab452db1c86e98957e;p=thirdparty%2Fxfsprogs-dev.git sync up user space with the kernel --- diff --git a/include/xfs_bit.h b/include/xfs_bit.h index 80eccc5e5..bf5732492 100644 --- a/include/xfs_bit.h +++ b/include/xfs_bit.h @@ -64,21 +64,6 @@ __uint64_t xfs_mask64lo(int n); #define XFS_MASK64LO(n) (((__uint64_t)1 << (n)) - 1) #endif -/* - * Index of low bit number in byte, -1 for none set, 0..7 otherwise. - */ -extern const char xfs_lowbit[256]; - -/* - * Index of high bit number in byte, -1 for none set, 0..7 otherwise. - */ -extern const char xfs_highbit[256]; - -/* - * Count of bits set in byte, 0..8. - */ -extern const char xfs_countbit[256]; - /* * xfs_lowbit32: get low bit set out of 32-bit argument, -1 if none set. */ @@ -99,4 +84,13 @@ extern int xfs_lowbit64(__uint64_t v); */ extern int xfs_highbit64(__uint64_t); +/* Count set bits in map starting with start_bit */ +int xfs_count_bits(uint *map, uint size, uint start_bit); + +/* Count continuous one bits in map starting with start_bit */ +int xfs_contig_bits(uint *map, uint size, uint start_bit); + +/* Find next set bit in map */ +int xfs_next_bit(uint *map, uint size, uint start_bit); + #endif /* __XFS_BIT_H__ */ diff --git a/include/xfs_inode.h b/include/xfs_inode.h index 79f541980..ce88ef35b 100644 --- a/include/xfs_inode.h +++ b/include/xfs_inode.h @@ -502,6 +502,7 @@ int xfs_iget(struct xfs_mount *, struct xfs_trans *, xfs_ino_t, uint, xfs_inode_t **, xfs_daddr_t); int xfs_vn_iget(vfs_t *, struct vnode *, xfs_ino_t); void xfs_iput(xfs_inode_t *, uint); +void xfs_iput_new(xfs_inode_t *, uint); void xfs_ilock(xfs_inode_t *, uint); int xfs_ilock_nowait(xfs_inode_t *, uint); void xfs_iunlock(xfs_inode_t *, uint); diff --git a/include/xfs_log.h b/include/xfs_log.h index 535305fa7..10d28cbff 100644 --- a/include/xfs_log.h +++ b/include/xfs_log.h @@ -48,16 +48,16 @@ #define CYCLE_LSN_NOCONV(lsn,arch) (((uint *)&(lsn))[LSN_FIELD_CYCLE(arch)]) #ifdef __KERNEL__ +#if (__GNUC__ == 2) && (__GNUC_MINOR__ == 95) +extern xfs_lsn_t _lsn_cmp(xfs_lsn_t, xfs_lsn_t, xfs_arch_t); +#define _lsn_cmp _xfs_lsn_cmp +#endif + /* - * By comparing each compnent, we don't have to worry about extra + * By comparing each component, we don't have to worry about extra * endian issues in treating two 32 bit numbers as one 64 bit number */ -static -#ifdef __GNUC__ -# if !((__GNUC__ == 2) && (__GNUC_MINOR__ == 95)) -__inline__ -#endif -#endif +static inline xfs_lsn_t _lsn_cmp(xfs_lsn_t lsn1, xfs_lsn_t lsn2, xfs_arch_t arch) { if (CYCLE_LSN(lsn1, arch) != CYCLE_LSN(lsn2, arch)) diff --git a/include/xfs_log_priv.h b/include/xfs_log_priv.h index 1d676426a..af24a806d 100644 --- a/include/xfs_log_priv.h +++ b/include/xfs_log_priv.h @@ -406,10 +406,11 @@ typedef struct xlog_rec_header { * - ic_state is the state of the iclog. */ typedef struct xlog_iclog_fields { + struct tq_struct ic_write_sched; sv_t ic_forcesema; struct xlog_in_core *ic_next; struct xlog_in_core *ic_prev; - struct xfs_buf *ic_bp; + struct xfs_buf *ic_bp; struct log *ic_log; xfs_log_callback_t *ic_callback; xfs_log_callback_t **ic_callback_tail; @@ -441,6 +442,7 @@ typedef struct xlog_in_core { * Defines to save our code from this glop. */ #define ic_forcesema hic_fields.ic_forcesema +#define ic_write_sched hic_fields.ic_write_sched #define ic_next hic_fields.ic_next #define ic_prev hic_fields.ic_prev #define ic_bp hic_fields.ic_bp diff --git a/include/xfs_mount.h b/include/xfs_mount.h index beb7ba93f..3a5383f2b 100644 --- a/include/xfs_mount.h +++ b/include/xfs_mount.h @@ -342,6 +342,7 @@ typedef struct xfs_mount { #define XFS_MOUNT_32BITINODES 0x00008000 /* do not create inodes above * 32 bits in size */ #define XFS_MOUNT_IRIXSGID 0x00010000 /* Irix-style sgid inheritance */ +#define XFS_MOUNT_NOLOGFLUSH 0x00020000 /* * Flags for m_cxfstype diff --git a/libxfs/xfs_bit.c b/libxfs/xfs_bit.c index 39dea3b69..d09ad27de 100644 --- a/libxfs/xfs_bit.c +++ b/libxfs/xfs_bit.c @@ -36,44 +36,8 @@ #include -/* - * Index of low bit number in byte, -1 for none set, 0..7 otherwise. - */ -const char xfs_lowbit[256] = { - -1, 0, 1, 0, 2, 0, 1, 0, /* 00 .. 07 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* 08 .. 0f */ - 4, 0, 1, 0, 2, 0, 1, 0, /* 10 .. 17 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* 18 .. 1f */ - 5, 0, 1, 0, 2, 0, 1, 0, /* 20 .. 27 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* 28 .. 2f */ - 4, 0, 1, 0, 2, 0, 1, 0, /* 30 .. 37 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* 38 .. 3f */ - 6, 0, 1, 0, 2, 0, 1, 0, /* 40 .. 47 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* 48 .. 4f */ - 4, 0, 1, 0, 2, 0, 1, 0, /* 50 .. 57 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* 58 .. 5f */ - 5, 0, 1, 0, 2, 0, 1, 0, /* 60 .. 67 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* 68 .. 6f */ - 4, 0, 1, 0, 2, 0, 1, 0, /* 70 .. 77 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* 78 .. 7f */ - 7, 0, 1, 0, 2, 0, 1, 0, /* 80 .. 87 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* 88 .. 8f */ - 4, 0, 1, 0, 2, 0, 1, 0, /* 90 .. 97 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* 98 .. 9f */ - 5, 0, 1, 0, 2, 0, 1, 0, /* a0 .. a7 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* a8 .. af */ - 4, 0, 1, 0, 2, 0, 1, 0, /* b0 .. b7 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* b8 .. bf */ - 6, 0, 1, 0, 2, 0, 1, 0, /* c0 .. c7 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* c8 .. cf */ - 4, 0, 1, 0, 2, 0, 1, 0, /* d0 .. d7 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* d8 .. df */ - 5, 0, 1, 0, 2, 0, 1, 0, /* e0 .. e7 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* e8 .. ef */ - 4, 0, 1, 0, 2, 0, 1, 0, /* f0 .. f7 */ - 3, 0, 1, 0, 2, 0, 1, 0, /* f8 .. ff */ -}; +#ifndef HAVE_ARCH_HIGHBIT /* * Index of high bit number in byte, -1 for none set, 0..7 otherwise. */ @@ -111,44 +75,7 @@ const char xfs_highbit[256] = { 7, 7, 7, 7, 7, 7, 7, 7, /* f0 .. f7 */ 7, 7, 7, 7, 7, 7, 7, 7, /* f8 .. ff */ }; - -/* - * Count of bits set in byte, 0..8. - */ -const char xfs_countbit[256] = { - 0, 1, 1, 2, 1, 2, 2, 3, /* 00 .. 07 */ - 1, 2, 2, 3, 2, 3, 3, 4, /* 08 .. 0f */ - 1, 2, 2, 3, 2, 3, 3, 4, /* 10 .. 17 */ - 2, 3, 3, 4, 3, 4, 4, 5, /* 18 .. 1f */ - 1, 2, 2, 3, 2, 3, 3, 4, /* 20 .. 27 */ - 2, 3, 3, 4, 3, 4, 4, 5, /* 28 .. 2f */ - 2, 3, 3, 4, 3, 4, 4, 5, /* 30 .. 37 */ - 3, 4, 4, 5, 4, 5, 5, 6, /* 38 .. 3f */ - 1, 2, 2, 3, 2, 3, 3, 4, /* 40 .. 47 */ - 2, 3, 3, 4, 3, 4, 4, 5, /* 48 .. 4f */ - 2, 3, 3, 4, 3, 4, 4, 5, /* 50 .. 57 */ - 3, 4, 4, 5, 4, 5, 5, 6, /* 58 .. 5f */ - 2, 3, 3, 4, 3, 4, 4, 5, /* 60 .. 67 */ - 3, 4, 4, 5, 4, 5, 5, 6, /* 68 .. 6f */ - 3, 4, 4, 5, 4, 5, 5, 6, /* 70 .. 77 */ - 4, 5, 5, 6, 5, 6, 6, 7, /* 78 .. 7f */ - 1, 2, 2, 3, 2, 3, 3, 4, /* 80 .. 87 */ - 2, 3, 3, 4, 3, 4, 4, 5, /* 88 .. 8f */ - 2, 3, 3, 4, 3, 4, 4, 5, /* 90 .. 97 */ - 3, 4, 4, 5, 4, 5, 5, 6, /* 98 .. 9f */ - 2, 3, 3, 4, 3, 4, 4, 5, /* a0 .. a7 */ - 3, 4, 4, 5, 4, 5, 5, 6, /* a8 .. af */ - 3, 4, 4, 5, 4, 5, 5, 6, /* b0 .. b7 */ - 4, 5, 5, 6, 5, 6, 6, 7, /* b8 .. bf */ - 2, 3, 3, 4, 3, 4, 4, 5, /* c0 .. c7 */ - 3, 4, 4, 5, 4, 5, 5, 6, /* c8 .. cf */ - 3, 4, 4, 5, 4, 5, 5, 6, /* d0 .. d7 */ - 4, 5, 5, 6, 5, 6, 6, 7, /* d8 .. df */ - 3, 4, 4, 5, 4, 5, 5, 6, /* e0 .. e7 */ - 4, 5, 5, 6, 5, 6, 6, 7, /* e8 .. ef */ - 4, 5, 5, 6, 5, 6, 6, 7, /* f0 .. f7 */ - 5, 6, 6, 7, 6, 7, 7, 8, /* f8 .. ff */ -}; +#endif /* * xfs_highbit32: get high bit set out of 32-bit argument, -1 if none set. @@ -157,6 +84,9 @@ int xfs_highbit32( __uint32_t v) { +#ifdef HAVE_ARCH_HIGHBIT + return highbit32(v); +#else int i; if (v & 0xffff0000) @@ -172,6 +102,7 @@ xfs_highbit32( else return -1; return i + xfs_highbit[(v >> i) & 0xff]; +#endif } /* @@ -181,63 +112,14 @@ int xfs_lowbit64( __uint64_t v) { - int i; -#if XFS_64 - if (v & 0x00000000ffffffff) - if (v & 0x000000000000ffff) - if (v & 0x00000000000000ff) - i = 0; - else - i = 8; - else - if (v & 0x0000000000ff0000) - i = 16; - else - i = 24; - else if (v & 0xffffffff00000000) - if (v & 0x0000ffff00000000) - if (v & 0x000000ff00000000) - i = 32; - else - i = 40; - else - if (v & 0x00ff000000000000) - i = 48; - else - i = 56; - else - return -1; - return i + xfs_lowbit[(v >> i) & 0xff]; -#else - __uint32_t vw; - - if ((vw = v)) { - if (vw & 0x0000ffff) - if (vw & 0x000000ff) - i = 0; - else - i = 8; - else - if (vw & 0x00ff0000) - i = 16; - else - i = 24; - return i + xfs_lowbit[(vw >> i) & 0xff]; - } else if ((vw = v >> 32)) { - if (vw & 0x0000ffff) - if (vw & 0x000000ff) - i = 32; - else - i = 40; - else - if (vw & 0x00ff0000) - i = 48; - else - i = 56; - return i + xfs_lowbit[(vw >> (i - 32)) & 0xff]; - } else - return -1; -#endif + int n; + n = ffs((unsigned)v); + if (n == 0) { + n = ffs(v >> 32); + if (n >= 0) + n+=32; + } + return n-1; } /* @@ -247,61 +129,8 @@ int xfs_highbit64( __uint64_t v) { - int i; -#if XFS_64 - if (v & 0xffffffff00000000) - if (v & 0xffff000000000000) - if (v & 0xff00000000000000) - i = 56; - else - i = 48; - else - if (v & 0x0000ff0000000000) - i = 40; - else - i = 32; - else if (v & 0x00000000ffffffff) - if (v & 0x00000000ffff0000) - if (v & 0x00000000ff000000) - i = 24; - else - i = 16; - else - if (v & 0x000000000000ff00) - i = 8; - else - i = 0; - else - return -1; - return i + xfs_highbit[(v >> i) & 0xff]; -#else - __uint32_t vw; - - if ((vw = v >> 32)) { - if (vw & 0xffff0000) - if (vw & 0xff000000) - i = 56; - else - i = 48; - else - if (vw & 0x0000ff00) - i = 40; - else - i = 32; - return i + xfs_highbit[(vw >> (i - 32)) & 0xff]; - } else if ((vw = v)) { - if (vw & 0xffff0000) - if (vw & 0xff000000) - i = 24; - else - i = 16; - else - if (vw & 0x0000ff00) - i = 8; - else - i = 0; - return i + xfs_highbit[(vw >> i) & 0xff]; - } else - return -1; -#endif + __uint32_t h = v >> 32; + if (h) + return xfs_highbit32(h) + 32; + return xfs_highbit32((__u32)v); } diff --git a/libxfs/xfs_dir2_block.c b/libxfs/xfs_dir2_block.c index a8ca760f9..a60d276c8 100644 --- a/libxfs/xfs_dir2_block.c +++ b/libxfs/xfs_dir2_block.c @@ -886,7 +886,8 @@ xfs_dir2_sf_to_block( xfs_dir2_leaf_entry_t *blp; /* block leaf entries */ xfs_dabuf_t *bp; /* block buffer */ xfs_dir2_block_tail_t *btp; /* block tail pointer */ - char buf[XFS_DIR2_SF_MAX_SIZE]; /* sf buffer */ + char *buf; /* sf buffer */ + int buf_len; xfs_dir2_data_entry_t *dep; /* data entry pointer */ xfs_inode_t *dp; /* incore directory inode */ int dummy; /* trash */ @@ -924,6 +925,10 @@ xfs_dir2_sf_to_block( * Copy the directory into the stack buffer. * Then pitch the incore inode data so we can make extents. */ + + buf_len = dp->i_df.if_bytes; + buf = kmem_alloc(dp->i_df.if_bytes, KM_SLEEP); + bcopy(sfp, buf, dp->i_df.if_bytes); xfs_idata_realloc(dp, -dp->i_df.if_bytes, XFS_DATA_FORK); dp->i_d.di_size = 0; @@ -937,6 +942,7 @@ xfs_dir2_sf_to_block( */ error = xfs_dir2_grow_inode(args, XFS_DIR2_DATA_SPACE, &blkno); if (error) { + kmem_free(buf, buf_len); return error; } /* @@ -944,6 +950,7 @@ xfs_dir2_sf_to_block( */ error = xfs_dir2_data_init(args, blkno, &bp); if (error) { + kmem_free(buf, buf_len); return error; } block = bp->data; @@ -1059,6 +1066,8 @@ xfs_dir2_sf_to_block( else sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep); } + /* Done with the temporary buffer */ + kmem_free(buf, buf_len); /* * Sort the leaf entries by hash value. */ diff --git a/libxfs/xfs_dir2_sf.c b/libxfs/xfs_dir2_sf.c index a2944698e..e28893440 100644 --- a/libxfs/xfs_dir2_sf.c +++ b/libxfs/xfs_dir2_sf.c @@ -415,7 +415,7 @@ xfs_dir2_sf_addname_hard( int new_isize) /* new directory size */ { int add_datasize; /* data size need for new ent */ - char buf[XFS_DIR2_SF_MAX_SIZE]; /* buffer for old */ + char *buf; /* buffer for old */ xfs_inode_t *dp; /* incore directory inode */ int eof; /* reached end of old dir */ int nbytes; /* temp for byte copies */ @@ -434,6 +434,7 @@ xfs_dir2_sf_addname_hard( sfp = (xfs_dir2_sf_t *)dp->i_df.if_u1.if_data; old_isize = (int)dp->i_d.di_size; + buf = kmem_alloc(old_isize, KM_SLEEP); oldsfp = (xfs_dir2_sf_t *)buf; bcopy(sfp, oldsfp, old_isize); /* @@ -490,6 +491,7 @@ xfs_dir2_sf_addname_hard( sfep = XFS_DIR2_SF_NEXTENTRY(sfp, sfep); bcopy(oldsfep, sfep, old_isize - nbytes); } + kmem_free(buf, old_isize); dp->i_d.di_size = new_isize; xfs_dir2_sf_check(args); } diff --git a/libxfs/xfs_rtbit.c b/libxfs/xfs_rtbit.c index c51cba34c..1b6c77931 100644 --- a/libxfs/xfs_rtbit.c +++ b/libxfs/xfs_rtbit.c @@ -43,19 +43,5 @@ int xfs_lowbit32( __uint32_t v) { - int i; - - if (v & 0x0000ffff) - if (v & 0x000000ff) - i = 0; - else - i = 8; - else if (v & 0xffff0000) - if (v & 0x00ff0000) - i = 16; - else - i = 24; - else - return -1; - return i + xfs_lowbit[(v >> i) & 0xff]; + return ffs(v)-1; }