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/gfs2_ondisk.h>
16 #include <asm/semaphore.h>
19 #include "lm_interface.h"
38 * gfs2_tune_init - Fill a gfs2_tune structure with default values
43 void gfs2_tune_init(struct gfs2_tune *gt)
45 spin_lock_init(>->gt_spin);
48 gt->gt_ilimit_tries = 3;
49 gt->gt_ilimit_min = 1;
50 gt->gt_demote_secs = 300;
51 gt->gt_incore_log_blocks = 1024;
52 gt->gt_log_flush_secs = 60;
53 gt->gt_jindex_refresh_secs = 60;
54 gt->gt_scand_secs = 15;
55 gt->gt_recoverd_secs = 60;
57 gt->gt_quotad_secs = 5;
58 gt->gt_inoded_secs = 15;
59 gt->gt_quota_simul_sync = 64;
60 gt->gt_quota_warn_period = 10;
61 gt->gt_quota_scale_num = 1;
62 gt->gt_quota_scale_den = 1;
63 gt->gt_quota_cache_secs = 300;
64 gt->gt_quota_quantum = 60;
65 gt->gt_atime_quantum = 3600;
66 gt->gt_new_files_jdata = 0;
67 gt->gt_new_files_directio = 0;
68 gt->gt_max_atomic_write = 4 << 20;
69 gt->gt_max_readahead = 1 << 18;
70 gt->gt_lockdump_size = 131072;
71 gt->gt_stall_secs = 600;
72 gt->gt_complain_secs = 10;
73 gt->gt_reclaim_limit = 5000;
74 gt->gt_entries_per_readdir = 32;
75 gt->gt_prefetch_secs = 10;
76 gt->gt_greedy_default = HZ / 10;
77 gt->gt_greedy_quantum = HZ / 40;
78 gt->gt_greedy_max = HZ / 4;
79 gt->gt_statfs_quantum = 30;
80 gt->gt_statfs_slow = 0;
84 * gfs2_check_sb - Check superblock
85 * @sdp: the filesystem
87 * @silent: Don't print a message if the check fails
89 * Checks the version code of the FS is one that we understand how to
90 * read and that the sizes of the various on-disk structures have not
94 int gfs2_check_sb(struct gfs2_sbd *sdp, struct gfs2_sb *sb, int silent)
98 if (sb->sb_header.mh_magic != GFS2_MAGIC ||
99 sb->sb_header.mh_type != GFS2_METATYPE_SB) {
101 printk(KERN_WARNING "GFS2: not a GFS2 filesystem\n");
105 /* If format numbers match exactly, we're done. */
107 if (sb->sb_fs_format == GFS2_FORMAT_FS &&
108 sb->sb_multihost_format == GFS2_FORMAT_MULTI)
111 if (sb->sb_fs_format != GFS2_FORMAT_FS) {
112 for (x = 0; gfs2_old_fs_formats[x]; x++)
113 if (gfs2_old_fs_formats[x] == sb->sb_fs_format)
116 if (!gfs2_old_fs_formats[x]) {
118 "GFS2: code version (%u, %u) is incompatible "
119 "with ondisk format (%u, %u)\n",
120 GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
121 sb->sb_fs_format, sb->sb_multihost_format);
123 "GFS2: I don't know how to upgrade this FS\n");
128 if (sb->sb_multihost_format != GFS2_FORMAT_MULTI) {
129 for (x = 0; gfs2_old_multihost_formats[x]; x++)
130 if (gfs2_old_multihost_formats[x] ==
131 sb->sb_multihost_format)
134 if (!gfs2_old_multihost_formats[x]) {
136 "GFS2: code version (%u, %u) is incompatible "
137 "with ondisk format (%u, %u)\n",
138 GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
139 sb->sb_fs_format, sb->sb_multihost_format);
141 "GFS2: I don't know how to upgrade this FS\n");
146 if (!sdp->sd_args.ar_upgrade) {
148 "GFS2: code version (%u, %u) is incompatible "
149 "with ondisk format (%u, %u)\n",
150 GFS2_FORMAT_FS, GFS2_FORMAT_MULTI,
151 sb->sb_fs_format, sb->sb_multihost_format);
153 "GFS2: Use the \"upgrade\" mount option to upgrade "
155 printk(KERN_INFO "GFS2: See the manual for more details\n");
163 * gfs2_read_sb - Read super block
164 * @sdp: The GFS2 superblock
165 * @gl: the glock for the superblock (assumed to be held)
166 * @silent: Don't print message if mount fails
170 int gfs2_read_sb(struct gfs2_sbd *sdp, struct gfs2_glock *gl, int silent)
172 struct buffer_head *bh;
173 uint32_t hash_blocks, ind_blocks, leaf_blocks;
178 error = gfs2_meta_read(gl, GFS2_SB_ADDR >> sdp->sd_fsb2bb_shift,
179 DIO_FORCE | DIO_START | DIO_WAIT, &bh);
182 fs_err(sdp, "can't read superblock\n");
186 gfs2_assert(sdp, sizeof(struct gfs2_sb) <= bh->b_size);
187 gfs2_sb_in(&sdp->sd_sb, bh->b_data);
190 error = gfs2_check_sb(sdp, &sdp->sd_sb, silent);
194 sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift -
195 GFS2_BASIC_BLOCK_SHIFT;
196 sdp->sd_fsb2bb = 1 << sdp->sd_fsb2bb_shift;
197 sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
198 sizeof(struct gfs2_dinode)) / sizeof(uint64_t);
199 sdp->sd_inptrs = (sdp->sd_sb.sb_bsize -
200 sizeof(struct gfs2_meta_header)) / sizeof(uint64_t);
201 sdp->sd_jbsize = sdp->sd_sb.sb_bsize - sizeof(struct gfs2_meta_header);
202 sdp->sd_hash_bsize = sdp->sd_sb.sb_bsize / 2;
203 sdp->sd_hash_bsize_shift = sdp->sd_sb.sb_bsize_shift - 1;
204 sdp->sd_hash_ptrs = sdp->sd_hash_bsize / sizeof(uint64_t);
205 sdp->sd_ut_per_block = (sdp->sd_sb.sb_bsize -
206 sizeof(struct gfs2_meta_header)) /
207 sizeof(struct gfs2_unlinked_tag);
208 sdp->sd_qc_per_block = (sdp->sd_sb.sb_bsize -
209 sizeof(struct gfs2_meta_header)) /
210 sizeof(struct gfs2_quota_change);
212 /* Compute maximum reservation required to add a entry to a directory */
214 hash_blocks = DIV_ROUND_UP(sizeof(uint64_t) * (1 << GFS2_DIR_MAX_DEPTH),
218 for (tmp_blocks = hash_blocks; tmp_blocks > sdp->sd_diptrs;) {
219 tmp_blocks = DIV_ROUND_UP(tmp_blocks, sdp->sd_inptrs);
220 ind_blocks += tmp_blocks;
223 leaf_blocks = 2 + GFS2_DIR_MAX_DEPTH;
225 sdp->sd_max_dirres = hash_blocks + ind_blocks + leaf_blocks;
227 sdp->sd_heightsize[0] = sdp->sd_sb.sb_bsize -
228 sizeof(struct gfs2_dinode);
229 sdp->sd_heightsize[1] = sdp->sd_sb.sb_bsize * sdp->sd_diptrs;
234 space = sdp->sd_heightsize[x - 1] * sdp->sd_inptrs;
236 m = do_div(d, sdp->sd_inptrs);
238 if (d != sdp->sd_heightsize[x - 1] || m)
240 sdp->sd_heightsize[x] = space;
242 sdp->sd_max_height = x;
243 gfs2_assert(sdp, sdp->sd_max_height <= GFS2_MAX_META_HEIGHT);
245 sdp->sd_jheightsize[0] = sdp->sd_sb.sb_bsize -
246 sizeof(struct gfs2_dinode);
247 sdp->sd_jheightsize[1] = sdp->sd_jbsize * sdp->sd_diptrs;
252 space = sdp->sd_jheightsize[x - 1] * sdp->sd_inptrs;
254 m = do_div(d, sdp->sd_inptrs);
256 if (d != sdp->sd_jheightsize[x - 1] || m)
258 sdp->sd_jheightsize[x] = space;
260 sdp->sd_max_jheight = x;
261 gfs2_assert(sdp, sdp->sd_max_jheight <= GFS2_MAX_META_HEIGHT);
266 int gfs2_do_upgrade(struct gfs2_sbd *sdp, struct gfs2_glock *sb_gl)
272 * gfs2_jindex_hold - Grab a lock on the jindex
273 * @sdp: The GFS2 superblock
274 * @ji_gh: the holder for the jindex glock
276 * This is very similar to the gfs2_rindex_hold() function, except that
277 * in general we hold the jindex lock for longer periods of time and
278 * we grab it far less frequently (in general) then the rgrp lock.
283 int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
285 struct gfs2_inode *dip = sdp->sd_jindex->u.generic_ip;
288 struct gfs2_jdesc *jd;
293 mutex_lock(&sdp->sd_jindex_mutex);
296 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED,
297 GL_LOCAL_EXCL, ji_gh);
301 name.len = sprintf(buf, "journal%u", sdp->sd_journals);
302 name.hash = gfs2_disk_hash(name.name, name.len);
304 error = gfs2_dir_search(sdp->sd_jindex,
306 if (error == -ENOENT) {
311 gfs2_glock_dq_uninit(ji_gh);
317 jd = kzalloc(sizeof(struct gfs2_jdesc), GFP_KERNEL);
321 jd->jd_inode = gfs2_lookupi(sdp->sd_jindex, &name, 1, NULL);
322 if (!jd->jd_inode || IS_ERR(jd->jd_inode)) {
326 error = PTR_ERR(jd->jd_inode);
331 spin_lock(&sdp->sd_jindex_spin);
332 jd->jd_jid = sdp->sd_journals++;
333 list_add_tail(&jd->jd_list, &sdp->sd_jindex_list);
334 spin_unlock(&sdp->sd_jindex_spin);
337 mutex_unlock(&sdp->sd_jindex_mutex);
343 * gfs2_jindex_free - Clear all the journal index information
344 * @sdp: The GFS2 superblock
348 void gfs2_jindex_free(struct gfs2_sbd *sdp)
350 struct list_head list;
351 struct gfs2_jdesc *jd;
353 spin_lock(&sdp->sd_jindex_spin);
354 list_add(&list, &sdp->sd_jindex_list);
355 list_del_init(&sdp->sd_jindex_list);
356 sdp->sd_journals = 0;
357 spin_unlock(&sdp->sd_jindex_spin);
359 while (!list_empty(&list)) {
360 jd = list_entry(list.next, struct gfs2_jdesc, jd_list);
361 list_del(&jd->jd_list);
367 static struct gfs2_jdesc *jdesc_find_i(struct list_head *head, unsigned int jid)
369 struct gfs2_jdesc *jd;
372 list_for_each_entry(jd, head, jd_list) {
373 if (jd->jd_jid == jid) {
385 struct gfs2_jdesc *gfs2_jdesc_find(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);
391 spin_unlock(&sdp->sd_jindex_spin);
396 void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid)
398 struct gfs2_jdesc *jd;
400 spin_lock(&sdp->sd_jindex_spin);
401 jd = jdesc_find_i(&sdp->sd_jindex_list, jid);
404 spin_unlock(&sdp->sd_jindex_spin);
407 struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp)
409 struct gfs2_jdesc *jd;
412 spin_lock(&sdp->sd_jindex_spin);
414 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
421 spin_unlock(&sdp->sd_jindex_spin);
429 int gfs2_jdesc_check(struct gfs2_jdesc *jd)
431 struct gfs2_inode *ip = jd->jd_inode->u.generic_ip;
432 struct gfs2_sbd *sdp = ip->i_sbd;
436 if (ip->i_di.di_size < (8 << 20) ||
437 ip->i_di.di_size > (1 << 30) ||
438 (ip->i_di.di_size & (sdp->sd_sb.sb_bsize - 1))) {
439 gfs2_consist_inode(ip);
442 jd->jd_blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift;
444 error = gfs2_write_alloc_required(ip,
448 gfs2_consist_inode(ip);
456 * gfs2_make_fs_rw - Turn a Read-Only FS into a Read-Write one
457 * @sdp: the filesystem
462 int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
464 struct gfs2_inode *ip = sdp->sd_jdesc->jd_inode->u.generic_ip;
465 struct gfs2_glock *j_gl = ip->i_gl;
466 struct gfs2_holder t_gh;
467 struct gfs2_log_header head;
470 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED,
471 GL_LOCAL_EXCL | GL_NEVER_RECURSE, &t_gh);
475 gfs2_meta_cache_flush(ip);
476 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA);
478 error = gfs2_find_jhead(sdp->sd_jdesc, &head);
482 if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
488 /* Initialize some head of the log stuff */
489 sdp->sd_log_sequence = head.lh_sequence + 1;
490 gfs2_log_pointers_init(sdp, head.lh_blkno);
492 error = gfs2_unlinked_init(sdp);
495 error = gfs2_quota_init(sdp);
499 set_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
501 gfs2_glock_dq_uninit(&t_gh);
506 gfs2_unlinked_cleanup(sdp);
509 t_gh.gh_flags |= GL_NOCACHE;
510 gfs2_glock_dq_uninit(&t_gh);
516 * gfs2_make_fs_ro - Turn a Read-Write FS into a Read-Only one
517 * @sdp: the filesystem
522 int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
524 struct gfs2_holder t_gh;
527 gfs2_unlinked_dealloc(sdp);
528 gfs2_quota_sync(sdp);
529 gfs2_statfs_sync(sdp);
531 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_SHARED,
532 GL_LOCAL_EXCL | GL_NEVER_RECURSE | GL_NOCACHE,
534 if (error && !test_bit(SDF_SHUTDOWN, &sdp->sd_flags))
537 gfs2_meta_syncfs(sdp);
538 gfs2_log_shutdown(sdp);
540 clear_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
543 gfs2_glock_dq_uninit(&t_gh);
545 gfs2_unlinked_cleanup(sdp);
546 gfs2_quota_cleanup(sdp);
551 int gfs2_statfs_init(struct gfs2_sbd *sdp)
553 struct gfs2_inode *m_ip = sdp->sd_statfs_inode->u.generic_ip;
554 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
555 struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip;
556 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
557 struct buffer_head *m_bh, *l_bh;
558 struct gfs2_holder gh;
561 error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, GL_NOCACHE,
566 error = gfs2_meta_inode_buffer(m_ip, &m_bh);
570 if (sdp->sd_args.ar_spectator) {
571 spin_lock(&sdp->sd_statfs_spin);
572 gfs2_statfs_change_in(m_sc, m_bh->b_data +
573 sizeof(struct gfs2_dinode));
574 spin_unlock(&sdp->sd_statfs_spin);
576 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
580 spin_lock(&sdp->sd_statfs_spin);
581 gfs2_statfs_change_in(m_sc, m_bh->b_data +
582 sizeof(struct gfs2_dinode));
583 gfs2_statfs_change_in(l_sc, l_bh->b_data +
584 sizeof(struct gfs2_dinode));
585 spin_unlock(&sdp->sd_statfs_spin);
594 gfs2_glock_dq_uninit(&gh);
599 void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free,
602 struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip;
603 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
604 struct buffer_head *l_bh;
607 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
611 mutex_lock(&sdp->sd_statfs_mutex);
612 gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1);
613 mutex_unlock(&sdp->sd_statfs_mutex);
615 spin_lock(&sdp->sd_statfs_spin);
616 l_sc->sc_total += total;
617 l_sc->sc_free += free;
618 l_sc->sc_dinodes += dinodes;
619 gfs2_statfs_change_out(l_sc, l_bh->b_data +
620 sizeof(struct gfs2_dinode));
621 spin_unlock(&sdp->sd_statfs_spin);
626 int gfs2_statfs_sync(struct gfs2_sbd *sdp)
628 struct gfs2_inode *m_ip = sdp->sd_statfs_inode->u.generic_ip;
629 struct gfs2_inode *l_ip = sdp->sd_sc_inode->u.generic_ip;
630 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
631 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
632 struct gfs2_holder gh;
633 struct buffer_head *m_bh, *l_bh;
636 error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, GL_NOCACHE,
641 error = gfs2_meta_inode_buffer(m_ip, &m_bh);
645 spin_lock(&sdp->sd_statfs_spin);
646 gfs2_statfs_change_in(m_sc, m_bh->b_data +
647 sizeof(struct gfs2_dinode));
648 if (!l_sc->sc_total && !l_sc->sc_free && !l_sc->sc_dinodes) {
649 spin_unlock(&sdp->sd_statfs_spin);
652 spin_unlock(&sdp->sd_statfs_spin);
654 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
658 error = gfs2_trans_begin(sdp, 2 * RES_DINODE, 0);
662 mutex_lock(&sdp->sd_statfs_mutex);
663 gfs2_trans_add_bh(l_ip->i_gl, l_bh, 1);
664 mutex_unlock(&sdp->sd_statfs_mutex);
666 spin_lock(&sdp->sd_statfs_spin);
667 m_sc->sc_total += l_sc->sc_total;
668 m_sc->sc_free += l_sc->sc_free;
669 m_sc->sc_dinodes += l_sc->sc_dinodes;
670 memset(l_sc, 0, sizeof(struct gfs2_statfs_change));
671 memset(l_bh->b_data + sizeof(struct gfs2_dinode),
672 0, sizeof(struct gfs2_statfs_change));
673 spin_unlock(&sdp->sd_statfs_spin);
675 gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1);
676 gfs2_statfs_change_out(m_sc, m_bh->b_data + sizeof(struct gfs2_dinode));
687 gfs2_glock_dq_uninit(&gh);
693 * gfs2_statfs_i - Do a statfs
694 * @sdp: the filesystem
695 * @sg: the sg structure
700 int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
702 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
703 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
705 spin_lock(&sdp->sd_statfs_spin);
708 sc->sc_total += l_sc->sc_total;
709 sc->sc_free += l_sc->sc_free;
710 sc->sc_dinodes += l_sc->sc_dinodes;
712 spin_unlock(&sdp->sd_statfs_spin);
716 if (sc->sc_free > sc->sc_total)
717 sc->sc_free = sc->sc_total;
718 if (sc->sc_dinodes < 0)
725 * statfs_fill - fill in the sg for a given RG
727 * @sc: the sc structure
729 * Returns: 0 on success, -ESTALE if the LVB is invalid
732 static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
733 struct gfs2_statfs_change *sc)
735 gfs2_rgrp_verify(rgd);
736 sc->sc_total += rgd->rd_ri.ri_data;
737 sc->sc_free += rgd->rd_rg.rg_free;
738 sc->sc_dinodes += rgd->rd_rg.rg_dinodes;
743 * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
744 * @sdp: the filesystem
745 * @sc: the sc info that will be returned
747 * Any error (other than a signal) will cause this routine to fall back
748 * to the synchronous version.
750 * FIXME: This really shouldn't busy wait like this.
755 int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change *sc)
757 struct gfs2_holder ri_gh;
758 struct gfs2_rgrpd *rgd_next;
759 struct gfs2_holder *gha, *gh;
760 unsigned int slots = 64;
765 memset(sc, 0, sizeof(struct gfs2_statfs_change));
766 gha = kcalloc(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
770 error = gfs2_rindex_hold(sdp, &ri_gh);
774 rgd_next = gfs2_rgrpd_get_first(sdp);
779 for (x = 0; x < slots; x++) {
782 if (gh->gh_gl && gfs2_glock_poll(gh)) {
783 err = gfs2_glock_wait(gh);
785 gfs2_holder_uninit(gh);
789 error = statfs_slow_fill(
790 gh->gh_gl->gl_object, sc);
791 gfs2_glock_dq_uninit(gh);
797 else if (rgd_next && !error) {
798 error = gfs2_glock_nq_init(rgd_next->rd_gl,
802 rgd_next = gfs2_rgrpd_get_next(rgd_next);
806 if (signal_pending(current))
807 error = -ERESTARTSYS;
816 gfs2_glock_dq_uninit(&ri_gh);
825 struct list_head list;
826 struct gfs2_holder gh;
830 * gfs2_lock_fs_check_clean - Stop all writes to the FS and check that all
832 * @sdp: the file system
833 * @state: the state to put the transaction lock into
834 * @t_gh: the hold on the transaction lock
839 int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, struct gfs2_holder *t_gh)
841 struct gfs2_inode *ip;
842 struct gfs2_holder ji_gh;
843 struct gfs2_jdesc *jd;
846 struct gfs2_log_header lh;
849 error = gfs2_jindex_hold(sdp, &ji_gh);
853 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
854 lfcc = kmalloc(sizeof(struct lfcc), GFP_KERNEL);
859 ip = jd->jd_inode->u.generic_ip;
860 error = gfs2_glock_nq_init(ip->i_gl,
867 list_add(&lfcc->list, &list);
870 error = gfs2_glock_nq_init(sdp->sd_trans_gl, LM_ST_DEFERRED,
871 LM_FLAG_PRIORITY | GL_NEVER_RECURSE | GL_NOCACHE,
874 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
875 error = gfs2_jdesc_check(jd);
878 error = gfs2_find_jhead(jd, &lh);
881 if (!(lh.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
888 gfs2_glock_dq_uninit(t_gh);
891 while (!list_empty(&list)) {
892 lfcc = list_entry(list.next, struct lfcc, list);
893 list_del(&lfcc->list);
894 gfs2_glock_dq_uninit(&lfcc->gh);
897 gfs2_glock_dq_uninit(&ji_gh);
903 * gfs2_freeze_fs - freezes the file system
904 * @sdp: the file system
906 * This function flushes data and meta data for all machines by
907 * aquiring the transaction log exclusively. All journals are
908 * ensured to be in a clean state as well.
913 int gfs2_freeze_fs(struct gfs2_sbd *sdp)
917 mutex_lock(&sdp->sd_freeze_lock);
919 if (!sdp->sd_freeze_count++) {
920 error = gfs2_lock_fs_check_clean(sdp, &sdp->sd_freeze_gh);
922 sdp->sd_freeze_count--;
925 mutex_unlock(&sdp->sd_freeze_lock);
931 * gfs2_unfreeze_fs - unfreezes the file system
932 * @sdp: the file system
934 * This function allows the file system to proceed by unlocking
935 * the exclusively held transaction lock. Other GFS2 nodes are
936 * now free to acquire the lock shared and go on with their lives.
940 void gfs2_unfreeze_fs(struct gfs2_sbd *sdp)
942 mutex_lock(&sdp->sd_freeze_lock);
944 if (sdp->sd_freeze_count && !--sdp->sd_freeze_count)
945 gfs2_glock_dq_uninit(&sdp->sd_freeze_gh);
947 mutex_unlock(&sdp->sd_freeze_lock);