]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Sync user and kernel code, make xfs_io -f option useful.
authorNathan Scott <nathans@sgi.com>
Mon, 7 Apr 2003 00:03:34 +0000 (00:03 +0000)
committerNathan Scott <nathans@sgi.com>
Mon, 7 Apr 2003 00:03:34 +0000 (00:03 +0000)
Sync user and kernel code.

include/xfs_mount.h
io/init.c
libxfs/xfs.h
libxfs/xfs_ialloc.c
libxfs/xfs_inode.c
libxfs/xfs_mount.c

index 06b7b626e32a4daa9732cd0e65885ac4e9586a31..a4a1cab1db78df676ab4340908c3eeca37f8de26 100644 (file)
@@ -291,6 +291,7 @@ typedef struct xfs_mount {
        int                     m_bsize;        /* fs logical block size */
        xfs_agnumber_t          m_agfrotor;     /* last ag where space found */
        xfs_agnumber_t          m_agirotor;     /* last ag dir inode alloced */
+       lock_t                  m_agirotor_lock;/* .. and lock protecting it */
        xfs_agnumber_t          m_maxagi;       /* highest inode alloc group */
        int                     m_ihsize;       /* size of next field */
        struct xfs_ihash        *m_ihash;       /* fs private inode hash table*/
index 8d4731c3f4fc8ee8f3245a25ffaccf8f731650d9..a6d2dc2ffad3581fa332754f65b8eb5c79743c24 100644 (file)
--- a/io/init.c
+++ b/io/init.c
@@ -62,6 +62,7 @@ init(
        int             argc,
        char            **argv)
 {
+       int             fflag = 0;
        int             c;
 
        progname = basename(argv[0]);
@@ -86,7 +87,8 @@ init(
                case 'd':       /* directIO */
                        directio = 1;
                        break;
-               case 'f':       /* ignore */
+               case 'f':       /* create */
+                       fflag = 1;
                        break;
                case 'p':       /* progname */
                        progname = optarg;
@@ -115,7 +117,7 @@ init(
                usage();
 
        fname = strdup(argv[optind]);
-       if ((fdesc = openfile(fname, append, 0, directio,
+       if ((fdesc = openfile(fname, append, fflag, directio,
                                readonly, osync, trunc, realtime)) < 0)
                exit(1);
 
index bb281f414db71258c9e447e84dea46451bd40915..6f5511212233dc09319063e3d7369e4930071627 100644 (file)
@@ -274,6 +274,8 @@ typedef struct { dev_t dev; } xfs_buftarg_t;
 #define mraccess(a)                    ((void) 0)
 #define ismrlocked(a,b)                        1
 #define spinlock_init(a,b)             ((void) 0)
+#define spin_lock(a)                   ((void) 0)
+#define spin_unlock(a)                 ((void) 0)
 #define __return_address               __builtin_return_address(0)
 #define xfs_btree_reada_bufl(m,fsb,c)  ((void) 0)
 #define xfs_btree_reada_bufs(m,fsb,c,x)        ((void) 0)
index 4f0e80b809b4c5b3773abea9fdbc84a8bdfba291..9b19b2a90f269af9563380815acb8b3388cb3b4b 100644 (file)
@@ -339,6 +339,21 @@ xfs_ialloc_ag_alloc(
        return 0;
 }
 
+STATIC __inline xfs_agnumber_t
+xfs_ialloc_next_ag(
+       xfs_mount_t     *mp)
+{
+       xfs_agnumber_t  agno;
+
+       spin_lock(&mp->m_agirotor_lock);
+       agno = mp->m_agirotor;
+       if (++mp->m_agirotor == mp->m_maxagi)
+               mp->m_agirotor = 0;
+       spin_unlock(&mp->m_agirotor_lock);
+
+       return agno;
+}
+
 /*
  * Select an allocation group to look for a free inode in, based on the parent
  * inode and then mode.         Return the allocation group buffer.
@@ -369,7 +384,7 @@ xfs_ialloc_ag_select(
        mp = tp->t_mountp;
        agcount = mp->m_maxagi;
        if (S_ISDIR(mode))
-               pagno = atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
+               pagno = xfs_ialloc_next_ag(mp);
        else {
                pagno = XFS_INO_TO_AGNO(mp, parent);
                if (pagno >= agcount)
@@ -397,7 +412,7 @@ xfs_ialloc_ag_select(
                        agbp = NULL;
 
                if (!pag->pagi_inodeok) {
-                       atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
+                       xfs_ialloc_next_ag(mp);
                        goto unlock_nextag;
                }
 
index adc4b557ed9dd2a192439c1808e9a7383be6e86a..cf10b16a63722b8fa8aac2702cf0f9b8d8ba14f9 100644 (file)
@@ -470,21 +470,16 @@ xfs_iformat_extents(
        ifp->if_bytes = size;
        ifp->if_real_bytes = real_size;
        if (size) {
-               xfs_validate_extents(
-                       (xfs_bmbt_rec_t *)XFS_DFORK_PTR_ARCH(dip, whichfork, ARCH_CONVERT),
-                       nex, 1, XFS_EXTFMT_INODE(ip));
-               dp = (xfs_bmbt_rec_t *)XFS_DFORK_PTR_ARCH(dip, whichfork, ARCH_CONVERT);
+               dp = (xfs_bmbt_rec_t *)
+                       XFS_DFORK_PTR_ARCH(dip, whichfork, ARCH_CONVERT);
+               xfs_validate_extents(dp, nex, 1, XFS_EXTFMT_INODE(ip));
                ep = ifp->if_u1.if_extents;
-#if ARCH_CONVERT != ARCH_NOCONVERT
                for (i = 0; i < nex; i++, ep++, dp++) {
                        ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0),
-                                                               ARCH_CONVERT);
+                                                               ARCH_CONVERT);
                        ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1),
-                                                               ARCH_CONVERT);
+                                                               ARCH_CONVERT);
                }
-#else
-               memcpy(ep, dp, size);
-#endif
                xfs_bmap_trace_exlist("xfs_iformat_extents", ip, nex,
                        whichfork);
                if (whichfork != XFS_DATA_FORK ||
@@ -1312,15 +1307,11 @@ xfs_iextents_copy(
                        continue;
                }
 
-#if ARCH_CONVERT != ARCH_NOCONVERT
                /* Translate to on disk format */
                put_unaligned(INT_GET(ep->l0, ARCH_CONVERT),
-                             (__uint64_t*)&dest_ep->l0);
+                             (__uint64_t*)&dest_ep->l0);
                put_unaligned(INT_GET(ep->l1, ARCH_CONVERT),
-                             (__uint64_t*)&dest_ep->l1);
-#else
-               *dest_ep = *ep;
-#endif
+                             (__uint64_t*)&dest_ep->l1);
                dest_ep++;
                ep++;
                copied++;
index 372c395056774d2b86f7f3e5a7faafa4d6ef6b96..d2d9316ab9ad75f254029f7f145349b12768e76d 100644 (file)
@@ -43,6 +43,7 @@ xfs_mount_common(xfs_mount_t *mp, xfs_sb_t *sbp)
        int     i;
 
        mp->m_agfrotor = mp->m_agirotor = 0;
+       spinlock_init(&mp->m_agirotor_lock, "m_agirotor_lock");
        mp->m_maxagi = mp->m_sb.sb_agcount;
        mp->m_blkbit_log = sbp->sb_blocklog + XFS_NBBYLOG;
        mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;