1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <linux/fs.h>
18#include "jfs_incore.h"
19#include "jfs_filsys.h"
20#include "jfs_superblock.h"
21#include "jfs_dmap.h"
22#include "jfs_imap.h"
23#include "jfs_metapage.h"
24#include "jfs_debug.h"
25
26
27
28
29
30
31
32
33
34
35
36
37int jfs_umount(struct super_block *sb)
38{
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;
44 struct jfs_log *log;
45 int rc = 0;
46
47 jfs_info("UnMount JFS: sb:0x%p", sb);
48
49
50
51
52
53
54 if ((log = sbi->log))
55
56
57
58 jfs_flush_journal(log, 2);
59
60
61
62
63 diUnmount(ipimap, 0);
64
65 diFreeSpecial(ipimap);
66 sbi->ipimap = NULL;
67
68
69
70
71 ipaimap2 = sbi->ipaimap2;
72 if (ipaimap2) {
73 diUnmount(ipaimap2, 0);
74 diFreeSpecial(ipaimap2);
75 sbi->ipaimap2 = NULL;
76 }
77
78
79
80
81 ipaimap = sbi->ipaimap;
82 diUnmount(ipaimap, 0);
83 diFreeSpecial(ipaimap);
84 sbi->ipaimap = NULL;
85
86
87
88
89 dbUnmount(ipbmap, 0);
90
91 diFreeSpecial(ipbmap);
92 sbi->ipimap = NULL;
93
94
95
96
97
98 filemap_write_and_wait(sbi->direct_inode->i_mapping);
99
100
101
102
103
104
105
106
107
108 if (log) {
109 updateSuper(sb, FM_CLEAN);
110
111
112
113
114
115
116 rc = lmLogClose(sb);
117 }
118 jfs_info("UnMount JFS Complete: rc = %d", rc);
119 return rc;
120}
121
122
123int jfs_umount_rw(struct super_block *sb)
124{
125 struct jfs_sb_info *sbi = JFS_SBI(sb);
126 struct jfs_log *log = sbi->log;
127
128 if (!log)
129 return 0;
130
131
132
133
134
135
136 jfs_flush_journal(log, 2);
137
138
139
140
141 dbSync(sbi->ipbmap);
142 diSync(sbi->ipimap);
143
144
145
146
147
148
149
150 filemap_write_and_wait(sbi->direct_inode->i_mapping);
151
152 updateSuper(sb, FM_CLEAN);
153
154 return lmLogClose(sb);
155}
156