]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
sync up user space with the kernel
authorSteve Lord <lord@sgi.com>
Fri, 24 May 2002 15:34:31 +0000 (15:34 +0000)
committerSteve Lord <lord@sgi.com>
Fri, 24 May 2002 15:34:31 +0000 (15:34 +0000)
include/xfs_bit.h
include/xfs_inode.h
include/xfs_log.h
include/xfs_log_priv.h
include/xfs_mount.h
libxfs/xfs_bit.c
libxfs/xfs_dir2_block.c
libxfs/xfs_dir2_sf.c
libxfs/xfs_rtbit.c

index 80eccc5e52f89bfb55f484010ce39c47dbc62eb1..bf573249281a39ebe065f973de7a6b3a07ffb880 100644 (file)
@@ -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__ */
index 79f541980788d383e67ecbe41f42ba0f8f62eb02..ce88ef35b72be22e279ea745a583fa2ee3c5bd9e 100644 (file)
@@ -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);
index 535305fa7c1b734be6ae866b2d108a593d58d766..10d28cbff6f0acc5c7592bc9b76b28742c7a3992 100644 (file)
 #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))
index 1d676426a6c88eea627f25afd54d86b2c42116f6..af24a806d71d13368ae65522b1b7e3b7941d8b54 100644 (file)
@@ -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
index beb7ba93f7cdcf8be3fa8f43d9adcc83f2732176..3a5383f2bf3e219131503c8642e85b10b4fada99 100644 (file)
@@ -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
index 39dea3b693f5af70e1c6cafa3416f3db9fc153db..d09ad27de8e50a0965211313f03223e0916c4b90 100644 (file)
 
 #include <xfs.h>
 
-/*
- * 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); 
 }
index a8ca760f96aff18f5b6de5a62a9da4f604ebd613..a60d276c880769dbcba5ef2ffa72bb8485b6afd5 100644 (file)
@@ -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.
         */
index a2944698e6ff2992c7355c3700c4f50d90dcd2e6..e28893440fe5482f812dd67f7da2998fd4a6f3db 100644 (file)
@@ -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);
 }
index c51cba34c9f77ccc33c4775aefece587f68a6edc..1b6c7793140cb36c2504df36be53db51f216f1a4 100644 (file)
@@ -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; 
 }