glops.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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/spinlock.h>
  10. #include <linux/completion.h>
  11. #include <linux/buffer_head.h>
  12. #include <linux/gfs2_ondisk.h>
  13. #include <linux/bio.h>
  14. #include <linux/posix_acl.h>
  15. #include "gfs2.h"
  16. #include "incore.h"
  17. #include "bmap.h"
  18. #include "glock.h"
  19. #include "glops.h"
  20. #include "inode.h"
  21. #include "log.h"
  22. #include "meta_io.h"
  23. #include "recovery.h"
  24. #include "rgrp.h"
  25. #include "util.h"
  26. #include "trans.h"
  27. #include "dir.h"
  28. struct workqueue_struct *gfs2_freeze_wq;
  29. static void gfs2_ail_error(struct gfs2_glock *gl, const struct buffer_head *bh)
  30. {
  31. fs_err(gl->gl_sbd, "AIL buffer %p: blocknr %llu state 0x%08lx mapping %p page state 0x%lx\n",
  32. bh, (unsigned long long)bh->b_blocknr, bh->b_state,
  33. bh->b_page->mapping, bh->b_page->flags);
  34. fs_err(gl->gl_sbd, "AIL glock %u:%llu mapping %p\n",
  35. gl->gl_name.ln_type, gl->gl_name.ln_number,
  36. gfs2_glock2aspace(gl));
  37. gfs2_lm_withdraw(gl->gl_sbd, "AIL error\n");
  38. }
  39. /**
  40. * __gfs2_ail_flush - remove all buffers for a given lock from the AIL
  41. * @gl: the glock
  42. * @fsync: set when called from fsync (not all buffers will be clean)
  43. *
  44. * None of the buffers should be dirty, locked, or pinned.
  45. */
  46. static void __gfs2_ail_flush(struct gfs2_glock *gl, bool fsync,
  47. unsigned int nr_revokes)
  48. {
  49. struct gfs2_sbd *sdp = gl->gl_sbd;
  50. struct list_head *head = &gl->gl_ail_list;
  51. struct gfs2_bufdata *bd, *tmp;
  52. struct buffer_head *bh;
  53. const unsigned long b_state = (1UL << BH_Dirty)|(1UL << BH_Pinned)|(1UL << BH_Lock);
  54. gfs2_log_lock(sdp);
  55. spin_lock(&sdp->sd_ail_lock);
  56. list_for_each_entry_safe_reverse(bd, tmp, head, bd_ail_gl_list) {
  57. if (nr_revokes == 0)
  58. break;
  59. bh = bd->bd_bh;
  60. if (bh->b_state & b_state) {
  61. if (fsync)
  62. continue;
  63. gfs2_ail_error(gl, bh);
  64. }
  65. gfs2_trans_add_revoke(sdp, bd);
  66. nr_revokes--;
  67. }
  68. GLOCK_BUG_ON(gl, !fsync && atomic_read(&gl->gl_ail_count));
  69. spin_unlock(&sdp->sd_ail_lock);
  70. gfs2_log_unlock(sdp);
  71. }
  72. static void gfs2_ail_empty_gl(struct gfs2_glock *gl)
  73. {
  74. struct gfs2_sbd *sdp = gl->gl_sbd;
  75. struct gfs2_trans tr;
  76. memset(&tr, 0, sizeof(tr));
  77. INIT_LIST_HEAD(&tr.tr_buf);
  78. INIT_LIST_HEAD(&tr.tr_databuf);
  79. tr.tr_revokes = atomic_read(&gl->gl_ail_count);
  80. if (!tr.tr_revokes)
  81. return;
  82. /* A shortened, inline version of gfs2_trans_begin()
  83. * tr->alloced is not set since the transaction structure is
  84. * on the stack */
  85. tr.tr_reserved = 1 + gfs2_struct2blk(sdp, tr.tr_revokes, sizeof(u64));
  86. tr.tr_ip = _RET_IP_;
  87. if (gfs2_log_reserve(sdp, tr.tr_reserved) < 0)
  88. return;
  89. WARN_ON_ONCE(current->journal_info);
  90. current->journal_info = &tr;
  91. __gfs2_ail_flush(gl, 0, tr.tr_revokes);
  92. gfs2_trans_end(sdp);
  93. gfs2_log_flush(sdp, NULL, NORMAL_FLUSH);
  94. }
  95. void gfs2_ail_flush(struct gfs2_glock *gl, bool fsync)
  96. {
  97. struct gfs2_sbd *sdp = gl->gl_sbd;
  98. unsigned int revokes = atomic_read(&gl->gl_ail_count);
  99. unsigned int max_revokes = (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_log_descriptor)) / sizeof(u64);
  100. int ret;
  101. if (!revokes)
  102. return;
  103. while (revokes > max_revokes)
  104. max_revokes += (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header)) / sizeof(u64);
  105. ret = gfs2_trans_begin(sdp, 0, max_revokes);
  106. if (ret)
  107. return;
  108. __gfs2_ail_flush(gl, fsync, max_revokes);
  109. gfs2_trans_end(sdp);
  110. gfs2_log_flush(sdp, NULL, NORMAL_FLUSH);
  111. }
  112. /**
  113. * rgrp_go_sync - sync out the metadata for this glock
  114. * @gl: the glock
  115. *
  116. * Called when demoting or unlocking an EX glock. We must flush
  117. * to disk all dirty buffers/pages relating to this glock, and must not
  118. * not return to caller to demote/unlock the glock until I/O is complete.
  119. */
  120. static void rgrp_go_sync(struct gfs2_glock *gl)
  121. {
  122. struct gfs2_sbd *sdp = gl->gl_sbd;
  123. struct address_space *mapping = &sdp->sd_aspace;
  124. struct gfs2_rgrpd *rgd;
  125. int error;
  126. spin_lock(&gl->gl_spin);
  127. rgd = gl->gl_object;
  128. if (rgd)
  129. gfs2_rgrp_brelse(rgd);
  130. spin_unlock(&gl->gl_spin);
  131. if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
  132. return;
  133. GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_EXCLUSIVE);
  134. gfs2_log_flush(sdp, gl, NORMAL_FLUSH);
  135. filemap_fdatawrite_range(mapping, gl->gl_vm.start, gl->gl_vm.end);
  136. error = filemap_fdatawait_range(mapping, gl->gl_vm.start, gl->gl_vm.end);
  137. mapping_set_error(mapping, error);
  138. gfs2_ail_empty_gl(gl);
  139. spin_lock(&gl->gl_spin);
  140. rgd = gl->gl_object;
  141. if (rgd)
  142. gfs2_free_clones(rgd);
  143. spin_unlock(&gl->gl_spin);
  144. }
  145. /**
  146. * rgrp_go_inval - invalidate the metadata for this glock
  147. * @gl: the glock
  148. * @flags:
  149. *
  150. * We never used LM_ST_DEFERRED with resource groups, so that we
  151. * should always see the metadata flag set here.
  152. *
  153. */
  154. static void rgrp_go_inval(struct gfs2_glock *gl, int flags)
  155. {
  156. struct gfs2_sbd *sdp = gl->gl_sbd;
  157. struct address_space *mapping = &sdp->sd_aspace;
  158. struct gfs2_rgrpd *rgd = gl->gl_object;
  159. if (rgd)
  160. gfs2_rgrp_brelse(rgd);
  161. WARN_ON_ONCE(!(flags & DIO_METADATA));
  162. gfs2_assert_withdraw(sdp, !atomic_read(&gl->gl_ail_count));
  163. truncate_inode_pages_range(mapping, gl->gl_vm.start, gl->gl_vm.end);
  164. if (rgd)
  165. rgd->rd_flags &= ~GFS2_RDF_UPTODATE;
  166. }
  167. /**
  168. * inode_go_sync - Sync the dirty data and/or metadata for an inode glock
  169. * @gl: the glock protecting the inode
  170. *
  171. */
  172. static void inode_go_sync(struct gfs2_glock *gl)
  173. {
  174. struct gfs2_inode *ip = gl->gl_object;
  175. struct address_space *metamapping = gfs2_glock2aspace(gl);
  176. int error;
  177. if (ip && !S_ISREG(ip->i_inode.i_mode))
  178. ip = NULL;
  179. if (ip) {
  180. if (test_and_clear_bit(GIF_SW_PAGED, &ip->i_flags))
  181. unmap_shared_mapping_range(ip->i_inode.i_mapping, 0, 0);
  182. inode_dio_wait(&ip->i_inode);
  183. }
  184. if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
  185. return;
  186. GLOCK_BUG_ON(gl, gl->gl_state != LM_ST_EXCLUSIVE);
  187. gfs2_log_flush(gl->gl_sbd, gl, NORMAL_FLUSH);
  188. filemap_fdatawrite(metamapping);
  189. if (ip) {
  190. struct address_space *mapping = ip->i_inode.i_mapping;
  191. filemap_fdatawrite(mapping);
  192. error = filemap_fdatawait(mapping);
  193. mapping_set_error(mapping, error);
  194. }
  195. error = filemap_fdatawait(metamapping);
  196. mapping_set_error(metamapping, error);
  197. gfs2_ail_empty_gl(gl);
  198. /*
  199. * Writeback of the data mapping may cause the dirty flag to be set
  200. * so we have to clear it again here.
  201. */
  202. smp_mb__before_atomic();
  203. clear_bit(GLF_DIRTY, &gl->gl_flags);
  204. }
  205. /**
  206. * inode_go_inval - prepare a inode glock to be released
  207. * @gl: the glock
  208. * @flags:
  209. *
  210. * Normally we invalidate everything, but if we are moving into
  211. * LM_ST_DEFERRED from LM_ST_SHARED or LM_ST_EXCLUSIVE then we
  212. * can keep hold of the metadata, since it won't have changed.
  213. *
  214. */
  215. static void inode_go_inval(struct gfs2_glock *gl, int flags)
  216. {
  217. struct gfs2_inode *ip = gl->gl_object;
  218. gfs2_assert_withdraw(gl->gl_sbd, !atomic_read(&gl->gl_ail_count));
  219. if (flags & DIO_METADATA) {
  220. struct address_space *mapping = gfs2_glock2aspace(gl);
  221. truncate_inode_pages(mapping, 0);
  222. if (ip) {
  223. set_bit(GIF_INVALID, &ip->i_flags);
  224. forget_all_cached_acls(&ip->i_inode);
  225. gfs2_dir_hash_inval(ip);
  226. }
  227. }
  228. if (ip == GFS2_I(gl->gl_sbd->sd_rindex)) {
  229. gfs2_log_flush(gl->gl_sbd, NULL, NORMAL_FLUSH);
  230. gl->gl_sbd->sd_rindex_uptodate = 0;
  231. }
  232. if (ip && S_ISREG(ip->i_inode.i_mode))
  233. truncate_inode_pages(ip->i_inode.i_mapping, 0);
  234. }
  235. /**
  236. * inode_go_demote_ok - Check to see if it's ok to unlock an inode glock
  237. * @gl: the glock
  238. *
  239. * Returns: 1 if it's ok
  240. */
  241. static int inode_go_demote_ok(const struct gfs2_glock *gl)
  242. {
  243. struct gfs2_sbd *sdp = gl->gl_sbd;
  244. struct gfs2_holder *gh;
  245. if (sdp->sd_jindex == gl->gl_object || sdp->sd_rindex == gl->gl_object)
  246. return 0;
  247. if (!list_empty(&gl->gl_holders)) {
  248. gh = list_entry(gl->gl_holders.next, struct gfs2_holder, gh_list);
  249. if (gh->gh_list.next != &gl->gl_holders)
  250. return 0;
  251. }
  252. return 1;
  253. }
  254. /**
  255. * gfs2_set_nlink - Set the inode's link count based on on-disk info
  256. * @inode: The inode in question
  257. * @nlink: The link count
  258. *
  259. * If the link count has hit zero, it must never be raised, whatever the
  260. * on-disk inode might say. When new struct inodes are created the link
  261. * count is set to 1, so that we can safely use this test even when reading
  262. * in on disk information for the first time.
  263. */
  264. static void gfs2_set_nlink(struct inode *inode, u32 nlink)
  265. {
  266. /*
  267. * We will need to review setting the nlink count here in the
  268. * light of the forthcoming ro bind mount work. This is a reminder
  269. * to do that.
  270. */
  271. if ((inode->i_nlink != nlink) && (inode->i_nlink != 0)) {
  272. if (nlink == 0)
  273. clear_nlink(inode);
  274. else
  275. set_nlink(inode, nlink);
  276. }
  277. }
  278. static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
  279. {
  280. const struct gfs2_dinode *str = buf;
  281. struct timespec atime;
  282. u16 height, depth;
  283. if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr)))
  284. goto corrupt;
  285. ip->i_no_formal_ino = be64_to_cpu(str->di_num.no_formal_ino);
  286. ip->i_inode.i_mode = be32_to_cpu(str->di_mode);
  287. ip->i_inode.i_rdev = 0;
  288. switch (ip->i_inode.i_mode & S_IFMT) {
  289. case S_IFBLK:
  290. case S_IFCHR:
  291. ip->i_inode.i_rdev = MKDEV(be32_to_cpu(str->di_major),
  292. be32_to_cpu(str->di_minor));
  293. break;
  294. };
  295. i_uid_write(&ip->i_inode, be32_to_cpu(str->di_uid));
  296. i_gid_write(&ip->i_inode, be32_to_cpu(str->di_gid));
  297. gfs2_set_nlink(&ip->i_inode, be32_to_cpu(str->di_nlink));
  298. i_size_write(&ip->i_inode, be64_to_cpu(str->di_size));
  299. gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks));
  300. atime.tv_sec = be64_to_cpu(str->di_atime);
  301. atime.tv_nsec = be32_to_cpu(str->di_atime_nsec);
  302. if (timespec_compare(&ip->i_inode.i_atime, &atime) < 0)
  303. ip->i_inode.i_atime = atime;
  304. ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
  305. ip->i_inode.i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec);
  306. ip->i_inode.i_ctime.tv_sec = be64_to_cpu(str->di_ctime);
  307. ip->i_inode.i_ctime.tv_nsec = be32_to_cpu(str->di_ctime_nsec);
  308. ip->i_goal = be64_to_cpu(str->di_goal_meta);
  309. ip->i_generation = be64_to_cpu(str->di_generation);
  310. ip->i_diskflags = be32_to_cpu(str->di_flags);
  311. ip->i_eattr = be64_to_cpu(str->di_eattr);
  312. /* i_diskflags and i_eattr must be set before gfs2_set_inode_flags() */
  313. gfs2_set_inode_flags(&ip->i_inode);
  314. height = be16_to_cpu(str->di_height);
  315. if (unlikely(height > GFS2_MAX_META_HEIGHT))
  316. goto corrupt;
  317. ip->i_height = (u8)height;
  318. depth = be16_to_cpu(str->di_depth);
  319. if (unlikely(depth > GFS2_DIR_MAX_DEPTH))
  320. goto corrupt;
  321. ip->i_depth = (u8)depth;
  322. ip->i_entries = be32_to_cpu(str->di_entries);
  323. if (S_ISREG(ip->i_inode.i_mode))
  324. gfs2_set_aops(&ip->i_inode);
  325. return 0;
  326. corrupt:
  327. gfs2_consist_inode(ip);
  328. return -EIO;
  329. }
  330. /**
  331. * gfs2_inode_refresh - Refresh the incore copy of the dinode
  332. * @ip: The GFS2 inode
  333. *
  334. * Returns: errno
  335. */
  336. int gfs2_inode_refresh(struct gfs2_inode *ip)
  337. {
  338. struct buffer_head *dibh;
  339. int error;
  340. error = gfs2_meta_inode_buffer(ip, &dibh);
  341. if (error)
  342. return error;
  343. error = gfs2_dinode_in(ip, dibh->b_data);
  344. brelse(dibh);
  345. clear_bit(GIF_INVALID, &ip->i_flags);
  346. return error;
  347. }
  348. /**
  349. * inode_go_lock - operation done after an inode lock is locked by a process
  350. * @gl: the glock
  351. * @flags:
  352. *
  353. * Returns: errno
  354. */
  355. static int inode_go_lock(struct gfs2_holder *gh)
  356. {
  357. struct gfs2_glock *gl = gh->gh_gl;
  358. struct gfs2_sbd *sdp = gl->gl_sbd;
  359. struct gfs2_inode *ip = gl->gl_object;
  360. int error = 0;
  361. if (!ip || (gh->gh_flags & GL_SKIP))
  362. return 0;
  363. if (test_bit(GIF_INVALID, &ip->i_flags)) {
  364. error = gfs2_inode_refresh(ip);
  365. if (error)
  366. return error;
  367. }
  368. if (gh->gh_state != LM_ST_DEFERRED)
  369. inode_dio_wait(&ip->i_inode);
  370. if ((ip->i_diskflags & GFS2_DIF_TRUNC_IN_PROG) &&
  371. (gl->gl_state == LM_ST_EXCLUSIVE) &&
  372. (gh->gh_state == LM_ST_EXCLUSIVE)) {
  373. spin_lock(&sdp->sd_trunc_lock);
  374. if (list_empty(&ip->i_trunc_list))
  375. list_add(&sdp->sd_trunc_list, &ip->i_trunc_list);
  376. spin_unlock(&sdp->sd_trunc_lock);
  377. wake_up(&sdp->sd_quota_wait);
  378. return 1;
  379. }
  380. return error;
  381. }
  382. /**
  383. * inode_go_dump - print information about an inode
  384. * @seq: The iterator
  385. * @ip: the inode
  386. *
  387. */
  388. static void inode_go_dump(struct seq_file *seq, const struct gfs2_glock *gl)
  389. {
  390. const struct gfs2_inode *ip = gl->gl_object;
  391. if (ip == NULL)
  392. return;
  393. gfs2_print_dbg(seq, " I: n:%llu/%llu t:%u f:0x%02lx d:0x%08x s:%llu\n",
  394. (unsigned long long)ip->i_no_formal_ino,
  395. (unsigned long long)ip->i_no_addr,
  396. IF2DT(ip->i_inode.i_mode), ip->i_flags,
  397. (unsigned int)ip->i_diskflags,
  398. (unsigned long long)i_size_read(&ip->i_inode));
  399. }
  400. /**
  401. * freeze_go_sync - promote/demote the freeze glock
  402. * @gl: the glock
  403. * @state: the requested state
  404. * @flags:
  405. *
  406. */
  407. static void freeze_go_sync(struct gfs2_glock *gl)
  408. {
  409. int error = 0;
  410. struct gfs2_sbd *sdp = gl->gl_sbd;
  411. if (gl->gl_state == LM_ST_SHARED &&
  412. test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
  413. atomic_set(&sdp->sd_freeze_state, SFS_STARTING_FREEZE);
  414. error = freeze_super(sdp->sd_vfs);
  415. if (error) {
  416. printk(KERN_INFO "GFS2: couldn't freeze filesystem: %d\n", error);
  417. gfs2_assert_withdraw(sdp, 0);
  418. }
  419. queue_work(gfs2_freeze_wq, &sdp->sd_freeze_work);
  420. gfs2_log_flush(sdp, NULL, FREEZE_FLUSH);
  421. }
  422. }
  423. /**
  424. * freeze_go_xmote_bh - After promoting/demoting the freeze glock
  425. * @gl: the glock
  426. *
  427. */
  428. static int freeze_go_xmote_bh(struct gfs2_glock *gl, struct gfs2_holder *gh)
  429. {
  430. struct gfs2_sbd *sdp = gl->gl_sbd;
  431. struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
  432. struct gfs2_glock *j_gl = ip->i_gl;
  433. struct gfs2_log_header_host head;
  434. int error;
  435. if (test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
  436. j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
  437. error = gfs2_find_jhead(sdp->sd_jdesc, &head);
  438. if (error)
  439. gfs2_consist(sdp);
  440. if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT))
  441. gfs2_consist(sdp);
  442. /* Initialize some head of the log stuff */
  443. if (!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) {
  444. sdp->sd_log_sequence = head.lh_sequence + 1;
  445. gfs2_log_pointers_init(sdp, head.lh_blkno);
  446. }
  447. }
  448. return 0;
  449. }
  450. /**
  451. * trans_go_demote_ok
  452. * @gl: the glock
  453. *
  454. * Always returns 0
  455. */
  456. static int freeze_go_demote_ok(const struct gfs2_glock *gl)
  457. {
  458. return 0;
  459. }
  460. /**
  461. * iopen_go_callback - schedule the dcache entry for the inode to be deleted
  462. * @gl: the glock
  463. *
  464. * gl_spin lock is held while calling this
  465. */
  466. static void iopen_go_callback(struct gfs2_glock *gl, bool remote)
  467. {
  468. struct gfs2_inode *ip = (struct gfs2_inode *)gl->gl_object;
  469. struct gfs2_sbd *sdp = gl->gl_sbd;
  470. if (!remote || (sdp->sd_vfs->s_flags & MS_RDONLY))
  471. return;
  472. if (gl->gl_demote_state == LM_ST_UNLOCKED &&
  473. gl->gl_state == LM_ST_SHARED && ip) {
  474. gl->gl_lockref.count++;
  475. if (queue_work(gfs2_delete_workqueue, &gl->gl_delete) == 0)
  476. gl->gl_lockref.count--;
  477. }
  478. }
  479. const struct gfs2_glock_operations gfs2_meta_glops = {
  480. .go_type = LM_TYPE_META,
  481. };
  482. const struct gfs2_glock_operations gfs2_inode_glops = {
  483. .go_sync = inode_go_sync,
  484. .go_inval = inode_go_inval,
  485. .go_demote_ok = inode_go_demote_ok,
  486. .go_lock = inode_go_lock,
  487. .go_dump = inode_go_dump,
  488. .go_type = LM_TYPE_INODE,
  489. .go_flags = GLOF_ASPACE | GLOF_LRU,
  490. };
  491. const struct gfs2_glock_operations gfs2_rgrp_glops = {
  492. .go_sync = rgrp_go_sync,
  493. .go_inval = rgrp_go_inval,
  494. .go_lock = gfs2_rgrp_go_lock,
  495. .go_unlock = gfs2_rgrp_go_unlock,
  496. .go_dump = gfs2_rgrp_dump,
  497. .go_type = LM_TYPE_RGRP,
  498. .go_flags = GLOF_LVB,
  499. };
  500. const struct gfs2_glock_operations gfs2_freeze_glops = {
  501. .go_sync = freeze_go_sync,
  502. .go_xmote_bh = freeze_go_xmote_bh,
  503. .go_demote_ok = freeze_go_demote_ok,
  504. .go_type = LM_TYPE_NONDISK,
  505. };
  506. const struct gfs2_glock_operations gfs2_iopen_glops = {
  507. .go_type = LM_TYPE_IOPEN,
  508. .go_callback = iopen_go_callback,
  509. .go_flags = GLOF_LRU,
  510. };
  511. const struct gfs2_glock_operations gfs2_flock_glops = {
  512. .go_type = LM_TYPE_FLOCK,
  513. .go_flags = GLOF_LRU,
  514. };
  515. const struct gfs2_glock_operations gfs2_nondisk_glops = {
  516. .go_type = LM_TYPE_NONDISK,
  517. };
  518. const struct gfs2_glock_operations gfs2_quota_glops = {
  519. .go_type = LM_TYPE_QUOTA,
  520. .go_flags = GLOF_LVB | GLOF_LRU,
  521. };
  522. const struct gfs2_glock_operations gfs2_journal_glops = {
  523. .go_type = LM_TYPE_JOURNAL,
  524. };
  525. const struct gfs2_glock_operations *gfs2_glops_list[] = {
  526. [LM_TYPE_META] = &gfs2_meta_glops,
  527. [LM_TYPE_INODE] = &gfs2_inode_glops,
  528. [LM_TYPE_RGRP] = &gfs2_rgrp_glops,
  529. [LM_TYPE_IOPEN] = &gfs2_iopen_glops,
  530. [LM_TYPE_FLOCK] = &gfs2_flock_glops,
  531. [LM_TYPE_NONDISK] = &gfs2_nondisk_glops,
  532. [LM_TYPE_QUOTA] = &gfs2_quota_glops,
  533. [LM_TYPE_JOURNAL] = &gfs2_journal_glops,
  534. };