ops_super.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  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. }
  160. /**
  161. * gfs2_write_super
  162. * @sb: the superblock
  163. *
  164. */
  165. static void gfs2_write_super(struct super_block *sb)
  166. {
  167. sb->s_dirt = 0;
  168. }
  169. /**
  170. * gfs2_sync_fs - sync the filesystem
  171. * @sb: the superblock
  172. *
  173. * Flushes the log to disk.
  174. */
  175. static int gfs2_sync_fs(struct super_block *sb, int wait)
  176. {
  177. sb->s_dirt = 0;
  178. if (wait && sb->s_fs_info)
  179. gfs2_log_flush(sb->s_fs_info, NULL);
  180. return 0;
  181. }
  182. /**
  183. * gfs2_freeze - prevent further writes to the filesystem
  184. * @sb: the VFS structure for the filesystem
  185. *
  186. */
  187. static int gfs2_freeze(struct super_block *sb)
  188. {
  189. struct gfs2_sbd *sdp = sb->s_fs_info;
  190. int error;
  191. if (test_bit(SDF_SHUTDOWN, &sdp->sd_flags))
  192. return -EINVAL;
  193. for (;;) {
  194. error = gfs2_freeze_fs(sdp);
  195. if (!error)
  196. break;
  197. switch (error) {
  198. case -EBUSY:
  199. fs_err(sdp, "waiting for recovery before freeze\n");
  200. break;
  201. default:
  202. fs_err(sdp, "error freezing FS: %d\n", error);
  203. break;
  204. }
  205. fs_err(sdp, "retrying...\n");
  206. msleep(1000);
  207. }
  208. return 0;
  209. }
  210. /**
  211. * gfs2_unfreeze - reallow writes to the filesystem
  212. * @sb: the VFS structure for the filesystem
  213. *
  214. */
  215. static int gfs2_unfreeze(struct super_block *sb)
  216. {
  217. gfs2_unfreeze_fs(sb->s_fs_info);
  218. return 0;
  219. }
  220. /**
  221. * statfs_fill - fill in the sg for a given RG
  222. * @rgd: the RG
  223. * @sc: the sc structure
  224. *
  225. * Returns: 0 on success, -ESTALE if the LVB is invalid
  226. */
  227. static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
  228. struct gfs2_statfs_change_host *sc)
  229. {
  230. gfs2_rgrp_verify(rgd);
  231. sc->sc_total += rgd->rd_data;
  232. sc->sc_free += rgd->rd_free;
  233. sc->sc_dinodes += rgd->rd_dinodes;
  234. return 0;
  235. }
  236. /**
  237. * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
  238. * @sdp: the filesystem
  239. * @sc: the sc info that will be returned
  240. *
  241. * Any error (other than a signal) will cause this routine to fall back
  242. * to the synchronous version.
  243. *
  244. * FIXME: This really shouldn't busy wait like this.
  245. *
  246. * Returns: errno
  247. */
  248. static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
  249. {
  250. struct gfs2_holder ri_gh;
  251. struct gfs2_rgrpd *rgd_next;
  252. struct gfs2_holder *gha, *gh;
  253. unsigned int slots = 64;
  254. unsigned int x;
  255. int done;
  256. int error = 0, err;
  257. memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
  258. gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
  259. if (!gha)
  260. return -ENOMEM;
  261. error = gfs2_rindex_hold(sdp, &ri_gh);
  262. if (error)
  263. goto out;
  264. rgd_next = gfs2_rgrpd_get_first(sdp);
  265. for (;;) {
  266. done = 1;
  267. for (x = 0; x < slots; x++) {
  268. gh = gha + x;
  269. if (gh->gh_gl && gfs2_glock_poll(gh)) {
  270. err = gfs2_glock_wait(gh);
  271. if (err) {
  272. gfs2_holder_uninit(gh);
  273. error = err;
  274. } else {
  275. if (!error)
  276. error = statfs_slow_fill(
  277. gh->gh_gl->gl_object, sc);
  278. gfs2_glock_dq_uninit(gh);
  279. }
  280. }
  281. if (gh->gh_gl)
  282. done = 0;
  283. else if (rgd_next && !error) {
  284. error = gfs2_glock_nq_init(rgd_next->rd_gl,
  285. LM_ST_SHARED,
  286. GL_ASYNC,
  287. gh);
  288. rgd_next = gfs2_rgrpd_get_next(rgd_next);
  289. done = 0;
  290. }
  291. if (signal_pending(current))
  292. error = -ERESTARTSYS;
  293. }
  294. if (done)
  295. break;
  296. yield();
  297. }
  298. gfs2_glock_dq_uninit(&ri_gh);
  299. out:
  300. kfree(gha);
  301. return error;
  302. }
  303. /**
  304. * gfs2_statfs_i - Do a statfs
  305. * @sdp: the filesystem
  306. * @sg: the sg structure
  307. *
  308. * Returns: errno
  309. */
  310. static int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
  311. {
  312. struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
  313. struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
  314. spin_lock(&sdp->sd_statfs_spin);
  315. *sc = *m_sc;
  316. sc->sc_total += l_sc->sc_total;
  317. sc->sc_free += l_sc->sc_free;
  318. sc->sc_dinodes += l_sc->sc_dinodes;
  319. spin_unlock(&sdp->sd_statfs_spin);
  320. if (sc->sc_free < 0)
  321. sc->sc_free = 0;
  322. if (sc->sc_free > sc->sc_total)
  323. sc->sc_free = sc->sc_total;
  324. if (sc->sc_dinodes < 0)
  325. sc->sc_dinodes = 0;
  326. return 0;
  327. }
  328. /**
  329. * gfs2_statfs - Gather and return stats about the filesystem
  330. * @sb: The superblock
  331. * @statfsbuf: The buffer
  332. *
  333. * Returns: 0 on success or error code
  334. */
  335. static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
  336. {
  337. struct super_block *sb = dentry->d_inode->i_sb;
  338. struct gfs2_sbd *sdp = sb->s_fs_info;
  339. struct gfs2_statfs_change_host sc;
  340. int error;
  341. if (gfs2_tune_get(sdp, gt_statfs_slow))
  342. error = gfs2_statfs_slow(sdp, &sc);
  343. else
  344. error = gfs2_statfs_i(sdp, &sc);
  345. if (error)
  346. return error;
  347. buf->f_type = GFS2_MAGIC;
  348. buf->f_bsize = sdp->sd_sb.sb_bsize;
  349. buf->f_blocks = sc.sc_total;
  350. buf->f_bfree = sc.sc_free;
  351. buf->f_bavail = sc.sc_free;
  352. buf->f_files = sc.sc_dinodes + sc.sc_free;
  353. buf->f_ffree = sc.sc_free;
  354. buf->f_namelen = GFS2_FNAMESIZE;
  355. return 0;
  356. }
  357. /**
  358. * gfs2_remount_fs - called when the FS is remounted
  359. * @sb: the filesystem
  360. * @flags: the remount flags
  361. * @data: extra data passed in (not used right now)
  362. *
  363. * Returns: errno
  364. */
  365. static int gfs2_remount_fs(struct super_block *sb, int *flags, char *data)
  366. {
  367. struct gfs2_sbd *sdp = sb->s_fs_info;
  368. int error;
  369. error = gfs2_mount_args(sdp, data, 1);
  370. if (error)
  371. return error;
  372. if (sdp->sd_args.ar_spectator)
  373. *flags |= MS_RDONLY;
  374. else {
  375. if (*flags & MS_RDONLY) {
  376. if (!(sb->s_flags & MS_RDONLY))
  377. error = gfs2_make_fs_ro(sdp);
  378. } else if (!(*flags & MS_RDONLY) &&
  379. (sb->s_flags & MS_RDONLY)) {
  380. error = gfs2_make_fs_rw(sdp);
  381. }
  382. }
  383. return error;
  384. }
  385. /**
  386. * gfs2_drop_inode - Drop an inode (test for remote unlink)
  387. * @inode: The inode to drop
  388. *
  389. * If we've received a callback on an iopen lock then its because a
  390. * remote node tried to deallocate the inode but failed due to this node
  391. * still having the inode open. Here we mark the link count zero
  392. * since we know that it must have reached zero if the GLF_DEMOTE flag
  393. * is set on the iopen glock. If we didn't do a disk read since the
  394. * remote node removed the final link then we might otherwise miss
  395. * this event. This check ensures that this node will deallocate the
  396. * inode's blocks, or alternatively pass the baton on to another
  397. * node for later deallocation.
  398. */
  399. static void gfs2_drop_inode(struct inode *inode)
  400. {
  401. struct gfs2_inode *ip = GFS2_I(inode);
  402. if (test_bit(GIF_USER, &ip->i_flags) && inode->i_nlink) {
  403. struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
  404. if (gl && test_bit(GLF_DEMOTE, &gl->gl_flags))
  405. clear_nlink(inode);
  406. }
  407. generic_drop_inode(inode);
  408. }
  409. /**
  410. * gfs2_clear_inode - Deallocate an inode when VFS is done with it
  411. * @inode: The VFS inode
  412. *
  413. */
  414. static void gfs2_clear_inode(struct inode *inode)
  415. {
  416. struct gfs2_inode *ip = GFS2_I(inode);
  417. /* This tells us its a "real" inode and not one which only
  418. * serves to contain an address space (see rgrp.c, meta_io.c)
  419. * which therefore doesn't have its own glocks.
  420. */
  421. if (test_bit(GIF_USER, &ip->i_flags)) {
  422. ip->i_gl->gl_object = NULL;
  423. gfs2_glock_put(ip->i_gl);
  424. ip->i_gl = NULL;
  425. if (ip->i_iopen_gh.gh_gl) {
  426. ip->i_iopen_gh.gh_gl->gl_object = NULL;
  427. gfs2_glock_dq_uninit(&ip->i_iopen_gh);
  428. }
  429. }
  430. }
  431. static int is_ancestor(const struct dentry *d1, const struct dentry *d2)
  432. {
  433. do {
  434. if (d1 == d2)
  435. return 1;
  436. d1 = d1->d_parent;
  437. } while (!IS_ROOT(d1));
  438. return 0;
  439. }
  440. /**
  441. * gfs2_show_options - Show mount options for /proc/mounts
  442. * @s: seq_file structure
  443. * @mnt: vfsmount
  444. *
  445. * Returns: 0 on success or error code
  446. */
  447. static int gfs2_show_options(struct seq_file *s, struct vfsmount *mnt)
  448. {
  449. struct gfs2_sbd *sdp = mnt->mnt_sb->s_fs_info;
  450. struct gfs2_args *args = &sdp->sd_args;
  451. if (is_ancestor(mnt->mnt_root, sdp->sd_master_dir))
  452. seq_printf(s, ",meta");
  453. if (args->ar_lockproto[0])
  454. seq_printf(s, ",lockproto=%s", args->ar_lockproto);
  455. if (args->ar_locktable[0])
  456. seq_printf(s, ",locktable=%s", args->ar_locktable);
  457. if (args->ar_hostdata[0])
  458. seq_printf(s, ",hostdata=%s", args->ar_hostdata);
  459. if (args->ar_spectator)
  460. seq_printf(s, ",spectator");
  461. if (args->ar_ignore_local_fs)
  462. seq_printf(s, ",ignore_local_fs");
  463. if (args->ar_localflocks)
  464. seq_printf(s, ",localflocks");
  465. if (args->ar_localcaching)
  466. seq_printf(s, ",localcaching");
  467. if (args->ar_debug)
  468. seq_printf(s, ",debug");
  469. if (args->ar_upgrade)
  470. seq_printf(s, ",upgrade");
  471. if (args->ar_posix_acl)
  472. seq_printf(s, ",acl");
  473. if (args->ar_quota != GFS2_QUOTA_DEFAULT) {
  474. char *state;
  475. switch (args->ar_quota) {
  476. case GFS2_QUOTA_OFF:
  477. state = "off";
  478. break;
  479. case GFS2_QUOTA_ACCOUNT:
  480. state = "account";
  481. break;
  482. case GFS2_QUOTA_ON:
  483. state = "on";
  484. break;
  485. default:
  486. state = "unknown";
  487. break;
  488. }
  489. seq_printf(s, ",quota=%s", state);
  490. }
  491. if (args->ar_suiddir)
  492. seq_printf(s, ",suiddir");
  493. if (args->ar_data != GFS2_DATA_DEFAULT) {
  494. char *state;
  495. switch (args->ar_data) {
  496. case GFS2_DATA_WRITEBACK:
  497. state = "writeback";
  498. break;
  499. case GFS2_DATA_ORDERED:
  500. state = "ordered";
  501. break;
  502. default:
  503. state = "unknown";
  504. break;
  505. }
  506. seq_printf(s, ",data=%s", state);
  507. }
  508. return 0;
  509. }
  510. /*
  511. * We have to (at the moment) hold the inodes main lock to cover
  512. * the gap between unlocking the shared lock on the iopen lock and
  513. * taking the exclusive lock. I'd rather do a shared -> exclusive
  514. * conversion on the iopen lock, but we can change that later. This
  515. * is safe, just less efficient.
  516. */
  517. static void gfs2_delete_inode(struct inode *inode)
  518. {
  519. struct gfs2_sbd *sdp = inode->i_sb->s_fs_info;
  520. struct gfs2_inode *ip = GFS2_I(inode);
  521. struct gfs2_holder gh;
  522. int error;
  523. if (!test_bit(GIF_USER, &ip->i_flags))
  524. goto out;
  525. error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
  526. if (unlikely(error)) {
  527. gfs2_glock_dq_uninit(&ip->i_iopen_gh);
  528. goto out;
  529. }
  530. gfs2_glock_dq_wait(&ip->i_iopen_gh);
  531. gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, &ip->i_iopen_gh);
  532. error = gfs2_glock_nq(&ip->i_iopen_gh);
  533. if (error)
  534. goto out_truncate;
  535. if (S_ISDIR(inode->i_mode) &&
  536. (ip->i_diskflags & GFS2_DIF_EXHASH)) {
  537. error = gfs2_dir_exhash_dealloc(ip);
  538. if (error)
  539. goto out_unlock;
  540. }
  541. if (ip->i_eattr) {
  542. error = gfs2_ea_dealloc(ip);
  543. if (error)
  544. goto out_unlock;
  545. }
  546. if (!gfs2_is_stuffed(ip)) {
  547. error = gfs2_file_dealloc(ip);
  548. if (error)
  549. goto out_unlock;
  550. }
  551. error = gfs2_dinode_dealloc(ip);
  552. if (error)
  553. goto out_unlock;
  554. out_truncate:
  555. error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
  556. if (error)
  557. goto out_unlock;
  558. /* Needs to be done before glock release & also in a transaction */
  559. truncate_inode_pages(&inode->i_data, 0);
  560. gfs2_trans_end(sdp);
  561. out_unlock:
  562. if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags))
  563. gfs2_glock_dq(&ip->i_iopen_gh);
  564. gfs2_holder_uninit(&ip->i_iopen_gh);
  565. gfs2_glock_dq_uninit(&gh);
  566. if (error && error != GLR_TRYFAILED)
  567. fs_warn(sdp, "gfs2_delete_inode: %d\n", error);
  568. out:
  569. truncate_inode_pages(&inode->i_data, 0);
  570. clear_inode(inode);
  571. }
  572. static struct inode *gfs2_alloc_inode(struct super_block *sb)
  573. {
  574. struct gfs2_inode *ip;
  575. ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL);
  576. if (ip) {
  577. ip->i_flags = 0;
  578. ip->i_gl = NULL;
  579. }
  580. return &ip->i_inode;
  581. }
  582. static void gfs2_destroy_inode(struct inode *inode)
  583. {
  584. kmem_cache_free(gfs2_inode_cachep, inode);
  585. }
  586. const struct super_operations gfs2_super_ops = {
  587. .alloc_inode = gfs2_alloc_inode,
  588. .destroy_inode = gfs2_destroy_inode,
  589. .write_inode = gfs2_write_inode,
  590. .delete_inode = gfs2_delete_inode,
  591. .put_super = gfs2_put_super,
  592. .write_super = gfs2_write_super,
  593. .sync_fs = gfs2_sync_fs,
  594. .freeze_fs = gfs2_freeze,
  595. .unfreeze_fs = gfs2_unfreeze,
  596. .statfs = gfs2_statfs,
  597. .remount_fs = gfs2_remount_fs,
  598. .clear_inode = gfs2_clear_inode,
  599. .drop_inode = gfs2_drop_inode,
  600. .show_options = gfs2_show_options,
  601. };