blob: 8f332d26b5ddf16a378d2c0bb3d40837aa42ed45 [file] [log] [blame]
David Teiglandb3b94fa2006-01-16 16:50:04 +00001/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
Bob Peterson091806ed2008-04-29 12:35:48 -05003 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
David Teiglandb3b94fa2006-01-16 16:50:04 +00004 *
5 * This copyrighted material is made available to anyone wishing to use,
6 * modify, copy, or redistribute it subject to the terms and conditions
Steven Whitehousee9fc2aa2006-09-01 11:05:15 -04007 * of the GNU General Public License version 2.
David Teiglandb3b94fa2006-01-16 16:50:04 +00008 */
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>
David Teiglandb3b94fa2006-01-16 16:50:04 +000015#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>
Steven Whitehouse5c676f62006-02-27 17:23:27 -050020#include <linux/gfs2_ondisk.h>
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040021#include <linux/crc32.h>
Fabio Massimo Di Nitto7d308592006-09-19 07:56:29 +020022#include <linux/lm_interface.h>
David Teiglandb3b94fa2006-01-16 16:50:04 +000023
24#include "gfs2.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050025#include "incore.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000026#include "glock.h"
27#include "inode.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000028#include "log.h"
29#include "mount.h"
30#include "ops_super.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000031#include "quota.h"
32#include "recovery.h"
33#include "rgrp.h"
34#include "super.h"
35#include "sys.h"
Steven Whitehouse5c676f62006-02-27 17:23:27 -050036#include "util.h"
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040037#include "trans.h"
38#include "dir.h"
39#include "eattr.h"
40#include "bmap.h"
David Teiglandb3b94fa2006-01-16 16:50:04 +000041
42/**
43 * gfs2_write_inode - Make sure the inode is stable on the disk
44 * @inode: The inode
45 * @sync: synchronous write flag
46 *
47 * Returns: errno
48 */
49
50static int gfs2_write_inode(struct inode *inode, int sync)
51{
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040052 struct gfs2_inode *ip = GFS2_I(inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +000053
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040054 /* Check this is a "normal" inode */
Bob Peterson091806ed2008-04-29 12:35:48 -050055 if (test_bit(GIF_USER, &ip->i_flags)) {
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040056 if (current->flags & PF_MEMALLOC)
57 return 0;
58 if (sync)
Steven Whitehouse3a8476d2006-06-19 09:10:39 -040059 gfs2_log_flush(GFS2_SB(inode), ip->i_gl);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -040060 }
David Teiglandb3b94fa2006-01-16 16:50:04 +000061
62 return 0;
63}
64
65/**
Steven Whitehouse9b8df982008-08-08 13:45:13 +010066 * gfs2_make_fs_ro - Turn a Read-Write FS into a Read-Only one
67 * @sdp: the filesystem
68 *
69 * Returns: errno
70 */
71
72static int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
73{
74 struct gfs2_holder t_gh;
75 int error;
76
77 gfs2_quota_sync(sdp);
78 gfs2_statfs_sync(sdp);
79
80 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED, GL_NOCACHE,
81 &t_gh);
82 if (error && !test_bit(SDF_SHUTDOWN, &sdp->sd_flags))
83 return error;
84
85 gfs2_meta_syncfs(sdp);
86 gfs2_log_shutdown(sdp);
87
88 clear_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
89
90 if (t_gh.gh_gl)
91 gfs2_glock_dq_uninit(&t_gh);
92
93 gfs2_quota_cleanup(sdp);
94
95 return error;
96}
97
98/**
David Teiglandb3b94fa2006-01-16 16:50:04 +000099 * gfs2_put_super - Unmount the filesystem
100 * @sb: The VFS superblock
101 *
102 */
103
104static void gfs2_put_super(struct super_block *sb)
105{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500106 struct gfs2_sbd *sdp = sb->s_fs_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000107 int error;
108
David Teiglandb3b94fa2006-01-16 16:50:04 +0000109 /* Unfreeze the filesystem, if we need to */
110
Steven Whitehousef55ab262006-02-21 12:51:39 +0000111 mutex_lock(&sdp->sd_freeze_lock);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000112 if (sdp->sd_freeze_count)
113 gfs2_glock_dq_uninit(&sdp->sd_freeze_gh);
Steven Whitehousef55ab262006-02-21 12:51:39 +0000114 mutex_unlock(&sdp->sd_freeze_lock);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000115
David Teiglandb3b94fa2006-01-16 16:50:04 +0000116 kthread_stop(sdp->sd_quotad_process);
117 kthread_stop(sdp->sd_logd_process);
118 kthread_stop(sdp->sd_recoverd_process);
119 while (sdp->sd_glockd_num--)
120 kthread_stop(sdp->sd_glockd_process[sdp->sd_glockd_num]);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000121
122 if (!(sb->s_flags & MS_RDONLY)) {
123 error = gfs2_make_fs_ro(sdp);
124 if (error)
125 gfs2_io_error(sdp);
126 }
David Teiglandb3b94fa2006-01-16 16:50:04 +0000127 /* At this point, we're through modifying the disk */
128
129 /* Release stuff */
130
Steven Whitehousef42faf42006-01-30 18:34:10 +0000131 iput(sdp->sd_jindex);
132 iput(sdp->sd_inum_inode);
133 iput(sdp->sd_statfs_inode);
134 iput(sdp->sd_rindex);
135 iput(sdp->sd_quota_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000136
137 gfs2_glock_put(sdp->sd_rename_gl);
138 gfs2_glock_put(sdp->sd_trans_gl);
139
140 if (!sdp->sd_args.ar_spectator) {
141 gfs2_glock_dq_uninit(&sdp->sd_journal_gh);
142 gfs2_glock_dq_uninit(&sdp->sd_jinode_gh);
143 gfs2_glock_dq_uninit(&sdp->sd_ir_gh);
144 gfs2_glock_dq_uninit(&sdp->sd_sc_gh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000145 gfs2_glock_dq_uninit(&sdp->sd_qc_gh);
Steven Whitehousef42faf42006-01-30 18:34:10 +0000146 iput(sdp->sd_ir_inode);
147 iput(sdp->sd_sc_inode);
Steven Whitehousef42faf42006-01-30 18:34:10 +0000148 iput(sdp->sd_qc_inode);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000149 }
150
151 gfs2_glock_dq_uninit(&sdp->sd_live_gh);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000152 gfs2_clear_rgrpd(sdp);
153 gfs2_jindex_free(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000154 /* Take apart glock structures and buffer lists */
Steven Whitehouse1bdad602008-06-03 14:09:53 +0100155 gfs2_gl_hash_clear(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000156 /* Unmount the locking protocol */
157 gfs2_lm_unmount(sdp);
158
159 /* At this point, we're through participating in the lockspace */
David Teiglandb3b94fa2006-01-16 16:50:04 +0000160 gfs2_sys_fs_del(sdp);
Steven Whitehouseff6af412006-09-09 16:56:34 -0400161 kfree(sdp);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000162}
163
164/**
Steven Whitehouse4a221952006-11-01 09:57:57 -0500165 * gfs2_write_super
166 * @sb: the superblock
David Teiglandb3b94fa2006-01-16 16:50:04 +0000167 *
David Teiglandb3b94fa2006-01-16 16:50:04 +0000168 */
169
170static void gfs2_write_super(struct super_block *sb)
171{
Steven Whitehouse4a221952006-11-01 09:57:57 -0500172 sb->s_dirt = 0;
173}
174
175/**
176 * gfs2_sync_fs - sync the filesystem
177 * @sb: the superblock
178 *
179 * Flushes the log to disk.
180 */
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100181
Steven Whitehouse4a221952006-11-01 09:57:57 -0500182static int gfs2_sync_fs(struct super_block *sb, int wait)
183{
184 sb->s_dirt = 0;
Bob Peterson9171f5a2008-06-09 12:08:23 -0500185 if (wait && sb->s_fs_info)
Steven Whitehouseb0041572006-11-23 10:51:34 -0500186 gfs2_log_flush(sb->s_fs_info, NULL);
Steven Whitehouse4a221952006-11-01 09:57:57 -0500187 return 0;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000188}
189
190/**
191 * gfs2_write_super_lockfs - prevent further writes to the filesystem
192 * @sb: the VFS structure for the filesystem
193 *
194 */
195
196static void gfs2_write_super_lockfs(struct super_block *sb)
197{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500198 struct gfs2_sbd *sdp = sb->s_fs_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000199 int error;
200
David Teiglandc3780512006-12-06 11:46:33 -0600201 if (test_bit(SDF_SHUTDOWN, &sdp->sd_flags))
202 return;
203
David Teiglandb3b94fa2006-01-16 16:50:04 +0000204 for (;;) {
205 error = gfs2_freeze_fs(sdp);
206 if (!error)
207 break;
208
209 switch (error) {
210 case -EBUSY:
211 fs_err(sdp, "waiting for recovery before freeze\n");
212 break;
213
214 default:
215 fs_err(sdp, "error freezing FS: %d\n", error);
216 break;
217 }
218
219 fs_err(sdp, "retrying...\n");
220 msleep(1000);
221 }
222}
223
224/**
225 * gfs2_unlockfs - reallow writes to the filesystem
226 * @sb: the VFS structure for the filesystem
227 *
228 */
229
230static void gfs2_unlockfs(struct super_block *sb)
231{
Steven Whitehouse2bdbc5d2006-09-05 09:34:20 -0400232 gfs2_unfreeze_fs(sb->s_fs_info);
David Teiglandb3b94fa2006-01-16 16:50:04 +0000233}
234
235/**
236 * gfs2_statfs - Gather and return stats about the filesystem
237 * @sb: The superblock
238 * @statfsbuf: The buffer
239 *
240 * Returns: 0 on success or error code
241 */
242
Steven Whitehouse0c0834a2006-07-03 11:38:01 -0400243static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
David Teiglandb3b94fa2006-01-16 16:50:04 +0000244{
Steven Whitehouse0c0834a2006-07-03 11:38:01 -0400245 struct super_block *sb = dentry->d_inode->i_sb;
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500246 struct gfs2_sbd *sdp = sb->s_fs_info;
Al Virobd209cc2006-10-13 23:43:19 -0400247 struct gfs2_statfs_change_host sc;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000248 int error;
249
David Teiglandb3b94fa2006-01-16 16:50:04 +0000250 if (gfs2_tune_get(sdp, gt_statfs_slow))
251 error = gfs2_statfs_slow(sdp, &sc);
252 else
253 error = gfs2_statfs_i(sdp, &sc);
254
255 if (error)
256 return error;
257
David Teiglandb3b94fa2006-01-16 16:50:04 +0000258 buf->f_type = GFS2_MAGIC;
259 buf->f_bsize = sdp->sd_sb.sb_bsize;
260 buf->f_blocks = sc.sc_total;
261 buf->f_bfree = sc.sc_free;
262 buf->f_bavail = sc.sc_free;
263 buf->f_files = sc.sc_dinodes + sc.sc_free;
264 buf->f_ffree = sc.sc_free;
265 buf->f_namelen = GFS2_FNAMESIZE;
266
267 return 0;
268}
269
270/**
271 * gfs2_remount_fs - called when the FS is remounted
272 * @sb: the filesystem
273 * @flags: the remount flags
274 * @data: extra data passed in (not used right now)
275 *
276 * Returns: errno
277 */
278
279static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
280{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500281 struct gfs2_sbd *sdp = sb->s_fs_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000282 int error;
283
David Teiglandb3b94fa2006-01-16 16:50:04 +0000284 error = gfs2_mount_args(sdp, data, 1);
285 if (error)
286 return error;
287
288 if (sdp->sd_args.ar_spectator)
289 *flags |= MS_RDONLY;
290 else {
291 if (*flags & MS_RDONLY) {
292 if (!(sb->s_flags & MS_RDONLY))
293 error = gfs2_make_fs_ro(sdp);
294 } else if (!(*flags & MS_RDONLY) &&
295 (sb->s_flags & MS_RDONLY)) {
296 error = gfs2_make_fs_rw(sdp);
297 }
298 }
299
300 if (*flags & (MS_NOATIME | MS_NODIRATIME))
301 set_bit(SDF_NOATIME, &sdp->sd_flags);
302 else
303 clear_bit(SDF_NOATIME, &sdp->sd_flags);
304
305 /* Don't let the VFS update atimes. GFS2 handles this itself. */
306 *flags |= MS_NOATIME | MS_NODIRATIME;
307
308 return error;
309}
310
311/**
Steven Whitehouse3b8249f2007-03-16 09:40:31 +0000312 * gfs2_drop_inode - Drop an inode (test for remote unlink)
313 * @inode: The inode to drop
314 *
315 * If we've received a callback on an iopen lock then its because a
316 * remote node tried to deallocate the inode but failed due to this node
317 * still having the inode open. Here we mark the link count zero
318 * since we know that it must have reached zero if the GLF_DEMOTE flag
319 * is set on the iopen glock. If we didn't do a disk read since the
320 * remote node removed the final link then we might otherwise miss
321 * this event. This check ensures that this node will deallocate the
322 * inode's blocks, or alternatively pass the baton on to another
323 * node for later deallocation.
324 */
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100325
Steven Whitehouse3b8249f2007-03-16 09:40:31 +0000326static void gfs2_drop_inode(struct inode *inode)
327{
Bob Peterson091806ed2008-04-29 12:35:48 -0500328 struct gfs2_inode *ip = GFS2_I(inode);
329
330 if (test_bit(GIF_USER, &ip->i_flags) && inode->i_nlink) {
Steven Whitehouse3b8249f2007-03-16 09:40:31 +0000331 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
332 if (gl && test_bit(GLF_DEMOTE, &gl->gl_flags))
333 clear_nlink(inode);
334 }
335 generic_drop_inode(inode);
336}
337
338/**
David Teiglandb3b94fa2006-01-16 16:50:04 +0000339 * gfs2_clear_inode - Deallocate an inode when VFS is done with it
340 * @inode: The VFS inode
341 *
342 */
343
344static void gfs2_clear_inode(struct inode *inode)
345{
Bob Peterson091806ed2008-04-29 12:35:48 -0500346 struct gfs2_inode *ip = GFS2_I(inode);
347
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400348 /* This tells us its a "real" inode and not one which only
349 * serves to contain an address space (see rgrp.c, meta_io.c)
350 * which therefore doesn't have its own glocks.
351 */
Bob Peterson091806ed2008-04-29 12:35:48 -0500352 if (test_bit(GIF_USER, &ip->i_flags)) {
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400353 ip->i_gl->gl_object = NULL;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000354 gfs2_glock_schedule_for_reclaim(ip->i_gl);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400355 gfs2_glock_put(ip->i_gl);
356 ip->i_gl = NULL;
Abhijith Dasd93cfa92007-06-11 08:22:32 +0100357 if (ip->i_iopen_gh.gh_gl) {
358 ip->i_iopen_gh.gh_gl->gl_object = NULL;
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400359 gfs2_glock_dq_uninit(&ip->i_iopen_gh);
Abhijith Dasd93cfa92007-06-11 08:22:32 +0100360 }
David Teiglandb3b94fa2006-01-16 16:50:04 +0000361 }
362}
363
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100364static int is_ancestor(const struct dentry *d1, const struct dentry *d2)
365{
366 do {
367 if (d1 == d2)
368 return 1;
369 d1 = d1->d_parent;
370 } while (!IS_ROOT(d1));
371 return 0;
372}
373
David Teiglandb3b94fa2006-01-16 16:50:04 +0000374/**
375 * gfs2_show_options - Show mount options for /proc/mounts
376 * @s: seq_file structure
377 * @mnt: vfsmount
378 *
379 * Returns: 0 on success or error code
380 */
381
382static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
383{
Steven Whitehouse5c676f62006-02-27 17:23:27 -0500384 struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info;
David Teiglandb3b94fa2006-01-16 16:50:04 +0000385 struct gfs2_args *args = &sdp->sd_args;
386
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100387 if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir))
388 seq_printf(s, ",meta");
David Teiglandb3b94fa2006-01-16 16:50:04 +0000389 if (args->ar_lockproto[0])
390 seq_printf(s, ",lockproto=%s", args->ar_lockproto);
391 if (args->ar_locktable[0])
392 seq_printf(s, ",locktable=%s", args->ar_locktable);
393 if (args->ar_hostdata[0])
394 seq_printf(s, ",hostdata=%s", args->ar_hostdata);
395 if (args->ar_spectator)
396 seq_printf(s, ",spectator");
397 if (args->ar_ignore_local_fs)
398 seq_printf(s, ",ignore_local_fs");
399 if (args->ar_localflocks)
400 seq_printf(s, ",localflocks");
401 if (args->ar_localcaching)
402 seq_printf(s, ",localcaching");
403 if (args->ar_debug)
404 seq_printf(s, ",debug");
405 if (args->ar_upgrade)
406 seq_printf(s, ",upgrade");
407 if (args->ar_num_glockd != GFS2_GLOCKD_DEFAULT)
408 seq_printf(s, ",num_glockd=%u", args->ar_num_glockd);
409 if (args->ar_posix_acl)
410 seq_printf(s, ",acl");
411 if (args->ar_quota != GFS2_QUOTA_DEFAULT) {
412 char *state;
413 switch (args->ar_quota) {
414 case GFS2_QUOTA_OFF:
415 state = "off";
416 break;
417 case GFS2_QUOTA_ACCOUNT:
418 state = "account";
419 break;
420 case GFS2_QUOTA_ON:
421 state = "on";
422 break;
423 default:
424 state = "unknown";
425 break;
426 }
427 seq_printf(s, ",quota=%s", state);
428 }
429 if (args->ar_suiddir)
430 seq_printf(s, ",suiddir");
431 if (args->ar_data != GFS2_DATA_DEFAULT) {
432 char *state;
433 switch (args->ar_data) {
434 case GFS2_DATA_WRITEBACK:
435 state = "writeback";
436 break;
437 case GFS2_DATA_ORDERED:
438 state = "ordered";
439 break;
440 default:
441 state = "unknown";
442 break;
443 }
444 seq_printf(s, ",data=%s", state);
445 }
446
447 return 0;
448}
449
Steven Whitehouse907b9bc2006-09-25 09:26:04 -0400450/*
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400451 * We have to (at the moment) hold the inodes main lock to cover
452 * the gap between unlocking the shared lock on the iopen lock and
453 * taking the exclusive lock. I'd rather do a shared -> exclusive
454 * conversion on the iopen lock, but we can change that later. This
455 * is safe, just less efficient.
456 */
Steven Whitehouse9b8df982008-08-08 13:45:13 +0100457
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400458static void gfs2_delete_inode(struct inode *inode)
459{
460 struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
461 struct gfs2_inode *ip = GFS2_I(inode);
462 struct gfs2_holder gh;
463 int error;
464
Bob Peterson091806ed2008-04-29 12:35:48 -0500465 if (!test_bit(GIF_USER, &ip->i_flags))
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400466 goto out;
467
Abhijith Dasd93cfa92007-06-11 08:22:32 +0100468 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400469 if (unlikely(error)) {
470 gfs2_glock_dq_uninit(&ip->i_iopen_gh);
471 goto out;
472 }
473
Abhijith Dasd93cfa92007-06-11 08:22:32 +0100474 gfs2_glock_dq_wait(&ip->i_iopen_gh);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400475 gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh);
476 error = gfs2_glock_nq(&ip->i_iopen_gh);
477 if (error)
478 goto out_uninit;
479
Steven Whitehouseb60623c2006-11-01 12:22:46 -0500480 if (S_ISDIR(inode->i_mode) &&
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400481 (ip->i_di.di_flags & GFS2_DIF_EXHASH)) {
482 error = gfs2_dir_exhash_dealloc(ip);
483 if (error)
484 goto out_unlock;
485 }
486
487 if (ip->i_di.di_eattr) {
488 error = gfs2_ea_dealloc(ip);
489 if (error)
490 goto out_unlock;
491 }
492
493 if (!gfs2_is_stuffed(ip)) {
494 error = gfs2_file_dealloc(ip);
495 if (error)
496 goto out_unlock;
497 }
498
499 error = gfs2_dinode_dealloc(ip);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100500 if (error)
501 goto out_unlock;
502
503 error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
504 if (error)
505 goto out_unlock;
506 /* Needs to be done before glock release & also in a transaction */
Steven Whitehouse49686f72007-01-08 14:31:40 +0000507 truncate_inode_pages(&inode->i_data, 0);
Steven Whitehouse16615be2007-09-17 10:59:52 +0100508 gfs2_trans_end(sdp);
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400509
510out_unlock:
511 gfs2_glock_dq(&ip->i_iopen_gh);
512out_uninit:
513 gfs2_holder_uninit(&ip->i_iopen_gh);
514 gfs2_glock_dq_uninit(&gh);
Steven Whitehouse3b8249f2007-03-16 09:40:31 +0000515 if (error && error != GLR_TRYFAILED)
Steven Whitehousefeaa7bb2006-06-14 15:32:57 -0400516 fs_warn(sdp, "gfs2_delete_inode: %d\n", error);
517out:
518 truncate_inode_pages(&inode->i_data, 0);
519 clear_inode(inode);
520}
521
Steven Whitehouse320dd102006-05-18 16:25:27 -0400522static struct inode *gfs2_alloc_inode(struct super_block *sb)
523{
Steven Whitehouse320dd102006-05-18 16:25:27 -0400524 struct gfs2_inode *ip;
525
526 ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL);
527 if (ip) {
528 ip->i_flags = 0;
529 ip->i_gl = NULL;
Steven Whitehouse320dd102006-05-18 16:25:27 -0400530 }
531 return &ip->i_inode;
532}
533
534static void gfs2_destroy_inode(struct inode *inode)
535{
536 kmem_cache_free(gfs2_inode_cachep, inode);
537}
538
Josef 'Jeff' Sipekee9b6d62007-02-12 00:55:41 -0800539const struct super_operations gfs2_super_ops = {
Steven Whitehouse4a221952006-11-01 09:57:57 -0500540 .alloc_inode = gfs2_alloc_inode,
541 .destroy_inode = gfs2_destroy_inode,
542 .write_inode = gfs2_write_inode,
543 .delete_inode = gfs2_delete_inode,
544 .put_super = gfs2_put_super,
545 .write_super = gfs2_write_super,
546 .sync_fs = gfs2_sync_fs,
547 .write_super_lockfs = gfs2_write_super_lockfs,
548 .unlockfs = gfs2_unlockfs,
549 .statfs = gfs2_statfs,
550 .remount_fs = gfs2_remount_fs,
551 .clear_inode = gfs2_clear_inode,
Steven Whitehouse3b8249f2007-03-16 09:40:31 +0000552 .drop_inode = gfs2_drop_inode,
Steven Whitehouse4a221952006-11-01 09:57:57 -0500553 .show_options = gfs2_show_options,
David Teiglandb3b94fa2006-01-16 16:50:04 +0000554};
555