Lines Matching refs:gl
75 static inline void gfs2_update_reply_times(struct gfs2_glock *gl) in gfs2_update_reply_times() argument
78 const unsigned gltype = gl->gl_name.ln_type; in gfs2_update_reply_times()
79 unsigned index = test_bit(GLF_BLOCKING, &gl->gl_flags) ? in gfs2_update_reply_times()
84 rtt = ktime_to_ns(ktime_sub(ktime_get_real(), gl->gl_dstamp)); in gfs2_update_reply_times()
85 lks = this_cpu_ptr(gl->gl_name.ln_sbd->sd_lkstats); in gfs2_update_reply_times()
86 gfs2_update_stats(&gl->gl_stats, index, rtt); /* Local */ in gfs2_update_reply_times()
90 trace_gfs2_glock_lock_time(gl, rtt); in gfs2_update_reply_times()
102 static inline void gfs2_update_request_times(struct gfs2_glock *gl) in gfs2_update_request_times() argument
105 const unsigned gltype = gl->gl_name.ln_type; in gfs2_update_request_times()
110 dstamp = gl->gl_dstamp; in gfs2_update_request_times()
111 gl->gl_dstamp = ktime_get_real(); in gfs2_update_request_times()
112 irt = ktime_to_ns(ktime_sub(gl->gl_dstamp, dstamp)); in gfs2_update_request_times()
113 lks = this_cpu_ptr(gl->gl_name.ln_sbd->sd_lkstats); in gfs2_update_request_times()
114 gfs2_update_stats(&gl->gl_stats, GFS2_LKS_SIRT, irt); /* Local */ in gfs2_update_request_times()
121 struct gfs2_glock *gl = arg; in gdlm_ast() local
122 unsigned ret = gl->gl_state; in gdlm_ast()
124 gfs2_update_reply_times(gl); in gdlm_ast()
125 BUG_ON(gl->gl_lksb.sb_flags & DLM_SBF_DEMOTED); in gdlm_ast()
127 if ((gl->gl_lksb.sb_flags & DLM_SBF_VALNOTVALID) && gl->gl_lksb.sb_lvbptr) in gdlm_ast()
128 memset(gl->gl_lksb.sb_lvbptr, 0, GDLM_LVB_SIZE); in gdlm_ast()
130 switch (gl->gl_lksb.sb_status) { in gdlm_ast()
132 if (gl->gl_ops->go_free) in gdlm_ast()
133 gl->gl_ops->go_free(gl); in gdlm_ast()
134 gfs2_glock_free(gl); in gdlm_ast()
151 ret = gl->gl_req; in gdlm_ast()
152 if (gl->gl_lksb.sb_flags & DLM_SBF_ALTMODE) { in gdlm_ast()
153 if (gl->gl_req == LM_ST_SHARED) in gdlm_ast()
155 else if (gl->gl_req == LM_ST_DEFERRED) in gdlm_ast()
161 set_bit(GLF_INITIAL, &gl->gl_flags); in gdlm_ast()
162 gfs2_glock_complete(gl, ret); in gdlm_ast()
165 if (!test_bit(GLF_INITIAL, &gl->gl_flags)) in gdlm_ast()
166 gl->gl_lksb.sb_lkid = 0; in gdlm_ast()
167 gfs2_glock_complete(gl, ret); in gdlm_ast()
172 struct gfs2_glock *gl = arg; in gdlm_bast() local
176 gfs2_glock_cb(gl, LM_ST_UNLOCKED); in gdlm_bast()
179 gfs2_glock_cb(gl, LM_ST_DEFERRED); in gdlm_bast()
182 gfs2_glock_cb(gl, LM_ST_SHARED); in gdlm_bast()
185 fs_err(gl->gl_name.ln_sbd, "unknown bast mode %d\n", mode); in gdlm_bast()
209 static u32 make_flags(struct gfs2_glock *gl, const unsigned int gfs_flags, in make_flags() argument
214 if (gl->gl_lksb.sb_lvbptr) in make_flags()
239 if (gl->gl_lksb.sb_lkid != 0) { in make_flags()
241 if (test_bit(GLF_BLOCKING, &gl->gl_flags)) in make_flags()
257 static int gdlm_lock(struct gfs2_glock *gl, unsigned int req_state, in gdlm_lock() argument
260 struct lm_lockstruct *ls = &gl->gl_name.ln_sbd->sd_lockstruct; in gdlm_lock()
266 req = make_mode(gl->gl_name.ln_sbd, req_state); in gdlm_lock()
267 lkf = make_flags(gl, flags, req); in gdlm_lock()
268 gfs2_glstats_inc(gl, GFS2_LKS_DCOUNT); in gdlm_lock()
269 gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT); in gdlm_lock()
270 if (gl->gl_lksb.sb_lkid) { in gdlm_lock()
271 gfs2_update_request_times(gl); in gdlm_lock()
275 gfs2_reverse_hex(strname + 7, gl->gl_name.ln_type); in gdlm_lock()
276 gfs2_reverse_hex(strname + 23, gl->gl_name.ln_number); in gdlm_lock()
277 gl->gl_dstamp = ktime_get_real(); in gdlm_lock()
284 error = dlm_lock(ls->ls_dlm, req, &gl->gl_lksb, lkf, strname, in gdlm_lock()
285 GDLM_STRNAME_BYTES - 1, 0, gdlm_ast, gl, gdlm_bast); in gdlm_lock()
293 static void gdlm_put_lock(struct gfs2_glock *gl) in gdlm_put_lock() argument
295 struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; in gdlm_put_lock()
299 if (gl->gl_lksb.sb_lkid == 0) { in gdlm_put_lock()
300 gfs2_glock_free(gl); in gdlm_put_lock()
304 clear_bit(GLF_BLOCKING, &gl->gl_flags); in gdlm_put_lock()
305 gfs2_glstats_inc(gl, GFS2_LKS_DCOUNT); in gdlm_put_lock()
306 gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT); in gdlm_put_lock()
307 gfs2_update_request_times(gl); in gdlm_put_lock()
311 gfs2_glock_free(gl); in gdlm_put_lock()
317 !gl->gl_lksb.sb_lvbptr) { in gdlm_put_lock()
318 gfs2_glock_free(gl); in gdlm_put_lock()
323 error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_VALBLK, in gdlm_put_lock()
324 NULL, gl); in gdlm_put_lock()
332 gl->gl_name.ln_type, in gdlm_put_lock()
333 (unsigned long long)gl->gl_name.ln_number, error); in gdlm_put_lock()
338 static void gdlm_cancel(struct gfs2_glock *gl) in gdlm_cancel() argument
340 struct lm_lockstruct *ls = &gl->gl_name.ln_sbd->sd_lockstruct; in gdlm_cancel()
341 dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_CANCEL, NULL, gl); in gdlm_cancel()