Lines Matching refs:sdp

53 void gfs2_jindex_free(struct gfs2_sbd *sdp)  in gfs2_jindex_free()  argument
58 spin_lock(&sdp->sd_jindex_spin); in gfs2_jindex_free()
59 list_add(&list, &sdp->sd_jindex_list); in gfs2_jindex_free()
60 list_del_init(&sdp->sd_jindex_list); in gfs2_jindex_free()
61 sdp->sd_journals = 0; in gfs2_jindex_free()
62 spin_unlock(&sdp->sd_jindex_spin); in gfs2_jindex_free()
91 struct gfs2_jdesc *gfs2_jdesc_find(struct gfs2_sbd *sdp, unsigned int jid) in gfs2_jdesc_find() argument
95 spin_lock(&sdp->sd_jindex_spin); in gfs2_jdesc_find()
96 jd = jdesc_find_i(&sdp->sd_jindex_list, jid); in gfs2_jdesc_find()
97 spin_unlock(&sdp->sd_jindex_spin); in gfs2_jdesc_find()
105 struct gfs2_sbd *sdp = GFS2_SB(jd->jd_inode); in gfs2_jdesc_check() local
111 jd->jd_blocks = size >> sdp->sd_sb.sb_bsize_shift; in gfs2_jdesc_check()
121 static int init_threads(struct gfs2_sbd *sdp) in init_threads() argument
126 p = kthread_run(gfs2_logd, sdp, "gfs2_logd"); in init_threads()
129 fs_err(sdp, "can't start logd thread: %d\n", error); in init_threads()
132 sdp->sd_logd_process = p; in init_threads()
134 p = kthread_run(gfs2_quotad, sdp, "gfs2_quotad"); in init_threads()
137 fs_err(sdp, "can't start quotad thread: %d\n", error); in init_threads()
140 sdp->sd_quotad_process = p; in init_threads()
144 kthread_stop(sdp->sd_logd_process); in init_threads()
145 sdp->sd_logd_process = NULL; in init_threads()
156 int gfs2_make_fs_rw(struct gfs2_sbd *sdp) in gfs2_make_fs_rw() argument
158 struct gfs2_inode *ip = GFS2_I(sdp->sd_jdesc->jd_inode); in gfs2_make_fs_rw()
164 error = init_threads(sdp); in gfs2_make_fs_rw()
168 error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED, 0, in gfs2_make_fs_rw()
175 error = gfs2_find_jhead(sdp->sd_jdesc, &head, false); in gfs2_make_fs_rw()
180 gfs2_consist(sdp); in gfs2_make_fs_rw()
186 sdp->sd_log_sequence = head.lh_sequence + 1; in gfs2_make_fs_rw()
187 gfs2_log_pointers_init(sdp, head.lh_blkno); in gfs2_make_fs_rw()
189 error = gfs2_quota_init(sdp); in gfs2_make_fs_rw()
193 set_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); in gfs2_make_fs_rw()
203 if (sdp->sd_quotad_process) in gfs2_make_fs_rw()
204 kthread_stop(sdp->sd_quotad_process); in gfs2_make_fs_rw()
205 sdp->sd_quotad_process = NULL; in gfs2_make_fs_rw()
206 if (sdp->sd_logd_process) in gfs2_make_fs_rw()
207 kthread_stop(sdp->sd_logd_process); in gfs2_make_fs_rw()
208 sdp->sd_logd_process = NULL; in gfs2_make_fs_rw()
230 int gfs2_statfs_init(struct gfs2_sbd *sdp) in gfs2_statfs_init() argument
232 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); in gfs2_statfs_init()
233 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master; in gfs2_statfs_init()
234 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); in gfs2_statfs_init()
235 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local; in gfs2_statfs_init()
249 if (sdp->sd_args.ar_spectator) { in gfs2_statfs_init()
250 spin_lock(&sdp->sd_statfs_spin); in gfs2_statfs_init()
253 spin_unlock(&sdp->sd_statfs_spin); in gfs2_statfs_init()
259 spin_lock(&sdp->sd_statfs_spin); in gfs2_statfs_init()
264 spin_unlock(&sdp->sd_statfs_spin); in gfs2_statfs_init()
276 void gfs2_statfs_change(struct gfs2_sbd *sdp, s64 total, s64 free, in gfs2_statfs_change() argument
279 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); in gfs2_statfs_change()
280 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local; in gfs2_statfs_change()
281 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master; in gfs2_statfs_change()
293 spin_lock(&sdp->sd_statfs_spin); in gfs2_statfs_change()
298 if (sdp->sd_args.ar_statfs_percent) { in gfs2_statfs_change()
300 y = m_sc->sc_free * sdp->sd_args.ar_statfs_percent; in gfs2_statfs_change()
304 spin_unlock(&sdp->sd_statfs_spin); in gfs2_statfs_change()
308 gfs2_wake_up_statfs(sdp); in gfs2_statfs_change()
311 void update_statfs(struct gfs2_sbd *sdp, struct buffer_head *m_bh, in update_statfs() argument
314 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); in update_statfs()
315 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); in update_statfs()
316 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master; in update_statfs()
317 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local; in update_statfs()
322 spin_lock(&sdp->sd_statfs_spin); in update_statfs()
330 spin_unlock(&sdp->sd_statfs_spin); in update_statfs()
335 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_statfs_sync() local
336 struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); in gfs2_statfs_sync()
337 struct gfs2_inode *l_ip = GFS2_I(sdp->sd_sc_inode); in gfs2_statfs_sync()
338 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master; in gfs2_statfs_sync()
339 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local; in gfs2_statfs_sync()
354 spin_lock(&sdp->sd_statfs_spin); in gfs2_statfs_sync()
358 spin_unlock(&sdp->sd_statfs_spin); in gfs2_statfs_sync()
361 spin_unlock(&sdp->sd_statfs_spin); in gfs2_statfs_sync()
367 error = gfs2_trans_begin(sdp, 2 * RES_DINODE, 0); in gfs2_statfs_sync()
371 update_statfs(sdp, m_bh, l_bh); in gfs2_statfs_sync()
372 sdp->sd_statfs_force_sync = 0; in gfs2_statfs_sync()
374 gfs2_trans_end(sdp); in gfs2_statfs_sync()
402 static int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, in gfs2_lock_fs_check_clean() argument
412 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { in gfs2_lock_fs_check_clean()
427 error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_EXCLUSIVE, in gfs2_lock_fs_check_clean()
430 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { in gfs2_lock_fs_check_clean()
504 struct gfs2_sbd *sdp = GFS2_SB(inode); in gfs2_write_inode() local
515 gfs2_ail1_flush(sdp, wbc); in gfs2_write_inode()
547 struct gfs2_sbd *sdp = GFS2_SB(inode); in gfs2_dirty_inode() local
556 if (unlikely(test_bit(SDF_WITHDRAWN, &sdp->sd_flags))) in gfs2_dirty_inode()
561 fs_err(sdp, "dirty_inode: glock %d\n", ret); in gfs2_dirty_inode()
569 ret = gfs2_trans_begin(sdp, RES_DINODE, 0); in gfs2_dirty_inode()
571 fs_err(sdp, "dirty_inode: gfs2_trans_begin %d\n", ret); in gfs2_dirty_inode()
585 gfs2_trans_end(sdp); in gfs2_dirty_inode()
598 int gfs2_make_fs_ro(struct gfs2_sbd *sdp) in gfs2_make_fs_ro() argument
603 error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED, GL_NOCACHE, in gfs2_make_fs_ro()
605 if (error && !test_bit(SDF_WITHDRAWN, &sdp->sd_flags)) in gfs2_make_fs_ro()
609 if (sdp->sd_quotad_process) in gfs2_make_fs_ro()
610 kthread_stop(sdp->sd_quotad_process); in gfs2_make_fs_ro()
611 sdp->sd_quotad_process = NULL; in gfs2_make_fs_ro()
612 if (sdp->sd_logd_process) in gfs2_make_fs_ro()
613 kthread_stop(sdp->sd_logd_process); in gfs2_make_fs_ro()
614 sdp->sd_logd_process = NULL; in gfs2_make_fs_ro()
616 gfs2_quota_sync(sdp->sd_vfs, 0); in gfs2_make_fs_ro()
617 gfs2_statfs_sync(sdp->sd_vfs, 0); in gfs2_make_fs_ro()
619 gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_SHUTDOWN | in gfs2_make_fs_ro()
621 wait_event(sdp->sd_reserving_log_wait, atomic_read(&sdp->sd_reserving_log) == 0); in gfs2_make_fs_ro()
622 gfs2_assert_warn(sdp, atomic_read(&sdp->sd_log_blks_free) == sdp->sd_jdesc->jd_blocks); in gfs2_make_fs_ro()
627 gfs2_quota_cleanup(sdp); in gfs2_make_fs_ro()
640 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_put_super() local
645 set_bit(SDF_NORECOVERY, &sdp->sd_flags); in gfs2_put_super()
650 spin_lock(&sdp->sd_jindex_spin); in gfs2_put_super()
651 list_for_each_entry(jd, &sdp->sd_jindex_list, jd_list) { in gfs2_put_super()
654 spin_unlock(&sdp->sd_jindex_spin); in gfs2_put_super()
659 spin_unlock(&sdp->sd_jindex_spin); in gfs2_put_super()
662 error = gfs2_make_fs_ro(sdp); in gfs2_put_super()
664 gfs2_io_error(sdp); in gfs2_put_super()
670 iput(sdp->sd_jindex); in gfs2_put_super()
671 iput(sdp->sd_statfs_inode); in gfs2_put_super()
672 iput(sdp->sd_rindex); in gfs2_put_super()
673 iput(sdp->sd_quota_inode); in gfs2_put_super()
675 gfs2_glock_put(sdp->sd_rename_gl); in gfs2_put_super()
676 gfs2_glock_put(sdp->sd_freeze_gl); in gfs2_put_super()
678 if (!sdp->sd_args.ar_spectator) { in gfs2_put_super()
679 gfs2_glock_dq_uninit(&sdp->sd_journal_gh); in gfs2_put_super()
680 gfs2_glock_dq_uninit(&sdp->sd_jinode_gh); in gfs2_put_super()
681 gfs2_glock_dq_uninit(&sdp->sd_sc_gh); in gfs2_put_super()
682 gfs2_glock_dq_uninit(&sdp->sd_qc_gh); in gfs2_put_super()
683 iput(sdp->sd_sc_inode); in gfs2_put_super()
684 iput(sdp->sd_qc_inode); in gfs2_put_super()
687 gfs2_glock_dq_uninit(&sdp->sd_live_gh); in gfs2_put_super()
688 gfs2_clear_rgrpd(sdp); in gfs2_put_super()
689 gfs2_jindex_free(sdp); in gfs2_put_super()
691 gfs2_gl_hash_clear(sdp); in gfs2_put_super()
692 gfs2_delete_debugfs_file(sdp); in gfs2_put_super()
694 gfs2_lm_unmount(sdp); in gfs2_put_super()
697 gfs2_sys_fs_del(sdp); in gfs2_put_super()
709 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_sync_fs() local
713 gfs2_log_flush(sdp, NULL, GFS2_LOG_HEAD_FLUSH_NORMAL | in gfs2_sync_fs()
715 return sdp->sd_log_error; in gfs2_sync_fs()
722 struct gfs2_sbd *sdp = container_of(work, struct gfs2_sbd, sd_freeze_work); in gfs2_freeze_func() local
723 struct super_block *sb = sdp->sd_vfs; in gfs2_freeze_func()
726 error = gfs2_glock_nq_init(sdp->sd_freeze_gl, LM_ST_SHARED, 0, in gfs2_freeze_func()
729 fs_info(sdp, "GFS2: couldn't get freeze lock : %d\n", error); in gfs2_freeze_func()
730 gfs2_assert_withdraw(sdp, 0); in gfs2_freeze_func()
732 atomic_set(&sdp->sd_freeze_state, SFS_UNFROZEN); in gfs2_freeze_func()
735 fs_info(sdp, "GFS2: couldn't thaw filesystem: %d\n", in gfs2_freeze_func()
737 gfs2_assert_withdraw(sdp, 0); in gfs2_freeze_func()
739 if (!test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) in gfs2_freeze_func()
744 clear_bit_unlock(SDF_FS_FROZEN, &sdp->sd_flags); in gfs2_freeze_func()
745 wake_up_bit(&sdp->sd_flags, SDF_FS_FROZEN); in gfs2_freeze_func()
757 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_freeze() local
760 mutex_lock(&sdp->sd_freeze_mutex); in gfs2_freeze()
761 if (atomic_read(&sdp->sd_freeze_state) != SFS_UNFROZEN) in gfs2_freeze()
764 if (test_bit(SDF_WITHDRAWN, &sdp->sd_flags)) { in gfs2_freeze()
770 error = gfs2_lock_fs_check_clean(sdp, &sdp->sd_freeze_gh); in gfs2_freeze()
775 fs_err(sdp, "waiting for recovery before freeze\n"); in gfs2_freeze()
777 fs_err(sdp, "error freezing FS: %d\n", error); in gfs2_freeze()
779 fs_err(sdp, "retrying...\n"); in gfs2_freeze()
782 set_bit(SDF_FS_FROZEN, &sdp->sd_flags); in gfs2_freeze()
784 mutex_unlock(&sdp->sd_freeze_mutex); in gfs2_freeze()
796 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_unfreeze() local
798 mutex_lock(&sdp->sd_freeze_mutex); in gfs2_unfreeze()
799 if (atomic_read(&sdp->sd_freeze_state) != SFS_FROZEN || in gfs2_unfreeze()
800 !gfs2_holder_initialized(&sdp->sd_freeze_gh)) { in gfs2_unfreeze()
801 mutex_unlock(&sdp->sd_freeze_mutex); in gfs2_unfreeze()
805 gfs2_glock_dq_uninit(&sdp->sd_freeze_gh); in gfs2_unfreeze()
806 mutex_unlock(&sdp->sd_freeze_mutex); in gfs2_unfreeze()
807 return wait_on_bit(&sdp->sd_flags, SDF_FS_FROZEN, TASK_INTERRUPTIBLE); in gfs2_unfreeze()
841 static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc) in gfs2_statfs_slow() argument
857 rgd_next = gfs2_rgrpd_get_first(sdp); in gfs2_statfs_slow()
914 static int gfs2_statfs_i(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host *sc) in gfs2_statfs_i() argument
916 struct gfs2_statfs_change_host *m_sc = &sdp->sd_statfs_master; in gfs2_statfs_i()
917 struct gfs2_statfs_change_host *l_sc = &sdp->sd_statfs_local; in gfs2_statfs_i()
919 spin_lock(&sdp->sd_statfs_spin); in gfs2_statfs_i()
926 spin_unlock(&sdp->sd_statfs_spin); in gfs2_statfs_i()
949 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_statfs() local
953 error = gfs2_rindex_update(sdp); in gfs2_statfs()
957 if (gfs2_tune_get(sdp, gt_statfs_slow)) in gfs2_statfs()
958 error = gfs2_statfs_slow(sdp, &sc); in gfs2_statfs()
960 error = gfs2_statfs_i(sdp, &sc); in gfs2_statfs()
966 buf->f_bsize = sdp->sd_sb.sb_bsize; in gfs2_statfs()
1043 struct gfs2_sbd *sdp = root->d_sb->s_fs_info; in gfs2_show_options() local
1044 struct gfs2_args *args = &sdp->sd_args; in gfs2_show_options()
1047 if (is_ancestor(root, sdp->sd_master_dir)) in gfs2_show_options()
1100 val = sdp->sd_tune.gt_logd_secs; in gfs2_show_options()
1103 val = sdp->sd_tune.gt_statfs_quantum; in gfs2_show_options()
1106 else if (sdp->sd_tune.gt_statfs_slow) in gfs2_show_options()
1108 val = sdp->sd_tune.gt_quota_quantum; in gfs2_show_options()
1129 if (test_bit(SDF_NOBARRIERS, &sdp->sd_flags)) in gfs2_show_options()
1131 if (test_bit(SDF_DEMOTE, &sdp->sd_flags)) in gfs2_show_options()
1156 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_dinode_dealloc() local
1166 error = gfs2_rindex_update(sdp); in gfs2_dinode_dealloc()
1174 rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr, 1); in gfs2_dinode_dealloc()
1185 error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_STATFS + RES_QUOTA, in gfs2_dinode_dealloc()
1186 sdp->sd_jdesc->jd_blocks); in gfs2_dinode_dealloc()
1194 gfs2_trans_end(sdp); in gfs2_dinode_dealloc()
1243 struct gfs2_sbd *sdp = sb->s_fs_info; in gfs2_evict_inode() local
1276 error = gfs2_check_blk_type(sdp, ip->i_no_addr, GFS2_BLKST_UNLINKED); in gfs2_evict_inode()
1332 gfs2_log_flush(sdp, ip->i_gl, GFS2_LOG_HEAD_FLUSH_NORMAL | in gfs2_evict_inode()
1342 error = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks); in gfs2_evict_inode()
1348 gfs2_trans_end(sdp); in gfs2_evict_inode()
1367 fs_warn(sdp, "gfs2_evict_inode: %d\n", error); in gfs2_evict_inode()