Commit 860b25d4a913a00331d333f8e207a088c7a1b84a
1 parent
20b95bf2c4
Exists in
master
and in
7 other branches
[GFS2] Remove drop of module ref where not needed
In an earlier patch "[GFS2] fix file_system_type leak on gfs2meta mount" we removed the code to grab a ref to the module which was not needed (since we know that the module cannot be unloaded at that time) so this patch removes the code to drop that reference. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Showing 1 changed file with 0 additions and 1 deletions Inline Diff
fs/gfs2/ops_fstype.c
1 | /* | 1 | /* |
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | 2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. |
3 | * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. | 3 | * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. |
4 | * | 4 | * |
5 | * This copyrighted material is made available to anyone wishing to use, | 5 | * This copyrighted material is made available to anyone wishing to use, |
6 | * modify, copy, or redistribute it subject to the terms and conditions | 6 | * modify, copy, or redistribute it subject to the terms and conditions |
7 | * of the GNU General Public License version 2. | 7 | * of the GNU General Public License version 2. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <linux/sched.h> | 10 | #include <linux/sched.h> |
11 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
12 | #include <linux/spinlock.h> | 12 | #include <linux/spinlock.h> |
13 | #include <linux/completion.h> | 13 | #include <linux/completion.h> |
14 | #include <linux/buffer_head.h> | 14 | #include <linux/buffer_head.h> |
15 | #include <linux/blkdev.h> | 15 | #include <linux/blkdev.h> |
16 | #include <linux/kthread.h> | 16 | #include <linux/kthread.h> |
17 | #include <linux/namei.h> | 17 | #include <linux/namei.h> |
18 | #include <linux/mount.h> | 18 | #include <linux/mount.h> |
19 | #include <linux/gfs2_ondisk.h> | 19 | #include <linux/gfs2_ondisk.h> |
20 | #include <linux/lm_interface.h> | 20 | #include <linux/lm_interface.h> |
21 | 21 | ||
22 | #include "gfs2.h" | 22 | #include "gfs2.h" |
23 | #include "incore.h" | 23 | #include "incore.h" |
24 | #include "bmap.h" | 24 | #include "bmap.h" |
25 | #include "daemon.h" | 25 | #include "daemon.h" |
26 | #include "glock.h" | 26 | #include "glock.h" |
27 | #include "glops.h" | 27 | #include "glops.h" |
28 | #include "inode.h" | 28 | #include "inode.h" |
29 | #include "mount.h" | 29 | #include "mount.h" |
30 | #include "ops_fstype.h" | 30 | #include "ops_fstype.h" |
31 | #include "ops_dentry.h" | 31 | #include "ops_dentry.h" |
32 | #include "ops_super.h" | 32 | #include "ops_super.h" |
33 | #include "recovery.h" | 33 | #include "recovery.h" |
34 | #include "rgrp.h" | 34 | #include "rgrp.h" |
35 | #include "super.h" | 35 | #include "super.h" |
36 | #include "sys.h" | 36 | #include "sys.h" |
37 | #include "util.h" | 37 | #include "util.h" |
38 | #include "log.h" | 38 | #include "log.h" |
39 | 39 | ||
40 | #define DO 0 | 40 | #define DO 0 |
41 | #define UNDO 1 | 41 | #define UNDO 1 |
42 | 42 | ||
43 | static struct gfs2_sbd *init_sbd(struct super_block *sb) | 43 | static struct gfs2_sbd *init_sbd(struct super_block *sb) |
44 | { | 44 | { |
45 | struct gfs2_sbd *sdp; | 45 | struct gfs2_sbd *sdp; |
46 | 46 | ||
47 | sdp = kzalloc(sizeof(struct gfs2_sbd), GFP_KERNEL); | 47 | sdp = kzalloc(sizeof(struct gfs2_sbd), GFP_KERNEL); |
48 | if (!sdp) | 48 | if (!sdp) |
49 | return NULL; | 49 | return NULL; |
50 | 50 | ||
51 | sb->s_fs_info = sdp; | 51 | sb->s_fs_info = sdp; |
52 | sdp->sd_vfs = sb; | 52 | sdp->sd_vfs = sb; |
53 | 53 | ||
54 | gfs2_tune_init(&sdp->sd_tune); | 54 | gfs2_tune_init(&sdp->sd_tune); |
55 | 55 | ||
56 | INIT_LIST_HEAD(&sdp->sd_reclaim_list); | 56 | INIT_LIST_HEAD(&sdp->sd_reclaim_list); |
57 | spin_lock_init(&sdp->sd_reclaim_lock); | 57 | spin_lock_init(&sdp->sd_reclaim_lock); |
58 | init_waitqueue_head(&sdp->sd_reclaim_wq); | 58 | init_waitqueue_head(&sdp->sd_reclaim_wq); |
59 | 59 | ||
60 | mutex_init(&sdp->sd_inum_mutex); | 60 | mutex_init(&sdp->sd_inum_mutex); |
61 | spin_lock_init(&sdp->sd_statfs_spin); | 61 | spin_lock_init(&sdp->sd_statfs_spin); |
62 | 62 | ||
63 | spin_lock_init(&sdp->sd_rindex_spin); | 63 | spin_lock_init(&sdp->sd_rindex_spin); |
64 | mutex_init(&sdp->sd_rindex_mutex); | 64 | mutex_init(&sdp->sd_rindex_mutex); |
65 | INIT_LIST_HEAD(&sdp->sd_rindex_list); | 65 | INIT_LIST_HEAD(&sdp->sd_rindex_list); |
66 | INIT_LIST_HEAD(&sdp->sd_rindex_mru_list); | 66 | INIT_LIST_HEAD(&sdp->sd_rindex_mru_list); |
67 | INIT_LIST_HEAD(&sdp->sd_rindex_recent_list); | 67 | INIT_LIST_HEAD(&sdp->sd_rindex_recent_list); |
68 | 68 | ||
69 | INIT_LIST_HEAD(&sdp->sd_jindex_list); | 69 | INIT_LIST_HEAD(&sdp->sd_jindex_list); |
70 | spin_lock_init(&sdp->sd_jindex_spin); | 70 | spin_lock_init(&sdp->sd_jindex_spin); |
71 | mutex_init(&sdp->sd_jindex_mutex); | 71 | mutex_init(&sdp->sd_jindex_mutex); |
72 | 72 | ||
73 | INIT_LIST_HEAD(&sdp->sd_quota_list); | 73 | INIT_LIST_HEAD(&sdp->sd_quota_list); |
74 | spin_lock_init(&sdp->sd_quota_spin); | 74 | spin_lock_init(&sdp->sd_quota_spin); |
75 | mutex_init(&sdp->sd_quota_mutex); | 75 | mutex_init(&sdp->sd_quota_mutex); |
76 | 76 | ||
77 | spin_lock_init(&sdp->sd_log_lock); | 77 | spin_lock_init(&sdp->sd_log_lock); |
78 | 78 | ||
79 | INIT_LIST_HEAD(&sdp->sd_log_le_buf); | 79 | INIT_LIST_HEAD(&sdp->sd_log_le_buf); |
80 | INIT_LIST_HEAD(&sdp->sd_log_le_revoke); | 80 | INIT_LIST_HEAD(&sdp->sd_log_le_revoke); |
81 | INIT_LIST_HEAD(&sdp->sd_log_le_rg); | 81 | INIT_LIST_HEAD(&sdp->sd_log_le_rg); |
82 | INIT_LIST_HEAD(&sdp->sd_log_le_databuf); | 82 | INIT_LIST_HEAD(&sdp->sd_log_le_databuf); |
83 | INIT_LIST_HEAD(&sdp->sd_log_le_ordered); | 83 | INIT_LIST_HEAD(&sdp->sd_log_le_ordered); |
84 | 84 | ||
85 | mutex_init(&sdp->sd_log_reserve_mutex); | 85 | mutex_init(&sdp->sd_log_reserve_mutex); |
86 | INIT_LIST_HEAD(&sdp->sd_ail1_list); | 86 | INIT_LIST_HEAD(&sdp->sd_ail1_list); |
87 | INIT_LIST_HEAD(&sdp->sd_ail2_list); | 87 | INIT_LIST_HEAD(&sdp->sd_ail2_list); |
88 | 88 | ||
89 | init_rwsem(&sdp->sd_log_flush_lock); | 89 | init_rwsem(&sdp->sd_log_flush_lock); |
90 | atomic_set(&sdp->sd_log_in_flight, 0); | 90 | atomic_set(&sdp->sd_log_in_flight, 0); |
91 | init_waitqueue_head(&sdp->sd_log_flush_wait); | 91 | init_waitqueue_head(&sdp->sd_log_flush_wait); |
92 | 92 | ||
93 | INIT_LIST_HEAD(&sdp->sd_revoke_list); | 93 | INIT_LIST_HEAD(&sdp->sd_revoke_list); |
94 | 94 | ||
95 | mutex_init(&sdp->sd_freeze_lock); | 95 | mutex_init(&sdp->sd_freeze_lock); |
96 | 96 | ||
97 | return sdp; | 97 | return sdp; |
98 | } | 98 | } |
99 | 99 | ||
100 | static void init_vfs(struct super_block *sb, unsigned noatime) | 100 | static void init_vfs(struct super_block *sb, unsigned noatime) |
101 | { | 101 | { |
102 | struct gfs2_sbd *sdp = sb->s_fs_info; | 102 | struct gfs2_sbd *sdp = sb->s_fs_info; |
103 | 103 | ||
104 | sb->s_magic = GFS2_MAGIC; | 104 | sb->s_magic = GFS2_MAGIC; |
105 | sb->s_op = &gfs2_super_ops; | 105 | sb->s_op = &gfs2_super_ops; |
106 | sb->s_export_op = &gfs2_export_ops; | 106 | sb->s_export_op = &gfs2_export_ops; |
107 | sb->s_time_gran = 1; | 107 | sb->s_time_gran = 1; |
108 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 108 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
109 | 109 | ||
110 | if (sb->s_flags & (MS_NOATIME | MS_NODIRATIME)) | 110 | if (sb->s_flags & (MS_NOATIME | MS_NODIRATIME)) |
111 | set_bit(noatime, &sdp->sd_flags); | 111 | set_bit(noatime, &sdp->sd_flags); |
112 | 112 | ||
113 | /* Don't let the VFS update atimes. GFS2 handles this itself. */ | 113 | /* Don't let the VFS update atimes. GFS2 handles this itself. */ |
114 | sb->s_flags |= MS_NOATIME | MS_NODIRATIME; | 114 | sb->s_flags |= MS_NOATIME | MS_NODIRATIME; |
115 | } | 115 | } |
116 | 116 | ||
117 | static int init_names(struct gfs2_sbd *sdp, int silent) | 117 | static int init_names(struct gfs2_sbd *sdp, int silent) |
118 | { | 118 | { |
119 | char *proto, *table; | 119 | char *proto, *table; |
120 | int error = 0; | 120 | int error = 0; |
121 | 121 | ||
122 | proto = sdp->sd_args.ar_lockproto; | 122 | proto = sdp->sd_args.ar_lockproto; |
123 | table = sdp->sd_args.ar_locktable; | 123 | table = sdp->sd_args.ar_locktable; |
124 | 124 | ||
125 | /* Try to autodetect */ | 125 | /* Try to autodetect */ |
126 | 126 | ||
127 | if (!proto[0] || !table[0]) { | 127 | if (!proto[0] || !table[0]) { |
128 | error = gfs2_read_super(sdp, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift); | 128 | error = gfs2_read_super(sdp, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift); |
129 | if (error) | 129 | if (error) |
130 | return error; | 130 | return error; |
131 | 131 | ||
132 | error = gfs2_check_sb(sdp, &sdp->sd_sb, silent); | 132 | error = gfs2_check_sb(sdp, &sdp->sd_sb, silent); |
133 | if (error) | 133 | if (error) |
134 | goto out; | 134 | goto out; |
135 | 135 | ||
136 | if (!proto[0]) | 136 | if (!proto[0]) |
137 | proto = sdp->sd_sb.sb_lockproto; | 137 | proto = sdp->sd_sb.sb_lockproto; |
138 | if (!table[0]) | 138 | if (!table[0]) |
139 | table = sdp->sd_sb.sb_locktable; | 139 | table = sdp->sd_sb.sb_locktable; |
140 | } | 140 | } |
141 | 141 | ||
142 | if (!table[0]) | 142 | if (!table[0]) |
143 | table = sdp->sd_vfs->s_id; | 143 | table = sdp->sd_vfs->s_id; |
144 | 144 | ||
145 | snprintf(sdp->sd_proto_name, GFS2_FSNAME_LEN, "%s", proto); | 145 | snprintf(sdp->sd_proto_name, GFS2_FSNAME_LEN, "%s", proto); |
146 | snprintf(sdp->sd_table_name, GFS2_FSNAME_LEN, "%s", table); | 146 | snprintf(sdp->sd_table_name, GFS2_FSNAME_LEN, "%s", table); |
147 | 147 | ||
148 | table = sdp->sd_table_name; | 148 | table = sdp->sd_table_name; |
149 | while ((table = strchr(table, '/'))) | 149 | while ((table = strchr(table, '/'))) |
150 | *table = '_'; | 150 | *table = '_'; |
151 | 151 | ||
152 | out: | 152 | out: |
153 | return error; | 153 | return error; |
154 | } | 154 | } |
155 | 155 | ||
156 | static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, | 156 | static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh, |
157 | int undo) | 157 | int undo) |
158 | { | 158 | { |
159 | struct task_struct *p; | 159 | struct task_struct *p; |
160 | int error = 0; | 160 | int error = 0; |
161 | 161 | ||
162 | if (undo) | 162 | if (undo) |
163 | goto fail_trans; | 163 | goto fail_trans; |
164 | 164 | ||
165 | for (sdp->sd_glockd_num = 0; | 165 | for (sdp->sd_glockd_num = 0; |
166 | sdp->sd_glockd_num < sdp->sd_args.ar_num_glockd; | 166 | sdp->sd_glockd_num < sdp->sd_args.ar_num_glockd; |
167 | sdp->sd_glockd_num++) { | 167 | sdp->sd_glockd_num++) { |
168 | p = kthread_run(gfs2_glockd, sdp, "gfs2_glockd"); | 168 | p = kthread_run(gfs2_glockd, sdp, "gfs2_glockd"); |
169 | error = IS_ERR(p); | 169 | error = IS_ERR(p); |
170 | if (error) { | 170 | if (error) { |
171 | fs_err(sdp, "can't start glockd thread: %d\n", error); | 171 | fs_err(sdp, "can't start glockd thread: %d\n", error); |
172 | goto fail; | 172 | goto fail; |
173 | } | 173 | } |
174 | sdp->sd_glockd_process[sdp->sd_glockd_num] = p; | 174 | sdp->sd_glockd_process[sdp->sd_glockd_num] = p; |
175 | } | 175 | } |
176 | 176 | ||
177 | error = gfs2_glock_nq_num(sdp, | 177 | error = gfs2_glock_nq_num(sdp, |
178 | GFS2_MOUNT_LOCK, &gfs2_nondisk_glops, | 178 | GFS2_MOUNT_LOCK, &gfs2_nondisk_glops, |
179 | LM_ST_EXCLUSIVE, LM_FLAG_NOEXP | GL_NOCACHE, | 179 | LM_ST_EXCLUSIVE, LM_FLAG_NOEXP | GL_NOCACHE, |
180 | mount_gh); | 180 | mount_gh); |
181 | if (error) { | 181 | if (error) { |
182 | fs_err(sdp, "can't acquire mount glock: %d\n", error); | 182 | fs_err(sdp, "can't acquire mount glock: %d\n", error); |
183 | goto fail; | 183 | goto fail; |
184 | } | 184 | } |
185 | 185 | ||
186 | error = gfs2_glock_nq_num(sdp, | 186 | error = gfs2_glock_nq_num(sdp, |
187 | GFS2_LIVE_LOCK, &gfs2_nondisk_glops, | 187 | GFS2_LIVE_LOCK, &gfs2_nondisk_glops, |
188 | LM_ST_SHARED, | 188 | LM_ST_SHARED, |
189 | LM_FLAG_NOEXP | GL_EXACT, | 189 | LM_FLAG_NOEXP | GL_EXACT, |
190 | &sdp->sd_live_gh); | 190 | &sdp->sd_live_gh); |
191 | if (error) { | 191 | if (error) { |
192 | fs_err(sdp, "can't acquire live glock: %d\n", error); | 192 | fs_err(sdp, "can't acquire live glock: %d\n", error); |
193 | goto fail_mount; | 193 | goto fail_mount; |
194 | } | 194 | } |
195 | 195 | ||
196 | error = gfs2_glock_get(sdp, GFS2_RENAME_LOCK, &gfs2_nondisk_glops, | 196 | error = gfs2_glock_get(sdp, GFS2_RENAME_LOCK, &gfs2_nondisk_glops, |
197 | CREATE, &sdp->sd_rename_gl); | 197 | CREATE, &sdp->sd_rename_gl); |
198 | if (error) { | 198 | if (error) { |
199 | fs_err(sdp, "can't create rename glock: %d\n", error); | 199 | fs_err(sdp, "can't create rename glock: %d\n", error); |
200 | goto fail_live; | 200 | goto fail_live; |
201 | } | 201 | } |
202 | 202 | ||
203 | error = gfs2_glock_get(sdp, GFS2_TRANS_LOCK, &gfs2_trans_glops, | 203 | error = gfs2_glock_get(sdp, GFS2_TRANS_LOCK, &gfs2_trans_glops, |
204 | CREATE, &sdp->sd_trans_gl); | 204 | CREATE, &sdp->sd_trans_gl); |
205 | if (error) { | 205 | if (error) { |
206 | fs_err(sdp, "can't create transaction glock: %d\n", error); | 206 | fs_err(sdp, "can't create transaction glock: %d\n", error); |
207 | goto fail_rename; | 207 | goto fail_rename; |
208 | } | 208 | } |
209 | set_bit(GLF_STICKY, &sdp->sd_trans_gl->gl_flags); | 209 | set_bit(GLF_STICKY, &sdp->sd_trans_gl->gl_flags); |
210 | 210 | ||
211 | return 0; | 211 | return 0; |
212 | 212 | ||
213 | fail_trans: | 213 | fail_trans: |
214 | gfs2_glock_put(sdp->sd_trans_gl); | 214 | gfs2_glock_put(sdp->sd_trans_gl); |
215 | fail_rename: | 215 | fail_rename: |
216 | gfs2_glock_put(sdp->sd_rename_gl); | 216 | gfs2_glock_put(sdp->sd_rename_gl); |
217 | fail_live: | 217 | fail_live: |
218 | gfs2_glock_dq_uninit(&sdp->sd_live_gh); | 218 | gfs2_glock_dq_uninit(&sdp->sd_live_gh); |
219 | fail_mount: | 219 | fail_mount: |
220 | gfs2_glock_dq_uninit(mount_gh); | 220 | gfs2_glock_dq_uninit(mount_gh); |
221 | fail: | 221 | fail: |
222 | while (sdp->sd_glockd_num--) | 222 | while (sdp->sd_glockd_num--) |
223 | kthread_stop(sdp->sd_glockd_process[sdp->sd_glockd_num]); | 223 | kthread_stop(sdp->sd_glockd_process[sdp->sd_glockd_num]); |
224 | 224 | ||
225 | return error; | 225 | return error; |
226 | } | 226 | } |
227 | 227 | ||
228 | static inline struct inode *gfs2_lookup_root(struct super_block *sb, | 228 | static inline struct inode *gfs2_lookup_root(struct super_block *sb, |
229 | u64 no_addr) | 229 | u64 no_addr) |
230 | { | 230 | { |
231 | return gfs2_inode_lookup(sb, DT_DIR, no_addr, 0, 0); | 231 | return gfs2_inode_lookup(sb, DT_DIR, no_addr, 0, 0); |
232 | } | 232 | } |
233 | 233 | ||
234 | static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) | 234 | static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) |
235 | { | 235 | { |
236 | struct super_block *sb = sdp->sd_vfs; | 236 | struct super_block *sb = sdp->sd_vfs; |
237 | struct gfs2_holder sb_gh; | 237 | struct gfs2_holder sb_gh; |
238 | u64 no_addr; | 238 | u64 no_addr; |
239 | struct inode *inode; | 239 | struct inode *inode; |
240 | int error = 0; | 240 | int error = 0; |
241 | 241 | ||
242 | if (undo) { | 242 | if (undo) { |
243 | if (sb->s_root) { | 243 | if (sb->s_root) { |
244 | dput(sb->s_root); | 244 | dput(sb->s_root); |
245 | sb->s_root = NULL; | 245 | sb->s_root = NULL; |
246 | } | 246 | } |
247 | return 0; | 247 | return 0; |
248 | } | 248 | } |
249 | 249 | ||
250 | error = gfs2_glock_nq_num(sdp, GFS2_SB_LOCK, &gfs2_meta_glops, | 250 | error = gfs2_glock_nq_num(sdp, GFS2_SB_LOCK, &gfs2_meta_glops, |
251 | LM_ST_SHARED, 0, &sb_gh); | 251 | LM_ST_SHARED, 0, &sb_gh); |
252 | if (error) { | 252 | if (error) { |
253 | fs_err(sdp, "can't acquire superblock glock: %d\n", error); | 253 | fs_err(sdp, "can't acquire superblock glock: %d\n", error); |
254 | return error; | 254 | return error; |
255 | } | 255 | } |
256 | 256 | ||
257 | error = gfs2_read_sb(sdp, sb_gh.gh_gl, silent); | 257 | error = gfs2_read_sb(sdp, sb_gh.gh_gl, silent); |
258 | if (error) { | 258 | if (error) { |
259 | fs_err(sdp, "can't read superblock: %d\n", error); | 259 | fs_err(sdp, "can't read superblock: %d\n", error); |
260 | goto out; | 260 | goto out; |
261 | } | 261 | } |
262 | 262 | ||
263 | /* Set up the buffer cache and SB for real */ | 263 | /* Set up the buffer cache and SB for real */ |
264 | if (sdp->sd_sb.sb_bsize < bdev_hardsect_size(sb->s_bdev)) { | 264 | if (sdp->sd_sb.sb_bsize < bdev_hardsect_size(sb->s_bdev)) { |
265 | error = -EINVAL; | 265 | error = -EINVAL; |
266 | fs_err(sdp, "FS block size (%u) is too small for device " | 266 | fs_err(sdp, "FS block size (%u) is too small for device " |
267 | "block size (%u)\n", | 267 | "block size (%u)\n", |
268 | sdp->sd_sb.sb_bsize, bdev_hardsect_size(sb->s_bdev)); | 268 | sdp->sd_sb.sb_bsize, bdev_hardsect_size(sb->s_bdev)); |
269 | goto out; | 269 | goto out; |
270 | } | 270 | } |
271 | if (sdp->sd_sb.sb_bsize > PAGE_SIZE) { | 271 | if (sdp->sd_sb.sb_bsize > PAGE_SIZE) { |
272 | error = -EINVAL; | 272 | error = -EINVAL; |
273 | fs_err(sdp, "FS block size (%u) is too big for machine " | 273 | fs_err(sdp, "FS block size (%u) is too big for machine " |
274 | "page size (%u)\n", | 274 | "page size (%u)\n", |
275 | sdp->sd_sb.sb_bsize, (unsigned int)PAGE_SIZE); | 275 | sdp->sd_sb.sb_bsize, (unsigned int)PAGE_SIZE); |
276 | goto out; | 276 | goto out; |
277 | } | 277 | } |
278 | sb_set_blocksize(sb, sdp->sd_sb.sb_bsize); | 278 | sb_set_blocksize(sb, sdp->sd_sb.sb_bsize); |
279 | 279 | ||
280 | /* Get the root inode */ | 280 | /* Get the root inode */ |
281 | no_addr = sdp->sd_sb.sb_root_dir.no_addr; | 281 | no_addr = sdp->sd_sb.sb_root_dir.no_addr; |
282 | if (sb->s_type == &gfs2meta_fs_type) | 282 | if (sb->s_type == &gfs2meta_fs_type) |
283 | no_addr = sdp->sd_sb.sb_master_dir.no_addr; | 283 | no_addr = sdp->sd_sb.sb_master_dir.no_addr; |
284 | inode = gfs2_lookup_root(sb, no_addr); | 284 | inode = gfs2_lookup_root(sb, no_addr); |
285 | if (IS_ERR(inode)) { | 285 | if (IS_ERR(inode)) { |
286 | error = PTR_ERR(inode); | 286 | error = PTR_ERR(inode); |
287 | fs_err(sdp, "can't read in root inode: %d\n", error); | 287 | fs_err(sdp, "can't read in root inode: %d\n", error); |
288 | goto out; | 288 | goto out; |
289 | } | 289 | } |
290 | 290 | ||
291 | sb->s_root = d_alloc_root(inode); | 291 | sb->s_root = d_alloc_root(inode); |
292 | if (!sb->s_root) { | 292 | if (!sb->s_root) { |
293 | fs_err(sdp, "can't get root dentry\n"); | 293 | fs_err(sdp, "can't get root dentry\n"); |
294 | error = -ENOMEM; | 294 | error = -ENOMEM; |
295 | iput(inode); | 295 | iput(inode); |
296 | } else | 296 | } else |
297 | sb->s_root->d_op = &gfs2_dops; | 297 | sb->s_root->d_op = &gfs2_dops; |
298 | 298 | ||
299 | out: | 299 | out: |
300 | gfs2_glock_dq_uninit(&sb_gh); | 300 | gfs2_glock_dq_uninit(&sb_gh); |
301 | return error; | 301 | return error; |
302 | } | 302 | } |
303 | 303 | ||
304 | /** | 304 | /** |
305 | * map_journal_extents - create a reusable "extent" mapping from all logical | 305 | * map_journal_extents - create a reusable "extent" mapping from all logical |
306 | * blocks to all physical blocks for the given journal. This will save | 306 | * blocks to all physical blocks for the given journal. This will save |
307 | * us time when writing journal blocks. Most journals will have only one | 307 | * us time when writing journal blocks. Most journals will have only one |
308 | * extent that maps all their logical blocks. That's because gfs2.mkfs | 308 | * extent that maps all their logical blocks. That's because gfs2.mkfs |
309 | * arranges the journal blocks sequentially to maximize performance. | 309 | * arranges the journal blocks sequentially to maximize performance. |
310 | * So the extent would map the first block for the entire file length. | 310 | * So the extent would map the first block for the entire file length. |
311 | * However, gfs2_jadd can happen while file activity is happening, so | 311 | * However, gfs2_jadd can happen while file activity is happening, so |
312 | * those journals may not be sequential. Less likely is the case where | 312 | * those journals may not be sequential. Less likely is the case where |
313 | * the users created their own journals by mounting the metafs and | 313 | * the users created their own journals by mounting the metafs and |
314 | * laying it out. But it's still possible. These journals might have | 314 | * laying it out. But it's still possible. These journals might have |
315 | * several extents. | 315 | * several extents. |
316 | * | 316 | * |
317 | * TODO: This should be done in bigger chunks rather than one block at a time, | 317 | * TODO: This should be done in bigger chunks rather than one block at a time, |
318 | * but since it's only done at mount time, I'm not worried about the | 318 | * but since it's only done at mount time, I'm not worried about the |
319 | * time it takes. | 319 | * time it takes. |
320 | */ | 320 | */ |
321 | static int map_journal_extents(struct gfs2_sbd *sdp) | 321 | static int map_journal_extents(struct gfs2_sbd *sdp) |
322 | { | 322 | { |
323 | struct gfs2_jdesc *jd = sdp->sd_jdesc; | 323 | struct gfs2_jdesc *jd = sdp->sd_jdesc; |
324 | unsigned int lb; | 324 | unsigned int lb; |
325 | u64 db, prev_db; /* logical block, disk block, prev disk block */ | 325 | u64 db, prev_db; /* logical block, disk block, prev disk block */ |
326 | struct gfs2_inode *ip = GFS2_I(jd->jd_inode); | 326 | struct gfs2_inode *ip = GFS2_I(jd->jd_inode); |
327 | struct gfs2_journal_extent *jext = NULL; | 327 | struct gfs2_journal_extent *jext = NULL; |
328 | struct buffer_head bh; | 328 | struct buffer_head bh; |
329 | int rc = 0; | 329 | int rc = 0; |
330 | 330 | ||
331 | prev_db = 0; | 331 | prev_db = 0; |
332 | 332 | ||
333 | for (lb = 0; lb < ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; lb++) { | 333 | for (lb = 0; lb < ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; lb++) { |
334 | bh.b_state = 0; | 334 | bh.b_state = 0; |
335 | bh.b_blocknr = 0; | 335 | bh.b_blocknr = 0; |
336 | bh.b_size = 1 << ip->i_inode.i_blkbits; | 336 | bh.b_size = 1 << ip->i_inode.i_blkbits; |
337 | rc = gfs2_block_map(jd->jd_inode, lb, &bh, 0); | 337 | rc = gfs2_block_map(jd->jd_inode, lb, &bh, 0); |
338 | db = bh.b_blocknr; | 338 | db = bh.b_blocknr; |
339 | if (rc || !db) { | 339 | if (rc || !db) { |
340 | printk(KERN_INFO "GFS2 journal mapping error %d: lb=" | 340 | printk(KERN_INFO "GFS2 journal mapping error %d: lb=" |
341 | "%u db=%llu\n", rc, lb, (unsigned long long)db); | 341 | "%u db=%llu\n", rc, lb, (unsigned long long)db); |
342 | break; | 342 | break; |
343 | } | 343 | } |
344 | if (!prev_db || db != prev_db + 1) { | 344 | if (!prev_db || db != prev_db + 1) { |
345 | jext = kzalloc(sizeof(struct gfs2_journal_extent), | 345 | jext = kzalloc(sizeof(struct gfs2_journal_extent), |
346 | GFP_KERNEL); | 346 | GFP_KERNEL); |
347 | if (!jext) { | 347 | if (!jext) { |
348 | printk(KERN_INFO "GFS2 error: out of memory " | 348 | printk(KERN_INFO "GFS2 error: out of memory " |
349 | "mapping journal extents.\n"); | 349 | "mapping journal extents.\n"); |
350 | rc = -ENOMEM; | 350 | rc = -ENOMEM; |
351 | break; | 351 | break; |
352 | } | 352 | } |
353 | jext->dblock = db; | 353 | jext->dblock = db; |
354 | jext->lblock = lb; | 354 | jext->lblock = lb; |
355 | jext->blocks = 1; | 355 | jext->blocks = 1; |
356 | list_add_tail(&jext->extent_list, &jd->extent_list); | 356 | list_add_tail(&jext->extent_list, &jd->extent_list); |
357 | } else { | 357 | } else { |
358 | jext->blocks++; | 358 | jext->blocks++; |
359 | } | 359 | } |
360 | prev_db = db; | 360 | prev_db = db; |
361 | } | 361 | } |
362 | return rc; | 362 | return rc; |
363 | } | 363 | } |
364 | 364 | ||
365 | static void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp) | 365 | static void gfs2_lm_others_may_mount(struct gfs2_sbd *sdp) |
366 | { | 366 | { |
367 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 367 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
368 | sdp->sd_lockstruct.ls_ops->lm_others_may_mount( | 368 | sdp->sd_lockstruct.ls_ops->lm_others_may_mount( |
369 | sdp->sd_lockstruct.ls_lockspace); | 369 | sdp->sd_lockstruct.ls_lockspace); |
370 | } | 370 | } |
371 | 371 | ||
372 | static int init_journal(struct gfs2_sbd *sdp, int undo) | 372 | static int init_journal(struct gfs2_sbd *sdp, int undo) |
373 | { | 373 | { |
374 | struct gfs2_holder ji_gh; | 374 | struct gfs2_holder ji_gh; |
375 | struct task_struct *p; | 375 | struct task_struct *p; |
376 | struct gfs2_inode *ip; | 376 | struct gfs2_inode *ip; |
377 | int jindex = 1; | 377 | int jindex = 1; |
378 | int error = 0; | 378 | int error = 0; |
379 | 379 | ||
380 | if (undo) { | 380 | if (undo) { |
381 | jindex = 0; | 381 | jindex = 0; |
382 | goto fail_recoverd; | 382 | goto fail_recoverd; |
383 | } | 383 | } |
384 | 384 | ||
385 | sdp->sd_jindex = gfs2_lookup_simple(sdp->sd_master_dir, "jindex"); | 385 | sdp->sd_jindex = gfs2_lookup_simple(sdp->sd_master_dir, "jindex"); |
386 | if (IS_ERR(sdp->sd_jindex)) { | 386 | if (IS_ERR(sdp->sd_jindex)) { |
387 | fs_err(sdp, "can't lookup journal index: %d\n", error); | 387 | fs_err(sdp, "can't lookup journal index: %d\n", error); |
388 | return PTR_ERR(sdp->sd_jindex); | 388 | return PTR_ERR(sdp->sd_jindex); |
389 | } | 389 | } |
390 | ip = GFS2_I(sdp->sd_jindex); | 390 | ip = GFS2_I(sdp->sd_jindex); |
391 | set_bit(GLF_STICKY, &ip->i_gl->gl_flags); | 391 | set_bit(GLF_STICKY, &ip->i_gl->gl_flags); |
392 | 392 | ||
393 | /* Load in the journal index special file */ | 393 | /* Load in the journal index special file */ |
394 | 394 | ||
395 | error = gfs2_jindex_hold(sdp, &ji_gh); | 395 | error = gfs2_jindex_hold(sdp, &ji_gh); |
396 | if (error) { | 396 | if (error) { |
397 | fs_err(sdp, "can't read journal index: %d\n", error); | 397 | fs_err(sdp, "can't read journal index: %d\n", error); |
398 | goto fail; | 398 | goto fail; |
399 | } | 399 | } |
400 | 400 | ||
401 | error = -EINVAL; | 401 | error = -EINVAL; |
402 | if (!gfs2_jindex_size(sdp)) { | 402 | if (!gfs2_jindex_size(sdp)) { |
403 | fs_err(sdp, "no journals!\n"); | 403 | fs_err(sdp, "no journals!\n"); |
404 | goto fail_jindex; | 404 | goto fail_jindex; |
405 | } | 405 | } |
406 | 406 | ||
407 | if (sdp->sd_args.ar_spectator) { | 407 | if (sdp->sd_args.ar_spectator) { |
408 | sdp->sd_jdesc = gfs2_jdesc_find(sdp, 0); | 408 | sdp->sd_jdesc = gfs2_jdesc_find(sdp, 0); |
409 | atomic_set(&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); | 409 | atomic_set(&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); |
410 | } else { | 410 | } else { |
411 | if (sdp->sd_lockstruct.ls_jid >= gfs2_jindex_size(sdp)) { | 411 | if (sdp->sd_lockstruct.ls_jid >= gfs2_jindex_size(sdp)) { |
412 | fs_err(sdp, "can't mount journal #%u\n", | 412 | fs_err(sdp, "can't mount journal #%u\n", |
413 | sdp->sd_lockstruct.ls_jid); | 413 | sdp->sd_lockstruct.ls_jid); |
414 | fs_err(sdp, "there are only %u journals (0 - %u)\n", | 414 | fs_err(sdp, "there are only %u journals (0 - %u)\n", |
415 | gfs2_jindex_size(sdp), | 415 | gfs2_jindex_size(sdp), |
416 | gfs2_jindex_size(sdp) - 1); | 416 | gfs2_jindex_size(sdp) - 1); |
417 | goto fail_jindex; | 417 | goto fail_jindex; |
418 | } | 418 | } |
419 | sdp->sd_jdesc = gfs2_jdesc_find(sdp, sdp->sd_lockstruct.ls_jid); | 419 | sdp->sd_jdesc = gfs2_jdesc_find(sdp, sdp->sd_lockstruct.ls_jid); |
420 | 420 | ||
421 | error = gfs2_glock_nq_num(sdp, sdp->sd_lockstruct.ls_jid, | 421 | error = gfs2_glock_nq_num(sdp, sdp->sd_lockstruct.ls_jid, |
422 | &gfs2_journal_glops, | 422 | &gfs2_journal_glops, |
423 | LM_ST_EXCLUSIVE, LM_FLAG_NOEXP, | 423 | LM_ST_EXCLUSIVE, LM_FLAG_NOEXP, |
424 | &sdp->sd_journal_gh); | 424 | &sdp->sd_journal_gh); |
425 | if (error) { | 425 | if (error) { |
426 | fs_err(sdp, "can't acquire journal glock: %d\n", error); | 426 | fs_err(sdp, "can't acquire journal glock: %d\n", error); |
427 | goto fail_jindex; | 427 | goto fail_jindex; |
428 | } | 428 | } |
429 | 429 | ||
430 | ip = GFS2_I(sdp->sd_jdesc->jd_inode); | 430 | ip = GFS2_I(sdp->sd_jdesc->jd_inode); |
431 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, | 431 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, |
432 | LM_FLAG_NOEXP | GL_EXACT | GL_NOCACHE, | 432 | LM_FLAG_NOEXP | GL_EXACT | GL_NOCACHE, |
433 | &sdp->sd_jinode_gh); | 433 | &sdp->sd_jinode_gh); |
434 | if (error) { | 434 | if (error) { |
435 | fs_err(sdp, "can't acquire journal inode glock: %d\n", | 435 | fs_err(sdp, "can't acquire journal inode glock: %d\n", |
436 | error); | 436 | error); |
437 | goto fail_journal_gh; | 437 | goto fail_journal_gh; |
438 | } | 438 | } |
439 | 439 | ||
440 | error = gfs2_jdesc_check(sdp->sd_jdesc); | 440 | error = gfs2_jdesc_check(sdp->sd_jdesc); |
441 | if (error) { | 441 | if (error) { |
442 | fs_err(sdp, "my journal (%u) is bad: %d\n", | 442 | fs_err(sdp, "my journal (%u) is bad: %d\n", |
443 | sdp->sd_jdesc->jd_jid, error); | 443 | sdp->sd_jdesc->jd_jid, error); |
444 | goto fail_jinode_gh; | 444 | goto fail_jinode_gh; |
445 | } | 445 | } |
446 | atomic_set(&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); | 446 | atomic_set(&sdp->sd_log_blks_free, sdp->sd_jdesc->jd_blocks); |
447 | 447 | ||
448 | /* Map the extents for this journal's blocks */ | 448 | /* Map the extents for this journal's blocks */ |
449 | map_journal_extents(sdp); | 449 | map_journal_extents(sdp); |
450 | } | 450 | } |
451 | 451 | ||
452 | if (sdp->sd_lockstruct.ls_first) { | 452 | if (sdp->sd_lockstruct.ls_first) { |
453 | unsigned int x; | 453 | unsigned int x; |
454 | for (x = 0; x < sdp->sd_journals; x++) { | 454 | for (x = 0; x < sdp->sd_journals; x++) { |
455 | error = gfs2_recover_journal(gfs2_jdesc_find(sdp, x)); | 455 | error = gfs2_recover_journal(gfs2_jdesc_find(sdp, x)); |
456 | if (error) { | 456 | if (error) { |
457 | fs_err(sdp, "error recovering journal %u: %d\n", | 457 | fs_err(sdp, "error recovering journal %u: %d\n", |
458 | x, error); | 458 | x, error); |
459 | goto fail_jinode_gh; | 459 | goto fail_jinode_gh; |
460 | } | 460 | } |
461 | } | 461 | } |
462 | 462 | ||
463 | gfs2_lm_others_may_mount(sdp); | 463 | gfs2_lm_others_may_mount(sdp); |
464 | } else if (!sdp->sd_args.ar_spectator) { | 464 | } else if (!sdp->sd_args.ar_spectator) { |
465 | error = gfs2_recover_journal(sdp->sd_jdesc); | 465 | error = gfs2_recover_journal(sdp->sd_jdesc); |
466 | if (error) { | 466 | if (error) { |
467 | fs_err(sdp, "error recovering my journal: %d\n", error); | 467 | fs_err(sdp, "error recovering my journal: %d\n", error); |
468 | goto fail_jinode_gh; | 468 | goto fail_jinode_gh; |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
472 | set_bit(SDF_JOURNAL_CHECKED, &sdp->sd_flags); | 472 | set_bit(SDF_JOURNAL_CHECKED, &sdp->sd_flags); |
473 | gfs2_glock_dq_uninit(&ji_gh); | 473 | gfs2_glock_dq_uninit(&ji_gh); |
474 | jindex = 0; | 474 | jindex = 0; |
475 | 475 | ||
476 | p = kthread_run(gfs2_recoverd, sdp, "gfs2_recoverd"); | 476 | p = kthread_run(gfs2_recoverd, sdp, "gfs2_recoverd"); |
477 | error = IS_ERR(p); | 477 | error = IS_ERR(p); |
478 | if (error) { | 478 | if (error) { |
479 | fs_err(sdp, "can't start recoverd thread: %d\n", error); | 479 | fs_err(sdp, "can't start recoverd thread: %d\n", error); |
480 | goto fail_jinode_gh; | 480 | goto fail_jinode_gh; |
481 | } | 481 | } |
482 | sdp->sd_recoverd_process = p; | 482 | sdp->sd_recoverd_process = p; |
483 | 483 | ||
484 | return 0; | 484 | return 0; |
485 | 485 | ||
486 | fail_recoverd: | 486 | fail_recoverd: |
487 | kthread_stop(sdp->sd_recoverd_process); | 487 | kthread_stop(sdp->sd_recoverd_process); |
488 | fail_jinode_gh: | 488 | fail_jinode_gh: |
489 | if (!sdp->sd_args.ar_spectator) | 489 | if (!sdp->sd_args.ar_spectator) |
490 | gfs2_glock_dq_uninit(&sdp->sd_jinode_gh); | 490 | gfs2_glock_dq_uninit(&sdp->sd_jinode_gh); |
491 | fail_journal_gh: | 491 | fail_journal_gh: |
492 | if (!sdp->sd_args.ar_spectator) | 492 | if (!sdp->sd_args.ar_spectator) |
493 | gfs2_glock_dq_uninit(&sdp->sd_journal_gh); | 493 | gfs2_glock_dq_uninit(&sdp->sd_journal_gh); |
494 | fail_jindex: | 494 | fail_jindex: |
495 | gfs2_jindex_free(sdp); | 495 | gfs2_jindex_free(sdp); |
496 | if (jindex) | 496 | if (jindex) |
497 | gfs2_glock_dq_uninit(&ji_gh); | 497 | gfs2_glock_dq_uninit(&ji_gh); |
498 | fail: | 498 | fail: |
499 | iput(sdp->sd_jindex); | 499 | iput(sdp->sd_jindex); |
500 | return error; | 500 | return error; |
501 | } | 501 | } |
502 | 502 | ||
503 | 503 | ||
504 | static int init_inodes(struct gfs2_sbd *sdp, int undo) | 504 | static int init_inodes(struct gfs2_sbd *sdp, int undo) |
505 | { | 505 | { |
506 | int error = 0; | 506 | int error = 0; |
507 | struct gfs2_inode *ip; | 507 | struct gfs2_inode *ip; |
508 | struct inode *inode; | 508 | struct inode *inode; |
509 | 509 | ||
510 | if (undo) | 510 | if (undo) |
511 | goto fail_qinode; | 511 | goto fail_qinode; |
512 | 512 | ||
513 | inode = gfs2_lookup_root(sdp->sd_vfs, sdp->sd_sb.sb_master_dir.no_addr); | 513 | inode = gfs2_lookup_root(sdp->sd_vfs, sdp->sd_sb.sb_master_dir.no_addr); |
514 | if (IS_ERR(inode)) { | 514 | if (IS_ERR(inode)) { |
515 | error = PTR_ERR(inode); | 515 | error = PTR_ERR(inode); |
516 | fs_err(sdp, "can't read in master directory: %d\n", error); | 516 | fs_err(sdp, "can't read in master directory: %d\n", error); |
517 | goto fail; | 517 | goto fail; |
518 | } | 518 | } |
519 | sdp->sd_master_dir = inode; | 519 | sdp->sd_master_dir = inode; |
520 | 520 | ||
521 | error = init_journal(sdp, undo); | 521 | error = init_journal(sdp, undo); |
522 | if (error) | 522 | if (error) |
523 | goto fail_master; | 523 | goto fail_master; |
524 | 524 | ||
525 | /* Read in the master inode number inode */ | 525 | /* Read in the master inode number inode */ |
526 | sdp->sd_inum_inode = gfs2_lookup_simple(sdp->sd_master_dir, "inum"); | 526 | sdp->sd_inum_inode = gfs2_lookup_simple(sdp->sd_master_dir, "inum"); |
527 | if (IS_ERR(sdp->sd_inum_inode)) { | 527 | if (IS_ERR(sdp->sd_inum_inode)) { |
528 | error = PTR_ERR(sdp->sd_inum_inode); | 528 | error = PTR_ERR(sdp->sd_inum_inode); |
529 | fs_err(sdp, "can't read in inum inode: %d\n", error); | 529 | fs_err(sdp, "can't read in inum inode: %d\n", error); |
530 | goto fail_journal; | 530 | goto fail_journal; |
531 | } | 531 | } |
532 | 532 | ||
533 | 533 | ||
534 | /* Read in the master statfs inode */ | 534 | /* Read in the master statfs inode */ |
535 | sdp->sd_statfs_inode = gfs2_lookup_simple(sdp->sd_master_dir, "statfs"); | 535 | sdp->sd_statfs_inode = gfs2_lookup_simple(sdp->sd_master_dir, "statfs"); |
536 | if (IS_ERR(sdp->sd_statfs_inode)) { | 536 | if (IS_ERR(sdp->sd_statfs_inode)) { |
537 | error = PTR_ERR(sdp->sd_statfs_inode); | 537 | error = PTR_ERR(sdp->sd_statfs_inode); |
538 | fs_err(sdp, "can't read in statfs inode: %d\n", error); | 538 | fs_err(sdp, "can't read in statfs inode: %d\n", error); |
539 | goto fail_inum; | 539 | goto fail_inum; |
540 | } | 540 | } |
541 | 541 | ||
542 | /* Read in the resource index inode */ | 542 | /* Read in the resource index inode */ |
543 | sdp->sd_rindex = gfs2_lookup_simple(sdp->sd_master_dir, "rindex"); | 543 | sdp->sd_rindex = gfs2_lookup_simple(sdp->sd_master_dir, "rindex"); |
544 | if (IS_ERR(sdp->sd_rindex)) { | 544 | if (IS_ERR(sdp->sd_rindex)) { |
545 | error = PTR_ERR(sdp->sd_rindex); | 545 | error = PTR_ERR(sdp->sd_rindex); |
546 | fs_err(sdp, "can't get resource index inode: %d\n", error); | 546 | fs_err(sdp, "can't get resource index inode: %d\n", error); |
547 | goto fail_statfs; | 547 | goto fail_statfs; |
548 | } | 548 | } |
549 | ip = GFS2_I(sdp->sd_rindex); | 549 | ip = GFS2_I(sdp->sd_rindex); |
550 | set_bit(GLF_STICKY, &ip->i_gl->gl_flags); | 550 | set_bit(GLF_STICKY, &ip->i_gl->gl_flags); |
551 | sdp->sd_rindex_uptodate = 0; | 551 | sdp->sd_rindex_uptodate = 0; |
552 | 552 | ||
553 | /* Read in the quota inode */ | 553 | /* Read in the quota inode */ |
554 | sdp->sd_quota_inode = gfs2_lookup_simple(sdp->sd_master_dir, "quota"); | 554 | sdp->sd_quota_inode = gfs2_lookup_simple(sdp->sd_master_dir, "quota"); |
555 | if (IS_ERR(sdp->sd_quota_inode)) { | 555 | if (IS_ERR(sdp->sd_quota_inode)) { |
556 | error = PTR_ERR(sdp->sd_quota_inode); | 556 | error = PTR_ERR(sdp->sd_quota_inode); |
557 | fs_err(sdp, "can't get quota file inode: %d\n", error); | 557 | fs_err(sdp, "can't get quota file inode: %d\n", error); |
558 | goto fail_rindex; | 558 | goto fail_rindex; |
559 | } | 559 | } |
560 | return 0; | 560 | return 0; |
561 | 561 | ||
562 | fail_qinode: | 562 | fail_qinode: |
563 | iput(sdp->sd_quota_inode); | 563 | iput(sdp->sd_quota_inode); |
564 | fail_rindex: | 564 | fail_rindex: |
565 | gfs2_clear_rgrpd(sdp); | 565 | gfs2_clear_rgrpd(sdp); |
566 | iput(sdp->sd_rindex); | 566 | iput(sdp->sd_rindex); |
567 | fail_statfs: | 567 | fail_statfs: |
568 | iput(sdp->sd_statfs_inode); | 568 | iput(sdp->sd_statfs_inode); |
569 | fail_inum: | 569 | fail_inum: |
570 | iput(sdp->sd_inum_inode); | 570 | iput(sdp->sd_inum_inode); |
571 | fail_journal: | 571 | fail_journal: |
572 | init_journal(sdp, UNDO); | 572 | init_journal(sdp, UNDO); |
573 | fail_master: | 573 | fail_master: |
574 | iput(sdp->sd_master_dir); | 574 | iput(sdp->sd_master_dir); |
575 | fail: | 575 | fail: |
576 | return error; | 576 | return error; |
577 | } | 577 | } |
578 | 578 | ||
579 | static int init_per_node(struct gfs2_sbd *sdp, int undo) | 579 | static int init_per_node(struct gfs2_sbd *sdp, int undo) |
580 | { | 580 | { |
581 | struct inode *pn = NULL; | 581 | struct inode *pn = NULL; |
582 | char buf[30]; | 582 | char buf[30]; |
583 | int error = 0; | 583 | int error = 0; |
584 | struct gfs2_inode *ip; | 584 | struct gfs2_inode *ip; |
585 | 585 | ||
586 | if (sdp->sd_args.ar_spectator) | 586 | if (sdp->sd_args.ar_spectator) |
587 | return 0; | 587 | return 0; |
588 | 588 | ||
589 | if (undo) | 589 | if (undo) |
590 | goto fail_qc_gh; | 590 | goto fail_qc_gh; |
591 | 591 | ||
592 | pn = gfs2_lookup_simple(sdp->sd_master_dir, "per_node"); | 592 | pn = gfs2_lookup_simple(sdp->sd_master_dir, "per_node"); |
593 | if (IS_ERR(pn)) { | 593 | if (IS_ERR(pn)) { |
594 | error = PTR_ERR(pn); | 594 | error = PTR_ERR(pn); |
595 | fs_err(sdp, "can't find per_node directory: %d\n", error); | 595 | fs_err(sdp, "can't find per_node directory: %d\n", error); |
596 | return error; | 596 | return error; |
597 | } | 597 | } |
598 | 598 | ||
599 | sprintf(buf, "inum_range%u", sdp->sd_jdesc->jd_jid); | 599 | sprintf(buf, "inum_range%u", sdp->sd_jdesc->jd_jid); |
600 | sdp->sd_ir_inode = gfs2_lookup_simple(pn, buf); | 600 | sdp->sd_ir_inode = gfs2_lookup_simple(pn, buf); |
601 | if (IS_ERR(sdp->sd_ir_inode)) { | 601 | if (IS_ERR(sdp->sd_ir_inode)) { |
602 | error = PTR_ERR(sdp->sd_ir_inode); | 602 | error = PTR_ERR(sdp->sd_ir_inode); |
603 | fs_err(sdp, "can't find local \"ir\" file: %d\n", error); | 603 | fs_err(sdp, "can't find local \"ir\" file: %d\n", error); |
604 | goto fail; | 604 | goto fail; |
605 | } | 605 | } |
606 | 606 | ||
607 | sprintf(buf, "statfs_change%u", sdp->sd_jdesc->jd_jid); | 607 | sprintf(buf, "statfs_change%u", sdp->sd_jdesc->jd_jid); |
608 | sdp->sd_sc_inode = gfs2_lookup_simple(pn, buf); | 608 | sdp->sd_sc_inode = gfs2_lookup_simple(pn, buf); |
609 | if (IS_ERR(sdp->sd_sc_inode)) { | 609 | if (IS_ERR(sdp->sd_sc_inode)) { |
610 | error = PTR_ERR(sdp->sd_sc_inode); | 610 | error = PTR_ERR(sdp->sd_sc_inode); |
611 | fs_err(sdp, "can't find local \"sc\" file: %d\n", error); | 611 | fs_err(sdp, "can't find local \"sc\" file: %d\n", error); |
612 | goto fail_ir_i; | 612 | goto fail_ir_i; |
613 | } | 613 | } |
614 | 614 | ||
615 | sprintf(buf, "quota_change%u", sdp->sd_jdesc->jd_jid); | 615 | sprintf(buf, "quota_change%u", sdp->sd_jdesc->jd_jid); |
616 | sdp->sd_qc_inode = gfs2_lookup_simple(pn, buf); | 616 | sdp->sd_qc_inode = gfs2_lookup_simple(pn, buf); |
617 | if (IS_ERR(sdp->sd_qc_inode)) { | 617 | if (IS_ERR(sdp->sd_qc_inode)) { |
618 | error = PTR_ERR(sdp->sd_qc_inode); | 618 | error = PTR_ERR(sdp->sd_qc_inode); |
619 | fs_err(sdp, "can't find local \"qc\" file: %d\n", error); | 619 | fs_err(sdp, "can't find local \"qc\" file: %d\n", error); |
620 | goto fail_ut_i; | 620 | goto fail_ut_i; |
621 | } | 621 | } |
622 | 622 | ||
623 | iput(pn); | 623 | iput(pn); |
624 | pn = NULL; | 624 | pn = NULL; |
625 | 625 | ||
626 | ip = GFS2_I(sdp->sd_ir_inode); | 626 | ip = GFS2_I(sdp->sd_ir_inode); |
627 | error = gfs2_glock_nq_init(ip->i_gl, | 627 | error = gfs2_glock_nq_init(ip->i_gl, |
628 | LM_ST_EXCLUSIVE, 0, | 628 | LM_ST_EXCLUSIVE, 0, |
629 | &sdp->sd_ir_gh); | 629 | &sdp->sd_ir_gh); |
630 | if (error) { | 630 | if (error) { |
631 | fs_err(sdp, "can't lock local \"ir\" file: %d\n", error); | 631 | fs_err(sdp, "can't lock local \"ir\" file: %d\n", error); |
632 | goto fail_qc_i; | 632 | goto fail_qc_i; |
633 | } | 633 | } |
634 | 634 | ||
635 | ip = GFS2_I(sdp->sd_sc_inode); | 635 | ip = GFS2_I(sdp->sd_sc_inode); |
636 | error = gfs2_glock_nq_init(ip->i_gl, | 636 | error = gfs2_glock_nq_init(ip->i_gl, |
637 | LM_ST_EXCLUSIVE, 0, | 637 | LM_ST_EXCLUSIVE, 0, |
638 | &sdp->sd_sc_gh); | 638 | &sdp->sd_sc_gh); |
639 | if (error) { | 639 | if (error) { |
640 | fs_err(sdp, "can't lock local \"sc\" file: %d\n", error); | 640 | fs_err(sdp, "can't lock local \"sc\" file: %d\n", error); |
641 | goto fail_ir_gh; | 641 | goto fail_ir_gh; |
642 | } | 642 | } |
643 | 643 | ||
644 | ip = GFS2_I(sdp->sd_qc_inode); | 644 | ip = GFS2_I(sdp->sd_qc_inode); |
645 | error = gfs2_glock_nq_init(ip->i_gl, | 645 | error = gfs2_glock_nq_init(ip->i_gl, |
646 | LM_ST_EXCLUSIVE, 0, | 646 | LM_ST_EXCLUSIVE, 0, |
647 | &sdp->sd_qc_gh); | 647 | &sdp->sd_qc_gh); |
648 | if (error) { | 648 | if (error) { |
649 | fs_err(sdp, "can't lock local \"qc\" file: %d\n", error); | 649 | fs_err(sdp, "can't lock local \"qc\" file: %d\n", error); |
650 | goto fail_ut_gh; | 650 | goto fail_ut_gh; |
651 | } | 651 | } |
652 | 652 | ||
653 | return 0; | 653 | return 0; |
654 | 654 | ||
655 | fail_qc_gh: | 655 | fail_qc_gh: |
656 | gfs2_glock_dq_uninit(&sdp->sd_qc_gh); | 656 | gfs2_glock_dq_uninit(&sdp->sd_qc_gh); |
657 | fail_ut_gh: | 657 | fail_ut_gh: |
658 | gfs2_glock_dq_uninit(&sdp->sd_sc_gh); | 658 | gfs2_glock_dq_uninit(&sdp->sd_sc_gh); |
659 | fail_ir_gh: | 659 | fail_ir_gh: |
660 | gfs2_glock_dq_uninit(&sdp->sd_ir_gh); | 660 | gfs2_glock_dq_uninit(&sdp->sd_ir_gh); |
661 | fail_qc_i: | 661 | fail_qc_i: |
662 | iput(sdp->sd_qc_inode); | 662 | iput(sdp->sd_qc_inode); |
663 | fail_ut_i: | 663 | fail_ut_i: |
664 | iput(sdp->sd_sc_inode); | 664 | iput(sdp->sd_sc_inode); |
665 | fail_ir_i: | 665 | fail_ir_i: |
666 | iput(sdp->sd_ir_inode); | 666 | iput(sdp->sd_ir_inode); |
667 | fail: | 667 | fail: |
668 | if (pn) | 668 | if (pn) |
669 | iput(pn); | 669 | iput(pn); |
670 | return error; | 670 | return error; |
671 | } | 671 | } |
672 | 672 | ||
673 | static int init_threads(struct gfs2_sbd *sdp, int undo) | 673 | static int init_threads(struct gfs2_sbd *sdp, int undo) |
674 | { | 674 | { |
675 | struct task_struct *p; | 675 | struct task_struct *p; |
676 | int error = 0; | 676 | int error = 0; |
677 | 677 | ||
678 | if (undo) | 678 | if (undo) |
679 | goto fail_quotad; | 679 | goto fail_quotad; |
680 | 680 | ||
681 | sdp->sd_log_flush_time = jiffies; | 681 | sdp->sd_log_flush_time = jiffies; |
682 | sdp->sd_jindex_refresh_time = jiffies; | 682 | sdp->sd_jindex_refresh_time = jiffies; |
683 | 683 | ||
684 | p = kthread_run(gfs2_logd, sdp, "gfs2_logd"); | 684 | p = kthread_run(gfs2_logd, sdp, "gfs2_logd"); |
685 | error = IS_ERR(p); | 685 | error = IS_ERR(p); |
686 | if (error) { | 686 | if (error) { |
687 | fs_err(sdp, "can't start logd thread: %d\n", error); | 687 | fs_err(sdp, "can't start logd thread: %d\n", error); |
688 | return error; | 688 | return error; |
689 | } | 689 | } |
690 | sdp->sd_logd_process = p; | 690 | sdp->sd_logd_process = p; |
691 | 691 | ||
692 | sdp->sd_statfs_sync_time = jiffies; | 692 | sdp->sd_statfs_sync_time = jiffies; |
693 | sdp->sd_quota_sync_time = jiffies; | 693 | sdp->sd_quota_sync_time = jiffies; |
694 | 694 | ||
695 | p = kthread_run(gfs2_quotad, sdp, "gfs2_quotad"); | 695 | p = kthread_run(gfs2_quotad, sdp, "gfs2_quotad"); |
696 | error = IS_ERR(p); | 696 | error = IS_ERR(p); |
697 | if (error) { | 697 | if (error) { |
698 | fs_err(sdp, "can't start quotad thread: %d\n", error); | 698 | fs_err(sdp, "can't start quotad thread: %d\n", error); |
699 | goto fail; | 699 | goto fail; |
700 | } | 700 | } |
701 | sdp->sd_quotad_process = p; | 701 | sdp->sd_quotad_process = p; |
702 | 702 | ||
703 | return 0; | 703 | return 0; |
704 | 704 | ||
705 | 705 | ||
706 | fail_quotad: | 706 | fail_quotad: |
707 | kthread_stop(sdp->sd_quotad_process); | 707 | kthread_stop(sdp->sd_quotad_process); |
708 | fail: | 708 | fail: |
709 | kthread_stop(sdp->sd_logd_process); | 709 | kthread_stop(sdp->sd_logd_process); |
710 | return error; | 710 | return error; |
711 | } | 711 | } |
712 | 712 | ||
713 | /** | 713 | /** |
714 | * gfs2_lm_mount - mount a locking protocol | 714 | * gfs2_lm_mount - mount a locking protocol |
715 | * @sdp: the filesystem | 715 | * @sdp: the filesystem |
716 | * @args: mount arguements | 716 | * @args: mount arguements |
717 | * @silent: if 1, don't complain if the FS isn't a GFS2 fs | 717 | * @silent: if 1, don't complain if the FS isn't a GFS2 fs |
718 | * | 718 | * |
719 | * Returns: errno | 719 | * Returns: errno |
720 | */ | 720 | */ |
721 | 721 | ||
722 | static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) | 722 | static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) |
723 | { | 723 | { |
724 | char *proto = sdp->sd_proto_name; | 724 | char *proto = sdp->sd_proto_name; |
725 | char *table = sdp->sd_table_name; | 725 | char *table = sdp->sd_table_name; |
726 | int flags = 0; | 726 | int flags = 0; |
727 | int error; | 727 | int error; |
728 | 728 | ||
729 | if (sdp->sd_args.ar_spectator) | 729 | if (sdp->sd_args.ar_spectator) |
730 | flags |= LM_MFLAG_SPECTATOR; | 730 | flags |= LM_MFLAG_SPECTATOR; |
731 | 731 | ||
732 | fs_info(sdp, "Trying to join cluster \"%s\", \"%s\"\n", proto, table); | 732 | fs_info(sdp, "Trying to join cluster \"%s\", \"%s\"\n", proto, table); |
733 | 733 | ||
734 | error = gfs2_mount_lockproto(proto, table, sdp->sd_args.ar_hostdata, | 734 | error = gfs2_mount_lockproto(proto, table, sdp->sd_args.ar_hostdata, |
735 | gfs2_glock_cb, sdp, | 735 | gfs2_glock_cb, sdp, |
736 | GFS2_MIN_LVB_SIZE, flags, | 736 | GFS2_MIN_LVB_SIZE, flags, |
737 | &sdp->sd_lockstruct, &sdp->sd_kobj); | 737 | &sdp->sd_lockstruct, &sdp->sd_kobj); |
738 | if (error) { | 738 | if (error) { |
739 | fs_info(sdp, "can't mount proto=%s, table=%s, hostdata=%s\n", | 739 | fs_info(sdp, "can't mount proto=%s, table=%s, hostdata=%s\n", |
740 | proto, table, sdp->sd_args.ar_hostdata); | 740 | proto, table, sdp->sd_args.ar_hostdata); |
741 | goto out; | 741 | goto out; |
742 | } | 742 | } |
743 | 743 | ||
744 | if (gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lockspace) || | 744 | if (gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lockspace) || |
745 | gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_ops) || | 745 | gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_ops) || |
746 | gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lvb_size >= | 746 | gfs2_assert_warn(sdp, sdp->sd_lockstruct.ls_lvb_size >= |
747 | GFS2_MIN_LVB_SIZE)) { | 747 | GFS2_MIN_LVB_SIZE)) { |
748 | gfs2_unmount_lockproto(&sdp->sd_lockstruct); | 748 | gfs2_unmount_lockproto(&sdp->sd_lockstruct); |
749 | goto out; | 749 | goto out; |
750 | } | 750 | } |
751 | 751 | ||
752 | if (sdp->sd_args.ar_spectator) | 752 | if (sdp->sd_args.ar_spectator) |
753 | snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.s", table); | 753 | snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.s", table); |
754 | else | 754 | else |
755 | snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.%u", table, | 755 | snprintf(sdp->sd_fsname, GFS2_FSNAME_LEN, "%s.%u", table, |
756 | sdp->sd_lockstruct.ls_jid); | 756 | sdp->sd_lockstruct.ls_jid); |
757 | 757 | ||
758 | fs_info(sdp, "Joined cluster. Now mounting FS...\n"); | 758 | fs_info(sdp, "Joined cluster. Now mounting FS...\n"); |
759 | 759 | ||
760 | if ((sdp->sd_lockstruct.ls_flags & LM_LSFLAG_LOCAL) && | 760 | if ((sdp->sd_lockstruct.ls_flags & LM_LSFLAG_LOCAL) && |
761 | !sdp->sd_args.ar_ignore_local_fs) { | 761 | !sdp->sd_args.ar_ignore_local_fs) { |
762 | sdp->sd_args.ar_localflocks = 1; | 762 | sdp->sd_args.ar_localflocks = 1; |
763 | sdp->sd_args.ar_localcaching = 1; | 763 | sdp->sd_args.ar_localcaching = 1; |
764 | } | 764 | } |
765 | 765 | ||
766 | out: | 766 | out: |
767 | return error; | 767 | return error; |
768 | } | 768 | } |
769 | 769 | ||
770 | void gfs2_lm_unmount(struct gfs2_sbd *sdp) | 770 | void gfs2_lm_unmount(struct gfs2_sbd *sdp) |
771 | { | 771 | { |
772 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) | 772 | if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) |
773 | gfs2_unmount_lockproto(&sdp->sd_lockstruct); | 773 | gfs2_unmount_lockproto(&sdp->sd_lockstruct); |
774 | } | 774 | } |
775 | 775 | ||
776 | /** | 776 | /** |
777 | * fill_super - Read in superblock | 777 | * fill_super - Read in superblock |
778 | * @sb: The VFS superblock | 778 | * @sb: The VFS superblock |
779 | * @data: Mount options | 779 | * @data: Mount options |
780 | * @silent: Don't complain if it's not a GFS2 filesystem | 780 | * @silent: Don't complain if it's not a GFS2 filesystem |
781 | * | 781 | * |
782 | * Returns: errno | 782 | * Returns: errno |
783 | */ | 783 | */ |
784 | 784 | ||
785 | static int fill_super(struct super_block *sb, void *data, int silent) | 785 | static int fill_super(struct super_block *sb, void *data, int silent) |
786 | { | 786 | { |
787 | struct gfs2_sbd *sdp; | 787 | struct gfs2_sbd *sdp; |
788 | struct gfs2_holder mount_gh; | 788 | struct gfs2_holder mount_gh; |
789 | int error; | 789 | int error; |
790 | 790 | ||
791 | sdp = init_sbd(sb); | 791 | sdp = init_sbd(sb); |
792 | if (!sdp) { | 792 | if (!sdp) { |
793 | printk(KERN_WARNING "GFS2: can't alloc struct gfs2_sbd\n"); | 793 | printk(KERN_WARNING "GFS2: can't alloc struct gfs2_sbd\n"); |
794 | return -ENOMEM; | 794 | return -ENOMEM; |
795 | } | 795 | } |
796 | 796 | ||
797 | error = gfs2_mount_args(sdp, (char *)data, 0); | 797 | error = gfs2_mount_args(sdp, (char *)data, 0); |
798 | if (error) { | 798 | if (error) { |
799 | printk(KERN_WARNING "GFS2: can't parse mount arguments\n"); | 799 | printk(KERN_WARNING "GFS2: can't parse mount arguments\n"); |
800 | goto fail; | 800 | goto fail; |
801 | } | 801 | } |
802 | 802 | ||
803 | init_vfs(sb, SDF_NOATIME); | 803 | init_vfs(sb, SDF_NOATIME); |
804 | 804 | ||
805 | /* Set up the buffer cache and fill in some fake block size values | 805 | /* Set up the buffer cache and fill in some fake block size values |
806 | to allow us to read-in the on-disk superblock. */ | 806 | to allow us to read-in the on-disk superblock. */ |
807 | sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, GFS2_BASIC_BLOCK); | 807 | sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, GFS2_BASIC_BLOCK); |
808 | sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits; | 808 | sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits; |
809 | sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - | 809 | sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - |
810 | GFS2_BASIC_BLOCK_SHIFT; | 810 | GFS2_BASIC_BLOCK_SHIFT; |
811 | sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift; | 811 | sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift; |
812 | 812 | ||
813 | error = init_names(sdp, silent); | 813 | error = init_names(sdp, silent); |
814 | if (error) | 814 | if (error) |
815 | goto fail; | 815 | goto fail; |
816 | 816 | ||
817 | gfs2_create_debugfs_file(sdp); | 817 | gfs2_create_debugfs_file(sdp); |
818 | 818 | ||
819 | error = gfs2_sys_fs_add(sdp); | 819 | error = gfs2_sys_fs_add(sdp); |
820 | if (error) | 820 | if (error) |
821 | goto fail; | 821 | goto fail; |
822 | 822 | ||
823 | error = gfs2_lm_mount(sdp, silent); | 823 | error = gfs2_lm_mount(sdp, silent); |
824 | if (error) | 824 | if (error) |
825 | goto fail_sys; | 825 | goto fail_sys; |
826 | 826 | ||
827 | error = init_locking(sdp, &mount_gh, DO); | 827 | error = init_locking(sdp, &mount_gh, DO); |
828 | if (error) | 828 | if (error) |
829 | goto fail_lm; | 829 | goto fail_lm; |
830 | 830 | ||
831 | error = init_sb(sdp, silent, DO); | 831 | error = init_sb(sdp, silent, DO); |
832 | if (error) | 832 | if (error) |
833 | goto fail_locking; | 833 | goto fail_locking; |
834 | 834 | ||
835 | error = init_inodes(sdp, DO); | 835 | error = init_inodes(sdp, DO); |
836 | if (error) | 836 | if (error) |
837 | goto fail_sb; | 837 | goto fail_sb; |
838 | 838 | ||
839 | error = init_per_node(sdp, DO); | 839 | error = init_per_node(sdp, DO); |
840 | if (error) | 840 | if (error) |
841 | goto fail_inodes; | 841 | goto fail_inodes; |
842 | 842 | ||
843 | error = gfs2_statfs_init(sdp); | 843 | error = gfs2_statfs_init(sdp); |
844 | if (error) { | 844 | if (error) { |
845 | fs_err(sdp, "can't initialize statfs subsystem: %d\n", error); | 845 | fs_err(sdp, "can't initialize statfs subsystem: %d\n", error); |
846 | goto fail_per_node; | 846 | goto fail_per_node; |
847 | } | 847 | } |
848 | 848 | ||
849 | error = init_threads(sdp, DO); | 849 | error = init_threads(sdp, DO); |
850 | if (error) | 850 | if (error) |
851 | goto fail_per_node; | 851 | goto fail_per_node; |
852 | 852 | ||
853 | if (!(sb->s_flags & MS_RDONLY)) { | 853 | if (!(sb->s_flags & MS_RDONLY)) { |
854 | error = gfs2_make_fs_rw(sdp); | 854 | error = gfs2_make_fs_rw(sdp); |
855 | if (error) { | 855 | if (error) { |
856 | fs_err(sdp, "can't make FS RW: %d\n", error); | 856 | fs_err(sdp, "can't make FS RW: %d\n", error); |
857 | goto fail_threads; | 857 | goto fail_threads; |
858 | } | 858 | } |
859 | } | 859 | } |
860 | 860 | ||
861 | gfs2_glock_dq_uninit(&mount_gh); | 861 | gfs2_glock_dq_uninit(&mount_gh); |
862 | 862 | ||
863 | return 0; | 863 | return 0; |
864 | 864 | ||
865 | fail_threads: | 865 | fail_threads: |
866 | init_threads(sdp, UNDO); | 866 | init_threads(sdp, UNDO); |
867 | fail_per_node: | 867 | fail_per_node: |
868 | init_per_node(sdp, UNDO); | 868 | init_per_node(sdp, UNDO); |
869 | fail_inodes: | 869 | fail_inodes: |
870 | init_inodes(sdp, UNDO); | 870 | init_inodes(sdp, UNDO); |
871 | fail_sb: | 871 | fail_sb: |
872 | init_sb(sdp, 0, UNDO); | 872 | init_sb(sdp, 0, UNDO); |
873 | fail_locking: | 873 | fail_locking: |
874 | init_locking(sdp, &mount_gh, UNDO); | 874 | init_locking(sdp, &mount_gh, UNDO); |
875 | fail_lm: | 875 | fail_lm: |
876 | gfs2_gl_hash_clear(sdp, WAIT); | 876 | gfs2_gl_hash_clear(sdp, WAIT); |
877 | gfs2_lm_unmount(sdp); | 877 | gfs2_lm_unmount(sdp); |
878 | while (invalidate_inodes(sb)) | 878 | while (invalidate_inodes(sb)) |
879 | yield(); | 879 | yield(); |
880 | fail_sys: | 880 | fail_sys: |
881 | gfs2_sys_fs_del(sdp); | 881 | gfs2_sys_fs_del(sdp); |
882 | fail: | 882 | fail: |
883 | gfs2_delete_debugfs_file(sdp); | 883 | gfs2_delete_debugfs_file(sdp); |
884 | kfree(sdp); | 884 | kfree(sdp); |
885 | sb->s_fs_info = NULL; | 885 | sb->s_fs_info = NULL; |
886 | return error; | 886 | return error; |
887 | } | 887 | } |
888 | 888 | ||
889 | static int gfs2_get_sb(struct file_system_type *fs_type, int flags, | 889 | static int gfs2_get_sb(struct file_system_type *fs_type, int flags, |
890 | const char *dev_name, void *data, struct vfsmount *mnt) | 890 | const char *dev_name, void *data, struct vfsmount *mnt) |
891 | { | 891 | { |
892 | struct super_block *sb; | 892 | struct super_block *sb; |
893 | struct gfs2_sbd *sdp; | 893 | struct gfs2_sbd *sdp; |
894 | int error = get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt); | 894 | int error = get_sb_bdev(fs_type, flags, dev_name, data, fill_super, mnt); |
895 | if (error) | 895 | if (error) |
896 | goto out; | 896 | goto out; |
897 | sb = mnt->mnt_sb; | 897 | sb = mnt->mnt_sb; |
898 | sdp = sb->s_fs_info; | 898 | sdp = sb->s_fs_info; |
899 | sdp->sd_gfs2mnt = mnt; | 899 | sdp->sd_gfs2mnt = mnt; |
900 | out: | 900 | out: |
901 | return error; | 901 | return error; |
902 | } | 902 | } |
903 | 903 | ||
904 | static int fill_super_meta(struct super_block *sb, struct super_block *new, | 904 | static int fill_super_meta(struct super_block *sb, struct super_block *new, |
905 | void *data, int silent) | 905 | void *data, int silent) |
906 | { | 906 | { |
907 | struct gfs2_sbd *sdp = sb->s_fs_info; | 907 | struct gfs2_sbd *sdp = sb->s_fs_info; |
908 | struct inode *inode; | 908 | struct inode *inode; |
909 | int error = 0; | 909 | int error = 0; |
910 | 910 | ||
911 | new->s_fs_info = sdp; | 911 | new->s_fs_info = sdp; |
912 | sdp->sd_vfs_meta = sb; | 912 | sdp->sd_vfs_meta = sb; |
913 | 913 | ||
914 | init_vfs(new, SDF_NOATIME); | 914 | init_vfs(new, SDF_NOATIME); |
915 | 915 | ||
916 | /* Get the master inode */ | 916 | /* Get the master inode */ |
917 | inode = igrab(sdp->sd_master_dir); | 917 | inode = igrab(sdp->sd_master_dir); |
918 | 918 | ||
919 | new->s_root = d_alloc_root(inode); | 919 | new->s_root = d_alloc_root(inode); |
920 | if (!new->s_root) { | 920 | if (!new->s_root) { |
921 | fs_err(sdp, "can't get root dentry\n"); | 921 | fs_err(sdp, "can't get root dentry\n"); |
922 | error = -ENOMEM; | 922 | error = -ENOMEM; |
923 | iput(inode); | 923 | iput(inode); |
924 | } else | 924 | } else |
925 | new->s_root->d_op = &gfs2_dops; | 925 | new->s_root->d_op = &gfs2_dops; |
926 | 926 | ||
927 | return error; | 927 | return error; |
928 | } | 928 | } |
929 | 929 | ||
930 | static int set_bdev_super(struct super_block *s, void *data) | 930 | static int set_bdev_super(struct super_block *s, void *data) |
931 | { | 931 | { |
932 | s->s_bdev = data; | 932 | s->s_bdev = data; |
933 | s->s_dev = s->s_bdev->bd_dev; | 933 | s->s_dev = s->s_bdev->bd_dev; |
934 | return 0; | 934 | return 0; |
935 | } | 935 | } |
936 | 936 | ||
937 | static int test_bdev_super(struct super_block *s, void *data) | 937 | static int test_bdev_super(struct super_block *s, void *data) |
938 | { | 938 | { |
939 | return s->s_bdev == data; | 939 | return s->s_bdev == data; |
940 | } | 940 | } |
941 | 941 | ||
942 | static struct super_block* get_gfs2_sb(const char *dev_name) | 942 | static struct super_block* get_gfs2_sb(const char *dev_name) |
943 | { | 943 | { |
944 | struct kstat stat; | 944 | struct kstat stat; |
945 | struct nameidata nd; | 945 | struct nameidata nd; |
946 | struct super_block *sb = NULL, *s; | 946 | struct super_block *sb = NULL, *s; |
947 | int error; | 947 | int error; |
948 | 948 | ||
949 | error = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); | 949 | error = path_lookup(dev_name, LOOKUP_FOLLOW, &nd); |
950 | if (error) { | 950 | if (error) { |
951 | printk(KERN_WARNING "GFS2: path_lookup on %s returned error\n", | 951 | printk(KERN_WARNING "GFS2: path_lookup on %s returned error\n", |
952 | dev_name); | 952 | dev_name); |
953 | goto out; | 953 | goto out; |
954 | } | 954 | } |
955 | error = vfs_getattr(nd.path.mnt, nd.path.dentry, &stat); | 955 | error = vfs_getattr(nd.path.mnt, nd.path.dentry, &stat); |
956 | 956 | ||
957 | list_for_each_entry(s, &gfs2_fs_type.fs_supers, s_instances) { | 957 | list_for_each_entry(s, &gfs2_fs_type.fs_supers, s_instances) { |
958 | if ((S_ISBLK(stat.mode) && s->s_dev == stat.rdev) || | 958 | if ((S_ISBLK(stat.mode) && s->s_dev == stat.rdev) || |
959 | (S_ISDIR(stat.mode) && | 959 | (S_ISDIR(stat.mode) && |
960 | s == nd.path.dentry->d_inode->i_sb)) { | 960 | s == nd.path.dentry->d_inode->i_sb)) { |
961 | sb = s; | 961 | sb = s; |
962 | goto free_nd; | 962 | goto free_nd; |
963 | } | 963 | } |
964 | } | 964 | } |
965 | 965 | ||
966 | printk(KERN_WARNING "GFS2: Unrecognized block device or " | 966 | printk(KERN_WARNING "GFS2: Unrecognized block device or " |
967 | "mount point %s\n", dev_name); | 967 | "mount point %s\n", dev_name); |
968 | 968 | ||
969 | free_nd: | 969 | free_nd: |
970 | path_put(&nd.path); | 970 | path_put(&nd.path); |
971 | out: | 971 | out: |
972 | return sb; | 972 | return sb; |
973 | } | 973 | } |
974 | 974 | ||
975 | static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags, | 975 | static int gfs2_get_sb_meta(struct file_system_type *fs_type, int flags, |
976 | const char *dev_name, void *data, struct vfsmount *mnt) | 976 | const char *dev_name, void *data, struct vfsmount *mnt) |
977 | { | 977 | { |
978 | int error = 0; | 978 | int error = 0; |
979 | struct super_block *sb = NULL, *new; | 979 | struct super_block *sb = NULL, *new; |
980 | struct gfs2_sbd *sdp; | 980 | struct gfs2_sbd *sdp; |
981 | 981 | ||
982 | sb = get_gfs2_sb(dev_name); | 982 | sb = get_gfs2_sb(dev_name); |
983 | if (!sb) { | 983 | if (!sb) { |
984 | printk(KERN_WARNING "GFS2: gfs2 mount does not exist\n"); | 984 | printk(KERN_WARNING "GFS2: gfs2 mount does not exist\n"); |
985 | error = -ENOENT; | 985 | error = -ENOENT; |
986 | goto error; | 986 | goto error; |
987 | } | 987 | } |
988 | sdp = sb->s_fs_info; | 988 | sdp = sb->s_fs_info; |
989 | if (sdp->sd_vfs_meta) { | 989 | if (sdp->sd_vfs_meta) { |
990 | printk(KERN_WARNING "GFS2: gfs2meta mount already exists\n"); | 990 | printk(KERN_WARNING "GFS2: gfs2meta mount already exists\n"); |
991 | error = -EBUSY; | 991 | error = -EBUSY; |
992 | goto error; | 992 | goto error; |
993 | } | 993 | } |
994 | down(&sb->s_bdev->bd_mount_sem); | 994 | down(&sb->s_bdev->bd_mount_sem); |
995 | new = sget(fs_type, test_bdev_super, set_bdev_super, sb->s_bdev); | 995 | new = sget(fs_type, test_bdev_super, set_bdev_super, sb->s_bdev); |
996 | up(&sb->s_bdev->bd_mount_sem); | 996 | up(&sb->s_bdev->bd_mount_sem); |
997 | if (IS_ERR(new)) { | 997 | if (IS_ERR(new)) { |
998 | error = PTR_ERR(new); | 998 | error = PTR_ERR(new); |
999 | goto error; | 999 | goto error; |
1000 | } | 1000 | } |
1001 | module_put(fs_type->owner); | ||
1002 | new->s_flags = flags; | 1001 | new->s_flags = flags; |
1003 | strlcpy(new->s_id, sb->s_id, sizeof(new->s_id)); | 1002 | strlcpy(new->s_id, sb->s_id, sizeof(new->s_id)); |
1004 | sb_set_blocksize(new, sb->s_blocksize); | 1003 | sb_set_blocksize(new, sb->s_blocksize); |
1005 | error = fill_super_meta(sb, new, data, flags & MS_SILENT ? 1 : 0); | 1004 | error = fill_super_meta(sb, new, data, flags & MS_SILENT ? 1 : 0); |
1006 | if (error) { | 1005 | if (error) { |
1007 | up_write(&new->s_umount); | 1006 | up_write(&new->s_umount); |
1008 | deactivate_super(new); | 1007 | deactivate_super(new); |
1009 | goto error; | 1008 | goto error; |
1010 | } | 1009 | } |
1011 | 1010 | ||
1012 | new->s_flags |= MS_ACTIVE; | 1011 | new->s_flags |= MS_ACTIVE; |
1013 | 1012 | ||
1014 | /* Grab a reference to the gfs2 mount point */ | 1013 | /* Grab a reference to the gfs2 mount point */ |
1015 | atomic_inc(&sdp->sd_gfs2mnt->mnt_count); | 1014 | atomic_inc(&sdp->sd_gfs2mnt->mnt_count); |
1016 | return simple_set_mnt(mnt, new); | 1015 | return simple_set_mnt(mnt, new); |
1017 | error: | 1016 | error: |
1018 | return error; | 1017 | return error; |
1019 | } | 1018 | } |
1020 | 1019 | ||
1021 | static void gfs2_kill_sb(struct super_block *sb) | 1020 | static void gfs2_kill_sb(struct super_block *sb) |
1022 | { | 1021 | { |
1023 | if (sb->s_fs_info) { | 1022 | if (sb->s_fs_info) { |
1024 | gfs2_delete_debugfs_file(sb->s_fs_info); | 1023 | gfs2_delete_debugfs_file(sb->s_fs_info); |
1025 | gfs2_meta_syncfs(sb->s_fs_info); | 1024 | gfs2_meta_syncfs(sb->s_fs_info); |
1026 | } | 1025 | } |
1027 | kill_block_super(sb); | 1026 | kill_block_super(sb); |
1028 | } | 1027 | } |
1029 | 1028 | ||
1030 | static void gfs2_kill_sb_meta(struct super_block *sb) | 1029 | static void gfs2_kill_sb_meta(struct super_block *sb) |
1031 | { | 1030 | { |
1032 | struct gfs2_sbd *sdp = sb->s_fs_info; | 1031 | struct gfs2_sbd *sdp = sb->s_fs_info; |
1033 | generic_shutdown_super(sb); | 1032 | generic_shutdown_super(sb); |
1034 | sdp->sd_vfs_meta = NULL; | 1033 | sdp->sd_vfs_meta = NULL; |
1035 | atomic_dec(&sdp->sd_gfs2mnt->mnt_count); | 1034 | atomic_dec(&sdp->sd_gfs2mnt->mnt_count); |
1036 | } | 1035 | } |
1037 | 1036 | ||
1038 | struct file_system_type gfs2_fs_type = { | 1037 | struct file_system_type gfs2_fs_type = { |
1039 | .name = "gfs2", | 1038 | .name = "gfs2", |
1040 | .fs_flags = FS_REQUIRES_DEV, | 1039 | .fs_flags = FS_REQUIRES_DEV, |
1041 | .get_sb = gfs2_get_sb, | 1040 | .get_sb = gfs2_get_sb, |
1042 | .kill_sb = gfs2_kill_sb, | 1041 | .kill_sb = gfs2_kill_sb, |
1043 | .owner = THIS_MODULE, | 1042 | .owner = THIS_MODULE, |
1044 | }; | 1043 | }; |
1045 | 1044 | ||
1046 | struct file_system_type gfs2meta_fs_type = { | 1045 | struct file_system_type gfs2meta_fs_type = { |
1047 | .name = "gfs2meta", | 1046 | .name = "gfs2meta", |
1048 | .fs_flags = FS_REQUIRES_DEV, | 1047 | .fs_flags = FS_REQUIRES_DEV, |
1049 | .get_sb = gfs2_get_sb_meta, | 1048 | .get_sb = gfs2_get_sb_meta, |
1050 | .kill_sb = gfs2_kill_sb_meta, | 1049 | .kill_sb = gfs2_kill_sb_meta, |
1051 | .owner = THIS_MODULE, | 1050 | .owner = THIS_MODULE, |
1052 | }; | 1051 | }; |
1053 | 1052 | ||
1054 | 1053 |