ops_super.c 16 KB

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