xfs
[Top] [All Lists]

force shutdown at xfs_growfs

To: linux-xfs@xxxxxxxxxxx
Subject: force shutdown at xfs_growfs
From: ASANO Masahiro <masano@xxxxxxxxxxxxxx>
Date: Wed, 25 Aug 2004 12:59:49 +0900 (JST)
Sender: linux-xfs-bounce@xxxxxxxxxxx
Hi SGI guys,

I'm afraid that it is dangerous to grow filesystem by xfs_growfs
under a situation of heavy file allocation. Because mp->m_maxagi is
updated before formatting new AGs, and other processes can touch
them. This causes filesystem shutting down.

Here is a patch for Linux-2.4.27.
This patch delays the update of m_maxagi.

Thank you.
--
masano
--- linux-2.4.27/fs/xfs/xfs_fsops.c.orig        2004-08-24 16:44:58.000000000 
+0900
+++ linux-2.4.27/fs/xfs/xfs_fsops.c     2004-08-24 16:51:31.000000000 +0900
@@ -149,6 +149,7 @@ xfs_growfs_data_private(
        int                     pct;
        xfs_sb_t                *sbp;
        xfs_trans_t             *tp;
+       int                     index = 0;
 
        nb = in->newblocks;
        pct = in->imaxpct;
@@ -183,7 +184,7 @@ xfs_growfs_data_private(
                memset(&mp->m_perag[oagcount], 0,
                        (nagcount - oagcount) * sizeof(xfs_perag_t));
                mp->m_flags |= XFS_MOUNT_32BITINODES;
-               xfs_initialize_perag(mp, nagcount);
+               index = xfs_initialize_perag(mp, nagcount);
                up_write(&mp->m_peraglock);
        }
        tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS);
@@ -372,6 +373,9 @@ xfs_growfs_data_private(
        if (error) {
                return error;
        }
+       /* initialize completed, update maxagi */
+       if (index)
+               mp->m_maxagi = index;
        if (mp->m_sb.sb_imax_pct) {
                __uint64_t icount = mp->m_sb.sb_dblocks * mp->m_sb.sb_imax_pct;
                do_div(icount, 100);
--- linux-2.4.27/fs/xfs/xfs_mount.c.orig        2004-08-24 16:48:43.000000000 
+0900
+++ linux-2.4.27/fs/xfs/xfs_mount.c     2004-08-24 17:30:31.000000000 +0900
@@ -318,7 +318,7 @@ xfs_mount_validate_sb(
        return 0;
 }
 
-void
+int
 xfs_initialize_perag(xfs_mount_t *mp, int agcount)
 {
        int             index, max_metadata;
@@ -377,7 +377,7 @@ xfs_initialize_perag(xfs_mount_t *mp, in
                        pag->pagi_inodeok = 1;
                }
        }
-       mp->m_maxagi = index;
+       return index;
 }
 
 /*
@@ -952,7 +952,7 @@ xfs_mountfs(
        mp->m_perag =
                kmem_zalloc(sbp->sb_agcount * sizeof(xfs_perag_t), KM_SLEEP);
 
-       xfs_initialize_perag(mp, sbp->sb_agcount);
+       mp->m_maxagi = xfs_initialize_perag(mp, sbp->sb_agcount);
 
        /*
         * log's mount-time initialization. Perform 1st part recovery if needed
--- linux-2.4.27/fs/xfs/xfs_mount.h.orig        2004-08-24 16:53:20.000000000 
+0900
+++ linux-2.4.27/fs/xfs/xfs_mount.h     2004-08-24 16:53:58.000000000 +0900
@@ -555,7 +555,7 @@ extern int  xfs_readsb(xfs_mount_t *mp);
 extern void    xfs_freesb(xfs_mount_t *);
 extern void    xfs_do_force_shutdown(bhv_desc_t *, int, char *, int);
 extern int     xfs_syncsub(xfs_mount_t *, int, int, int *);
-extern void    xfs_initialize_perag(xfs_mount_t *, int);
+extern int     xfs_initialize_perag(xfs_mount_t *, int);
 extern void    xfs_xlatesb(void *, struct xfs_sb *, int, xfs_arch_t,
                        __int64_t);
 
<Prev in Thread] Current Thread [Next in Thread>