Lines Matching refs:osb

98 static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
333 static int ocfs2_lock_create(struct ocfs2_super *osb,
339 static void __ocfs2_cluster_unlock(struct ocfs2_super *osb,
342 static inline void ocfs2_cluster_unlock(struct ocfs2_super *osb,
346 __ocfs2_cluster_unlock(osb, lockres, level, _RET_IP_);
353 static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb,
367 static void ocfs2_downconvert_on_unlock(struct ocfs2_super *osb,
371 static void ocfs2_drop_osb_locks(struct ocfs2_super *osb);
375 static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
380 static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb,
382 static int ocfs2_cancel_convert(struct ocfs2_super *osb,
510 static void ocfs2_lock_res_init_common(struct ocfs2_super *osb,
528 ocfs2_add_lockres_tracking(res, osb->osb_dlm_debug);
658 struct ocfs2_super *osb)
665 ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_SUPER,
666 &ocfs2_super_lops, osb);
670 struct ocfs2_super *osb)
676 ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_RENAME,
677 &ocfs2_rename_lops, osb);
681 struct ocfs2_super *osb)
687 ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_NFS_SYNC,
688 &ocfs2_nfs_sync_lops, osb);
691 static void ocfs2_nfs_sync_lock_init(struct ocfs2_super *osb)
693 ocfs2_nfs_sync_lock_res_init(&osb->osb_nfs_sync_lockres, osb);
694 init_rwsem(&osb->nfs_sync_rwlock);
697 void ocfs2_trim_fs_lock_res_init(struct ocfs2_super *osb)
699 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres;
702 mutex_lock(&osb->obs_trim_fs_mutex);
706 ocfs2_lock_res_init_common(osb, lockres, OCFS2_LOCK_TYPE_TRIM_FS,
707 &ocfs2_trim_fs_lops, osb);
710 void ocfs2_trim_fs_lock_res_uninit(struct ocfs2_super *osb)
712 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres;
714 ocfs2_simple_drop_lockres(osb, lockres);
717 mutex_unlock(&osb->obs_trim_fs_mutex);
721 struct ocfs2_super *osb)
725 ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_ORPHAN_SCAN,
726 &ocfs2_orphan_scan_lops, osb);
756 struct ocfs2_super *osb, u64 ref_blkno,
762 ocfs2_lock_res_init_common(osb, lockres, OCFS2_LOCK_TYPE_REFCOUNT,
763 &ocfs2_refcount_block_lops, osb);
1068 struct ocfs2_super *osb)
1088 ocfs2_wake_downconvert_thread(osb);
1094 struct ocfs2_super *osb)
1099 __lockres_clear_pending(lockres, generation, osb);
1116 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
1136 ocfs2_schedule_blocked_lock(osb, lockres);
1141 ocfs2_wake_downconvert_thread(osb);
1147 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
1204 __lockres_clear_pending(lockres, lockres->l_pending_gen, osb);
1308 static int ocfs2_lock_create(struct ocfs2_super *osb,
1333 ret = ocfs2_dlm_lock(osb->cconn,
1339 lockres_clear_pending(lockres, gen, osb);
1468 static int __ocfs2_cluster_lock(struct ocfs2_super *osb,
1477 int wait, catch_signals = !(osb->s_mount_opt & OCFS2_MOUNT_NOINTR);
1581 ret = ocfs2_dlm_lock(osb->cconn,
1587 lockres_clear_pending(lockres, gen, osb);
1623 ocfs2_wake_downconvert_thread(osb);
1671 static inline int ocfs2_cluster_lock(struct ocfs2_super *osb,
1677 return __ocfs2_cluster_lock(osb, lockres, level, lkm_flags, arg_flags,
1682 static void __ocfs2_cluster_unlock(struct ocfs2_super *osb,
1691 ocfs2_downconvert_on_unlock(osb, lockres);
1699 static int ocfs2_create_new_lock(struct ocfs2_super *osb,
1713 return ocfs2_lock_create(osb, lockres, level, lkm_flags);
1725 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1739 ret = ocfs2_create_new_lock(osb, &OCFS2_I(inode)->ip_rw_lockres, 1, 1);
1749 ret = ocfs2_create_new_lock(osb, &OCFS2_I(inode)->ip_inode_lockres, 1, 0);
1755 ret = ocfs2_create_new_lock(osb, &OCFS2_I(inode)->ip_open_lockres, 0, 0);
1767 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1773 if (ocfs2_mount_local(osb))
1780 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
1791 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1797 if (ocfs2_mount_local(osb))
1804 status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0);
1812 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1818 if (!ocfs2_mount_local(osb))
1819 ocfs2_cluster_unlock(osb, lockres, level);
1829 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1834 if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
1839 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_PR, 0, 0);
1851 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1857 if (ocfs2_is_hard_readonly(osb)) {
1863 if (ocfs2_mount_local(osb))
1876 status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0);
1888 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1893 if (ocfs2_mount_local(osb))
1897 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_PR);
1899 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
1909 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
1918 ret = ocfs2_prepare_cancel_convert(osb, lockres);
1921 ret = ocfs2_cancel_convert(osb, lockres);
1980 struct ocfs2_super *osb = OCFS2_SB(file->f_mapping->host->i_sb);
2003 ret = ocfs2_lock_create(osb, lockres, DLM_LOCK_NL, 0);
2025 ret = ocfs2_dlm_lock(osb->cconn, level, &lockres->l_lksb, lkm_flags,
2076 struct ocfs2_super *osb = OCFS2_SB(file->f_mapping->host->i_sb);
2102 ret = ocfs2_downconvert_lock(osb, lockres, DLM_LOCK_NL, 0, gen);
2113 static void ocfs2_downconvert_on_unlock(struct ocfs2_super *osb,
2137 ocfs2_wake_downconvert_thread(osb);
2321 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2323 if (ocfs2_mount_local(osb))
2434 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2445 if (ocfs2_is_hard_readonly(osb)) {
2452 ocfs2_mount_local(osb))
2456 ocfs2_wait_for_recovery(osb);
2464 status = __ocfs2_cluster_lock(osb, lockres, level, dlm_flags,
2480 ocfs2_wait_for_recovery(osb);
2621 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2627 if (!ocfs2_is_hard_readonly(osb) &&
2628 !ocfs2_mount_local(osb))
2629 ocfs2_cluster_unlock(osb, lockres, level);
2749 int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno)
2755 if (ocfs2_is_hard_readonly(osb))
2758 if (ocfs2_mount_local(osb))
2761 lockres = &osb->osb_orphan_scan.os_lockres;
2762 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0);
2771 *seqno = osb->osb_orphan_scan.os_seqno + 1;
2776 void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno)
2781 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb)) {
2782 lockres = &osb->osb_orphan_scan.os_lockres;
2786 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
2790 int ocfs2_super_lock(struct ocfs2_super *osb,
2795 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
2797 if (ocfs2_is_hard_readonly(osb))
2800 if (ocfs2_mount_local(osb))
2803 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
2815 status = ocfs2_refresh_slot_info(osb);
2820 ocfs2_cluster_unlock(osb, lockres, level);
2829 void ocfs2_super_unlock(struct ocfs2_super *osb,
2833 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
2835 if (!ocfs2_mount_local(osb))
2836 ocfs2_cluster_unlock(osb, lockres, level);
2839 int ocfs2_rename_lock(struct ocfs2_super *osb)
2842 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres;
2844 if (ocfs2_is_hard_readonly(osb))
2847 if (ocfs2_mount_local(osb))
2850 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0);
2857 void ocfs2_rename_unlock(struct ocfs2_super *osb)
2859 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres;
2861 if (!ocfs2_mount_local(osb))
2862 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
2865 int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)
2868 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;
2870 if (ocfs2_is_hard_readonly(osb))
2874 down_write(&osb->nfs_sync_rwlock);
2876 down_read(&osb->nfs_sync_rwlock);
2878 if (ocfs2_mount_local(osb))
2881 status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE,
2887 up_write(&osb->nfs_sync_rwlock);
2889 up_read(&osb->nfs_sync_rwlock);
2895 void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex)
2897 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;
2899 if (!ocfs2_mount_local(osb))
2900 ocfs2_cluster_unlock(osb, lockres,
2903 up_write(&osb->nfs_sync_rwlock);
2905 up_read(&osb->nfs_sync_rwlock);
2908 int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
2913 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres;
2918 if (ocfs2_is_hard_readonly(osb))
2921 if (ocfs2_mount_local(osb))
2924 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX,
2949 void ocfs2_trim_fs_unlock(struct ocfs2_super *osb,
2953 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres;
2955 if (ocfs2_mount_local(osb))
2969 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
2977 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
2981 if (ocfs2_is_hard_readonly(osb)) {
2987 if (ocfs2_mount_local(osb))
2990 ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0);
3001 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
3003 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb))
3004 ocfs2_cluster_unlock(osb, &dl->dl_lockres, level);
3280 struct ocfs2_super *osb;
3288 osb = inode->i_private;
3289 ocfs2_get_dlm_debug(osb->osb_dlm_debug);
3290 priv->p_dlm_debug = osb->osb_dlm_debug;
3306 static void ocfs2_dlm_init_debug(struct ocfs2_super *osb)
3308 struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug;
3311 osb->osb_debug_root, osb, &ocfs2_dlm_debug_fops);
3313 debugfs_create_u32("locking_filter", 0600, osb->osb_debug_root,
3318 static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb)
3320 struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug;
3326 int ocfs2_dlm_init(struct ocfs2_super *osb)
3331 if (ocfs2_mount_local(osb)) {
3332 osb->node_num = 0;
3336 ocfs2_dlm_init_debug(osb);
3339 osb->dc_task = kthread_run(ocfs2_downconvert_thread, osb, "ocfs2dc-%s",
3340 osb->uuid_str);
3341 if (IS_ERR(osb->dc_task)) {
3342 status = PTR_ERR(osb->dc_task);
3343 osb->dc_task = NULL;
3349 status = ocfs2_cluster_connect(osb->osb_cluster_stack,
3350 osb->osb_cluster_name,
3351 strlen(osb->osb_cluster_name),
3352 osb->uuid_str,
3353 strlen(osb->uuid_str),
3354 &lproto, ocfs2_do_node_down, osb,
3361 status = ocfs2_cluster_this_node(conn, &osb->node_num);
3371 ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb);
3372 ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb);
3373 ocfs2_nfs_sync_lock_init(osb);
3374 ocfs2_orphan_scan_lock_res_init(&osb->osb_orphan_scan.os_lockres, osb);
3376 osb->cconn = conn;
3379 ocfs2_dlm_shutdown_debug(osb);
3380 if (osb->dc_task)
3381 kthread_stop(osb->dc_task);
3387 void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
3390 ocfs2_drop_osb_locks(osb);
3398 if (osb->dc_task) {
3399 kthread_stop(osb->dc_task);
3400 osb->dc_task = NULL;
3403 ocfs2_lock_res_free(&osb->osb_super_lockres);
3404 ocfs2_lock_res_free(&osb->osb_rename_lockres);
3405 ocfs2_lock_res_free(&osb->osb_nfs_sync_lockres);
3406 ocfs2_lock_res_free(&osb->osb_orphan_scan.os_lockres);
3408 if (osb->cconn) {
3409 ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
3410 osb->cconn = NULL;
3412 ocfs2_dlm_shutdown_debug(osb);
3416 static int ocfs2_drop_lock(struct ocfs2_super *osb,
3483 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, lkm_flags);
3498 static void ocfs2_process_blocked_lock(struct ocfs2_super *osb,
3507 void ocfs2_mark_lockres_freeing(struct ocfs2_super *osb,
3518 if (lockres->l_flags & OCFS2_LOCK_QUEUED && current == osb->dc_task) {
3537 spin_lock_irqsave(&osb->dc_task_lock, flags2);
3539 osb->blocked_lock_count--;
3540 spin_unlock_irqrestore(&osb->dc_task_lock, flags2);
3549 ocfs2_process_blocked_lock(osb, lockres);
3567 void ocfs2_simple_drop_lockres(struct ocfs2_super *osb,
3572 ocfs2_mark_lockres_freeing(osb, lockres);
3573 ret = ocfs2_drop_lock(osb, lockres);
3578 static void ocfs2_drop_osb_locks(struct ocfs2_super *osb)
3580 ocfs2_simple_drop_lockres(osb, &osb->osb_super_lockres);
3581 ocfs2_simple_drop_lockres(osb, &osb->osb_rename_lockres);
3582 ocfs2_simple_drop_lockres(osb, &osb->osb_nfs_sync_lockres);
3583 ocfs2_simple_drop_lockres(osb, &osb->osb_orphan_scan.os_lockres);
3646 static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
3664 if (ocfs2_userspace_stack(osb) &&
3671 ret = ocfs2_dlm_lock(osb->cconn,
3677 lockres_clear_pending(lockres, generation, osb);
3690 static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb,
3719 static int ocfs2_cancel_convert(struct ocfs2_super *osb,
3724 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb,
3736 static int ocfs2_unblock_lock(struct ocfs2_super *osb,
3792 ret = ocfs2_prepare_cancel_convert(osb, lockres);
3795 ret = ocfs2_cancel_convert(osb, lockres);
3918 ret = ocfs2_downconvert_lock(osb, lockres, new_level, set_lvb,
4032 static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
4036 ocfs2_dentry_lock_put(osb, dl);
4191 struct ocfs2_super *osb = OCFS2_SB(oinfo->dqi_gi.dqi_sb);
4194 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb))
4195 ocfs2_cluster_unlock(osb, lockres, level);
4246 struct ocfs2_super *osb = OCFS2_SB(oinfo->dqi_gi.dqi_sb);
4251 if (ocfs2_is_hard_readonly(osb)) {
4256 if (ocfs2_mount_local(osb))
4259 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
4280 struct ocfs2_super *osb = lockres->l_priv;
4283 if (ocfs2_is_hard_readonly(osb))
4286 if (ocfs2_mount_local(osb))
4289 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
4300 struct ocfs2_super *osb = lockres->l_priv;
4302 if (!ocfs2_mount_local(osb))
4303 ocfs2_cluster_unlock(osb, lockres, level);
4306 static void ocfs2_process_blocked_lock(struct ocfs2_super *osb,
4332 status = ocfs2_unblock_lock(osb, lockres, &ctl);
4341 ocfs2_schedule_blocked_lock(osb, lockres);
4349 lockres->l_ops->post_unlock(osb, lockres);
4352 static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb,
4370 spin_lock_irqsave(&osb->dc_task_lock, flags);
4373 &osb->blocked_lock_list);
4374 osb->blocked_lock_count++;
4376 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4379 static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb)
4385 spin_lock_irqsave(&osb->dc_task_lock, flags);
4388 osb->dc_work_sequence = osb->dc_wake_sequence;
4390 processed = osb->blocked_lock_count;
4393 * remove items off osb->blocked_lock_list. Downconvert up to
4397 while (processed && !list_empty(&osb->blocked_lock_list)) {
4398 lockres = list_entry(osb->blocked_lock_list.next,
4401 osb->blocked_lock_count--;
4402 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4407 ocfs2_process_blocked_lock(osb, lockres);
4409 spin_lock_irqsave(&osb->dc_task_lock, flags);
4411 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4414 static int ocfs2_downconvert_thread_lists_empty(struct ocfs2_super *osb)
4419 spin_lock_irqsave(&osb->dc_task_lock, flags);
4420 if (list_empty(&osb->blocked_lock_list))
4423 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4427 static int ocfs2_downconvert_thread_should_wake(struct ocfs2_super *osb)
4432 spin_lock_irqsave(&osb->dc_task_lock, flags);
4433 if (osb->dc_work_sequence != osb->dc_wake_sequence)
4435 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4442 struct ocfs2_super *osb = arg;
4447 ocfs2_downconvert_thread_lists_empty(osb))) {
4449 wait_event_interruptible(osb->dc_event,
4450 ocfs2_downconvert_thread_should_wake(osb) ||
4455 ocfs2_downconvert_thread_do_work(osb);
4458 osb->dc_task = NULL;
4462 void ocfs2_wake_downconvert_thread(struct ocfs2_super *osb)
4466 spin_lock_irqsave(&osb->dc_task_lock, flags);
4469 osb->dc_wake_sequence++;
4470 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4471 wake_up(&osb->dc_event);