2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2005 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>
17 #include <asm/semaphore.h>
20 #include "lm_interface.h"
39 * gfs2_tune_init - Fill a gfs2_tune structure with default values
44 void gfs2_tune_init(struct gfs2_tune *gt)
46 spin_lock_init(>->gt_spin);
49 gt->gt_ilimit_tries = 3;
50 gt->gt_ilimit_min = 1;
51 gt->gt_demote_secs = 300;
52 gt->gt_incore_log_blocks = 1024;
53 gt->gt_log_flush_secs = 60;
54 gt->gt_jindex_refresh_secs = 60;
55 gt->gt_scand_secs = 15;
56 gt->gt_recoverd_secs = 60;
58 gt->gt_quotad_secs = 5;
59 gt->gt_inoded_secs = 15;
60 gt->gt_quota_simul_sync = 64;
61 gt->gt_quota_warn_period = 10;
62 gt->gt_quota_scale_num = 1;
63 gt->gt_quota_scale_den = 1;
64 gt->gt_quota_cache_secs = 300;
65 gt->gt_quota_quantum = 60;
66 gt->gt_atime_quantum = 3600;
67 gt->gt_new_files_jdata = 0;
68 gt->gt_new_files_directio = 0;
69 gt->gt_max_atomic_write = 4 << 20;
70 gt->gt_max_readahead = 1 << 18;
71 gt->gt_lockdump_size = 131072;
72 gt->gt_stall_secs = 600;
73 gt->gt_complain_secs = 10;
74 gt->gt_reclaim_limit = 5000;
75 gt->gt_entries_per_readdir = 32;
76 gt->gt_prefetch_secs = 10;
77 gt->gt_greedy_default = HZ / 10;
78 gt->gt_greedy_quantum = HZ / 40;
79 gt->gt_greedy_max = HZ / 4;
80 gt->gt_statfs_quantum = 30;
81 gt->gt_statfs_slow = 0;
85 * gfs2_check_sb - Check superblock
86 * @sdp: the filesystem
88 * @silent: Don't print a message if the check fails
90 * Checks the version code of the FS is one that we understand how to
91 * read and that the sizes of the various on-disk structures have not
95 int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent)
99 if (sb->sb_header.mh_magic != GFS2_MAGIC ||
100 sb->sb_header.mh_type != GFS2_METATYPE_SB) {
102 printk(KERN_WARNING "GFS2: not a GFS2 filesystem\n");
106 /* If format numbers match exactly, we're done. */
108 if (sb->sb_fs_format == GFS2_FORMAT_FS &&
109 sb->sb_multihost_format == GFS2_FORMAT_MULTI)
112 if (sb->sb_fs_format != GFS2_FORMAT_FS) {
113 for (x = 0; gfs2_old_fs_formats[x]; x++)
114 if (gfs2_old_fs_formats[x] == sb->sb_fs_format)
117 if (!gfs2_old_fs_formats[x]) {
119 "GFS2: code version (%u, %u) is incompatible "
120 "with ondisk format (%u, %u)\n",
121 GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
122 sb->sb_fs_format, sb->sb_multihost_format);
124 "GFS2: I don't know how to upgrade this FS\n");
129 if (sb->sb_multihost_format != GFS2_FORMAT_MULTI) {
130 for (x = 0; gfs2_old_multihost_formats[x]; x++)
131 if (gfs2_old_multihost_formats[x] ==
132 sb->sb_multihost_format)
135 if (!gfs2_old_multihost_formats[x]) {
137 "GFS2: code version (%u, %u) is incompatible "
138 "with ondisk format (%u, %u)\n",
139 GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
140 sb->sb_fs_format, sb->sb_multihost_format);
142 "GFS2: I don't know how to upgrade this FS\n");
147 if (!sdp->sd_args.ar_upgrade) {
149 "GFS2: code version (%u, %u) is incompatible "
150 "with ondisk format (%u, %u)\n",
151 GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
152 sb->sb_fs_format, sb->sb_multihost_format);
154 "GFS2: Use the \"upgrade\" mount option to upgrade "
156 printk(KERN_INFO "GFS2: See the manual for more details\n");
164 * gfs2_read_sb - Read super block
165 * @sdp: The GFS2 superblock
166 * @gl: the glock for the superblock (assumed to be held)
167 * @silent: Don't print message if mount fails
171 int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent)
173 struct buffer_head *bh;
174 uint32_t hash_blocks, ind_blocks, leaf_blocks;
179 error = gfs2_meta_read(gl, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift,
180 DIO_FORCE | DIO_START | DIO_WAIT, &bh);
183 fs_err(sdp, "can't read superblock\n");
187 gfs2_assert(sdp, sizeof(struct gfs2_sb) <= bh->b_size);
188 gfs2_sb_in(&sdp->sd_sb, bh->b_data);
191 error = gfs2_check_sb(sdp, &sdp->sd_sb, silent);
195 sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift -
196 GFS2_BASIC_BLOCK_SHIFT;
197 sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift;
198 sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
199 sizeof(struct gfs2_dinode)) / sizeof(uint64_t);
200 sdp->sd_inptrs = (sdp->sd_sb.sb_bsize -
201 sizeof(struct gfs2_meta_header)) / sizeof(uint64_t);
202 sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
203 sdp->sd_hash_bsize = sdp->sd_sb.sb_bsize / 2;
204 sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1;
205 sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t);
206 sdp->sd_ut_per_block = (sdp->sd_sb.sb_bsize -
207 sizeof(struct gfs2_meta_header)) /
208 sizeof(struct gfs2_unlinked_tag);
209 sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize -
210 sizeof(struct gfs2_meta_header)) /
211 sizeof(struct gfs2_quota_change);
213 /* Compute maximum reservation required to add a entry to a directory */
215 hash_blocks = DIV_ROUND_UP(sizeof(uint64_t) * (1 << GFS2_DIR_MAX_DEPTH),
219 for (tmp_blocks = hash_blocks; tmp_blocks > sdp->sd_diptrs;) {
220 tmp_blocks = DIV_ROUND_UP(tmp_blocks, sdp->sd_inptrs);
221 ind_blocks += tmp_blocks;
224 leaf_blocks = 2 + GFS2_DIR_MAX_DEPTH;
226 sdp->sd_max_dirres = hash_blocks + ind_blocks + leaf_blocks;
228 sdp->sd_heightsize[0] = sdp->sd_sb.sb_bsize -
229 sizeof(struct gfs2_dinode);
230 sdp->sd_heightsize[1] = sdp->sd_sb.sb_bsize * sdp->sd_diptrs;
235 space = sdp->sd_heightsize[x - 1] * sdp->sd_inptrs;
237 m = do_div(d, sdp->sd_inptrs);
239 if (d != sdp->sd_heightsize[x - 1] || m)
241 sdp->sd_heightsize[x] = space;
243 sdp->sd_max_height = x;
244 gfs2_assert(sdp, sdp->sd_max_height <= GFS2_MAX_META_HEIGHT);
246 sdp->sd_jheightsize[0] = sdp->sd_sb.sb_bsize -
247 sizeof(struct gfs2_dinode);
248 sdp->sd_jheightsize[1] = sdp->sd_jbsize * sdp->sd_diptrs;
253 space = sdp->sd_jheightsize[x - 1] * sdp->sd_inptrs;
255 m = do_div(d, sdp->sd_inptrs);
257 if (d != sdp->sd_jheightsize[x - 1] || m)
259 sdp->sd_jheightsize[x] = space;
261 sdp->sd_max_jheight = x;
262 gfs2_assert(sdp, sdp->sd_max_jheight <= GFS2_MAX_META_HEIGHT);
268 * gfs2_jindex_hold - Grab a lock on the jindex
269 * @sdp: The GFS2 superblock
270 * @ji_gh: the holder for the jindex glock
272 * This is very similar to the gfs2_rindex_hold() function, except that
273 * in general we hold the jindex lock for longer periods of time and
274 * we grab it far less frequently (in general) then the rgrp lock.
279 int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
281 struct gfs2_inode *dip = sdp->sd_jindex->u.generic_ip;
284 struct gfs2_jdesc *jd;
289 mutex_lock(&sdp->sd_jindex_mutex);
292 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED,
293 GL_LOCAL_EXCL, ji_gh);
297 name.len = sprintf(buf, "journal%u", sdp->sd_journals);
298 name.hash = gfs2_disk_hash(name.name, name.len);
300 error = gfs2_dir_search(sdp->sd_jindex,
302 if (error == -ENOENT) {
307 gfs2_glock_dq_uninit(ji_gh);
313 jd = kzalloc(sizeof(struct gfs2_jdesc), GFP_KERNEL);
317 jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1, NULL);
318 if (!jd->jd_inode || IS_ERR(jd->jd_inode)) {
322 error = PTR_ERR(jd->jd_inode);
327 spin_lock(&sdp->sd_jindex_spin);
328 jd->jd_jid = sdp->sd_journals++;
329 list_add_tail(&jd->jd_list, &sdp->sd_jindex_list);
330 spin_unlock(&sdp->sd_jindex_spin);
333 mutex_unlock(&sdp->sd_jindex_mutex);
339 * gfs2_jindex_free - Clear all the journal index information
340 * @sdp: The GFS2 superblock
344 void gfs2_jindex_free(struct gfs2_sbd *sdp)
346 struct list_head list;
347 struct gfs2_jdesc *jd;
349 spin_lock(&sdp->sd_jindex_spin);
350 list_add(&list, &sdp->sd_jindex_list);
351 list_del_init(&sdp->sd_jindex_list);
352 sdp->sd_journals = 0;
353 spin_unlock(&sdp->sd_jindex_spin);
355 while (!list_empty(&list)) {
356 jd = list_entry(list.next, struct gfs2_jdesc, jd_list);
357 list_del(&jd->jd_list);
363 static struct gfs2_jdesc *jdesc_find_i(struct list_head *head, unsigned int jid)
365 struct gfs2_jdesc *jd;
368 list_for_each_entry(jd, head, jd_list) {
369 if (jd->jd_jid == jid) {
381 struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid)
383 struct gfs2_jdesc *jd;
385 spin_lock(&sdp->sd_jindex_spin);
386 jd = jdesc_find_i(&sdp->sd_jindex_list, jid);
387 spin_unlock(&sdp->sd_jindex_spin);
392 void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid)
394 struct gfs2_jdesc *jd;
396 spin_lock(&sdp->sd_jindex_spin);
397 jd = jdesc_find_i(&sdp->sd_jindex_list, jid);
400 spin_unlock(&sdp->sd_jindex_spin);
403 struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp)
405 struct gfs2_jdesc *jd;
408 spin_lock(&sdp->sd_jindex_spin);
410 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
417 spin_unlock(&sdp->sd_jindex_spin);
425 int gfs2_jdesc_check(struct gfs2_jdesc *jd)
427 struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
428 struct gfs2_sbd *sdp = ip->i_sbd;
432 if (ip->i_di.di_size < (8 << 20) ||
433 ip->i_di.di_size > (1 << 30) ||
434 (ip->i_di.di_size & (sdp->sd_sb.sb_bsize - 1))) {
435 gfs2_consist_inode(ip);
438 jd->jd_blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift;
440 error = gfs2_write_alloc_required(ip,
444 gfs2_consist_inode(ip);
452 * gfs2_make_fs_rw - Turn a Read-Only FS into a Read-Write one
453 * @sdp: the filesystem
458 int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
460 struct gfs2_inode *ip = sdp->sd_jdesc->jd_inode->u.generic_ip;
461 struct gfs2_glock *j_gl = ip->i_gl;
462 struct gfs2_holder t_gh;
463 struct gfs2_log_header head;
466 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED,
467 GL_LOCAL_EXCL, &t_gh);
471 gfs2_meta_cache_flush(ip);
472 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA);
474 error = gfs2_find_jhead(sdp->sd_jdesc, &head);
478 if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
484 /* Initialize some head of the log stuff */
485 sdp->sd_log_sequence = head.lh_sequence + 1;
486 gfs2_log_pointers_init(sdp, head.lh_blkno);
488 error = gfs2_unlinked_init(sdp);
491 error = gfs2_quota_init(sdp);
495 set_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
497 gfs2_glock_dq_uninit(&t_gh);
502 gfs2_unlinked_cleanup(sdp);
505 t_gh.gh_flags |= GL_NOCACHE;
506 gfs2_glock_dq_uninit(&t_gh);
512 * gfs2_make_fs_ro - Turn a Read-Write FS into a Read-Only one
513 * @sdp: the filesystem
518 int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
520 struct gfs2_holder t_gh;
523 gfs2_unlinked_dealloc(sdp);
524 gfs2_quota_sync(sdp);
525 gfs2_statfs_sync(sdp);
527 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED,
528 GL_LOCAL_EXCL | GL_NOCACHE,
530 if (error && !test_bit(SDF_SHUTDOWN, &sdp->sd_flags))
533 gfs2_meta_syncfs(sdp);
534 gfs2_log_shutdown(sdp);
536 clear_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
539 gfs2_glock_dq_uninit(&t_gh);
541 gfs2_unlinked_cleanup(sdp);
542 gfs2_quota_cleanup(sdp);
547 int gfs2_statfs_init(struct gfs2_sbd *sdp)
549 struct gfs2_inode *m_ip = sdp->sd_statfs_inode->u.generic_ip;
550 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
551 struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip;
552 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
553 struct buffer_head *m_bh, *l_bh;
554 struct gfs2_holder gh;
557 error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, GL_NOCACHE,
562 error = gfs2_meta_inode_buffer(m_ip, &m_bh);
566 if (sdp->sd_args.ar_spectator) {
567 spin_lock(&sdp->sd_statfs_spin);
568 gfs2_statfs_change_in(m_sc, m_bh->b_data +
569 sizeof(struct gfs2_dinode));
570 spin_unlock(&sdp->sd_statfs_spin);
572 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
576 spin_lock(&sdp->sd_statfs_spin);
577 gfs2_statfs_change_in(m_sc, m_bh->b_data +
578 sizeof(struct gfs2_dinode));
579 gfs2_statfs_change_in(l_sc, l_bh->b_data +
580 sizeof(struct gfs2_dinode));
581 spin_unlock(&sdp->sd_statfs_spin);
590 gfs2_glock_dq_uninit(&gh);
595 void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free,
598 struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip;
599 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
600 struct buffer_head *l_bh;
603 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
607 mutex_lock(&sdp->sd_statfs_mutex);
608 gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1);
609 mutex_unlock(&sdp->sd_statfs_mutex);
611 spin_lock(&sdp->sd_statfs_spin);
612 l_sc->sc_total += total;
613 l_sc->sc_free += free;
614 l_sc->sc_dinodes += dinodes;
615 gfs2_statfs_change_out(l_sc, l_bh->b_data +
616 sizeof(struct gfs2_dinode));
617 spin_unlock(&sdp->sd_statfs_spin);
622 int gfs2_statfs_sync(struct gfs2_sbd *sdp)
624 struct gfs2_inode *m_ip = sdp->sd_statfs_inode->u.generic_ip;
625 struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip;
626 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
627 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
628 struct gfs2_holder gh;
629 struct buffer_head *m_bh, *l_bh;
632 error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, GL_NOCACHE,
637 error = gfs2_meta_inode_buffer(m_ip, &m_bh);
641 spin_lock(&sdp->sd_statfs_spin);
642 gfs2_statfs_change_in(m_sc, m_bh->b_data +
643 sizeof(struct gfs2_dinode));
644 if (!l_sc->sc_total && !l_sc->sc_free && !l_sc->sc_dinodes) {
645 spin_unlock(&sdp->sd_statfs_spin);
648 spin_unlock(&sdp->sd_statfs_spin);
650 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
654 error = gfs2_trans_begin(sdp, 2 * RES_DINODE, 0);
658 mutex_lock(&sdp->sd_statfs_mutex);
659 gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1);
660 mutex_unlock(&sdp->sd_statfs_mutex);
662 spin_lock(&sdp->sd_statfs_spin);
663 m_sc->sc_total += l_sc->sc_total;
664 m_sc->sc_free += l_sc->sc_free;
665 m_sc->sc_dinodes += l_sc->sc_dinodes;
666 memset(l_sc, 0, sizeof(struct gfs2_statfs_change));
667 memset(l_bh->b_data + sizeof(struct gfs2_dinode),
668 0, sizeof(struct gfs2_statfs_change));
669 spin_unlock(&sdp->sd_statfs_spin);
671 gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1);
672 gfs2_statfs_change_out(m_sc, m_bh->b_data + sizeof(struct gfs2_dinode));
683 gfs2_glock_dq_uninit(&gh);
689 * gfs2_statfs_i - Do a statfs
690 * @sdp: the filesystem
691 * @sg: the sg structure
696 int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
698 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
699 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
701 spin_lock(&sdp->sd_statfs_spin);
704 sc->sc_total += l_sc->sc_total;
705 sc->sc_free += l_sc->sc_free;
706 sc->sc_dinodes += l_sc->sc_dinodes;
708 spin_unlock(&sdp->sd_statfs_spin);
712 if (sc->sc_free > sc->sc_total)
713 sc->sc_free = sc->sc_total;
714 if (sc->sc_dinodes < 0)
721 * statfs_fill - fill in the sg for a given RG
723 * @sc: the sc structure
725 * Returns: 0 on success, -ESTALE if the LVB is invalid
728 static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
729 struct gfs2_statfs_change *sc)
731 gfs2_rgrp_verify(rgd);
732 sc->sc_total += rgd->rd_ri.ri_data;
733 sc->sc_free += rgd->rd_rg.rg_free;
734 sc->sc_dinodes += rgd->rd_rg.rg_dinodes;
739 * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
740 * @sdp: the filesystem
741 * @sc: the sc info that will be returned
743 * Any error (other than a signal) will cause this routine to fall back
744 * to the synchronous version.
746 * FIXME: This really shouldn't busy wait like this.
751 int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
753 struct gfs2_holder ri_gh;
754 struct gfs2_rgrpd *rgd_next;
755 struct gfs2_holder *gha, *gh;
756 unsigned int slots = 64;
761 memset(sc, 0, sizeof(struct gfs2_statfs_change));
762 gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
766 error = gfs2_rindex_hold(sdp, &ri_gh);
770 rgd_next = gfs2_rgrpd_get_first(sdp);
775 for (x = 0; x < slots; x++) {
778 if (gh->gh_gl && gfs2_glock_poll(gh)) {
779 err = gfs2_glock_wait(gh);
781 gfs2_holder_uninit(gh);
785 error = statfs_slow_fill(
786 gh->gh_gl->gl_object, sc);
787 gfs2_glock_dq_uninit(gh);
793 else if (rgd_next && !error) {
794 error = gfs2_glock_nq_init(rgd_next->rd_gl,
798 rgd_next = gfs2_rgrpd_get_next(rgd_next);
802 if (signal_pending(current))
803 error = -ERESTARTSYS;
812 gfs2_glock_dq_uninit(&ri_gh);
821 struct list_head list;
822 struct gfs2_holder gh;
826 * gfs2_lock_fs_check_clean - Stop all writes to the FS and check that all
828 * @sdp: the file system
829 * @state: the state to put the transaction lock into
830 * @t_gh: the hold on the transaction lock
835 static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp,
836 struct gfs2_holder *t_gh)
838 struct gfs2_inode *ip;
839 struct gfs2_holder ji_gh;
840 struct gfs2_jdesc *jd;
843 struct gfs2_log_header lh;
846 error = gfs2_jindex_hold(sdp, &ji_gh);
850 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
851 lfcc = kmalloc(sizeof(struct lfcc), GFP_KERNEL);
856 ip = jd->jd_inode->u.generic_ip;
857 error = gfs2_glock_nq_init(ip->i_gl,
864 list_add(&lfcc->list, &list);
867 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_DEFERRED,
868 LM_FLAG_PRIORITY | GL_NOCACHE,
871 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
872 error = gfs2_jdesc_check(jd);
875 error = gfs2_find_jhead(jd, &lh);
878 if (!(lh.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
885 gfs2_glock_dq_uninit(t_gh);
888 while (!list_empty(&list)) {
889 lfcc = list_entry(list.next, struct lfcc, list);
890 list_del(&lfcc->list);
891 gfs2_glock_dq_uninit(&lfcc->gh);
894 gfs2_glock_dq_uninit(&ji_gh);
900 * gfs2_freeze_fs - freezes the file system
901 * @sdp: the file system
903 * This function flushes data and meta data for all machines by
904 * aquiring the transaction log exclusively. All journals are
905 * ensured to be in a clean state as well.
910 int gfs2_freeze_fs(struct gfs2_sbd *sdp)
914 mutex_lock(&sdp->sd_freeze_lock);
916 if (!sdp->sd_freeze_count++) {
917 error = gfs2_lock_fs_check_clean(sdp, &sdp->sd_freeze_gh);
919 sdp->sd_freeze_count--;
922 mutex_unlock(&sdp->sd_freeze_lock);
928 * gfs2_unfreeze_fs - unfreezes the file system
929 * @sdp: the file system
931 * This function allows the file system to proceed by unlocking
932 * the exclusively held transaction lock. Other GFS2 nodes are
933 * now free to acquire the lock shared and go on with their lives.
937 void gfs2_unfreeze_fs(struct gfs2_sbd *sdp)
939 mutex_lock(&sdp->sd_freeze_lock);
941 if (sdp->sd_freeze_count && !--sdp->sd_freeze_count)
942 gfs2_glock_dq_uninit(&sdp->sd_freeze_gh);
944 mutex_unlock(&sdp->sd_freeze_lock);