ops_super.c 16 KB

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