2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
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 v.2.
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>
15 #include <linux/crc32.h>
16 #include <linux/gfs2_ondisk.h>
19 #include "lm_interface.h"
37 * gfs2_tune_init - Fill a gfs2_tune structure with default values
42 void gfs2_tune_init(struct gfs2_tune *gt)
44 spin_lock_init(>->gt_spin);
47 gt->gt_ilimit_tries = 3;
48 gt->gt_ilimit_min = 1;
49 gt->gt_demote_secs = 300;
50 gt->gt_incore_log_blocks = 1024;
51 gt->gt_log_flush_secs = 60;
52 gt->gt_jindex_refresh_secs = 60;
53 gt->gt_scand_secs = 15;
54 gt->gt_recoverd_secs = 60;
56 gt->gt_quotad_secs = 5;
57 gt->gt_quota_simul_sync = 64;
58 gt->gt_quota_warn_period = 10;
59 gt->gt_quota_scale_num = 1;
60 gt->gt_quota_scale_den = 1;
61 gt->gt_quota_cache_secs = 300;
62 gt->gt_quota_quantum = 60;
63 gt->gt_atime_quantum = 3600;
64 gt->gt_new_files_jdata = 0;
65 gt->gt_new_files_directio = 0;
66 gt->gt_max_atomic_write = 4 << 20;
67 gt->gt_max_readahead = 1 << 18;
68 gt->gt_lockdump_size = 131072;
69 gt->gt_stall_secs = 600;
70 gt->gt_complain_secs = 10;
71 gt->gt_reclaim_limit = 5000;
72 gt->gt_entries_per_readdir = 32;
73 gt->gt_prefetch_secs = 10;
74 gt->gt_greedy_default = HZ / 10;
75 gt->gt_greedy_quantum = HZ / 40;
76 gt->gt_greedy_max = HZ / 4;
77 gt->gt_statfs_quantum = 30;
78 gt->gt_statfs_slow = 0;
82 * gfs2_check_sb - Check superblock
83 * @sdp: the filesystem
85 * @silent: Don't print a message if the check fails
87 * Checks the version code of the FS is one that we understand how to
88 * read and that the sizes of the various on-disk structures have not
92 int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent)
96 if (sb->sb_header.mh_magic != GFS2_MAGIC ||
97 sb->sb_header.mh_type != GFS2_METATYPE_SB) {
99 printk(KERN_WARNING "GFS2: not a GFS2 filesystem\n");
103 /* If format numbers match exactly, we're done. */
105 if (sb->sb_fs_format == GFS2_FORMAT_FS &&
106 sb->sb_multihost_format == GFS2_FORMAT_MULTI)
109 if (sb->sb_fs_format != GFS2_FORMAT_FS) {
110 for (x = 0; gfs2_old_fs_formats[x]; x++)
111 if (gfs2_old_fs_formats[x] == sb->sb_fs_format)
114 if (!gfs2_old_fs_formats[x]) {
116 "GFS2: code version (%u, %u) is incompatible "
117 "with ondisk format (%u, %u)\n",
118 GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
119 sb->sb_fs_format, sb->sb_multihost_format);
121 "GFS2: I don't know how to upgrade this FS\n");
126 if (sb->sb_multihost_format != GFS2_FORMAT_MULTI) {
127 for (x = 0; gfs2_old_multihost_formats[x]; x++)
128 if (gfs2_old_multihost_formats[x] ==
129 sb->sb_multihost_format)
132 if (!gfs2_old_multihost_formats[x]) {
134 "GFS2: code version (%u, %u) is incompatible "
135 "with ondisk format (%u, %u)\n",
136 GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
137 sb->sb_fs_format, sb->sb_multihost_format);
139 "GFS2: I don't know how to upgrade this FS\n");
144 if (!sdp->sd_args.ar_upgrade) {
146 "GFS2: code version (%u, %u) is incompatible "
147 "with ondisk format (%u, %u)\n",
148 GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
149 sb->sb_fs_format, sb->sb_multihost_format);
151 "GFS2: Use the \"upgrade\" mount option to upgrade "
153 printk(KERN_INFO "GFS2: See the manual for more details\n");
161 * gfs2_read_sb - Read super block
162 * @sdp: The GFS2 superblock
163 * @gl: the glock for the superblock (assumed to be held)
164 * @silent: Don't print message if mount fails
168 int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent)
170 struct buffer_head *bh;
171 uint32_t hash_blocks, ind_blocks, leaf_blocks;
176 error = gfs2_meta_read(gl, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift,
177 DIO_FORCE | DIO_START | DIO_WAIT, &bh);
180 fs_err(sdp, "can't read superblock\n");
184 gfs2_assert(sdp, sizeof(struct gfs2_sb) <= bh->b_size);
185 gfs2_sb_in(&sdp->sd_sb, bh->b_data);
188 error = gfs2_check_sb(sdp, &sdp->sd_sb, silent);
192 sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift -
193 GFS2_BASIC_BLOCK_SHIFT;
194 sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift;
195 sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
196 sizeof(struct gfs2_dinode)) / sizeof(uint64_t);
197 sdp->sd_inptrs = (sdp->sd_sb.sb_bsize -
198 sizeof(struct gfs2_meta_header)) / sizeof(uint64_t);
199 sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
200 sdp->sd_hash_bsize = sdp->sd_sb.sb_bsize / 2;
201 sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1;
202 sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t);
203 sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize -
204 sizeof(struct gfs2_meta_header)) /
205 sizeof(struct gfs2_quota_change);
207 /* Compute maximum reservation required to add a entry to a directory */
209 hash_blocks = DIV_ROUND_UP(sizeof(uint64_t) * (1 << GFS2_DIR_MAX_DEPTH),
213 for (tmp_blocks = hash_blocks; tmp_blocks > sdp->sd_diptrs;) {
214 tmp_blocks = DIV_ROUND_UP(tmp_blocks, sdp->sd_inptrs);
215 ind_blocks += tmp_blocks;
218 leaf_blocks = 2 + GFS2_DIR_MAX_DEPTH;
220 sdp->sd_max_dirres = hash_blocks + ind_blocks + leaf_blocks;
222 sdp->sd_heightsize[0] = sdp->sd_sb.sb_bsize -
223 sizeof(struct gfs2_dinode);
224 sdp->sd_heightsize[1] = sdp->sd_sb.sb_bsize * sdp->sd_diptrs;
229 space = sdp->sd_heightsize[x - 1] * sdp->sd_inptrs;
231 m = do_div(d, sdp->sd_inptrs);
233 if (d != sdp->sd_heightsize[x - 1] || m)
235 sdp->sd_heightsize[x] = space;
237 sdp->sd_max_height = x;
238 gfs2_assert(sdp, sdp->sd_max_height <= GFS2_MAX_META_HEIGHT);
240 sdp->sd_jheightsize[0] = sdp->sd_sb.sb_bsize -
241 sizeof(struct gfs2_dinode);
242 sdp->sd_jheightsize[1] = sdp->sd_jbsize * sdp->sd_diptrs;
247 space = sdp->sd_jheightsize[x - 1] * sdp->sd_inptrs;
249 m = do_div(d, sdp->sd_inptrs);
251 if (d != sdp->sd_jheightsize[x - 1] || m)
253 sdp->sd_jheightsize[x] = space;
255 sdp->sd_max_jheight = x;
256 gfs2_assert(sdp, sdp->sd_max_jheight <= GFS2_MAX_META_HEIGHT);
262 * gfs2_jindex_hold - Grab a lock on the jindex
263 * @sdp: The GFS2 superblock
264 * @ji_gh: the holder for the jindex glock
266 * This is very similar to the gfs2_rindex_hold() function, except that
267 * in general we hold the jindex lock for longer periods of time and
268 * we grab it far less frequently (in general) then the rgrp lock.
273 int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
275 struct gfs2_inode *dip = GFS2_I(sdp->sd_jindex);
278 struct gfs2_jdesc *jd;
283 mutex_lock(&sdp->sd_jindex_mutex);
286 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED,
287 GL_LOCAL_EXCL, ji_gh);
291 name.len = sprintf(buf, "journal%u", sdp->sd_journals);
292 name.hash = gfs2_disk_hash(name.name, name.len);
294 error = gfs2_dir_search(sdp->sd_jindex, &name, NULL, NULL);
295 if (error == -ENOENT) {
300 gfs2_glock_dq_uninit(ji_gh);
306 jd = kzalloc(sizeof(struct gfs2_jdesc), GFP_KERNEL);
310 jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1, NULL);
311 if (!jd->jd_inode || IS_ERR(jd->jd_inode)) {
315 error = PTR_ERR(jd->jd_inode);
320 spin_lock(&sdp->sd_jindex_spin);
321 jd->jd_jid = sdp->sd_journals++;
322 list_add_tail(&jd->jd_list, &sdp->sd_jindex_list);
323 spin_unlock(&sdp->sd_jindex_spin);
326 mutex_unlock(&sdp->sd_jindex_mutex);
332 * gfs2_jindex_free - Clear all the journal index information
333 * @sdp: The GFS2 superblock
337 void gfs2_jindex_free(struct gfs2_sbd *sdp)
339 struct list_head list;
340 struct gfs2_jdesc *jd;
342 spin_lock(&sdp->sd_jindex_spin);
343 list_add(&list, &sdp->sd_jindex_list);
344 list_del_init(&sdp->sd_jindex_list);
345 sdp->sd_journals = 0;
346 spin_unlock(&sdp->sd_jindex_spin);
348 while (!list_empty(&list)) {
349 jd = list_entry(list.next, struct gfs2_jdesc, jd_list);
350 list_del(&jd->jd_list);
356 static struct gfs2_jdesc *jdesc_find_i(struct list_head *head, unsigned int jid)
358 struct gfs2_jdesc *jd;
361 list_for_each_entry(jd, head, jd_list) {
362 if (jd->jd_jid == jid) {
374 struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid)
376 struct gfs2_jdesc *jd;
378 spin_lock(&sdp->sd_jindex_spin);
379 jd = jdesc_find_i(&sdp->sd_jindex_list, jid);
380 spin_unlock(&sdp->sd_jindex_spin);
385 void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid)
387 struct gfs2_jdesc *jd;
389 spin_lock(&sdp->sd_jindex_spin);
390 jd = jdesc_find_i(&sdp->sd_jindex_list, jid);
393 spin_unlock(&sdp->sd_jindex_spin);
396 struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp)
398 struct gfs2_jdesc *jd;
401 spin_lock(&sdp->sd_jindex_spin);
403 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
410 spin_unlock(&sdp->sd_jindex_spin);
418 int gfs2_jdesc_check(struct gfs2_jdesc *jd)
420 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
421 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
425 if (ip->i_di.di_size < (8 << 20) || ip->i_di.di_size > (1 << 30) ||
426 (ip->i_di.di_size & (sdp->sd_sb.sb_bsize - 1))) {
427 gfs2_consist_inode(ip);
430 jd->jd_blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift;
432 error = gfs2_write_alloc_required(ip, 0, ip->i_di.di_size, &ar);
434 gfs2_consist_inode(ip);
442 * gfs2_make_fs_rw - Turn a Read-Only FS into a Read-Write one
443 * @sdp: the filesystem
448 int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
450 struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
451 struct gfs2_glock *j_gl = ip->i_gl;
452 struct gfs2_holder t_gh;
453 struct gfs2_log_header head;
456 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED,
457 GL_LOCAL_EXCL, &t_gh);
461 gfs2_meta_cache_flush(ip);
462 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA);
464 error = gfs2_find_jhead(sdp->sd_jdesc, &head);
468 if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
474 /* Initialize some head of the log stuff */
475 sdp->sd_log_sequence = head.lh_sequence + 1;
476 gfs2_log_pointers_init(sdp, head.lh_blkno);
478 error = gfs2_quota_init(sdp);
482 set_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
484 gfs2_glock_dq_uninit(&t_gh);
491 t_gh.gh_flags |= GL_NOCACHE;
492 gfs2_glock_dq_uninit(&t_gh);
498 * gfs2_make_fs_ro - Turn a Read-Write FS into a Read-Only one
499 * @sdp: the filesystem
504 int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
506 struct gfs2_holder t_gh;
509 gfs2_quota_sync(sdp);
510 gfs2_statfs_sync(sdp);
512 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED,
513 GL_LOCAL_EXCL | GL_NOCACHE,
515 if (error && !test_bit(SDF_SHUTDOWN, &sdp->sd_flags))
518 gfs2_meta_syncfs(sdp);
519 gfs2_log_shutdown(sdp);
521 clear_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
524 gfs2_glock_dq_uninit(&t_gh);
526 gfs2_quota_cleanup(sdp);
531 int gfs2_statfs_init(struct gfs2_sbd *sdp)
533 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
534 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
535 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
536 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
537 struct buffer_head *m_bh, *l_bh;
538 struct gfs2_holder gh;
541 error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, GL_NOCACHE,
546 error = gfs2_meta_inode_buffer(m_ip, &m_bh);
550 if (sdp->sd_args.ar_spectator) {
551 spin_lock(&sdp->sd_statfs_spin);
552 gfs2_statfs_change_in(m_sc, m_bh->b_data +
553 sizeof(struct gfs2_dinode));
554 spin_unlock(&sdp->sd_statfs_spin);
556 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
560 spin_lock(&sdp->sd_statfs_spin);
561 gfs2_statfs_change_in(m_sc, m_bh->b_data +
562 sizeof(struct gfs2_dinode));
563 gfs2_statfs_change_in(l_sc, l_bh->b_data +
564 sizeof(struct gfs2_dinode));
565 spin_unlock(&sdp->sd_statfs_spin);
574 gfs2_glock_dq_uninit(&gh);
579 void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free,
582 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
583 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
584 struct buffer_head *l_bh;
587 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
591 mutex_lock(&sdp->sd_statfs_mutex);
592 gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1);
593 mutex_unlock(&sdp->sd_statfs_mutex);
595 spin_lock(&sdp->sd_statfs_spin);
596 l_sc->sc_total += total;
597 l_sc->sc_free += free;
598 l_sc->sc_dinodes += dinodes;
599 gfs2_statfs_change_out(l_sc, l_bh->b_data +
600 sizeof(struct gfs2_dinode));
601 spin_unlock(&sdp->sd_statfs_spin);
606 int gfs2_statfs_sync(struct gfs2_sbd *sdp)
608 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
609 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
610 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
611 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
612 struct gfs2_holder gh;
613 struct buffer_head *m_bh, *l_bh;
616 error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, GL_NOCACHE,
621 error = gfs2_meta_inode_buffer(m_ip, &m_bh);
625 spin_lock(&sdp->sd_statfs_spin);
626 gfs2_statfs_change_in(m_sc, m_bh->b_data +
627 sizeof(struct gfs2_dinode));
628 if (!l_sc->sc_total && !l_sc->sc_free && !l_sc->sc_dinodes) {
629 spin_unlock(&sdp->sd_statfs_spin);
632 spin_unlock(&sdp->sd_statfs_spin);
634 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
638 error = gfs2_trans_begin(sdp, 2 * RES_DINODE, 0);
642 mutex_lock(&sdp->sd_statfs_mutex);
643 gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1);
644 mutex_unlock(&sdp->sd_statfs_mutex);
646 spin_lock(&sdp->sd_statfs_spin);
647 m_sc->sc_total += l_sc->sc_total;
648 m_sc->sc_free += l_sc->sc_free;
649 m_sc->sc_dinodes += l_sc->sc_dinodes;
650 memset(l_sc, 0, sizeof(struct gfs2_statfs_change));
651 memset(l_bh->b_data + sizeof(struct gfs2_dinode),
652 0, sizeof(struct gfs2_statfs_change));
653 spin_unlock(&sdp->sd_statfs_spin);
655 gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1);
656 gfs2_statfs_change_out(m_sc, m_bh->b_data + sizeof(struct gfs2_dinode));
667 gfs2_glock_dq_uninit(&gh);
673 * gfs2_statfs_i - Do a statfs
674 * @sdp: the filesystem
675 * @sg: the sg structure
680 int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
682 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
683 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
685 spin_lock(&sdp->sd_statfs_spin);
688 sc->sc_total += l_sc->sc_total;
689 sc->sc_free += l_sc->sc_free;
690 sc->sc_dinodes += l_sc->sc_dinodes;
692 spin_unlock(&sdp->sd_statfs_spin);
696 if (sc->sc_free > sc->sc_total)
697 sc->sc_free = sc->sc_total;
698 if (sc->sc_dinodes < 0)
705 * statfs_fill - fill in the sg for a given RG
707 * @sc: the sc structure
709 * Returns: 0 on success, -ESTALE if the LVB is invalid
712 static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
713 struct gfs2_statfs_change *sc)
715 gfs2_rgrp_verify(rgd);
716 sc->sc_total += rgd->rd_ri.ri_data;
717 sc->sc_free += rgd->rd_rg.rg_free;
718 sc->sc_dinodes += rgd->rd_rg.rg_dinodes;
723 * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
724 * @sdp: the filesystem
725 * @sc: the sc info that will be returned
727 * Any error (other than a signal) will cause this routine to fall back
728 * to the synchronous version.
730 * FIXME: This really shouldn't busy wait like this.
735 int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
737 struct gfs2_holder ri_gh;
738 struct gfs2_rgrpd *rgd_next;
739 struct gfs2_holder *gha, *gh;
740 unsigned int slots = 64;
745 memset(sc, 0, sizeof(struct gfs2_statfs_change));
746 gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
750 error = gfs2_rindex_hold(sdp, &ri_gh);
754 rgd_next = gfs2_rgrpd_get_first(sdp);
759 for (x = 0; x < slots; x++) {
762 if (gh->gh_gl && gfs2_glock_poll(gh)) {
763 err = gfs2_glock_wait(gh);
765 gfs2_holder_uninit(gh);
769 error = statfs_slow_fill(
770 gh->gh_gl->gl_object, sc);
771 gfs2_glock_dq_uninit(gh);
777 else if (rgd_next && !error) {
778 error = gfs2_glock_nq_init(rgd_next->rd_gl,
782 rgd_next = gfs2_rgrpd_get_next(rgd_next);
786 if (signal_pending(current))
787 error = -ERESTARTSYS;
796 gfs2_glock_dq_uninit(&ri_gh);
805 struct list_head list;
806 struct gfs2_holder gh;
810 * gfs2_lock_fs_check_clean - Stop all writes to the FS and check that all
812 * @sdp: the file system
813 * @state: the state to put the transaction lock into
814 * @t_gh: the hold on the transaction lock
819 static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp,
820 struct gfs2_holder *t_gh)
822 struct gfs2_inode *ip;
823 struct gfs2_holder ji_gh;
824 struct gfs2_jdesc *jd;
827 struct gfs2_log_header lh;
830 error = gfs2_jindex_hold(sdp, &ji_gh);
834 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
835 lfcc = kmalloc(sizeof(struct lfcc), GFP_KERNEL);
840 ip = GFS2_I(jd->jd_inode);
841 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &lfcc->gh);
846 list_add(&lfcc->list, &list);
849 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_DEFERRED,
850 LM_FLAG_PRIORITY | GL_NOCACHE,
853 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
854 error = gfs2_jdesc_check(jd);
857 error = gfs2_find_jhead(jd, &lh);
860 if (!(lh.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
867 gfs2_glock_dq_uninit(t_gh);
870 while (!list_empty(&list)) {
871 lfcc = list_entry(list.next, struct lfcc, list);
872 list_del(&lfcc->list);
873 gfs2_glock_dq_uninit(&lfcc->gh);
876 gfs2_glock_dq_uninit(&ji_gh);
882 * gfs2_freeze_fs - freezes the file system
883 * @sdp: the file system
885 * This function flushes data and meta data for all machines by
886 * aquiring the transaction log exclusively. All journals are
887 * ensured to be in a clean state as well.
892 int gfs2_freeze_fs(struct gfs2_sbd *sdp)
896 mutex_lock(&sdp->sd_freeze_lock);
898 if (!sdp->sd_freeze_count++) {
899 error = gfs2_lock_fs_check_clean(sdp, &sdp->sd_freeze_gh);
901 sdp->sd_freeze_count--;
904 mutex_unlock(&sdp->sd_freeze_lock);
910 * gfs2_unfreeze_fs - unfreezes the file system
911 * @sdp: the file system
913 * This function allows the file system to proceed by unlocking
914 * the exclusively held transaction lock. Other GFS2 nodes are
915 * now free to acquire the lock shared and go on with their lives.
919 void gfs2_unfreeze_fs(struct gfs2_sbd *sdp)
921 mutex_lock(&sdp->sd_freeze_lock);
923 if (sdp->sd_freeze_count && !--sdp->sd_freeze_count)
924 gfs2_glock_dq_uninit(&sdp->sd_freeze_gh);
926 mutex_unlock(&sdp->sd_freeze_lock);