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 gfs2_delete_debugfs_file(sdp);
742 /* Unmount the locking protocol */
743 gfs2_lm_unmount(sdp);
745 /* At this point, we're through participating in the lockspace */
746 gfs2_sys_fs_del(sdp);
751 * gfs2_sync_fs - sync the filesystem
752 * @sb: the superblock
754 * Flushes the log to disk.
757 static int gfs2_sync_fs(struct super_block *sb, int wait)
759 struct gfs2_sbd *sdp = sb->s_fs_info;
761 gfs2_quota_sync(sb, -1);
763 gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL |
765 return sdp->sd_log_error;
768 void gfs2_freeze_func(struct work_struct *work)
771 struct gfs2_holder freeze_gh;
772 struct gfs2_sbd *sdp = container_of(work, struct gfs2_sbd, sd_freeze_work);
773 struct super_block *sb = sdp->sd_vfs;
775 atomic_inc(&sb->s_active);
776 error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED,
777 LM_FLAG_NOEXP | GL_EXACT, &freeze_gh);
779 fs_info(sdp, "GFS2: couldn't get freeze lock : %d\n", error);
780 gfs2_assert_withdraw(sdp, 0);
782 atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN);
783 error = thaw_super(sb);
785 fs_info(sdp, "GFS2: couldn't thaw filesystem: %d\n",
787 gfs2_assert_withdraw(sdp, 0);
789 gfs2_glock_dq_uninit(&freeze_gh);
791 deactivate_super(sb);
792 clear_bit_unlock(SDF_FS_FROZEN, &sdp->sd_flags);
793 wake_up_bit(&sdp->sd_flags, SDF_FS_FROZEN);
798 * gfs2_freeze - prevent further writes to the filesystem
799 * @sb: the VFS structure for the filesystem
803 static int gfs2_freeze(struct super_block *sb)
805 struct gfs2_sbd *sdp = sb->s_fs_info;
808 mutex_lock(&sdp->sd_freeze_mutex);
809 if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN)
813 if (gfs2_withdrawn(sdp)) {
818 error = gfs2_lock_fs_check_clean(sdp);
823 fs_err(sdp, "waiting for recovery before freeze\n");
824 else if (error == -EIO) {
825 fs_err(sdp, "Fatal IO error: cannot freeze gfs2 due "
826 "to recovery error.\n");
829 fs_err(sdp, "error freezing FS: %d\n", error);
831 fs_err(sdp, "retrying...\n");
834 set_bit(SDF_FS_FROZEN, &sdp->sd_flags);
836 mutex_unlock(&sdp->sd_freeze_mutex);
841 * gfs2_unfreeze - reallow writes to the filesystem
842 * @sb: the VFS structure for the filesystem
846 static int gfs2_unfreeze(struct super_block *sb)
848 struct gfs2_sbd *sdp = sb->s_fs_info;
850 mutex_lock(&sdp->sd_freeze_mutex);
851 if (atomic_read(&sdp->sd_freeze_state) != SFS_FROZEN ||
852 !gfs2_holder_initialized(&sdp->sd_freeze_gh)) {
853 mutex_unlock(&sdp->sd_freeze_mutex);
857 gfs2_glock_dq_uninit(&sdp->sd_freeze_gh);
858 mutex_unlock(&sdp->sd_freeze_mutex);
859 return wait_on_bit(&sdp->sd_flags, SDF_FS_FROZEN, TASK_INTERRUPTIBLE);
863 * statfs_fill - fill in the sg for a given RG
865 * @sc: the sc structure
867 * Returns: 0 on success, -ESTALE if the LVB is invalid
870 static int statfs_slow_fill(struct gfs2_rgrpd *rgd,
871 struct gfs2_statfs_change_host *sc)
873 gfs2_rgrp_verify(rgd);
874 sc->sc_total += rgd->rd_data;
875 sc->sc_free += rgd->rd_free;
876 sc->sc_dinodes += rgd->rd_dinodes;
881 * gfs2_statfs_slow - Stat a filesystem using asynchronous locking
882 * @sdp: the filesystem
883 * @sc: the sc info that will be returned
885 * Any error (other than a signal) will cause this routine to fall back
886 * to the synchronous version.
888 * FIXME: This really shouldn't busy wait like this.
893 static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
895 struct gfs2_rgrpd *rgd_next;
896 struct gfs2_holder *gha, *gh;
897 unsigned int slots = 64;
902 memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
903 gha = kmalloc_array(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
906 for (x = 0; x < slots; x++)
907 gfs2_holder_mark_uninitialized(gha + x);
909 rgd_next = gfs2_rgrpd_get_first(sdp);
914 for (x = 0; x < slots; x++) {
917 if (gfs2_holder_initialized(gh) && gfs2_glock_poll(gh)) {
918 err = gfs2_glock_wait(gh);
920 gfs2_holder_uninit(gh);
924 struct gfs2_rgrpd *rgd =
925 gfs2_glock2rgrp(gh->gh_gl);
927 error = statfs_slow_fill(rgd, sc);
929 gfs2_glock_dq_uninit(gh);
933 if (gfs2_holder_initialized(gh))
935 else if (rgd_next && !error) {
936 error = gfs2_glock_nq_init(rgd_next->rd_gl,
940 rgd_next = gfs2_rgrpd_get_next(rgd_next);
944 if (signal_pending(current))
945 error = -ERESTARTSYS;
959 * gfs2_statfs_i - Do a statfs
960 * @sdp: the filesystem
961 * @sg: the sg structure
966 static int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc)
968 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master;
969 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local;
971 spin_lock(&sdp->sd_statfs_spin);
974 sc->sc_total += l_sc->sc_total;
975 sc->sc_free += l_sc->sc_free;
976 sc->sc_dinodes += l_sc->sc_dinodes;
978 spin_unlock(&sdp->sd_statfs_spin);
982 if (sc->sc_free > sc->sc_total)
983 sc->sc_free = sc->sc_total;
984 if (sc->sc_dinodes < 0)
991 * gfs2_statfs - Gather and return stats about the filesystem
992 * @sb: The superblock
993 * @statfsbuf: The buffer
995 * Returns: 0 on success or error code
998 static int gfs2_statfs(struct dentry *dentry, struct kstatfs *buf)
1000 struct super_block *sb = dentry->d_sb;
1001 struct gfs2_sbd *sdp = sb->s_fs_info;
1002 struct gfs2_statfs_change_host sc;
1005 error = gfs2_rindex_update(sdp);
1009 if (gfs2_tune_get(sdp, gt_statfs_slow))
1010 error = gfs2_statfs_slow(sdp, &sc);
1012 error = gfs2_statfs_i(sdp, &sc);
1017 buf->f_type = GFS2_MAGIC;
1018 buf->f_bsize = sdp->sd_sb.sb_bsize;
1019 buf->f_blocks = sc.sc_total;
1020 buf->f_bfree = sc.sc_free;
1021 buf->f_bavail = sc.sc_free;
1022 buf->f_files = sc.sc_dinodes + sc.sc_free;
1023 buf->f_ffree = sc.sc_free;
1024 buf->f_namelen = GFS2_FNAMESIZE;
1030 * gfs2_drop_inode - Drop an inode (test for remote unlink)
1031 * @inode: The inode to drop
1033 * If we've received a callback on an iopen lock then it's because a
1034 * remote node tried to deallocate the inode but failed due to this node
1035 * still having the inode open. Here we mark the link count zero
1036 * since we know that it must have reached zero if the GLF_DEMOTE flag
1037 * is set on the iopen glock. If we didn't do a disk read since the
1038 * remote node removed the final link then we might otherwise miss
1039 * this event. This check ensures that this node will deallocate the
1040 * inode's blocks, or alternatively pass the baton on to another
1041 * node for later deallocation.
1044 static int gfs2_drop_inode(struct inode *inode)
1046 struct gfs2_inode *ip = GFS2_I(inode);
1048 if (!test_bit(GIF_FREE_VFS_INODE, &ip->i_flags) &&
1050 gfs2_holder_initialized(&ip->i_iopen_gh)) {
1051 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1052 if (test_bit(GLF_DEMOTE, &gl->gl_flags))
1057 * When under memory pressure when an inode's link count has dropped to
1058 * zero, defer deleting the inode to the delete workqueue. This avoids
1059 * calling into DLM under memory pressure, which can deadlock.
1061 if (!inode->i_nlink &&
1062 unlikely(current->flags & PF_MEMALLOC) &&
1063 gfs2_holder_initialized(&ip->i_iopen_gh)) {
1064 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1066 gfs2_glock_hold(gl);
1067 if (!gfs2_queue_delete_work(gl, 0))
1068 gfs2_glock_queue_put(gl);
1072 return generic_drop_inode(inode);
1075 static int is_ancestor(const struct dentry *d1, const struct dentry *d2)
1081 } while (!IS_ROOT(d1));
1086 * gfs2_show_options - Show mount options for /proc/mounts
1087 * @s: seq_file structure
1088 * @root: root of this (sub)tree
1090 * Returns: 0 on success or error code
1093 static int gfs2_show_options(struct seq_file *s, struct dentry *root)
1095 struct gfs2_sbd *sdp = root->d_sb->s_fs_info;
1096 struct gfs2_args *args = &sdp->sd_args;
1099 if (is_ancestor(root, sdp->sd_master_dir))
1100 seq_puts(s, ",meta");
1101 if (args->ar_lockproto[0])
1102 seq_show_option(s, "lockproto", args->ar_lockproto);
1103 if (args->ar_locktable[0])
1104 seq_show_option(s, "locktable", args->ar_locktable);
1105 if (args->ar_hostdata[0])
1106 seq_show_option(s, "hostdata", args->ar_hostdata);
1107 if (args->ar_spectator)
1108 seq_puts(s, ",spectator");
1109 if (args->ar_localflocks)
1110 seq_puts(s, ",localflocks");
1112 seq_puts(s, ",debug");
1113 if (args->ar_posix_acl)
1114 seq_puts(s, ",acl");
1115 if (args->ar_quota != GFS2_QUOTA_DEFAULT) {
1117 switch (args->ar_quota) {
1118 case GFS2_QUOTA_OFF:
1121 case GFS2_QUOTA_ACCOUNT:
1131 seq_printf(s, ",quota=%s", state);
1133 if (args->ar_suiddir)
1134 seq_puts(s, ",suiddir");
1135 if (args->ar_data != GFS2_DATA_DEFAULT) {
1137 switch (args->ar_data) {
1138 case GFS2_DATA_WRITEBACK:
1139 state = "writeback";
1141 case GFS2_DATA_ORDERED:
1148 seq_printf(s, ",data=%s", state);
1150 if (args->ar_discard)
1151 seq_puts(s, ",discard");
1152 val = sdp->sd_tune.gt_logd_secs;
1154 seq_printf(s, ",commit=%d", val);
1155 val = sdp->sd_tune.gt_statfs_quantum;
1157 seq_printf(s, ",statfs_quantum=%d", val);
1158 else if (sdp->sd_tune.gt_statfs_slow)
1159 seq_puts(s, ",statfs_quantum=0");
1160 val = sdp->sd_tune.gt_quota_quantum;
1162 seq_printf(s, ",quota_quantum=%d", val);
1163 if (args->ar_statfs_percent)
1164 seq_printf(s, ",statfs_percent=%d", args->ar_statfs_percent);
1165 if (args->ar_errors != GFS2_ERRORS_DEFAULT) {
1168 switch (args->ar_errors) {
1169 case GFS2_ERRORS_WITHDRAW:
1172 case GFS2_ERRORS_PANIC:
1179 seq_printf(s, ",errors=%s", state);
1181 if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags))
1182 seq_puts(s, ",nobarrier");
1183 if (test_bit(SDF_DEMOTE, &sdp->sd_flags))
1184 seq_puts(s, ",demote_interface_used");
1185 if (args->ar_rgrplvb)
1186 seq_puts(s, ",rgrplvb");
1187 if (args->ar_loccookie)
1188 seq_puts(s, ",loccookie");
1192 static void gfs2_final_release_pages(struct gfs2_inode *ip)
1194 struct inode *inode = &ip->i_inode;
1195 struct gfs2_glock *gl = ip->i_gl;
1197 truncate_inode_pages(gfs2_glock2aspace(ip->i_gl), 0);
1198 truncate_inode_pages(&inode->i_data, 0);
1200 if (atomic_read(&gl->gl_revokes) == 0) {
1201 clear_bit(GLF_LFLUSH, &gl->gl_flags);
1202 clear_bit(GLF_DIRTY, &gl->gl_flags);
1206 static int gfs2_dinode_dealloc(struct gfs2_inode *ip)
1208 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
1209 struct gfs2_rgrpd *rgd;
1210 struct gfs2_holder gh;
1213 if (gfs2_get_inode_blocks(&ip->i_inode) != 1) {
1214 gfs2_consist_inode(ip);
1218 error = gfs2_rindex_update(sdp);
1222 error = gfs2_quota_hold(ip, NO_UID_QUOTA_CHANGE, NO_GID_QUOTA_CHANGE);
1226 rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1);
1228 gfs2_consist_inode(ip);
1233 error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &gh);
1237 error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA,
1238 sdp->sd_jdesc->jd_blocks);
1240 goto out_rg_gunlock;
1242 gfs2_free_di(rgd, ip);
1244 gfs2_final_release_pages(ip);
1246 gfs2_trans_end(sdp);
1249 gfs2_glock_dq_uninit(&gh);
1251 gfs2_quota_unhold(ip);
1256 * gfs2_glock_put_eventually
1257 * @gl: The glock to put
1259 * When under memory pressure, trigger a deferred glock put to make sure we
1260 * won't call into DLM and deadlock. Otherwise, put the glock directly.
1263 static void gfs2_glock_put_eventually(struct gfs2_glock *gl)
1265 if (current->flags & PF_MEMALLOC)
1266 gfs2_glock_queue_put(gl);
1271 static bool gfs2_upgrade_iopen_glock(struct inode *inode)
1273 struct gfs2_inode *ip = GFS2_I(inode);
1274 struct gfs2_sbd *sdp = GFS2_SB(inode);
1275 struct gfs2_holder *gh = &ip->i_iopen_gh;
1276 long timeout = 5 * HZ;
1279 gh->gh_flags |= GL_NOCACHE;
1280 gfs2_glock_dq_wait(gh);
1283 * If there are no other lock holders, we'll get the lock immediately.
1284 * Otherwise, the other nodes holding the lock will be notified about
1285 * our locking request. If they don't have the inode open, they'll
1286 * evict the cached inode and release the lock. Otherwise, if they
1287 * poke the inode glock, we'll take this as an indication that they
1288 * still need the iopen glock and that they'll take care of deleting
1289 * the inode when they're done. As a last resort, if another node
1290 * keeps holding the iopen glock without showing any activity on the
1291 * inode glock, we'll eventually time out.
1293 * Note that we're passing the LM_FLAG_TRY_1CB flag to the first
1294 * locking request as an optimization to notify lock holders as soon as
1295 * possible. Without that flag, they'd be notified implicitly by the
1296 * second locking request.
1299 gfs2_holder_reinit(LM_ST_EXCLUSIVE, LM_FLAG_TRY_1CB | GL_NOCACHE, gh);
1300 error = gfs2_glock_nq(gh);
1301 if (error != GLR_TRYFAILED)
1304 gfs2_holder_reinit(LM_ST_EXCLUSIVE, GL_ASYNC | GL_NOCACHE, gh);
1305 error = gfs2_glock_nq(gh);
1309 timeout = wait_event_interruptible_timeout(sdp->sd_async_glock_wait,
1310 !test_bit(HIF_WAIT, &gh->gh_iflags) ||
1311 test_bit(GLF_DEMOTE, &ip->i_gl->gl_flags),
1313 if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) {
1321 * evict_should_delete - determine whether the inode is eligible for deletion
1322 * @inode: The inode to evict
1324 * This function determines whether the evicted inode is eligible to be deleted
1325 * and locks the inode glock.
1327 * Returns: the fate of the dinode
1329 static enum dinode_demise evict_should_delete(struct inode *inode,
1330 struct gfs2_holder *gh)
1332 struct gfs2_inode *ip = GFS2_I(inode);
1333 struct super_block *sb = inode->i_sb;
1334 struct gfs2_sbd *sdp = sb->s_fs_info;
1337 if (test_bit(GIF_ALLOC_FAILED, &ip->i_flags)) {
1338 BUG_ON(!gfs2_glock_is_locked_by_me(ip->i_gl));
1342 if (test_bit(GIF_DEFERRED_DELETE, &ip->i_flags))
1343 return SHOULD_DEFER_EVICTION;
1345 /* Deletes should never happen under memory pressure anymore. */
1346 if (WARN_ON_ONCE(current->flags & PF_MEMALLOC))
1347 return SHOULD_DEFER_EVICTION;
1349 /* Must not read inode block until block type has been verified */
1350 ret = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, GL_SKIP, gh);
1351 if (unlikely(ret)) {
1352 glock_clear_object(ip->i_iopen_gh.gh_gl, ip);
1353 ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
1354 gfs2_glock_dq_uninit(&ip->i_iopen_gh);
1355 return SHOULD_DEFER_EVICTION;
1358 if (gfs2_inode_already_deleted(ip->i_gl, ip->i_no_formal_ino))
1359 return SHOULD_NOT_DELETE_DINODE;
1360 ret = gfs2_check_blk_type(sdp, ip->i_no_addr, GFS2_BLKST_UNLINKED);
1362 return SHOULD_NOT_DELETE_DINODE;
1364 if (test_bit(GIF_INVALID, &ip->i_flags)) {
1365 ret = gfs2_inode_refresh(ip);
1367 return SHOULD_NOT_DELETE_DINODE;
1371 * The inode may have been recreated in the meantime.
1374 return SHOULD_NOT_DELETE_DINODE;
1377 if (gfs2_holder_initialized(&ip->i_iopen_gh) &&
1378 test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
1379 if (!gfs2_upgrade_iopen_glock(inode)) {
1380 gfs2_holder_uninit(&ip->i_iopen_gh);
1381 return SHOULD_NOT_DELETE_DINODE;
1384 return SHOULD_DELETE_DINODE;
1388 * evict_unlinked_inode - delete the pieces of an unlinked evicted inode
1389 * @inode: The inode to evict
1391 static int evict_unlinked_inode(struct inode *inode)
1393 struct gfs2_inode *ip = GFS2_I(inode);
1396 if (S_ISDIR(inode->i_mode) &&
1397 (ip->i_diskflags & GFS2_DIF_EXHASH)) {
1398 ret = gfs2_dir_exhash_dealloc(ip);
1404 ret = gfs2_ea_dealloc(ip);
1409 if (!gfs2_is_stuffed(ip)) {
1410 ret = gfs2_file_dealloc(ip);
1415 /* We're about to clear the bitmap for the dinode, but as soon as we
1416 do, gfs2_create_inode can create another inode at the same block
1417 location and try to set gl_object again. We clear gl_object here so
1418 that subsequent inode creates don't see an old gl_object. */
1419 glock_clear_object(ip->i_gl, ip);
1420 ret = gfs2_dinode_dealloc(ip);
1421 gfs2_inode_remember_delete(ip->i_gl, ip->i_no_formal_ino);
1427 * evict_linked_inode - evict an inode whose dinode has not been unlinked
1428 * @inode: The inode to evict
1430 static int evict_linked_inode(struct inode *inode)
1432 struct super_block *sb = inode->i_sb;
1433 struct gfs2_sbd *sdp = sb->s_fs_info;
1434 struct gfs2_inode *ip = GFS2_I(inode);
1435 struct address_space *metamapping;
1438 gfs2_log_flush(sdp, ip->i_gl, GFS2_LOG_HEAD_FLUSH_NORMAL |
1439 GFS2_LFC_EVICT_INODE);
1440 metamapping = gfs2_glock2aspace(ip->i_gl);
1441 if (test_bit(GLF_DIRTY, &ip->i_gl->gl_flags)) {
1442 filemap_fdatawrite(metamapping);
1443 filemap_fdatawait(metamapping);
1445 write_inode_now(inode, 1);
1446 gfs2_ail_flush(ip->i_gl, 0);
1448 ret = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
1452 /* Needs to be done before glock release & also in a transaction */
1453 truncate_inode_pages(&inode->i_data, 0);
1454 truncate_inode_pages(metamapping, 0);
1455 gfs2_trans_end(sdp);
1460 * gfs2_evict_inode - Remove an inode from cache
1461 * @inode: The inode to evict
1463 * There are three cases to consider:
1464 * 1. i_nlink == 0, we are final opener (and must deallocate)
1465 * 2. i_nlink == 0, we are not the final opener (and cannot deallocate)
1468 * If the fs is read only, then we have to treat all cases as per #3
1469 * since we are unable to do any deallocation. The inode will be
1470 * deallocated by the next read/write node to attempt an allocation
1471 * in the same resource group
1473 * We have to (at the moment) hold the inodes main lock to cover
1474 * the gap between unlocking the shared lock on the iopen lock and
1475 * taking the exclusive lock. I'd rather do a shared -> exclusive
1476 * conversion on the iopen lock, but we can change that later. This
1477 * is safe, just less efficient.
1480 static void gfs2_evict_inode(struct inode *inode)
1482 struct super_block *sb = inode->i_sb;
1483 struct gfs2_sbd *sdp = sb->s_fs_info;
1484 struct gfs2_inode *ip = GFS2_I(inode);
1485 struct gfs2_holder gh;
1488 if (test_bit(GIF_FREE_VFS_INODE, &ip->i_flags)) {
1493 if (inode->i_nlink || sb_rdonly(sb))
1496 gfs2_holder_mark_uninitialized(&gh);
1497 ret = evict_should_delete(inode, &gh);
1498 if (ret == SHOULD_DEFER_EVICTION)
1500 if (ret == SHOULD_DELETE_DINODE)
1501 ret = evict_unlinked_inode(inode);
1503 ret = evict_linked_inode(inode);
1505 if (gfs2_rs_active(&ip->i_res))
1506 gfs2_rs_deltree(&ip->i_res);
1508 if (gfs2_holder_initialized(&gh)) {
1509 glock_clear_object(ip->i_gl, ip);
1510 gfs2_glock_dq_uninit(&gh);
1512 if (ret && ret != GLR_TRYFAILED && ret != -EROFS)
1513 fs_warn(sdp, "gfs2_evict_inode: %d\n", ret);
1515 truncate_inode_pages_final(&inode->i_data);
1517 gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);
1518 gfs2_rs_delete(ip, NULL);
1519 gfs2_ordered_del_inode(ip);
1521 gfs2_dir_hash_inval(ip);
1523 glock_clear_object(ip->i_gl, ip);
1524 wait_on_bit_io(&ip->i_flags, GIF_GLOP_PENDING, TASK_UNINTERRUPTIBLE);
1525 gfs2_glock_add_to_lru(ip->i_gl);
1526 gfs2_glock_put_eventually(ip->i_gl);
1529 if (gfs2_holder_initialized(&ip->i_iopen_gh)) {
1530 struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1532 glock_clear_object(gl, ip);
1533 if (test_bit(HIF_HOLDER, &ip->i_iopen_gh.gh_iflags)) {
1534 ip->i_iopen_gh.gh_flags |= GL_NOCACHE;
1535 gfs2_glock_dq(&ip->i_iopen_gh);
1537 gfs2_glock_hold(gl);
1538 gfs2_holder_uninit(&ip->i_iopen_gh);
1539 gfs2_glock_put_eventually(gl);
1543 static struct inode *gfs2_alloc_inode(struct super_block *sb)
1545 struct gfs2_inode *ip;
1547 ip = kmem_cache_alloc(gfs2_inode_cachep, GFP_KERNEL);
1552 gfs2_holder_mark_uninitialized(&ip->i_iopen_gh);
1553 memset(&ip->i_res, 0, sizeof(ip->i_res));
1554 RB_CLEAR_NODE(&ip->i_res.rs_node);
1556 return &ip->i_inode;
1559 static void gfs2_free_inode(struct inode *inode)
1561 kmem_cache_free(gfs2_inode_cachep, GFS2_I(inode));
1564 extern void free_local_statfs_inodes(struct gfs2_sbd *sdp)
1566 struct local_statfs_inode *lsi, *safe;
1568 /* Run through the statfs inodes list to iput and free memory */
1569 list_for_each_entry_safe(lsi, safe, &sdp->sd_sc_inodes_list, si_list) {
1570 if (lsi->si_jid == sdp->sd_jdesc->jd_jid)
1571 sdp->sd_sc_inode = NULL; /* belongs to this node */
1572 if (lsi->si_sc_inode)
1573 iput(lsi->si_sc_inode);
1574 list_del(&lsi->si_list);
1579 extern struct inode *find_local_statfs_inode(struct gfs2_sbd *sdp,
1582 struct local_statfs_inode *lsi;
1584 /* Return the local (per node) statfs inode in the
1585 * sdp->sd_sc_inodes_list corresponding to the 'index'. */
1586 list_for_each_entry(lsi, &sdp->sd_sc_inodes_list, si_list) {
1587 if (lsi->si_jid == index)
1588 return lsi->si_sc_inode;
1593 const struct super_operations gfs2_super_ops = {
1594 .alloc_inode = gfs2_alloc_inode,
1595 .free_inode = gfs2_free_inode,
1596 .write_inode = gfs2_write_inode,
1597 .dirty_inode = gfs2_dirty_inode,
1598 .evict_inode = gfs2_evict_inode,
1599 .put_super = gfs2_put_super,
1600 .sync_fs = gfs2_sync_fs,
1601 .freeze_super = gfs2_freeze,
1602 .thaw_super = gfs2_unfreeze,
1603 .statfs = gfs2_statfs,
1604 .drop_inode = gfs2_drop_inode,
1605 .show_options = gfs2_show_options,