1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) International Business Machines Corp., 2000-2004
9 * note: file system in transition to aggregate/fileset:
12 * file system unmount is interpreted as mount of the single/only
13 * fileset in the aggregate and, if unmount of the last fileset,
14 * as unmount of the aggerate;
18 #include "jfs_incore.h"
19 #include "jfs_filsys.h"
20 #include "jfs_superblock.h"
23 #include "jfs_metapage.h"
24 #include "jfs_debug.h"
27 * NAME: jfs_umount(vfsp, flags, crp)
29 * FUNCTION: vfs_umount()
31 * PARAMETERS: vfsp - virtual file system pointer
32 * flags - unmount for shutdown
35 * RETURN : EBUSY - device has open files
37 int jfs_umount(struct super_block
*sb
)
39 struct jfs_sb_info
*sbi
= JFS_SBI(sb
);
40 struct inode
*ipbmap
= sbi
->ipbmap
;
41 struct inode
*ipimap
= sbi
->ipimap
;
42 struct inode
*ipaimap
= sbi
->ipaimap
;
43 struct inode
*ipaimap2
= sbi
->ipaimap2
;
47 jfs_info("UnMount JFS: sb:0x%p", sb
);
50 * update superblock and close log
52 * if mounted read-write and log based recovery was enabled
56 * Wait for outstanding transactions to be written to log:
58 jfs_flush_journal(log
, 2);
61 * close fileset inode allocation map (aka fileset inode)
65 diFreeSpecial(ipimap
);
69 * close secondary aggregate inode allocation map
72 diUnmount(ipaimap2
, 0);
73 diFreeSpecial(ipaimap2
);
78 * close aggregate inode allocation map
80 diUnmount(ipaimap
, 0);
81 diFreeSpecial(ipaimap
);
85 * close aggregate block allocation map
89 diFreeSpecial(ipbmap
);
93 * Make sure all metadata makes it to disk before we mark
94 * the superblock as clean
96 filemap_write_and_wait(sbi
->direct_inode
->i_mapping
);
99 * ensure all file system file pages are propagated to their
100 * home blocks on disk (and their in-memory buffer pages are
101 * invalidated) BEFORE updating file system superblock state
102 * (to signify file system is unmounted cleanly, and thus in
103 * consistent state) and log superblock active file system
104 * list (to signify skip logredo()).
106 if (log
) { /* log = NULL if read-only mount */
107 updateSuper(sb
, FM_CLEAN
);
112 * remove file system from log active file system list.
116 jfs_info("UnMount JFS Complete: rc = %d", rc
);
121 int jfs_umount_rw(struct super_block
*sb
)
123 struct jfs_sb_info
*sbi
= JFS_SBI(sb
);
124 struct jfs_log
*log
= sbi
->log
;
132 * remove file system from log active file system list.
134 jfs_flush_journal(log
, 2);
137 * Make sure all metadata makes it to disk
143 * Note that we have to do this even if sync_blockdev() will
144 * do exactly the same a few instructions later: We can't
145 * mark the superblock clean before everything is flushed to
148 filemap_write_and_wait(sbi
->direct_inode
->i_mapping
);
150 updateSuper(sb
, FM_CLEAN
);
152 return lmLogClose(sb
);