Lines Matching refs:osb

99 static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
334 static int ocfs2_lock_create(struct ocfs2_super *osb,
340 static void __ocfs2_cluster_unlock(struct ocfs2_super *osb,
343 static inline void ocfs2_cluster_unlock(struct ocfs2_super *osb,
347 __ocfs2_cluster_unlock(osb, lockres, level, _RET_IP_);
354 static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb,
368 static void ocfs2_downconvert_on_unlock(struct ocfs2_super *osb,
372 static void ocfs2_drop_osb_locks(struct ocfs2_super *osb);
376 static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
381 static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb,
383 static int ocfs2_cancel_convert(struct ocfs2_super *osb,
511 static void ocfs2_lock_res_init_common(struct ocfs2_super *osb,
529 ocfs2_add_lockres_tracking(res, osb->osb_dlm_debug);
659 struct ocfs2_super *osb)
666 ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_SUPER,
667 &ocfs2_super_lops, osb);
671 struct ocfs2_super *osb)
677 ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_RENAME,
678 &ocfs2_rename_lops, osb);
682 struct ocfs2_super *osb)
688 ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_NFS_SYNC,
689 &ocfs2_nfs_sync_lops, osb);
692 static void ocfs2_nfs_sync_lock_init(struct ocfs2_super *osb)
694 ocfs2_nfs_sync_lock_res_init(&osb->osb_nfs_sync_lockres, osb);
695 init_rwsem(&osb->nfs_sync_rwlock);
698 void ocfs2_trim_fs_lock_res_init(struct ocfs2_super *osb)
700 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres;
703 mutex_lock(&osb->obs_trim_fs_mutex);
707 ocfs2_lock_res_init_common(osb, lockres, OCFS2_LOCK_TYPE_TRIM_FS,
708 &ocfs2_trim_fs_lops, osb);
711 void ocfs2_trim_fs_lock_res_uninit(struct ocfs2_super *osb)
713 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres;
715 ocfs2_simple_drop_lockres(osb, lockres);
718 mutex_unlock(&osb->obs_trim_fs_mutex);
722 struct ocfs2_super *osb)
726 ocfs2_lock_res_init_common(osb, res, OCFS2_LOCK_TYPE_ORPHAN_SCAN,
727 &ocfs2_orphan_scan_lops, osb);
757 struct ocfs2_super *osb, u64 ref_blkno,
763 ocfs2_lock_res_init_common(osb, lockres, OCFS2_LOCK_TYPE_REFCOUNT,
764 &ocfs2_refcount_block_lops, osb);
1069 struct ocfs2_super *osb)
1089 ocfs2_wake_downconvert_thread(osb);
1095 struct ocfs2_super *osb)
1100 __lockres_clear_pending(lockres, generation, osb);
1117 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
1137 ocfs2_schedule_blocked_lock(osb, lockres);
1142 ocfs2_wake_downconvert_thread(osb);
1148 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
1205 __lockres_clear_pending(lockres, lockres->l_pending_gen, osb);
1309 static int ocfs2_lock_create(struct ocfs2_super *osb,
1334 ret = ocfs2_dlm_lock(osb->cconn,
1340 lockres_clear_pending(lockres, gen, osb);
1469 static int __ocfs2_cluster_lock(struct ocfs2_super *osb,
1478 int wait, catch_signals = !(osb->s_mount_opt & OCFS2_MOUNT_NOINTR);
1582 ret = ocfs2_dlm_lock(osb->cconn,
1588 lockres_clear_pending(lockres, gen, osb);
1624 ocfs2_wake_downconvert_thread(osb);
1672 static inline int ocfs2_cluster_lock(struct ocfs2_super *osb,
1678 return __ocfs2_cluster_lock(osb, lockres, level, lkm_flags, arg_flags,
1683 static void __ocfs2_cluster_unlock(struct ocfs2_super *osb,
1692 ocfs2_downconvert_on_unlock(osb, lockres);
1700 static int ocfs2_create_new_lock(struct ocfs2_super *osb,
1714 return ocfs2_lock_create(osb, lockres, level, lkm_flags);
1726 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1740 ret = ocfs2_create_new_lock(osb, &OCFS2_I(inode)->ip_rw_lockres, 1, 1);
1750 ret = ocfs2_create_new_lock(osb, &OCFS2_I(inode)->ip_inode_lockres, 1, 0);
1756 ret = ocfs2_create_new_lock(osb, &OCFS2_I(inode)->ip_open_lockres, 0, 0);
1768 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1774 if (ocfs2_mount_local(osb))
1781 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
1792 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1798 if (ocfs2_mount_local(osb))
1805 status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0);
1813 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1819 if (!ocfs2_mount_local(osb))
1820 ocfs2_cluster_unlock(osb, lockres, level);
1830 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1835 if (ocfs2_is_hard_readonly(osb) || ocfs2_mount_local(osb))
1840 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_PR, 0, 0);
1852 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1858 if (ocfs2_is_hard_readonly(osb)) {
1864 if (ocfs2_mount_local(osb))
1877 status = ocfs2_cluster_lock(osb, lockres, level, DLM_LKF_NOQUEUE, 0);
1889 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
1894 if (ocfs2_mount_local(osb))
1898 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_PR);
1900 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
1910 struct ocfs2_super *osb = ocfs2_get_lockres_osb(lockres);
1919 ret = ocfs2_prepare_cancel_convert(osb, lockres);
1922 ret = ocfs2_cancel_convert(osb, lockres);
1981 struct ocfs2_super *osb = OCFS2_SB(file->f_mapping->host->i_sb);
2004 ret = ocfs2_lock_create(osb, lockres, DLM_LOCK_NL, 0);
2026 ret = ocfs2_dlm_lock(osb->cconn, level, &lockres->l_lksb, lkm_flags,
2077 struct ocfs2_super *osb = OCFS2_SB(file->f_mapping->host->i_sb);
2103 ret = ocfs2_downconvert_lock(osb, lockres, DLM_LOCK_NL, 0, gen);
2114 static void ocfs2_downconvert_on_unlock(struct ocfs2_super *osb,
2138 ocfs2_wake_downconvert_thread(osb);
2317 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2319 if (ocfs2_mount_local(osb))
2425 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2436 if (ocfs2_is_hard_readonly(osb)) {
2443 ocfs2_mount_local(osb))
2447 ocfs2_wait_for_recovery(osb);
2455 status = __ocfs2_cluster_lock(osb, lockres, level, dlm_flags,
2471 ocfs2_wait_for_recovery(osb);
2612 struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
2618 if (!ocfs2_is_hard_readonly(osb) &&
2619 !ocfs2_mount_local(osb))
2620 ocfs2_cluster_unlock(osb, lockres, level);
2740 int ocfs2_orphan_scan_lock(struct ocfs2_super *osb, u32 *seqno)
2746 if (ocfs2_is_hard_readonly(osb))
2749 if (ocfs2_mount_local(osb))
2752 lockres = &osb->osb_orphan_scan.os_lockres;
2753 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0);
2762 *seqno = osb->osb_orphan_scan.os_seqno + 1;
2767 void ocfs2_orphan_scan_unlock(struct ocfs2_super *osb, u32 seqno)
2772 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb)) {
2773 lockres = &osb->osb_orphan_scan.os_lockres;
2777 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
2781 int ocfs2_super_lock(struct ocfs2_super *osb,
2786 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
2788 if (ocfs2_is_hard_readonly(osb))
2791 if (ocfs2_mount_local(osb))
2794 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
2806 status = ocfs2_refresh_slot_info(osb);
2811 ocfs2_cluster_unlock(osb, lockres, level);
2820 void ocfs2_super_unlock(struct ocfs2_super *osb,
2824 struct ocfs2_lock_res *lockres = &osb->osb_super_lockres;
2826 if (!ocfs2_mount_local(osb))
2827 ocfs2_cluster_unlock(osb, lockres, level);
2830 int ocfs2_rename_lock(struct ocfs2_super *osb)
2833 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres;
2835 if (ocfs2_is_hard_readonly(osb))
2838 if (ocfs2_mount_local(osb))
2841 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX, 0, 0);
2848 void ocfs2_rename_unlock(struct ocfs2_super *osb)
2850 struct ocfs2_lock_res *lockres = &osb->osb_rename_lockres;
2852 if (!ocfs2_mount_local(osb))
2853 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
2856 int ocfs2_nfs_sync_lock(struct ocfs2_super *osb, int ex)
2859 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;
2861 if (ocfs2_is_hard_readonly(osb))
2865 down_write(&osb->nfs_sync_rwlock);
2867 down_read(&osb->nfs_sync_rwlock);
2869 if (ocfs2_mount_local(osb))
2872 status = ocfs2_cluster_lock(osb, lockres, ex ? LKM_EXMODE : LKM_PRMODE,
2878 up_write(&osb->nfs_sync_rwlock);
2880 up_read(&osb->nfs_sync_rwlock);
2886 void ocfs2_nfs_sync_unlock(struct ocfs2_super *osb, int ex)
2888 struct ocfs2_lock_res *lockres = &osb->osb_nfs_sync_lockres;
2890 if (!ocfs2_mount_local(osb))
2891 ocfs2_cluster_unlock(osb, lockres,
2894 up_write(&osb->nfs_sync_rwlock);
2896 up_read(&osb->nfs_sync_rwlock);
2899 int ocfs2_trim_fs_lock(struct ocfs2_super *osb,
2904 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres;
2909 if (ocfs2_is_hard_readonly(osb))
2912 if (ocfs2_mount_local(osb))
2915 status = ocfs2_cluster_lock(osb, lockres, DLM_LOCK_EX,
2940 void ocfs2_trim_fs_unlock(struct ocfs2_super *osb,
2944 struct ocfs2_lock_res *lockres = &osb->osb_trim_fs_lockres;
2946 if (ocfs2_mount_local(osb))
2960 ocfs2_cluster_unlock(osb, lockres, DLM_LOCK_EX);
2968 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
2972 if (ocfs2_is_hard_readonly(osb)) {
2978 if (ocfs2_mount_local(osb))
2981 ret = ocfs2_cluster_lock(osb, &dl->dl_lockres, level, 0, 0);
2992 struct ocfs2_super *osb = OCFS2_SB(dentry->d_sb);
2994 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb))
2995 ocfs2_cluster_unlock(osb, &dl->dl_lockres, level);
3271 struct ocfs2_super *osb;
3279 osb = inode->i_private;
3280 ocfs2_get_dlm_debug(osb->osb_dlm_debug);
3281 priv->p_dlm_debug = osb->osb_dlm_debug;
3297 static void ocfs2_dlm_init_debug(struct ocfs2_super *osb)
3299 struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug;
3302 osb->osb_debug_root, osb, &ocfs2_dlm_debug_fops);
3304 debugfs_create_u32("locking_filter", 0600, osb->osb_debug_root,
3309 static void ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb)
3311 struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug;
3317 int ocfs2_dlm_init(struct ocfs2_super *osb)
3322 if (ocfs2_mount_local(osb)) {
3323 osb->node_num = 0;
3327 ocfs2_dlm_init_debug(osb);
3330 osb->dc_task = kthread_run(ocfs2_downconvert_thread, osb, "ocfs2dc-%s",
3331 osb->uuid_str);
3332 if (IS_ERR(osb->dc_task)) {
3333 status = PTR_ERR(osb->dc_task);
3334 osb->dc_task = NULL;
3340 status = ocfs2_cluster_connect(osb->osb_cluster_stack,
3341 osb->osb_cluster_name,
3342 strlen(osb->osb_cluster_name),
3343 osb->uuid_str,
3344 strlen(osb->uuid_str),
3345 &lproto, ocfs2_do_node_down, osb,
3352 status = ocfs2_cluster_this_node(conn, &osb->node_num);
3362 ocfs2_super_lock_res_init(&osb->osb_super_lockres, osb);
3363 ocfs2_rename_lock_res_init(&osb->osb_rename_lockres, osb);
3364 ocfs2_nfs_sync_lock_init(osb);
3365 ocfs2_orphan_scan_lock_res_init(&osb->osb_orphan_scan.os_lockres, osb);
3367 osb->cconn = conn;
3370 ocfs2_dlm_shutdown_debug(osb);
3371 if (osb->dc_task)
3372 kthread_stop(osb->dc_task);
3378 void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
3381 ocfs2_drop_osb_locks(osb);
3389 if (osb->dc_task) {
3390 kthread_stop(osb->dc_task);
3391 osb->dc_task = NULL;
3394 ocfs2_lock_res_free(&osb->osb_super_lockres);
3395 ocfs2_lock_res_free(&osb->osb_rename_lockres);
3396 ocfs2_lock_res_free(&osb->osb_nfs_sync_lockres);
3397 ocfs2_lock_res_free(&osb->osb_orphan_scan.os_lockres);
3399 if (osb->cconn) {
3400 ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
3401 osb->cconn = NULL;
3403 ocfs2_dlm_shutdown_debug(osb);
3407 static int ocfs2_drop_lock(struct ocfs2_super *osb,
3474 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb, lkm_flags);
3489 static void ocfs2_process_blocked_lock(struct ocfs2_super *osb,
3498 void ocfs2_mark_lockres_freeing(struct ocfs2_super *osb,
3509 if (lockres->l_flags & OCFS2_LOCK_QUEUED && current == osb->dc_task) {
3528 spin_lock_irqsave(&osb->dc_task_lock, flags2);
3530 osb->blocked_lock_count--;
3531 spin_unlock_irqrestore(&osb->dc_task_lock, flags2);
3540 ocfs2_process_blocked_lock(osb, lockres);
3558 void ocfs2_simple_drop_lockres(struct ocfs2_super *osb,
3563 ocfs2_mark_lockres_freeing(osb, lockres);
3564 ret = ocfs2_drop_lock(osb, lockres);
3569 static void ocfs2_drop_osb_locks(struct ocfs2_super *osb)
3571 ocfs2_simple_drop_lockres(osb, &osb->osb_super_lockres);
3572 ocfs2_simple_drop_lockres(osb, &osb->osb_rename_lockres);
3573 ocfs2_simple_drop_lockres(osb, &osb->osb_nfs_sync_lockres);
3574 ocfs2_simple_drop_lockres(osb, &osb->osb_orphan_scan.os_lockres);
3637 static int ocfs2_downconvert_lock(struct ocfs2_super *osb,
3655 if (ocfs2_userspace_stack(osb) &&
3662 ret = ocfs2_dlm_lock(osb->cconn,
3668 lockres_clear_pending(lockres, generation, osb);
3681 static int ocfs2_prepare_cancel_convert(struct ocfs2_super *osb,
3710 static int ocfs2_cancel_convert(struct ocfs2_super *osb,
3715 ret = ocfs2_dlm_unlock(osb->cconn, &lockres->l_lksb,
3727 static int ocfs2_unblock_lock(struct ocfs2_super *osb,
3783 ret = ocfs2_prepare_cancel_convert(osb, lockres);
3786 ret = ocfs2_cancel_convert(osb, lockres);
3909 ret = ocfs2_downconvert_lock(osb, lockres, new_level, set_lvb,
4012 static void ocfs2_dentry_post_unlock(struct ocfs2_super *osb,
4016 ocfs2_dentry_lock_put(osb, dl);
4171 struct ocfs2_super *osb = OCFS2_SB(oinfo->dqi_gi.dqi_sb);
4174 if (!ocfs2_is_hard_readonly(osb) && !ocfs2_mount_local(osb))
4175 ocfs2_cluster_unlock(osb, lockres, level);
4226 struct ocfs2_super *osb = OCFS2_SB(oinfo->dqi_gi.dqi_sb);
4231 if (ocfs2_is_hard_readonly(osb)) {
4236 if (ocfs2_mount_local(osb))
4239 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
4260 struct ocfs2_super *osb = lockres->l_priv;
4263 if (ocfs2_is_hard_readonly(osb))
4266 if (ocfs2_mount_local(osb))
4269 status = ocfs2_cluster_lock(osb, lockres, level, 0, 0);
4280 struct ocfs2_super *osb = lockres->l_priv;
4282 if (!ocfs2_mount_local(osb))
4283 ocfs2_cluster_unlock(osb, lockres, level);
4286 static void ocfs2_process_blocked_lock(struct ocfs2_super *osb,
4312 status = ocfs2_unblock_lock(osb, lockres, &ctl);
4321 ocfs2_schedule_blocked_lock(osb, lockres);
4329 lockres->l_ops->post_unlock(osb, lockres);
4332 static void ocfs2_schedule_blocked_lock(struct ocfs2_super *osb,
4350 spin_lock_irqsave(&osb->dc_task_lock, flags);
4353 &osb->blocked_lock_list);
4354 osb->blocked_lock_count++;
4356 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4359 static void ocfs2_downconvert_thread_do_work(struct ocfs2_super *osb)
4365 spin_lock_irqsave(&osb->dc_task_lock, flags);
4368 osb->dc_work_sequence = osb->dc_wake_sequence;
4370 processed = osb->blocked_lock_count;
4373 * remove items off osb->blocked_lock_list. Downconvert up to
4377 while (processed && !list_empty(&osb->blocked_lock_list)) {
4378 lockres = list_entry(osb->blocked_lock_list.next,
4381 osb->blocked_lock_count--;
4382 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4387 ocfs2_process_blocked_lock(osb, lockres);
4389 spin_lock_irqsave(&osb->dc_task_lock, flags);
4391 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4394 static int ocfs2_downconvert_thread_lists_empty(struct ocfs2_super *osb)
4399 spin_lock_irqsave(&osb->dc_task_lock, flags);
4400 if (list_empty(&osb->blocked_lock_list))
4403 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4407 static int ocfs2_downconvert_thread_should_wake(struct ocfs2_super *osb)
4412 spin_lock_irqsave(&osb->dc_task_lock, flags);
4413 if (osb->dc_work_sequence != osb->dc_wake_sequence)
4415 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4422 struct ocfs2_super *osb = arg;
4427 ocfs2_downconvert_thread_lists_empty(osb))) {
4429 wait_event_interruptible(osb->dc_event,
4430 ocfs2_downconvert_thread_should_wake(osb) ||
4435 ocfs2_downconvert_thread_do_work(osb);
4438 osb->dc_task = NULL;
4442 void ocfs2_wake_downconvert_thread(struct ocfs2_super *osb)
4446 spin_lock_irqsave(&osb->dc_task_lock, flags);
4449 osb->dc_wake_sequence++;
4450 spin_unlock_irqrestore(&osb->dc_task_lock, flags);
4451 wake_up(&osb->dc_event);