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);
2322 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2324 if (ocfs2_mount_local(osb))
2435 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2446 if (ocfs2_is_hard_readonly(osb)) {
2453 ocfs2_mount_local(osb))
2457 ocfs2_wait_for_recovery(osb);
2465 status = __ocfs2_cluster_lock(osb, lockres, level, dlm_flags,
2481 ocfs2_wait_for_recovery(osb);
2622 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2628 if (!ocfs2_is_hard_readonly(osb) &&
2629 !ocfs2_mount_local(osb))
2630 ocfs2_cluster_unlock(osb, lockres, level);
2750 int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno)
2756 if (ocfs2_is_hard_readonly(osb))
2759 if (ocfs2_mount_local(osb))
2762 lockres = &osb->osb_orphan_scan.os_lockres;
2763 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0);
2772 *seqno = osb->osb_orphan_scan.os_seqno + 1;
2777 void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno)
2782 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb)) {
2783 lockres = &osb->osb_orphan_scan.os_lockres;
2787 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
2791 int ocfs2_super_lock(struct ocfs2_super *osb,
2796 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
2798 if (ocfs2_is_hard_readonly(osb))
2801 if (ocfs2_mount_local(osb))
2804 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
2816 status = ocfs2_refresh_slot_info(osb);
2821 ocfs2_cluster_unlock(osb, lockres, level);
2830 void ocfs2_super_unlock(struct ocfs2_super *osb,
2834 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
2836 if (!ocfs2_mount_local(osb))
2837 ocfs2_cluster_unlock(osb, lockres, level);
2840 int ocfs2_rename_lock(struct ocfs2_super *osb)
2843 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres;
2845 if (ocfs2_is_hard_readonly(osb))
2848 if (ocfs2_mount_local(osb))
2851 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0);
2858 void ocfs2_rename_unlock(struct ocfs2_super *osb)
2860 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres;
2862 if (!ocfs2_mount_local(osb))
2863 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
2866 int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)
2869 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;
2871 if (ocfs2_is_hard_readonly(osb))
2875 down_write(&osb->nfs_sync_rwlock);
2877 down_read(&osb->nfs_sync_rwlock);
2879 if (ocfs2_mount_local(osb))
2882 status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE,
2888 up_write(&osb->nfs_sync_rwlock);
2890 up_read(&osb->nfs_sync_rwlock);
2896 void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex)
2898 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;
2900 if (!ocfs2_mount_local(osb))
2901 ocfs2_cluster_unlock(osb, lockres,
2904 up_write(&osb->nfs_sync_rwlock);
2906 up_read(&osb->nfs_sync_rwlock);
2909 int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
2914 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres;
2919 if (ocfs2_is_hard_readonly(osb))
2922 if (ocfs2_mount_local(osb))
2925 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX,
2950 void ocfs2_trim_fs_unlock(struct ocfs2_super *osb,
2954 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres;
2956 if (ocfs2_mount_local(osb))
2970 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
2978 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
2982 if (ocfs2_is_hard_readonly(osb)) {
2988 if (ocfs2_mount_local(osb))
2991 ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0);
3002 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
3004 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb))
3005 ocfs2_cluster_unlock(osb, &dl->dl_lockres, level);
3281 struct ocfs2_super *osb;
3289 osb = inode->i_private;
3290 ocfs2_get_dlm_debug(osb->osb_dlm_debug);
3291 priv->p_dlm_debug = osb->osb_dlm_debug;
3307 static void ocfs2_dlm_init_debug(struct ocfs2_super *osb)
3309 struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug;
3312 osb->osb_debug_root, osb, &ocfs2_dlm_debug_fops);
3314 debugfs_create_u32("locking_filter", 0600, osb->osb_debug_root,
3319 static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb)
3321 struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug;
3327 int ocfs2_dlm_init(struct ocfs2_super *osb)
3332 if (ocfs2_mount_local(osb)) {
3333 osb->node_num = 0;
3337 ocfs2_dlm_init_debug(osb);
3340 osb->dc_task = kthread_run(ocfs2_downconvert_thread, osb, "ocfs2dc-%s",
3341 osb->uuid_str);
3342 if (IS_ERR(osb->dc_task)) {
3343 status = PTR_ERR(osb->dc_task);
3344 osb->dc_task = NULL;
3350 status = ocfs2_cluster_connect(osb->osb_cluster_stack,
3351 osb->osb_cluster_name,
3352 strlen(osb->osb_cluster_name),
3353 osb->uuid_str,
3354 strlen(osb->uuid_str),
3355 &lproto, ocfs2_do_node_down, osb,
3362 status = ocfs2_cluster_this_node(conn, &osb->node_num);
3372 ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb);
3373 ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb);
3374 ocfs2_nfs_sync_lock_init(osb);
3375 ocfs2_orphan_scan_lock_res_init(&osb->osb_orphan_scan.os_lockres, osb);
3377 osb->cconn = conn;
3380 ocfs2_dlm_shutdown_debug(osb);
3381 if (osb->dc_task)
3382 kthread_stop(osb->dc_task);
3388 void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
3391 ocfs2_drop_osb_locks(osb);
3399 if (osb->dc_task) {
3400 kthread_stop(osb->dc_task);
3401 osb->dc_task = NULL;
3404 ocfs2_lock_res_free(&osb->osb_super_lockres);
3405 ocfs2_lock_res_free(&osb->osb_rename_lockres);
3406 ocfs2_lock_res_free(&osb->osb_nfs_sync_lockres);
3407 ocfs2_lock_res_free(&osb->osb_orphan_scan.os_lockres);
3409 if (osb->cconn) {
3410 ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
3411 osb->cconn = NULL;
3413 ocfs2_dlm_shutdown_debug(osb);
3417 static int ocfs2_drop_lock(struct ocfs2_super *osb,
3484 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, lkm_flags);
3499 static void ocfs2_process_blocked_lock(struct ocfs2_super *osb,
3508 void ocfs2_mark_lockres_freeing(struct ocfs2_super *osb,
3519 if (lockres->l_flags & OCFS2_LOCK_QUEUED && current == osb->dc_task) {
3538 spin_lock_irqsave(&osb->dc_task_lock, flags2);
3540 osb->blocked_lock_count--;
3541 spin_unlock_irqrestore(&osb->dc_task_lock, flags2);
3550 ocfs2_process_blocked_lock(osb, lockres);
3568 void ocfs2_simple_drop_lockres(struct ocfs2_super *osb,
3573 ocfs2_mark_lockres_freeing(osb, lockres);
3574 ret = ocfs2_drop_lock(osb, lockres);
3579 static void ocfs2_drop_osb_locks(struct ocfs2_super *osb)
3581 ocfs2_simple_drop_lockres(osb, &osb->osb_super_lockres);
3582 ocfs2_simple_drop_lockres(osb, &osb->osb_rename_lockres);
3583 ocfs2_simple_drop_lockres(osb, &osb->osb_nfs_sync_lockres);
3584 ocfs2_simple_drop_lockres(osb, &osb->osb_orphan_scan.os_lockres);
3647 static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
3665 if (ocfs2_userspace_stack(osb) &&
3672 ret = ocfs2_dlm_lock(osb->cconn,
3678 lockres_clear_pending(lockres, generation, osb);
3691 static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb,
3720 static int ocfs2_cancel_convert(struct ocfs2_super *osb,
3725 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb,
3737 static int ocfs2_unblock_lock(struct ocfs2_super *osb,
3793 ret = ocfs2_prepare_cancel_convert(osb, lockres);
3796 ret = ocfs2_cancel_convert(osb, lockres);
3919 ret = ocfs2_downconvert_lock(osb, lockres, new_level, set_lvb,
4033 static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
4037 ocfs2_dentry_lock_put(osb, dl);
4192 struct ocfs2_super *osb = OCFS2_SB(oinfo->dqi_gi.dqi_sb);
4195 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb))
4196 ocfs2_cluster_unlock(osb, lockres, level);
4247 struct ocfs2_super *osb = OCFS2_SB(oinfo->dqi_gi.dqi_sb);
4252 if (ocfs2_is_hard_readonly(osb)) {
4257 if (ocfs2_mount_local(osb))
4260 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
4281 struct ocfs2_super *osb = lockres->l_priv;
4284 if (ocfs2_is_hard_readonly(osb))
4287 if (ocfs2_mount_local(osb))
4290 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
4301 struct ocfs2_super *osb = lockres->l_priv;
4303 if (!ocfs2_mount_local(osb))
4304 ocfs2_cluster_unlock(osb, lockres, level);
4307 static void ocfs2_process_blocked_lock(struct ocfs2_super *osb,
4333 status = ocfs2_unblock_lock(osb, lockres, &ctl);
4342 ocfs2_schedule_blocked_lock(osb, lockres);
4350 lockres->l_ops->post_unlock(osb, lockres);
4353 static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb,
4371 spin_lock_irqsave(&osb->dc_task_lock, flags);
4374 &osb->blocked_lock_list);
4375 osb->blocked_lock_count++;
4377 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4380 static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb)
4386 spin_lock_irqsave(&osb->dc_task_lock, flags);
4389 osb->dc_work_sequence = osb->dc_wake_sequence;
4391 processed = osb->blocked_lock_count;
4394 * remove items off osb->blocked_lock_list. Downconvert up to
4398 while (processed && !list_empty(&osb->blocked_lock_list)) {
4399 lockres = list_entry(osb->blocked_lock_list.next,
4402 osb->blocked_lock_count--;
4403 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4408 ocfs2_process_blocked_lock(osb, lockres);
4410 spin_lock_irqsave(&osb->dc_task_lock, flags);
4412 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4415 static int ocfs2_downconvert_thread_lists_empty(struct ocfs2_super *osb)
4420 spin_lock_irqsave(&osb->dc_task_lock, flags);
4421 if (list_empty(&osb->blocked_lock_list))
4424 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4428 static int ocfs2_downconvert_thread_should_wake(struct ocfs2_super *osb)
4433 spin_lock_irqsave(&osb->dc_task_lock, flags);
4434 if (osb->dc_work_sequence != osb->dc_wake_sequence)
4436 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4443 struct ocfs2_super *osb = arg;
4448 ocfs2_downconvert_thread_lists_empty(osb))) {
4450 wait_event_interruptible(osb->dc_event,
4451 ocfs2_downconvert_thread_should_wake(osb) ||
4456 ocfs2_downconvert_thread_do_work(osb);
4459 osb->dc_task = NULL;
4463 void ocfs2_wake_downconvert_thread(struct ocfs2_super *osb)
4467 spin_lock_irqsave(&osb->dc_task_lock, flags);
4470 osb->dc_wake_sequence++;
4471 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4472 wake_up(&osb->dc_event);