]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
sync kernel changes (32 bit inodes) with userspace code.
authorNathan Scott <nathans@sgi.com>
Tue, 11 Dec 2001 02:51:37 +0000 (02:51 +0000)
committerNathan Scott <nathans@sgi.com>
Tue, 11 Dec 2001 02:51:37 +0000 (02:51 +0000)
include/libxfs.h
include/xfs_ag.h
include/xfs_alloc.h
libxfs/init.c
libxfs/xfs.h
libxfs/xfs_alloc.c
libxfs/xfs_bmap.c
libxfs/xfs_ialloc.c
libxfs/xfs_mount.c

index a01b3b19f95b979d55643580d6caf3758b641216..a6f4ac9c8830f850dac025eef346c9263d1a1385 100644 (file)
@@ -129,6 +129,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 */
+       xfs_agnumber_t  m_maxagi;               /* highest inode alloc group */
        uint                    m_rsumlevels;   /* rt summary levels */
        uint                    m_rsumsize;     /* size of rt summary, bytes */
        struct xfs_inode        *m_rbmip;       /* pointer to bitmap inode */
index f8509111152c30e82584fd52d3961a9a54fd7f02..40ee6b07ad7ead6fa05b02a6a7c4ce3de8d367a5 100644 (file)
@@ -196,6 +196,8 @@ typedef struct xfs_perag
 {
        char            pagf_init;      /* this agf's entry is initialized */
        char            pagi_init;      /* this agi's entry is initialized */
+       char            pagf_metadata;  /* the agf is prefered to be metadata */
+       char            pagi_inodeok;   /* The agi is ok for inodes */
        __uint8_t       pagf_levels[XFS_BTNUM_AGF];
                                        /* # of levels in bno & cnt btree */
        __uint32_t      pagf_flcount;   /* count of blocks in freelist */
index 55a2efa5912062a3e2d3435ef9a772d18a1a0492..2a0ccf01ccc14d5f3ab5891a6946e87836e8728d 100644 (file)
@@ -86,6 +86,12 @@ typedef struct xfs_alloc_arg {
        char            userdata;       /* set if this is user data */
 } xfs_alloc_arg_t;
 
+/*
+ * Defines for userdata
+ */
+#define XFS_ALLOC_USERDATA             1       /* allocation is for user data*/
+#define XFS_ALLOC_INITIAL_USER_DATA    2       /* special case start of file */
+
 
 #ifdef __KERNEL__
 
index 51b24e4c92086e9ed5d2f7187ff8139bd102712d..9954cdae768efde89cffe8a280f58bf70be1802c 100644 (file)
@@ -634,6 +634,7 @@ rtmount_inodes(xfs_mount_t *mp)
        return 0;
 }
 
+#define XFS_MOUNT_32BITINODES  0x1
 /*
  * Mount structure initialization, provides a filled-in xfs_mount_t
  * such that the numerous XFS_* macros can be used.  If dev is zero,
@@ -657,6 +658,7 @@ libxfs_mount(
        mp->m_dev = dev;
        mp->m_rtdev = rtdev;
        mp->m_logdev = logdev;
+       mp->m_flags = XFS_MOUNT_32BITINODES;
        mp->m_sb = *sb;
        sbp = &(mp->m_sb);
        manage_zones(0);
index 23535234169b36b1b5acdf7c8d7807aa9a2ff098..008629a6d3343cd76daaa3273b156908d6587a36 100644 (file)
@@ -246,8 +246,9 @@ typedef struct { dev_t dev; } buftarg_t;
 #define TRACE_ALLOC(s,a)               ((void) 0)
 #define TRACE_MODAGF(a,b,c)            ((void) 0)
 #define XFS_FORCED_SHUTDOWN(mp)                0
-#define XFS_MOUNT_WSYNC                        0
-#define XFS_MOUNT_NOALIGN              0
+#define XFS_MOUNT_WSYNC                        0       /* ignored in userspace */
+#define XFS_MOUNT_NOALIGN              0       /* ignored in userspace */
+#define XFS_MOUNT_32BITINODES          0x1     /* enforce in userspace */
 #define XFS_ILOCK_EXCL                 0
 #define mrlock(a,b,c)                  ((void) 0)
 #define mraccunlock(a)                 ((void) 0)
index 8786269bd1609a512c586dd5efba9348e18ec805..148f229014877db675c202b957ca2f7e6942f54b 100644 (file)
@@ -1769,6 +1769,16 @@ xfs_alloc_fix_freelist(
                }
        } else
                agbp = NULL;
+
+       /* If this is a metadata prefered pag and we are user data
+        * then try somewhere else if we are not being asked to
+        * try harder at this point
+        */
+       if (pag->pagf_metadata && args->userdata && flags) {
+               args->agbp = NULL;
+               return 0;
+       }
+
        need = XFS_MIN_FREELIST_PAG(pag, mp);
        delta = need > pag->pagf_flcount ? need - pag->pagf_flcount : 0;
        /*
@@ -2168,6 +2178,7 @@ xfs_alloc_vextent(
        xfs_mount_t     *mp;    /* mount structure pointer */
        xfs_agnumber_t  sagno;  /* starting allocation group number */
        xfs_alloctype_t type;   /* input allocation type */
+       int             bump_rotor = 0;
 
        mp = args->mp;
        type = args->otype = args->type;
@@ -2228,6 +2239,11 @@ xfs_alloc_vextent(
                 * Try near allocation first, then anywhere-in-ag after
                 * the first a.g. fails.
                 */
+               if ((args->userdata  == XFS_ALLOC_INITIAL_USER_DATA) &&
+                   (mp->m_flags & XFS_MOUNT_32BITINODES)) {
+                       args->fsbno = XFS_AGB_TO_FSB(mp, mp->m_agfrotor, 0);
+                       bump_rotor = 1;
+               }
                args->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno);
                args->type = XFS_ALLOCTYPE_NEAR_BNO;
                /* FALLTHROUGH */
@@ -2309,7 +2325,8 @@ xfs_alloc_vextent(
                                }
                        }
                }
-               mp->m_agfrotor = (args->agno + 1) % mp->m_sb.sb_agcount;
+               if (bump_rotor || (type == XFS_ALLOCTYPE_ANY_AG))
+                       mp->m_agfrotor = (args->agno + 1) % mp->m_sb.sb_agcount;
                break;
        default:
                ASSERT(0);
index 0b1c203231a80520b4559eef09b01c19c37c1533..ccb54eddf8e32d43b03f30616345c5317d59d942 100644 (file)
@@ -3794,7 +3794,15 @@ xfs_bmapi(
                                        bma.prevp = &prev;
                                        bma.gotp = &got;
                                        bma.total = total;
-                                       bma.userdata = userdata;
+                                       bma.userdata = 0;
+                               }
+                               /* Indicate if this is the first user data
+                                * in the file, or just any user data.
+                                */
+                               if (userdata) {
+                                       bma.userdata = (aoff == 0) ? 
+                                               XFS_ALLOC_INITIAL_USER_DATA : 
+                                               XFS_ALLOC_USERDATA;
                                }
                                /*
                                 * Fill in changeable bma fields.
index 8d6ef493df0b070086fa54ccf930bf4224d6510e..fde856a704a6d01103ad68c96f5e0b6e95d3308e 100644 (file)
@@ -367,7 +367,7 @@ xfs_ialloc_ag_select(
         */
        needspace = S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode);
        mp = tp->t_mountp;
-       agcount = mp->m_sb.sb_agcount;
+       agcount = mp->m_maxagi;
        if (S_ISDIR(mode))
                pagno = atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
        else
@@ -393,6 +393,12 @@ xfs_ialloc_ag_select(
                        }
                } else
                        agbp = NULL;
+
+               if (!pag->pagi_inodeok) {
+                       atomicIncWithWrap((int *)&mp->m_agirotor, agcount);
+                       goto unlock_nextag;
+               }
+
                /*
                 * Is there enough free space for the file plus a block
                 * of inodes (if we need to allocate some)?
@@ -424,6 +430,7 @@ xfs_ialloc_ag_select(
                                return agbp;
                        }
                }
+unlock_nextag:
                mraccunlock(&mp->m_peraglock);
                if (agbp)
                        xfs_trans_brelse(tp, agbp);
@@ -605,6 +612,10 @@ nextag:
                        return noroom ? ENOSPC : 0;
                }
                mraccess(&mp->m_peraglock);
+               if (mp->m_perag[tagno].pagi_inodeok == 0) {
+                       mraccunlock(&mp->m_peraglock);
+                       goto nextag;
+               }
                error = xfs_ialloc_read_agi(mp, tp, tagno, &agbp);
                mraccunlock(&mp->m_peraglock);
                if (error)
index 4d54373b08abce6c37e45e8820a88720b7f5b2ef..bff0bfc844aa30cb61a9e8e407f865ac2af248b4 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;
+       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;
        mp->m_agno_log = xfs_highbit32(sbp->sb_agcount - 1) + 1;