1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
4 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
7 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10 #include <linux/sched/signal.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/statfs.h>
16 #include <linux/seq_file.h>
17 #include <linux/mount.h>
18 #include <linux/kthread.h>
19 #include <linux/delay.h>
20 #include <linux/gfs2_ondisk.h>
21 #include <linux/crc32.h>
22 #include <linux/time.h>
23 #include <linux/wait.h>
24 #include <linux/writeback.h>
25 #include <linux/backing-dev.h>
26 #include <linux/kernel.h>
49 SHOULD_NOT_DELETE_DINODE,
50 SHOULD_DEFER_EVICTION,
54 * gfs2_jindex_free - Clear all the journal index information
55 * @sdp: The GFS2 superblock
59 void gfs2_jindex_free(struct gfs2_sbd *sdp)
61 struct list_head list;
62 struct gfs2_jdesc *jd;
64 spin_lock(&sdp->sd_jindex_spin);
65 list_add(&list, &sdp->sd_jindex_list);
66 list_del_init(&sdp->sd_jindex_list);
68 spin_unlock(&sdp->sd_jindex_spin);
71 while (!list_empty(&list)) {
72 jd = list_first_entry(&list, struct gfs2_jdesc, jd_list);
73 gfs2_free_journal_extents(jd);
74 list_del(&jd->jd_list);
81 static struct gfs2_jdesc *jdesc_find_i(struct list_head *head, unsigned int jid)
83 struct gfs2_jdesc *jd;
86 list_for_each_entry(jd, head, jd_list) {
87 if (jd->jd_jid == jid) {
99 struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid)
101 struct gfs2_jdesc *jd;
103 spin_lock(&sdp->sd_jindex_spin);
104 jd = jdesc_find_i(&sdp->sd_jindex_list, jid);
105 spin_unlock(&sdp->sd_jindex_spin);
110 int gfs2_jdesc_check(struct gfs2_jdesc *jd)
112 struct gfs2_inode *ip = GFS2_I(jd->jd_inode);
113 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode);
114 u64 size = i_size_read(jd->jd_inode);
116 if (gfs2_check_internal_file_size(jd->jd_inode, 8 << 20, BIT(30)))
119 jd->jd_blocks = size >> sdp->sd_sb.sb_bsize_shift;
121 if (gfs2_write_alloc_required(ip, 0, size)) {
122 gfs2_consist_inode(ip);
129 static int init_threads(struct gfs2_sbd *sdp)
131 struct task_struct *p;
134 p = kthread_run(gfs2_logd, sdp, "gfs2_logd");
137 fs_err(sdp, "can't start logd thread: %d\n", error);
140 sdp->sd_logd_process = p;
142 p = kthread_run(gfs2_quotad, sdp, "gfs2_quotad");
145 fs_err(sdp, "can't start quotad thread: %d\n", error);
148 sdp->sd_quotad_process = p;
152 kthread_stop(sdp->sd_logd_process);
153 sdp->sd_logd_process = NULL;
158 * gfs2_make_fs_rw - Turn a Read-Only FS into a Read-Write one
159 * @sdp: the filesystem
164 int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
166 struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode);
167 struct gfs2_glock *j_gl = ip->i_gl;
168 struct gfs2_holder freeze_gh;
169 struct gfs2_log_header_host head;
172 error = init_threads(sdp);
176 error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED,
177 LM_FLAG_NOEXP | GL_EXACT,
182 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA);
183 if (gfs2_withdrawn(sdp)) {
188 error = gfs2_find_jhead(sdp->sd_jdesc, &head, false);
189 if (error || gfs2_withdrawn(sdp))
192 if (!(head.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
198 /* Initialize some head of the log stuff */
199 sdp->sd_log_sequence = head.lh_sequence + 1;
200 gfs2_log_pointers_init(sdp, head.lh_blkno);
202 error = gfs2_quota_init(sdp);
203 if (error || gfs2_withdrawn(sdp))
206 set_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
208 gfs2_glock_dq_uninit(&freeze_gh);
213 gfs2_glock_dq_uninit(&freeze_gh);
215 if (sdp->sd_quotad_process)
216 kthread_stop(sdp->sd_quotad_process);
217 sdp->sd_quotad_process = NULL;
218 if (sdp->sd_logd_process)
219 kthread_stop(sdp->sd_logd_process);
220 sdp->sd_logd_process = NULL;
224 void gfs2_statfs_change_in(struct gfs2_statfs_change_host *sc, const void *buf)
226 const struct gfs2_statfs_change *str = buf;
228 sc->sc_total = be64_to_cpu(str->sc_total);
229 sc->sc_free = be64_to_cpu(str->sc_free);
230 sc->sc_dinodes = be64_to_cpu(str->sc_dinodes);
233 void gfs2_statfs_change_out(const struct gfs2_statfs_change_host *sc, void *buf)
235 struct gfs2_statfs_change *str = buf;
237 str->sc_total = cpu_to_be64(sc->sc_total);
238 str->sc_free = cpu_to_be64(sc->sc_free);
239 str->sc_dinodes = cpu_to_be64(sc->sc_dinodes);
242 int gfs2_statfs_init(struct gfs2_sbd *sdp)
244 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
245 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
246 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
247 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
248 struct buffer_head *m_bh, *l_bh;
249 struct gfs2_holder gh;
252 error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, GL_NOCACHE,
257 error = gfs2_meta_inode_buffer(m_ip, &m_bh);
261 if (sdp->sd_args.ar_spectator) {
262 spin_lock(&sdp->sd_statfs_spin);
263 gfs2_statfs_change_in(m_sc, m_bh->b_data +
264 sizeof(struct gfs2_dinode));
265 spin_unlock(&sdp->sd_statfs_spin);
267 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
271 spin_lock(&sdp->sd_statfs_spin);
272 gfs2_statfs_change_in(m_sc, m_bh->b_data +
273 sizeof(struct gfs2_dinode));
274 gfs2_statfs_change_in(l_sc, l_bh->b_data +
275 sizeof(struct gfs2_dinode));
276 spin_unlock(&sdp->sd_statfs_spin);
284 gfs2_glock_dq_uninit(&gh);
288 void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free,
291 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
292 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
293 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
294 struct buffer_head *l_bh;
299 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
303 gfs2_trans_add_meta(l_ip->i_gl, l_bh);
305 spin_lock(&sdp->sd_statfs_spin);
306 l_sc->sc_total += total;
307 l_sc->sc_free += free;
308 l_sc->sc_dinodes += dinodes;
309 gfs2_statfs_change_out(l_sc, l_bh->b_data + sizeof(struct gfs2_dinode));
310 if (sdp->sd_args.ar_statfs_percent) {
311 x = 100 * l_sc->sc_free;
312 y = m_sc->sc_free * sdp->sd_args.ar_statfs_percent;
313 if (x >= y || x <= -y)
316 spin_unlock(&sdp->sd_statfs_spin);
320 gfs2_wake_up_statfs(sdp);
323 void update_statfs(struct gfs2_sbd *sdp, struct buffer_head *m_bh,
324 struct buffer_head *l_bh)
326 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
327 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
328 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
329 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
331 gfs2_trans_add_meta(l_ip->i_gl, l_bh);
332 gfs2_trans_add_meta(m_ip->i_gl, m_bh);
334 spin_lock(&sdp->sd_statfs_spin);
335 m_sc->sc_total += l_sc->sc_total;
336 m_sc->sc_free += l_sc->sc_free;
337 m_sc->sc_dinodes += l_sc->sc_dinodes;
338 memset(l_sc, 0, sizeof(struct gfs2_statfs_change));
339 memset(l_bh->b_data + sizeof(struct gfs2_dinode),
340 0, sizeof(struct gfs2_statfs_change));
341 gfs2_statfs_change_out(m_sc, m_bh->b_data + sizeof(struct gfs2_dinode));
342 spin_unlock(&sdp->sd_statfs_spin);
345 int gfs2_statfs_sync(struct super_block *sb, int type)
347 struct gfs2_sbd *sdp = sb->s_fs_info;
348 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode);
349 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode);
350 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
351 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
352 struct gfs2_holder gh;
353 struct buffer_head *m_bh, *l_bh;
357 error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, GL_NOCACHE,
362 error = gfs2_meta_inode_buffer(m_ip, &m_bh);
366 spin_lock(&sdp->sd_statfs_spin);
367 gfs2_statfs_change_in(m_sc, m_bh->b_data +
368 sizeof(struct gfs2_dinode));
369 if (!l_sc->sc_total && !l_sc->sc_free && !l_sc->sc_dinodes) {
370 spin_unlock(&sdp->sd_statfs_spin);
373 spin_unlock(&sdp->sd_statfs_spin);
375 error = gfs2_meta_inode_buffer(l_ip, &l_bh);
379 error = gfs2_trans_begin(sdp, 2 * RES_DINODE, 0);
383 update_statfs(sdp, m_bh, l_bh);
384 sdp->sd_statfs_force_sync = 0;
393 gfs2_glock_dq_uninit(&gh);
400 struct list_head list;
401 struct gfs2_holder gh;
405 * gfs2_lock_fs_check_clean - Stop all writes to the FS and check that all
407 * @sdp: the file system
408 * @state: the state to put the transaction lock into
409 * @t_gh: the hold on the transaction lock
414 static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp)
416 struct gfs2_inode *ip;
417 struct gfs2_jdesc *jd;
420 struct gfs2_log_header_host lh;
423 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
424 lfcc = kmalloc(sizeof(struct lfcc), GFP_KERNEL);
429 ip = GFS2_I(jd->jd_inode);
430 error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, 0, &lfcc->gh);
435 list_add(&lfcc->list, &list);
438 error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_EXCLUSIVE,
439 LM_FLAG_NOEXP, &sdp->sd_freeze_gh);
443 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
444 error = gfs2_jdesc_check(jd);
447 error = gfs2_find_jhead(jd, &lh, false);
450 if (!(lh.lh_flags & GFS2_LOG_HEAD_UNMOUNT)) {
457 gfs2_glock_dq_uninit(&sdp->sd_freeze_gh);
460 while (!list_empty(&list)) {
461 lfcc = list_first_entry(&list, struct lfcc, list);
462 list_del(&lfcc->list);
463 gfs2_glock_dq_uninit(&lfcc->gh);
469 void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf)
471 struct gfs2_dinode *str = buf;
473 str->di_header.mh_magic = cpu_to_be32(GFS2_MAGIC);
474 str->di_header.mh_type = cpu_to_be32(GFS2_METATYPE_DI);
475 str->di_header.mh_format = cpu_to_be32(GFS2_FORMAT_DI);
476 str->di_num.no_addr = cpu_to_be64(ip->i_no_addr);
477 str->di_num.no_formal_ino = cpu_to_be64(ip->i_no_formal_ino);
478 str->di_mode = cpu_to_be32(ip->i_inode.i_mode);
479 str->di_uid = cpu_to_be32(i_uid_read(&ip->i_inode));
480 str->di_gid = cpu_to_be32(i_gid_read(&ip->i_inode));
481 str->di_nlink = cpu_to_be32(ip->i_inode.i_nlink);
482 str->di_size = cpu_to_be64(i_size_read(&ip->i_inode));
483 str->di_blocks = cpu_to_be64(gfs2_get_inode_blocks(&ip->i_inode));
484 str->di_atime = cpu_to_be64(ip->i_inode.i_atime.tv_sec);
485 str->di_mtime = cpu_to_be64(ip->i_inode.i_mtime.tv_sec);
486 str->di_ctime = cpu_to_be64(ip->i_inode.i_ctime.tv_sec);
488 str->di_goal_meta = cpu_to_be64(ip->i_goal);
489 str->di_goal_data = cpu_to_be64(ip->i_goal);
490 str->di_generation = cpu_to_be64(ip->i_generation);
492 str->di_flags = cpu_to_be32(ip->i_diskflags);
493 str->di_height = cpu_to_be16(ip->i_height);
494 str->di_payload_format = cpu_to_be32(S_ISDIR(ip->i_inode.i_mode) &&
495 !(ip->i_diskflags & GFS2_DIF_EXHASH) ?
497 str->di_depth = cpu_to_be16(ip->i_depth);
498 str->di_entries = cpu_to_be32(ip->i_entries);
500 str->di_eattr = cpu_to_be64(ip->i_eattr);
501 str->di_atime_nsec = cpu_to_be32(ip->i_inode.i_atime.tv_nsec);
502 str->di_mtime_nsec = cpu_to_be32(ip->i_inode.i_mtime.tv_nsec);
503 str->di_ctime_nsec = cpu_to_be32(ip->i_inode.i_ctime.tv_nsec);
507 * gfs2_write_inode - Make sure the inode is stable on the disk
509 * @wbc: The writeback control structure
514 static int gfs2_write_inode(struct inode *inode, struct writeback_control *wbc)
516 struct gfs2_inode *ip = GFS2_I(inode);
517 struct gfs2_sbd *sdp = GFS2_SB(inode);
518 struct address_space *metamapping = gfs2_glock2aspace(ip->i_gl);
519 struct backing_dev_info *bdi = inode_to_bdi(metamapping->host);
521 bool flush_all = (wbc->sync_mode == WB_SYNC_ALL || gfs2_is_jdata(ip));
524 gfs2_log_flush(GFS2_SB(inode), ip->i_gl,
525 GFS2_LOG_HEAD_FLUSH_NORMAL |
526 GFS2_LFC_WRITE_INODE);
527 if (bdi->wb.dirty_exceeded)
528 gfs2_ail1_flush(sdp, wbc);
530 filemap_fdatawrite(metamapping);
532 ret = filemap_fdatawait(metamapping);
534 mark_inode_dirty_sync(inode);
536 spin_lock(&inode->i_lock);
537 if (!(inode->i_flags & I_DIRTY))
538 gfs2_ordered_del_inode(ip);
539 spin_unlock(&inode->i_lock);
545 * gfs2_dirty_inode - check for atime updates
546 * @inode: The inode in question
547 * @flags: The type of dirty
549 * Unfortunately it can be called under any combination of inode
550 * glock and transaction lock, so we have to check carefully.
552 * At the moment this deals only with atime - it should be possible
553 * to expand that role in future, once a review of the locking has
557 static void gfs2_dirty_inode(struct inode *inode, int flags)
559 struct gfs2_inode *ip = GFS2_I(inode);
560 struct gfs2_sbd *sdp = GFS2_SB(inode);
561 struct buffer_head *bh;
562 struct gfs2_holder gh;
564 int need_endtrans = 0;
567 if (!(flags & I_DIRTY_INODE))
569 if (unlikely(gfs2_withdrawn(sdp)))
571 if (!gfs2_glock_is_locked_by_me(ip->i_gl)) {
572 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
574 fs_err(sdp, "dirty_inode: glock %d\n", ret);
575 gfs2_dump_glock(NULL, ip->i_gl, true);
579 } else if (WARN_ON_ONCE(ip->i_gl->gl_state != LM_ST_EXCLUSIVE))
582 if (current->journal_info == NULL) {
583 ret = gfs2_trans_begin(sdp, RES_DINODE, 0);
585 fs_err(sdp, "dirty_inode: gfs2_trans_begin %d\n", ret);
591 ret = gfs2_meta_inode_buffer(ip, &bh);
593 gfs2_trans_add_meta(ip->i_gl, bh);
594 gfs2_dinode_out(ip, bh->b_data);
602 gfs2_glock_dq_uninit(&gh);
606 * gfs2_make_fs_ro - Turn a Read-Write FS into a Read-Only one
607 * @sdp: the filesystem
612 int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
614 struct gfs2_holder freeze_gh;
616 int log_write_allowed = test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
618 gfs2_holder_mark_uninitialized(&freeze_gh);
619 if (sdp->sd_freeze_gl &&
620 !gfs2_glock_is_locked_by_me(sdp->sd_freeze_gl)) {
621 if (!log_write_allowed) {
622 error = gfs2_glock_nq_init(sdp->sd_freeze_gl,
623 LM_ST_SHARED, LM_FLAG_TRY |
624 LM_FLAG_NOEXP | GL_EXACT,
626 if (error == GLR_TRYFAILED)
629 error = gfs2_glock_nq_init(sdp->sd_freeze_gl,
631 LM_FLAG_NOEXP | GL_EXACT,
633 if (error && !gfs2_withdrawn(sdp))
638 gfs2_flush_delete_work(sdp);
639 if (!log_write_allowed && current == sdp->sd_quotad_process)
640 fs_warn(sdp, "The quotad daemon is withdrawing.\n");
641 else if (sdp->sd_quotad_process)
642 kthread_stop(sdp->sd_quotad_process);
643 sdp->sd_quotad_process = NULL;
645 if (!log_write_allowed && current == sdp->sd_logd_process)
646 fs_warn(sdp, "The logd daemon is withdrawing.\n");
647 else if (sdp->sd_logd_process)
648 kthread_stop(sdp->sd_logd_process);
649 sdp->sd_logd_process = NULL;
651 if (log_write_allowed) {
652 gfs2_quota_sync(sdp->sd_vfs, 0);
653 gfs2_statfs_sync(sdp->sd_vfs, 0);
655 gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_SHUTDOWN |
656 GFS2_LFC_MAKE_FS_RO);
657 wait_event(sdp->sd_reserving_log_wait,
658 atomic_read(&sdp->sd_reserving_log) == 0);
659 gfs2_assert_warn(sdp, atomic_read(&sdp->sd_log_blks_free) ==
660 sdp->sd_jdesc->jd_blocks);
662 wait_event_timeout(sdp->sd_reserving_log_wait,
663 atomic_read(&sdp->sd_reserving_log) == 0,
666 if (gfs2_holder_initialized(&freeze_gh))
667 gfs2_glock_dq_uninit(&freeze_gh);
669 gfs2_quota_cleanup(sdp);
671 if (!log_write_allowed)
672 sdp->sd_vfs->s_flags |= SB_RDONLY;
678 * gfs2_put_super - Unmount the filesystem
679 * @sb: The VFS superblock
683 static void gfs2_put_super(struct super_block *sb)
685 struct gfs2_sbd *sdp = sb->s_fs_info;
687 struct gfs2_jdesc *jd;
689 /* No more recovery requests */
690 set_bit(SDF_NORECOVERY, &sdp->sd_flags);
693 /* Wait on outstanding recovery */
695 spin_lock(&sdp->sd_jindex_spin);
696 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) {
697 if (!test_bit(JDF_RECOVERY, &jd->jd_flags))
699 spin_unlock(&sdp->sd_jindex_spin);
700 wait_on_bit(&jd->jd_flags, JDF_RECOVERY,
701 TASK_UNINTERRUPTIBLE);
704 spin_unlock(&sdp->sd_jindex_spin);
706 if (!sb_rdonly(sb)) {
707 error = gfs2_make_fs_ro(sdp);
711 WARN_ON(gfs2_withdrawing(sdp));
713 /* At this point, we're through modifying the disk */
717 iput(sdp->sd_jindex);
718 iput(sdp->sd_statfs_inode);
719 iput(sdp->sd_rindex);
720 iput(sdp->sd_quota_inode);
722 gfs2_glock_put(sdp->sd_rename_gl);
723 gfs2_glock_put(sdp->sd_freeze_gl);
725 if (!sdp->sd_args.ar_spectator) {
726 if (gfs2_holder_initialized(&sdp->sd_journal_gh))
727 gfs2_glock_dq_uninit(&sdp->sd_journal_gh);
728 if (gfs2_holder_initialized(&sdp->sd_jinode_gh))
729 gfs2_glock_dq_uninit(&sdp->sd_jinode_gh);
730 gfs2_glock_dq_uninit(&sdp->sd_sc_gh);
731 gfs2_glock_dq_uninit(&sdp->sd_qc_gh);
732 free_local_statfs_inodes(sdp);
733 iput(sdp->sd_qc_inode);
736 gfs2_glock_dq_uninit(&sdp->sd_live_gh);
737 gfs2_clear_rgrpd(sdp);
738 gfs2_jindex_free(sdp);
739 /* Take apart glock structures and buffer lists */
740 gfs2_gl_hash_clear(sdp);
741 truncate_inode_pages_final(&sdp->sd_aspace);
742 gfs2_delete_debugfs_file(sdp);
743 /* Unmount the locking protocol */
744 gfs2_lm_unmount(sdp);
746 /* At this point, we're through participating in the lockspace */
747 gfs2_sys_fs_del(sdp);
752 * gfs2_sync_fs - sync the filesystem
753 * @sb: the superblock
755 * Flushes the log to disk.
758 static int gfs2_sync_fs(struct super_block *sb, int wait)
760 struct gfs2_sbd *sdp = sb->s_fs_info;
762 gfs2_quota_sync(sb, -1);
764 gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL |
766 return sdp->sd_log_error;
769 void gfs2_freeze_func(struct work_struct *work)
772 struct gfs2_holder freeze_gh;
773 struct gfs2_sbd *sdp = container_of(work, struct gfs2_sbd, sd_freeze_work);
774 struct super_block *sb = sdp->sd_vfs;
776 atomic_inc(&sb->s_active);
777 error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED,
778 LM_FLAG_NOEXP | GL_EXACT, &freeze_gh);
780 fs_info(sdp, "GFS2: couldn't get freeze lock : %d\n", error);
781 gfs2_assert_withdraw(sdp, 0);
783 atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN);
784 error = thaw_super(sb);
786 fs_info(sdp, "GFS2: couldn't thaw filesystem: %d\n",
788 gfs2_assert_withdraw(sdp, 0);
790 gfs2_glock_dq_uninit(&freeze_gh);
792 deactivate_super(sb);
793 clear_bit_unlock(SDF_FS_FROZEN, &sdp->sd_flags);
794 wake_up_bit(&sdp->sd_flags, SDF_FS_FROZEN);
799 * gfs2_freeze - prevent further writes to the filesystem
800 * @sb: the VFS structure for the filesystem
804 static int gfs2_freeze(struct super_block *sb)
806 struct gfs2_sbd *sdp = sb->s_fs_info;
809 mutex_lock(&sdp->sd_freeze_mutex);
810 if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN)
814 if (gfs2_withdrawn(sdp)) {
819 error = gfs2_lock_fs_check_clean(sdp);
824 fs_err(sdp, "waiting for recovery before freeze\n");
825 else if (error == -EIO) {
826 fs_err(sdp, "Fatal IO error: cannot freeze gfs2 due "
827 "to recovery error.\n");
830 fs_err(sdp, "error freezing FS: %d\n", error);
832 fs_err(sdp, "retrying...\n");
835 set_bit(SDF_FS_FROZEN, &sdp->sd_flags);
837 mutex_unlock(&sdp->sd_freeze_mutex);
842 * gfs2_unfreeze - reallow writes to the filesystem
843 * @sb: the VFS structure for the filesystem
847 static int gfs2_unfreeze(struct super_block *sb)
849 struct gfs2_sbd *sdp = sb->s_fs_info;
851 mutex_lock(&sdp->sd_freeze_mutex);
852 if (atomic_read(&sdp->sd_freeze_state) != SFS_FROZEN ||
853 !gfs2_holder_initialized(&sdp->sd_freeze_gh)) {
854 mutex_unlock(&sdp->sd_freeze_mutex);
858 gfs2_glock_dq_uninit(&sdp->sd_freeze_gh);
859 mutex_unlock(&sdp->sd_freeze_mutex);
860 return wait_on_bit(&sdp->sd_flags, SDF_FS_FROZEN, TASK_INTERRUPTIBLE);
864 * statfs_fill - fill in the sg for a given RG
866 * @sc: the sc structure
868 * Returns: 0 on success, -ESTALE if the LVB is invalid
871 static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
872 struct gfs2_statfs_change_host *sc)
874 gfs2_rgrp_verify(rgd);
875 sc->sc_total += rgd->rd_data;
876 sc->sc_free += rgd->rd_free;
877 sc->sc_dinodes += rgd->rd_dinodes;
882 * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
883 * @sdp: the filesystem
884 * @sc: the sc info that will be returned
886 * Any error (other than a signal) will cause this routine to fall back
887 * to the synchronous version.
889 * FIXME: This really shouldn't busy wait like this.
894 static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
896 struct gfs2_rgrpd *rgd_next;
897 struct gfs2_holder *gha, *gh;
898 unsigned int slots = 64;
903 memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
904 gha = kmalloc_array(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
907 for (x = 0; x < slots; x++)
908 gfs2_holder_mark_uninitialized(gha + x);
910 rgd_next = gfs2_rgrpd_get_first(sdp);
915 for (x = 0; x < slots; x++) {
918 if (gfs2_holder_initialized(gh) && gfs2_glock_poll(gh)) {
919 err = gfs2_glock_wait(gh);
921 gfs2_holder_uninit(gh);
925 struct gfs2_rgrpd *rgd =
926 gfs2_glock2rgrp(gh->gh_gl);
928 error = statfs_slow_fill(rgd, sc);
930 gfs2_glock_dq_uninit(gh);
934 if (gfs2_holder_initialized(gh))
936 else if (rgd_next && !error) {
937 error = gfs2_glock_nq_init(rgd_next->rd_gl,
941 rgd_next = gfs2_rgrpd_get_next(rgd_next);
945 if (signal_pending(current))
946 error = -ERESTARTSYS;
960 * gfs2_statfs_i - Do a statfs
961 * @sdp: the filesystem
962 * @sg: the sg structure
967 static int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
969 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
970 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
972 spin_lock(&sdp->sd_statfs_spin);
975 sc->sc_total += l_sc->sc_total;
976 sc->sc_free += l_sc->sc_free;
977 sc->sc_dinodes += l_sc->sc_dinodes;
979 spin_unlock(&sdp->sd_statfs_spin);
983 if (sc->sc_free > sc->sc_total)
984 sc->sc_free = sc->sc_total;
985 if (sc->sc_dinodes < 0)
992 * gfs2_statfs - Gather and return stats about the filesystem
993 * @sb: The superblock
994 * @statfsbuf: The buffer
996 * Returns: 0 on success or error code
999 static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
1001 struct super_block *sb = dentry->d_sb;
1002 struct gfs2_sbd *sdp = sb->s_fs_info;
1003 struct gfs2_statfs_change_host sc;
1006 error = gfs2_rindex_update(sdp);
1010 if (gfs2_tune_get(sdp, gt_statfs_slow))
1011 error = gfs2_statfs_slow(sdp, &sc);
1013 error = gfs2_statfs_i(sdp, &sc);
1018 buf->f_type = GFS2_MAGIC;
1019 buf->f_bsize = sdp->sd_sb.sb_bsize;
1020 buf->f_blocks = sc.sc_total;
1021 buf->f_bfree = sc.sc_free;
1022 buf->f_bavail = sc.sc_free;
1023 buf->f_files = sc.sc_dinodes + sc.sc_free;
1024 buf->f_ffree = sc.sc_free;
1025 buf->f_namelen = GFS2_FNAMESIZE;
1031 * gfs2_drop_inode - Drop an inode (test for remote unlink)
1032 * @inode: The inode to drop
1034 * If we've received a callback on an iopen lock then it's because a
1035 * remote node tried to deallocate the inode but failed due to this node
1036 * still having the inode open. Here we mark the link count zero
1037 * since we know that it must have reached zero if the GLF_DEMOTE flag
1038 * is set on the iopen glock. If we didn't do a disk read since the
1039 * remote node removed the final link then we might otherwise miss
1040 * this event. This check ensures that this node will deallocate the
1041 * inode's blocks, or alternatively pass the baton on to another
1042 * node for later deallocation.
1045 static int gfs2_drop_inode(struct inode *inode)
1047 struct gfs2_inode *ip = GFS2_I(inode);
1049 if (!test_bit(GIF_FREE_VFS_INODE, &ip->i_flags) &&
1051 gfs2_holder_initialized(&ip->i_iopen_gh)) {
1052 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1053 if (test_bit(GLF_DEMOTE, &gl->gl_flags))
1058 * When under memory pressure when an inode's link count has dropped to
1059 * zero, defer deleting the inode to the delete workqueue. This avoids
1060 * calling into DLM under memory pressure, which can deadlock.
1062 if (!inode->i_nlink &&
1063 unlikely(current->flags & PF_MEMALLOC) &&
1064 gfs2_holder_initialized(&ip->i_iopen_gh)) {
1065 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1067 gfs2_glock_hold(gl);
1068 if (!gfs2_queue_delete_work(gl, 0))
1069 gfs2_glock_queue_put(gl);
1073 return generic_drop_inode(inode);
1076 static int is_ancestor(const struct dentry *d1, const struct dentry *d2)
1082 } while (!IS_ROOT(d1));
1087 * gfs2_show_options - Show mount options for /proc/mounts
1088 * @s: seq_file structure
1089 * @root: root of this (sub)tree
1091 * Returns: 0 on success or error code
1094 static int gfs2_show_options(struct seq_file *s, struct dentry *root)
1096 struct gfs2_sbd *sdp = root->d_sb->s_fs_info;
1097 struct gfs2_args *args = &sdp->sd_args;
1100 if (is_ancestor(root, sdp->sd_master_dir))
1101 seq_puts(s, ",meta");
1102 if (args->ar_lockproto[0])
1103 seq_show_option(s, "lockproto", args->ar_lockproto);
1104 if (args->ar_locktable[0])
1105 seq_show_option(s, "locktable", args->ar_locktable);
1106 if (args->ar_hostdata[0])
1107 seq_show_option(s, "hostdata", args->ar_hostdata);
1108 if (args->ar_spectator)
1109 seq_puts(s, ",spectator");
1110 if (args->ar_localflocks)
1111 seq_puts(s, ",localflocks");
1113 seq_puts(s, ",debug");
1114 if (args->ar_posix_acl)
1115 seq_puts(s, ",acl");
1116 if (args->ar_quota != GFS2_QUOTA_DEFAULT) {
1118 switch (args->ar_quota) {
1119 case GFS2_QUOTA_OFF:
1122 case GFS2_QUOTA_ACCOUNT:
1132 seq_printf(s, ",quota=%s", state);
1134 if (args->ar_suiddir)
1135 seq_puts(s, ",suiddir");
1136 if (args->ar_data != GFS2_DATA_DEFAULT) {
1138 switch (args->ar_data) {
1139 case GFS2_DATA_WRITEBACK:
1140 state = "writeback";
1142 case GFS2_DATA_ORDERED:
1149 seq_printf(s, ",data=%s", state);
1151 if (args->ar_discard)
1152 seq_puts(s, ",discard");
1153 val = sdp->sd_tune.gt_logd_secs;
1155 seq_printf(s, ",commit=%d", val);
1156 val = sdp->sd_tune.gt_statfs_quantum;
1158 seq_printf(s, ",statfs_quantum=%d", val);
1159 else if (sdp->sd_tune.gt_statfs_slow)
1160 seq_puts(s, ",statfs_quantum=0");
1161 val = sdp->sd_tune.gt_quota_quantum;
1163 seq_printf(s, ",quota_quantum=%d", val);
1164 if (args->ar_statfs_percent)
1165 seq_printf(s, ",statfs_percent=%d", args->ar_statfs_percent);
1166 if (args->ar_errors != GFS2_ERRORS_DEFAULT) {
1169 switch (args->ar_errors) {
1170 case GFS2_ERRORS_WITHDRAW:
1173 case GFS2_ERRORS_PANIC:
1180 seq_printf(s, ",errors=%s", state);
1182 if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags))
1183 seq_puts(s, ",nobarrier");
1184 if (test_bit(SDF_DEMOTE, &sdp->sd_flags))
1185 seq_puts(s, ",demote_interface_used");
1186 if (args->ar_rgrplvb)
1187 seq_puts(s, ",rgrplvb");
1188 if (args->ar_loccookie)
1189 seq_puts(s, ",loccookie");
1193 static void gfs2_final_release_pages(struct gfs2_inode *ip)
1195 struct inode *inode = &ip->i_inode;
1196 struct gfs2_glock *gl = ip->i_gl;
1198 truncate_inode_pages(gfs2_glock2aspace(ip->i_gl), 0);
1199 truncate_inode_pages(&inode->i_data, 0);
1201 if (atomic_read(&gl->gl_revokes) == 0) {
1202 clear_bit(GLF_LFLUSH, &gl->gl_flags);
1203 clear_bit(GLF_DIRTY, &gl->gl_flags);
1207 static int gfs2_dinode_dealloc(struct gfs2_inode *ip)
1209 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1210 struct gfs2_rgrpd *rgd;
1211 struct gfs2_holder gh;
1214 if (gfs2_get_inode_blocks(&ip->i_inode) != 1) {
1215 gfs2_consist_inode(ip);
1219 error = gfs2_rindex_update(sdp);
1223 error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
1227 rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
1229 gfs2_consist_inode(ip);
1234 error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &gh);
1238 error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA,
1239 sdp->sd_jdesc->jd_blocks);
1241 goto out_rg_gunlock;
1243 gfs2_free_di(rgd, ip);
1245 gfs2_final_release_pages(ip);
1247 gfs2_trans_end(sdp);
1250 gfs2_glock_dq_uninit(&gh);
1252 gfs2_quota_unhold(ip);
1257 * gfs2_glock_put_eventually
1258 * @gl: The glock to put
1260 * When under memory pressure, trigger a deferred glock put to make sure we
1261 * won't call into DLM and deadlock. Otherwise, put the glock directly.
1264 static void gfs2_glock_put_eventually(struct gfs2_glock *gl)
1266 if (current->flags & PF_MEMALLOC)
1267 gfs2_glock_queue_put(gl);
1272 static bool gfs2_upgrade_iopen_glock(struct inode *inode)
1274 struct gfs2_inode *ip = GFS2_I(inode);
1275 struct gfs2_sbd *sdp = GFS2_SB(inode);
1276 struct gfs2_holder *gh = &ip->i_iopen_gh;
1277 long timeout = 5 * HZ;
1280 gh->gh_flags |= GL_NOCACHE;
1281 gfs2_glock_dq_wait(gh);
1284 * If there are no other lock holders, we'll get the lock immediately.
1285 * Otherwise, the other nodes holding the lock will be notified about
1286 * our locking request. If they don't have the inode open, they'll
1287 * evict the cached inode and release the lock. Otherwise, if they
1288 * poke the inode glock, we'll take this as an indication that they
1289 * still need the iopen glock and that they'll take care of deleting
1290 * the inode when they're done. As a last resort, if another node
1291 * keeps holding the iopen glock without showing any activity on the
1292 * inode glock, we'll eventually time out.
1294 * Note that we're passing the LM_FLAG_TRY_1CB flag to the first
1295 * locking request as an optimization to notify lock holders as soon as
1296 * possible. Without that flag, they'd be notified implicitly by the
1297 * second locking request.
1300 gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, gh);
1301 error = gfs2_glock_nq(gh);
1302 if (error != GLR_TRYFAILED)
1305 gfs2_holder_reinit(LM_ST_EXCLUSIVE, GL_ASYNC | GL_NOCACHE, gh);
1306 error = gfs2_glock_nq(gh);
1310 timeout = wait_event_interruptible_timeout(sdp->sd_async_glock_wait,
1311 !test_bit(HIF_WAIT, &gh->gh_iflags) ||
1312 test_bit(GLF_DEMOTE, &ip->i_gl->gl_flags),
1314 if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) {
1322 * evict_should_delete - determine whether the inode is eligible for deletion
1323 * @inode: The inode to evict
1325 * This function determines whether the evicted inode is eligible to be deleted
1326 * and locks the inode glock.
1328 * Returns: the fate of the dinode
1330 static enum dinode_demise evict_should_delete(struct inode *inode,
1331 struct gfs2_holder *gh)
1333 struct gfs2_inode *ip = GFS2_I(inode);
1334 struct super_block *sb = inode->i_sb;
1335 struct gfs2_sbd *sdp = sb->s_fs_info;
1338 if (test_bit(GIF_ALLOC_FAILED, &ip->i_flags)) {
1339 BUG_ON(!gfs2_glock_is_locked_by_me(ip->i_gl));
1343 if (test_bit(GIF_DEFERRED_DELETE, &ip->i_flags))
1344 return SHOULD_DEFER_EVICTION;
1346 /* Deletes should never happen under memory pressure anymore. */
1347 if (WARN_ON_ONCE(current->flags & PF_MEMALLOC))
1348 return SHOULD_DEFER_EVICTION;
1350 /* Must not read inode block until block type has been verified */
1351 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, gh);
1352 if (unlikely(ret)) {
1353 glock_clear_object(ip->i_iopen_gh.gh_gl, ip);
1354 ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
1355 gfs2_glock_dq_uninit(&ip->i_iopen_gh);
1356 return SHOULD_DEFER_EVICTION;
1359 if (gfs2_inode_already_deleted(ip->i_gl, ip->i_no_formal_ino))
1360 return SHOULD_NOT_DELETE_DINODE;
1361 ret = gfs2_check_blk_type(sdp, ip->i_no_addr, GFS2_BLKST_UNLINKED);
1363 return SHOULD_NOT_DELETE_DINODE;
1365 if (test_bit(GIF_INVALID, &ip->i_flags)) {
1366 ret = gfs2_inode_refresh(ip);
1368 return SHOULD_NOT_DELETE_DINODE;
1372 * The inode may have been recreated in the meantime.
1375 return SHOULD_NOT_DELETE_DINODE;
1378 if (gfs2_holder_initialized(&ip->i_iopen_gh) &&
1379 test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
1380 if (!gfs2_upgrade_iopen_glock(inode)) {
1381 gfs2_holder_uninit(&ip->i_iopen_gh);
1382 return SHOULD_NOT_DELETE_DINODE;
1385 return SHOULD_DELETE_DINODE;
1389 * evict_unlinked_inode - delete the pieces of an unlinked evicted inode
1390 * @inode: The inode to evict
1392 static int evict_unlinked_inode(struct inode *inode)
1394 struct gfs2_inode *ip = GFS2_I(inode);
1397 if (S_ISDIR(inode->i_mode) &&
1398 (ip->i_diskflags & GFS2_DIF_EXHASH)) {
1399 ret = gfs2_dir_exhash_dealloc(ip);
1405 ret = gfs2_ea_dealloc(ip);
1410 if (!gfs2_is_stuffed(ip)) {
1411 ret = gfs2_file_dealloc(ip);
1416 /* We're about to clear the bitmap for the dinode, but as soon as we
1417 do, gfs2_create_inode can create another inode at the same block
1418 location and try to set gl_object again. We clear gl_object here so
1419 that subsequent inode creates don't see an old gl_object. */
1420 glock_clear_object(ip->i_gl, ip);
1421 ret = gfs2_dinode_dealloc(ip);
1422 gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino);
1428 * evict_linked_inode - evict an inode whose dinode has not been unlinked
1429 * @inode: The inode to evict
1431 static int evict_linked_inode(struct inode *inode)
1433 struct super_block *sb = inode->i_sb;
1434 struct gfs2_sbd *sdp = sb->s_fs_info;
1435 struct gfs2_inode *ip = GFS2_I(inode);
1436 struct address_space *metamapping;
1439 gfs2_log_flush(sdp, ip->i_gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
1440 GFS2_LFC_EVICT_INODE);
1441 metamapping = gfs2_glock2aspace(ip->i_gl);
1442 if (test_bit(GLF_DIRTY, &ip->i_gl->gl_flags)) {
1443 filemap_fdatawrite(metamapping);
1444 filemap_fdatawait(metamapping);
1446 write_inode_now(inode, 1);
1447 gfs2_ail_flush(ip->i_gl, 0);
1449 ret = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
1453 /* Needs to be done before glock release & also in a transaction */
1454 truncate_inode_pages(&inode->i_data, 0);
1455 truncate_inode_pages(metamapping, 0);
1456 gfs2_trans_end(sdp);
1461 * gfs2_evict_inode - Remove an inode from cache
1462 * @inode: The inode to evict
1464 * There are three cases to consider:
1465 * 1. i_nlink == 0, we are final opener (and must deallocate)
1466 * 2. i_nlink == 0, we are not the final opener (and cannot deallocate)
1469 * If the fs is read only, then we have to treat all cases as per #3
1470 * since we are unable to do any deallocation. The inode will be
1471 * deallocated by the next read/write node to attempt an allocation
1472 * in the same resource group
1474 * We have to (at the moment) hold the inodes main lock to cover
1475 * the gap between unlocking the shared lock on the iopen lock and
1476 * taking the exclusive lock. I'd rather do a shared -> exclusive
1477 * conversion on the iopen lock, but we can change that later. This
1478 * is safe, just less efficient.
1481 static void gfs2_evict_inode(struct inode *inode)
1483 struct super_block *sb = inode->i_sb;
1484 struct gfs2_sbd *sdp = sb->s_fs_info;
1485 struct gfs2_inode *ip = GFS2_I(inode);
1486 struct gfs2_holder gh;
1489 if (test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) {
1494 if (inode->i_nlink || sb_rdonly(sb))
1497 gfs2_holder_mark_uninitialized(&gh);
1498 ret = evict_should_delete(inode, &gh);
1499 if (ret == SHOULD_DEFER_EVICTION)
1501 if (ret == SHOULD_DELETE_DINODE)
1502 ret = evict_unlinked_inode(inode);
1504 ret = evict_linked_inode(inode);
1506 if (gfs2_rs_active(&ip->i_res))
1507 gfs2_rs_deltree(&ip->i_res);
1509 if (gfs2_holder_initialized(&gh)) {
1510 glock_clear_object(ip->i_gl, ip);
1511 gfs2_glock_dq_uninit(&gh);
1513 if (ret && ret != GLR_TRYFAILED && ret != -EROFS)
1514 fs_warn(sdp, "gfs2_evict_inode: %d\n", ret);
1516 truncate_inode_pages_final(&inode->i_data);
1518 gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
1519 gfs2_rs_delete(ip, NULL);
1520 gfs2_ordered_del_inode(ip);
1522 gfs2_dir_hash_inval(ip);
1524 glock_clear_object(ip->i_gl, ip);
1525 wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
1526 gfs2_glock_add_to_lru(ip->i_gl);
1527 gfs2_glock_put_eventually(ip->i_gl);
1530 if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
1531 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1533 glock_clear_object(gl, ip);
1534 if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
1535 ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
1536 gfs2_glock_dq(&ip->i_iopen_gh);
1538 gfs2_glock_hold(gl);
1539 gfs2_holder_uninit(&ip->i_iopen_gh);
1540 gfs2_glock_put_eventually(gl);
1544 static struct inode *gfs2_alloc_inode(struct super_block *sb)
1546 struct gfs2_inode *ip;
1548 ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL);
1553 gfs2_holder_mark_uninitialized(&ip->i_iopen_gh);
1554 memset(&ip->i_res, 0, sizeof(ip->i_res));
1555 RB_CLEAR_NODE(&ip->i_res.rs_node);
1557 return &ip->i_inode;
1560 static void gfs2_free_inode(struct inode *inode)
1562 kmem_cache_free(gfs2_inode_cachep, GFS2_I(inode));
1565 extern void free_local_statfs_inodes(struct gfs2_sbd *sdp)
1567 struct local_statfs_inode *lsi, *safe;
1569 /* Run through the statfs inodes list to iput and free memory */
1570 list_for_each_entry_safe(lsi, safe, &sdp->sd_sc_inodes_list, si_list) {
1571 if (lsi->si_jid == sdp->sd_jdesc->jd_jid)
1572 sdp->sd_sc_inode = NULL; /* belongs to this node */
1573 if (lsi->si_sc_inode)
1574 iput(lsi->si_sc_inode);
1575 list_del(&lsi->si_list);
1580 extern struct inode *find_local_statfs_inode(struct gfs2_sbd *sdp,
1583 struct local_statfs_inode *lsi;
1585 /* Return the local (per node) statfs inode in the
1586 * sdp->sd_sc_inodes_list corresponding to the 'index'. */
1587 list_for_each_entry(lsi, &sdp->sd_sc_inodes_list, si_list) {
1588 if (lsi->si_jid == index)
1589 return lsi->si_sc_inode;
1594 const struct super_operations gfs2_super_ops = {
1595 .alloc_inode = gfs2_alloc_inode,
1596 .free_inode = gfs2_free_inode,
1597 .write_inode = gfs2_write_inode,
1598 .dirty_inode = gfs2_dirty_inode,
1599 .evict_inode = gfs2_evict_inode,
1600 .put_super = gfs2_put_super,
1601 .sync_fs = gfs2_sync_fs,
1602 .freeze_super = gfs2_freeze,
1603 .thaw_super = gfs2_unfreeze,
1604 .statfs = gfs2_statfs,
1605 .drop_inode = gfs2_drop_inode,
1606 .show_options = gfs2_show_options,