Commit | Line | Data |
---|---|---|
b3b94faa DT |
1 | /* |
2 | * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. | |
091806ed | 3 | * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. |
b3b94faa DT |
4 | * |
5 | * This copyrighted material is made available to anyone wishing to use, | |
6 | * modify, copy, or redistribute it subject to the terms and conditions | |
e9fc2aa0 | 7 | * of the GNU General Public License version 2. |
b3b94faa DT |
8 | */ |
9 | ||
10 | #include <linux/sched.h> | |
11 | #include <linux/slab.h> | |
12 | #include <linux/spinlock.h> | |
13 | #include <linux/completion.h> | |
14 | #include <linux/buffer_head.h> | |
b3b94faa DT |
15 | #include <linux/statfs.h> |
16 | #include <linux/seq_file.h> | |
17 | #include <linux/mount.h> | |
18 | #include <linux/kthread.h> | |
19 | #include <linux/delay.h> | |
5c676f6d | 20 | #include <linux/gfs2_ondisk.h> |
feaa7bba | 21 | #include <linux/crc32.h> |
7d308590 | 22 | #include <linux/lm_interface.h> |
719ee344 | 23 | #include <linux/time.h> |
b3b94faa DT |
24 | |
25 | #include "gfs2.h" | |
5c676f6d | 26 | #include "incore.h" |
b3b94faa DT |
27 | #include "glock.h" |
28 | #include "inode.h" | |
b3b94faa DT |
29 | #include "log.h" |
30 | #include "mount.h" | |
b3b94faa DT |
31 | #include "quota.h" |
32 | #include "recovery.h" | |
33 | #include "rgrp.h" | |
34 | #include "super.h" | |
35 | #include "sys.h" | |
5c676f6d | 36 | #include "util.h" |
feaa7bba SW |
37 | #include "trans.h" |
38 | #include "dir.h" | |
39 | #include "eattr.h" | |
40 | #include "bmap.h" | |
719ee344 | 41 | #include "meta_io.h" |
b3b94faa DT |
42 | |
43 | /** | |
44 | * gfs2_write_inode - Make sure the inode is stable on the disk | |
45 | * @inode: The inode | |
46 | * @sync: synchronous write flag | |
47 | * | |
48 | * Returns: errno | |
49 | */ | |
50 | ||
51 | static int gfs2_write_inode(struct inode *inode, int sync) | |
52 | { | |
feaa7bba | 53 | struct gfs2_inode *ip = GFS2_I(inode); |
719ee344 SW |
54 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
55 | struct gfs2_holder gh; | |
56 | struct buffer_head *bh; | |
57 | struct timespec atime; | |
58 | struct gfs2_dinode *di; | |
59 | int ret = 0; | |
60 | ||
61 | /* Check this is a "normal" inode, etc */ | |
62 | if (!test_bit(GIF_USER, &ip->i_flags) || | |
63 | (current->flags & PF_MEMALLOC)) | |
64 | return 0; | |
65 | ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); | |
66 | if (ret) | |
67 | goto do_flush; | |
68 | ret = gfs2_trans_begin(sdp, RES_DINODE, 0); | |
69 | if (ret) | |
70 | goto do_unlock; | |
71 | ret = gfs2_meta_inode_buffer(ip, &bh); | |
72 | if (ret == 0) { | |
73 | di = (struct gfs2_dinode *)bh->b_data; | |
74 | atime.tv_sec = be64_to_cpu(di->di_atime); | |
75 | atime.tv_nsec = be32_to_cpu(di->di_atime_nsec); | |
76 | if (timespec_compare(&inode->i_atime, &atime) > 0) { | |
77 | gfs2_trans_add_bh(ip->i_gl, bh, 1); | |
78 | gfs2_dinode_out(ip, bh->b_data); | |
79 | } | |
80 | brelse(bh); | |
feaa7bba | 81 | } |
719ee344 SW |
82 | gfs2_trans_end(sdp); |
83 | do_unlock: | |
84 | gfs2_glock_dq_uninit(&gh); | |
85 | do_flush: | |
86 | if (sync != 0) | |
87 | gfs2_log_flush(GFS2_SB(inode), ip->i_gl); | |
88 | return ret; | |
b3b94faa DT |
89 | } |
90 | ||
9b8df98f SW |
91 | /** |
92 | * gfs2_make_fs_ro - Turn a Read-Write FS into a Read-Only one | |
93 | * @sdp: the filesystem | |
94 | * | |
95 | * Returns: errno | |
96 | */ | |
97 | ||
98 | static int gfs2_make_fs_ro(struct gfs2_sbd *sdp) | |
99 | { | |
100 | struct gfs2_holder t_gh; | |
101 | int error; | |
102 | ||
103 | gfs2_quota_sync(sdp); | |
104 | gfs2_statfs_sync(sdp); | |
105 | ||
106 | error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, GL_NOCACHE, | |
107 | &t_gh); | |
108 | if (error && !test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) | |
109 | return error; | |
110 | ||
111 | gfs2_meta_syncfs(sdp); | |
112 | gfs2_log_shutdown(sdp); | |
113 | ||
114 | clear_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); | |
115 | ||
116 | if (t_gh.gh_gl) | |
117 | gfs2_glock_dq_uninit(&t_gh); | |
118 | ||
119 | gfs2_quota_cleanup(sdp); | |
120 | ||
121 | return error; | |
122 | } | |
123 | ||
b3b94faa DT |
124 | /** |
125 | * gfs2_put_super - Unmount the filesystem | |
126 | * @sb: The VFS superblock | |
127 | * | |
128 | */ | |
129 | ||
130 | static void gfs2_put_super(struct super_block *sb) | |
131 | { | |
5c676f6d | 132 | struct gfs2_sbd *sdp = sb->s_fs_info; |
b3b94faa DT |
133 | int error; |
134 | ||
b3b94faa DT |
135 | /* Unfreeze the filesystem, if we need to */ |
136 | ||
f55ab26a | 137 | mutex_lock(&sdp->sd_freeze_lock); |
b3b94faa DT |
138 | if (sdp->sd_freeze_count) |
139 | gfs2_glock_dq_uninit(&sdp->sd_freeze_gh); | |
f55ab26a | 140 | mutex_unlock(&sdp->sd_freeze_lock); |
b3b94faa | 141 | |
b3b94faa DT |
142 | kthread_stop(sdp->sd_quotad_process); |
143 | kthread_stop(sdp->sd_logd_process); | |
144 | kthread_stop(sdp->sd_recoverd_process); | |
b3b94faa DT |
145 | |
146 | if (!(sb->s_flags & MS_RDONLY)) { | |
147 | error = gfs2_make_fs_ro(sdp); | |
148 | if (error) | |
149 | gfs2_io_error(sdp); | |
150 | } | |
b3b94faa DT |
151 | /* At this point, we're through modifying the disk */ |
152 | ||
153 | /* Release stuff */ | |
154 | ||
f42faf4f SW |
155 | iput(sdp->sd_jindex); |
156 | iput(sdp->sd_inum_inode); | |
157 | iput(sdp->sd_statfs_inode); | |
158 | iput(sdp->sd_rindex); | |
159 | iput(sdp->sd_quota_inode); | |
b3b94faa DT |
160 | |
161 | gfs2_glock_put(sdp->sd_rename_gl); | |
162 | gfs2_glock_put(sdp->sd_trans_gl); | |
163 | ||
164 | if (!sdp->sd_args.ar_spectator) { | |
165 | gfs2_glock_dq_uninit(&sdp->sd_journal_gh); | |
166 | gfs2_glock_dq_uninit(&sdp->sd_jinode_gh); | |
167 | gfs2_glock_dq_uninit(&sdp->sd_ir_gh); | |
168 | gfs2_glock_dq_uninit(&sdp->sd_sc_gh); | |
b3b94faa | 169 | gfs2_glock_dq_uninit(&sdp->sd_qc_gh); |
f42faf4f SW |
170 | iput(sdp->sd_ir_inode); |
171 | iput(sdp->sd_sc_inode); | |
f42faf4f | 172 | iput(sdp->sd_qc_inode); |
b3b94faa DT |
173 | } |
174 | ||
175 | gfs2_glock_dq_uninit(&sdp->sd_live_gh); | |
b3b94faa DT |
176 | gfs2_clear_rgrpd(sdp); |
177 | gfs2_jindex_free(sdp); | |
b3b94faa | 178 | /* Take apart glock structures and buffer lists */ |
1bdad606 | 179 | gfs2_gl_hash_clear(sdp); |
b3b94faa DT |
180 | /* Unmount the locking protocol */ |
181 | gfs2_lm_unmount(sdp); | |
182 | ||
183 | /* At this point, we're through participating in the lockspace */ | |
b3b94faa | 184 | gfs2_sys_fs_del(sdp); |
ff6af411 | 185 | kfree(sdp); |
b3b94faa DT |
186 | } |
187 | ||
188 | /** | |
4a221953 SW |
189 | * gfs2_write_super |
190 | * @sb: the superblock | |
b3b94faa | 191 | * |
b3b94faa DT |
192 | */ |
193 | ||
194 | static void gfs2_write_super(struct super_block *sb) | |
195 | { | |
4a221953 SW |
196 | sb->s_dirt = 0; |
197 | } | |
198 | ||
199 | /** | |
200 | * gfs2_sync_fs - sync the filesystem | |
201 | * @sb: the superblock | |
202 | * | |
203 | * Flushes the log to disk. | |
204 | */ | |
9b8df98f | 205 | |
4a221953 SW |
206 | static int gfs2_sync_fs(struct super_block *sb, int wait) |
207 | { | |
208 | sb->s_dirt = 0; | |
9171f5a9 | 209 | if (wait && sb->s_fs_info) |
b004157a | 210 | gfs2_log_flush(sb->s_fs_info, NULL); |
4a221953 | 211 | return 0; |
b3b94faa DT |
212 | } |
213 | ||
214 | /** | |
215 | * gfs2_write_super_lockfs - prevent further writes to the filesystem | |
216 | * @sb: the VFS structure for the filesystem | |
217 | * | |
218 | */ | |
219 | ||
220 | static void gfs2_write_super_lockfs(struct super_block *sb) | |
221 | { | |
5c676f6d | 222 | struct gfs2_sbd *sdp = sb->s_fs_info; |
b3b94faa DT |
223 | int error; |
224 | ||
c3780511 DT |
225 | if (test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) |
226 | return; | |
227 | ||
b3b94faa DT |
228 | for (;;) { |
229 | error = gfs2_freeze_fs(sdp); | |
230 | if (!error) | |
231 | break; | |
232 | ||
233 | switch (error) { | |
234 | case -EBUSY: | |
235 | fs_err(sdp, "waiting for recovery before freeze\n"); | |
236 | break; | |
237 | ||
238 | default: | |
239 | fs_err(sdp, "error freezing FS: %d\n", error); | |
240 | break; | |
241 | } | |
242 | ||
243 | fs_err(sdp, "retrying...\n"); | |
244 | msleep(1000); | |
245 | } | |
246 | } | |
247 | ||
248 | /** | |
249 | * gfs2_unlockfs - reallow writes to the filesystem | |
250 | * @sb: the VFS structure for the filesystem | |
251 | * | |
252 | */ | |
253 | ||
254 | static void gfs2_unlockfs(struct super_block *sb) | |
255 | { | |
2bdbc5d7 | 256 | gfs2_unfreeze_fs(sb->s_fs_info); |
b3b94faa DT |
257 | } |
258 | ||
259 | /** | |
260 | * gfs2_statfs - Gather and return stats about the filesystem | |
261 | * @sb: The superblock | |
262 | * @statfsbuf: The buffer | |
263 | * | |
264 | * Returns: 0 on success or error code | |
265 | */ | |
266 | ||
0c0834a3 | 267 | static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf) |
b3b94faa | 268 | { |
0c0834a3 | 269 | struct super_block *sb = dentry->d_inode->i_sb; |
5c676f6d | 270 | struct gfs2_sbd *sdp = sb->s_fs_info; |
bd209cc0 | 271 | struct gfs2_statfs_change_host sc; |
b3b94faa DT |
272 | int error; |
273 | ||
b3b94faa DT |
274 | if (gfs2_tune_get(sdp, gt_statfs_slow)) |
275 | error = gfs2_statfs_slow(sdp, &sc); | |
276 | else | |
277 | error = gfs2_statfs_i(sdp, &sc); | |
278 | ||
279 | if (error) | |
280 | return error; | |
281 | ||
b3b94faa DT |
282 | buf->f_type = GFS2_MAGIC; |
283 | buf->f_bsize = sdp->sd_sb.sb_bsize; | |
284 | buf->f_blocks = sc.sc_total; | |
285 | buf->f_bfree = sc.sc_free; | |
286 | buf->f_bavail = sc.sc_free; | |
287 | buf->f_files = sc.sc_dinodes + sc.sc_free; | |
288 | buf->f_ffree = sc.sc_free; | |
289 | buf->f_namelen = GFS2_FNAMESIZE; | |
290 | ||
291 | return 0; | |
292 | } | |
293 | ||
294 | /** | |
295 | * gfs2_remount_fs - called when the FS is remounted | |
296 | * @sb: the filesystem | |
297 | * @flags: the remount flags | |
298 | * @data: extra data passed in (not used right now) | |
299 | * | |
300 | * Returns: errno | |
301 | */ | |
302 | ||
303 | static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data) | |
304 | { | |
5c676f6d | 305 | struct gfs2_sbd *sdp = sb->s_fs_info; |
b3b94faa DT |
306 | int error; |
307 | ||
b3b94faa DT |
308 | error = gfs2_mount_args(sdp, data, 1); |
309 | if (error) | |
310 | return error; | |
311 | ||
312 | if (sdp->sd_args.ar_spectator) | |
313 | *flags |= MS_RDONLY; | |
314 | else { | |
315 | if (*flags & MS_RDONLY) { | |
316 | if (!(sb->s_flags & MS_RDONLY)) | |
317 | error = gfs2_make_fs_ro(sdp); | |
318 | } else if (!(*flags & MS_RDONLY) && | |
319 | (sb->s_flags & MS_RDONLY)) { | |
320 | error = gfs2_make_fs_rw(sdp); | |
321 | } | |
322 | } | |
323 | ||
b3b94faa DT |
324 | return error; |
325 | } | |
326 | ||
3b8249f6 SW |
327 | /** |
328 | * gfs2_drop_inode - Drop an inode (test for remote unlink) | |
329 | * @inode: The inode to drop | |
330 | * | |
331 | * If we've received a callback on an iopen lock then its because a | |
332 | * remote node tried to deallocate the inode but failed due to this node | |
333 | * still having the inode open. Here we mark the link count zero | |
334 | * since we know that it must have reached zero if the GLF_DEMOTE flag | |
335 | * is set on the iopen glock. If we didn't do a disk read since the | |
336 | * remote node removed the final link then we might otherwise miss | |
337 | * this event. This check ensures that this node will deallocate the | |
338 | * inode's blocks, or alternatively pass the baton on to another | |
339 | * node for later deallocation. | |
340 | */ | |
9b8df98f | 341 | |
3b8249f6 SW |
342 | static void gfs2_drop_inode(struct inode *inode) |
343 | { | |
091806ed BP |
344 | struct gfs2_inode *ip = GFS2_I(inode); |
345 | ||
346 | if (test_bit(GIF_USER, &ip->i_flags) && inode->i_nlink) { | |
3b8249f6 SW |
347 | struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl; |
348 | if (gl && test_bit(GLF_DEMOTE, &gl->gl_flags)) | |
349 | clear_nlink(inode); | |
350 | } | |
351 | generic_drop_inode(inode); | |
352 | } | |
353 | ||
b3b94faa DT |
354 | /** |
355 | * gfs2_clear_inode - Deallocate an inode when VFS is done with it | |
356 | * @inode: The VFS inode | |
357 | * | |
358 | */ | |
359 | ||
360 | static void gfs2_clear_inode(struct inode *inode) | |
361 | { | |
091806ed BP |
362 | struct gfs2_inode *ip = GFS2_I(inode); |
363 | ||
feaa7bba SW |
364 | /* This tells us its a "real" inode and not one which only |
365 | * serves to contain an address space (see rgrp.c, meta_io.c) | |
366 | * which therefore doesn't have its own glocks. | |
367 | */ | |
091806ed | 368 | if (test_bit(GIF_USER, &ip->i_flags)) { |
feaa7bba | 369 | ip->i_gl->gl_object = NULL; |
feaa7bba SW |
370 | gfs2_glock_put(ip->i_gl); |
371 | ip->i_gl = NULL; | |
d93cfa98 AD |
372 | if (ip->i_iopen_gh.gh_gl) { |
373 | ip->i_iopen_gh.gh_gl->gl_object = NULL; | |
feaa7bba | 374 | gfs2_glock_dq_uninit(&ip->i_iopen_gh); |
d93cfa98 | 375 | } |
b3b94faa DT |
376 | } |
377 | } | |
378 | ||
9b8df98f SW |
379 | static int is_ancestor(const struct dentry *d1, const struct dentry *d2) |
380 | { | |
381 | do { | |
382 | if (d1 == d2) | |
383 | return 1; | |
384 | d1 = d1->d_parent; | |
385 | } while (!IS_ROOT(d1)); | |
386 | return 0; | |
387 | } | |
388 | ||
b3b94faa DT |
389 | /** |
390 | * gfs2_show_options - Show mount options for /proc/mounts | |
391 | * @s: seq_file structure | |
392 | * @mnt: vfsmount | |
393 | * | |
394 | * Returns: 0 on success or error code | |
395 | */ | |
396 | ||
397 | static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt) | |
398 | { | |
5c676f6d | 399 | struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info; |
b3b94faa DT |
400 | struct gfs2_args *args = &sdp->sd_args; |
401 | ||
9b8df98f SW |
402 | if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir)) |
403 | seq_printf(s, ",meta"); | |
b3b94faa DT |
404 | if (args->ar_lockproto[0]) |
405 | seq_printf(s, ",lockproto=%s", args->ar_lockproto); | |
406 | if (args->ar_locktable[0]) | |
407 | seq_printf(s, ",locktable=%s", args->ar_locktable); | |
408 | if (args->ar_hostdata[0]) | |
409 | seq_printf(s, ",hostdata=%s", args->ar_hostdata); | |
410 | if (args->ar_spectator) | |
411 | seq_printf(s, ",spectator"); | |
412 | if (args->ar_ignore_local_fs) | |
413 | seq_printf(s, ",ignore_local_fs"); | |
414 | if (args->ar_localflocks) | |
415 | seq_printf(s, ",localflocks"); | |
416 | if (args->ar_localcaching) | |
417 | seq_printf(s, ",localcaching"); | |
418 | if (args->ar_debug) | |
419 | seq_printf(s, ",debug"); | |
420 | if (args->ar_upgrade) | |
421 | seq_printf(s, ",upgrade"); | |
b3b94faa DT |
422 | if (args->ar_posix_acl) |
423 | seq_printf(s, ",acl"); | |
424 | if (args->ar_quota != GFS2_QUOTA_DEFAULT) { | |
425 | char *state; | |
426 | switch (args->ar_quota) { | |
427 | case GFS2_QUOTA_OFF: | |
428 | state = "off"; | |
429 | break; | |
430 | case GFS2_QUOTA_ACCOUNT: | |
431 | state = "account"; | |
432 | break; | |
433 | case GFS2_QUOTA_ON: | |
434 | state = "on"; | |
435 | break; | |
436 | default: | |
437 | state = "unknown"; | |
438 | break; | |
439 | } | |
440 | seq_printf(s, ",quota=%s", state); | |
441 | } | |
442 | if (args->ar_suiddir) | |
443 | seq_printf(s, ",suiddir"); | |
444 | if (args->ar_data != GFS2_DATA_DEFAULT) { | |
445 | char *state; | |
446 | switch (args->ar_data) { | |
447 | case GFS2_DATA_WRITEBACK: | |
448 | state = "writeback"; | |
449 | break; | |
450 | case GFS2_DATA_ORDERED: | |
451 | state = "ordered"; | |
452 | break; | |
453 | default: | |
454 | state = "unknown"; | |
455 | break; | |
456 | } | |
457 | seq_printf(s, ",data=%s", state); | |
458 | } | |
459 | ||
460 | return 0; | |
461 | } | |
462 | ||
907b9bce | 463 | /* |
feaa7bba SW |
464 | * We have to (at the moment) hold the inodes main lock to cover |
465 | * the gap between unlocking the shared lock on the iopen lock and | |
466 | * taking the exclusive lock. I'd rather do a shared -> exclusive | |
467 | * conversion on the iopen lock, but we can change that later. This | |
468 | * is safe, just less efficient. | |
469 | */ | |
9b8df98f | 470 | |
feaa7bba SW |
471 | static void gfs2_delete_inode(struct inode *inode) |
472 | { | |
473 | struct gfs2_sbd *sdp = inode->i_sb->s_fs_info; | |
474 | struct gfs2_inode *ip = GFS2_I(inode); | |
475 | struct gfs2_holder gh; | |
476 | int error; | |
477 | ||
091806ed | 478 | if (!test_bit(GIF_USER, &ip->i_flags)) |
feaa7bba SW |
479 | goto out; |
480 | ||
d93cfa98 | 481 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); |
feaa7bba SW |
482 | if (unlikely(error)) { |
483 | gfs2_glock_dq_uninit(&ip->i_iopen_gh); | |
484 | goto out; | |
485 | } | |
486 | ||
d93cfa98 | 487 | gfs2_glock_dq_wait(&ip->i_iopen_gh); |
feaa7bba SW |
488 | gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh); |
489 | error = gfs2_glock_nq(&ip->i_iopen_gh); | |
490 | if (error) | |
1bb7322f | 491 | goto out_truncate; |
feaa7bba | 492 | |
b60623c2 | 493 | if (S_ISDIR(inode->i_mode) && |
383f01fb | 494 | (ip->i_diskflags & GFS2_DIF_EXHASH)) { |
feaa7bba SW |
495 | error = gfs2_dir_exhash_dealloc(ip); |
496 | if (error) | |
497 | goto out_unlock; | |
498 | } | |
499 | ||
3767ac21 | 500 | if (ip->i_eattr) { |
feaa7bba SW |
501 | error = gfs2_ea_dealloc(ip); |
502 | if (error) | |
503 | goto out_unlock; | |
504 | } | |
505 | ||
506 | if (!gfs2_is_stuffed(ip)) { | |
507 | error = gfs2_file_dealloc(ip); | |
508 | if (error) | |
509 | goto out_unlock; | |
510 | } | |
511 | ||
512 | error = gfs2_dinode_dealloc(ip); | |
16615be1 SW |
513 | if (error) |
514 | goto out_unlock; | |
515 | ||
1bb7322f | 516 | out_truncate: |
16615be1 SW |
517 | error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); |
518 | if (error) | |
519 | goto out_unlock; | |
520 | /* Needs to be done before glock release & also in a transaction */ | |
49686f71 | 521 | truncate_inode_pages(&inode->i_data, 0); |
16615be1 | 522 | gfs2_trans_end(sdp); |
feaa7bba SW |
523 | |
524 | out_unlock: | |
1bb7322f SW |
525 | if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) |
526 | gfs2_glock_dq(&ip->i_iopen_gh); | |
feaa7bba SW |
527 | gfs2_holder_uninit(&ip->i_iopen_gh); |
528 | gfs2_glock_dq_uninit(&gh); | |
3b8249f6 | 529 | if (error && error != GLR_TRYFAILED) |
feaa7bba SW |
530 | fs_warn(sdp, "gfs2_delete_inode: %d\n", error); |
531 | out: | |
532 | truncate_inode_pages(&inode->i_data, 0); | |
533 | clear_inode(inode); | |
534 | } | |
535 | ||
320dd101 SW |
536 | static struct inode *gfs2_alloc_inode(struct super_block *sb) |
537 | { | |
320dd101 SW |
538 | struct gfs2_inode *ip; |
539 | ||
540 | ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL); | |
541 | if (ip) { | |
542 | ip->i_flags = 0; | |
543 | ip->i_gl = NULL; | |
320dd101 SW |
544 | } |
545 | return &ip->i_inode; | |
546 | } | |
547 | ||
548 | static void gfs2_destroy_inode(struct inode *inode) | |
549 | { | |
550 | kmem_cache_free(gfs2_inode_cachep, inode); | |
551 | } | |
552 | ||
ee9b6d61 | 553 | const struct super_operations gfs2_super_ops = { |
4a221953 SW |
554 | .alloc_inode = gfs2_alloc_inode, |
555 | .destroy_inode = gfs2_destroy_inode, | |
556 | .write_inode = gfs2_write_inode, | |
557 | .delete_inode = gfs2_delete_inode, | |
558 | .put_super = gfs2_put_super, | |
559 | .write_super = gfs2_write_super, | |
560 | .sync_fs = gfs2_sync_fs, | |
561 | .write_super_lockfs = gfs2_write_super_lockfs, | |
562 | .unlockfs = gfs2_unlockfs, | |
563 | .statfs = gfs2_statfs, | |
564 | .remount_fs = gfs2_remount_fs, | |
565 | .clear_inode = gfs2_clear_inode, | |
3b8249f6 | 566 | .drop_inode = gfs2_drop_inode, |
4a221953 | 567 | .show_options = gfs2_show_options, |
b3b94faa DT |
568 | }; |
569 |