2 * Copyright (c) International Business Machines Corp., 2000-2002
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
12 * the GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * note: file system in transition to aggregate/fileset:
25 * file system unmount is interpreted as mount of the single/only
26 * fileset in the aggregate and, if unmount of the last fileset,
27 * as unmount of the aggerate;
31 #include "jfs_incore.h"
32 #include "jfs_filsys.h"
33 #include "jfs_superblock.h"
36 #include "jfs_metapage.h"
37 #include "jfs_debug.h"
40 * NAME: jfs_umount(vfsp, flags, crp)
42 * FUNCTION: vfs_umount()
44 * PARAMETERS: vfsp - virtual file system pointer
45 * flags - unmount for shutdown
48 * RETURN : EBUSY - device has open files
50 int jfs_umount(struct super_block *sb)
52 struct jfs_sb_info *sbi = JFS_SBI(sb);
53 struct inode *ipbmap = sbi->ipbmap;
54 struct inode *ipimap = sbi->ipimap;
55 struct inode *ipaimap = sbi->ipaimap;
56 struct inode *ipaimap2 = sbi->ipaimap2;
60 jFYI(1, ("\n UnMount JFS: sb:0x%p\n", sb));
63 * update superblock and close log
65 * if mounted read-write and log based recovery was enabled
69 * Wait for outstanding transactions to be written to log:
71 jfs_flush_journal(log, 1);
74 * close fileset inode allocation map (aka fileset inode)
76 jEVENT(0, ("jfs_umount: close ipimap:0x%p\n", ipimap));
79 diFreeSpecial(ipimap);
83 * close secondary aggregate inode allocation map
85 ipaimap2 = sbi->ipaimap2;
87 jEVENT(0, ("jfs_umount: close ipaimap2:0x%p\n", ipaimap2));
88 diUnmount(ipaimap2, 0);
89 diFreeSpecial(ipaimap2);
94 * close aggregate inode allocation map
96 ipaimap = sbi->ipaimap;
97 jEVENT(0, ("jfs_umount: close ipaimap:0x%p\n", ipaimap));
98 diUnmount(ipaimap, 0);
99 diFreeSpecial(ipaimap);
103 * close aggregate block allocation map
105 jEVENT(0, ("jfs_umount: close ipbmap:%p\n", ipbmap));
106 dbUnmount(ipbmap, 0);
108 diFreeSpecial(ipbmap);
112 * Make sure all metadata makes it to disk before we mark
113 * the superblock as clean
115 fsync_inode_data_buffers(sb->s_bdev->bd_inode);
118 * ensure all file system file pages are propagated to their
119 * home blocks on disk (and their in-memory buffer pages are
120 * invalidated) BEFORE updating file system superblock state
121 * (to signify file system is unmounted cleanly, and thus in
122 * consistent state) and log superblock active file system
123 * list (to signify skip logredo()).
125 if (log) { /* log = NULL if read-only mount */
126 rc = updateSuper(sb, FM_CLEAN);
131 * remove file system from log active file system list.
133 rc = lmLogClose(sb, log);
135 jFYI(0, (" UnMount JFS Complete: %d\n", rc));
140 int jfs_umount_rw(struct super_block *sb)
142 struct jfs_sb_info *sbi = JFS_SBI(sb);
143 struct jfs_log *log = sbi->log;
151 * remove file system from log active file system list.
153 jfs_flush_journal(log, 1);
156 * Make sure all metadata makes it to disk
160 fsync_inode_data_buffers(sb->s_bdev->bd_inode);
162 updateSuper(sb, FM_CLEAN);
165 return lmLogClose(sb, log);