fs/dlm/ast.c

Source file repositories/reference/linux-study-clean/fs/dlm/ast.c

File Facts

System
Linux kernel
Corpus path
fs/dlm/ast.c
Extension
.c
Size
7065 bytes
Lines
276
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

if (lkb->lkb_last_cast_cb_mode != -1) {
			if (dlm_modes_compat(mode, lkb->lkb_last_cast_cb_mode)) {
				log_debug(ls, "skip %x bast mode %d for cast mode %d",
					  lkb->lkb_id, mode,
					  lkb->lkb_last_cast_cb_mode);
				return true;
			}
		}

		/*
		 * Suppress some redundant basts here, do more on removal.
		 * Don't even add a bast if the callback just before it
		 * is a bast for the same mode or a more restrictive mode.
		 * (the addional > PR check is needed for PR/CW inversion)
		 */
		if (lkb->lkb_last_cb_mode != -1 &&
		    lkb->lkb_last_cb_flags & DLM_CB_BAST) {
			prev_mode = lkb->lkb_last_cb_mode;

			if ((prev_mode == mode) ||
			    (prev_mode > mode && prev_mode > DLM_LOCK_PR)) {
				log_debug(ls, "skip %x add bast mode %d for bast mode %d",
					  lkb->lkb_id, mode, prev_mode);
				return true;
			}
		}

		lkb->lkb_last_bast_time = ktime_get();
		lkb->lkb_last_bast_cb_mode = mode;
	} else if (flags & DLM_CB_CAST) {
		if (test_bit(DLM_DFL_USER_BIT, &lkb->lkb_dflags)) {
			prev_mode = lkb->lkb_last_cast_cb_mode;

			if (!status && lkb->lkb_lksb->sb_lvbptr &&
			    dlm_lvb_operations[prev_mode + 1][mode + 1]) {
				if (copy_lvb)
					*copy_lvb = 1;
			}
		}

		lkb->lkb_last_cast_cb_mode = mode;
		lkb->lkb_last_cast_time = ktime_get();
	}

	lkb->lkb_last_cb_mode = mode;
	lkb->lkb_last_cb_flags = flags;

	return false;
}

int dlm_get_cb(struct dlm_lkb *lkb, uint32_t flags, int mode,
	       int status, uint32_t sbflags,
	       struct dlm_callback **cb)
{
	struct dlm_rsb *rsb = lkb->lkb_resource;
	struct dlm_ls *ls = rsb->res_ls;

	*cb = dlm_allocate_cb();
	if (WARN_ON_ONCE(!*cb))
		return -ENOMEM;

	/* for tracing */
	(*cb)->lkb_id = lkb->lkb_id;
	(*cb)->ls_id = ls->ls_global_id;
	memcpy((*cb)->res_name, rsb->res_name, rsb->res_length);
	(*cb)->res_length = rsb->res_length;

	(*cb)->flags = flags;
	(*cb)->mode = mode;
	(*cb)->sb_status = status;
	(*cb)->sb_flags = (sbflags & 0x000000FF);
	(*cb)->lkb_lksb = lkb->lkb_lksb;

	return 0;
}

static int dlm_get_queue_cb(struct dlm_lkb *lkb, uint32_t flags, int mode,
			    int status, uint32_t sbflags,
			    struct dlm_callback **cb)
{
	int rv;

	rv = dlm_get_cb(lkb, flags, mode, status, sbflags, cb);
	if (rv)
		return rv;

	(*cb)->astfn = lkb->lkb_astfn;
	(*cb)->bastfn = lkb->lkb_bastfn;
	(*cb)->astparam = lkb->lkb_astparam;
	INIT_WORK(&(*cb)->work, dlm_callback_work);

Annotation

Implementation Notes