diff options
Diffstat (limited to 'drivers/staging/lustre/lustre/ldlm/ldlm_flock.c')
-rw-r--r-- | drivers/staging/lustre/lustre/ldlm/ldlm_flock.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c index 4310154e1728..b88b78606aee 100644 --- a/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c +++ b/drivers/staging/lustre/lustre/ldlm/ldlm_flock.c @@ -92,7 +92,7 @@ ldlm_flocks_overlap(struct ldlm_lock *lock, struct ldlm_lock *new) } static inline void -ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) +ldlm_flock_destroy(struct ldlm_lock *lock, enum ldlm_mode mode, __u64 flags) { LDLM_DEBUG(lock, "ldlm_flock_destroy(mode: %d, flags: 0x%llx)", mode, flags); @@ -107,7 +107,8 @@ ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) lock->l_flags |= LDLM_FL_LOCAL_ONLY | LDLM_FL_CBPENDING; /* when reaching here, it is under lock_res_and_lock(). Thus, - need call the nolock version of ldlm_lock_decref_internal*/ + * need call the nolock version of ldlm_lock_decref_internal + */ ldlm_lock_decref_internal_nolock(lock, mode); } @@ -133,7 +134,7 @@ ldlm_flock_destroy(struct ldlm_lock *lock, ldlm_mode_t mode, __u64 flags) * would be collected and ASTs sent. */ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, - int first_enq, ldlm_error_t *err, + int first_enq, enum ldlm_error *err, struct list_head *work_list) { struct ldlm_resource *res = req->l_resource; @@ -143,7 +144,7 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, struct ldlm_lock *lock = NULL; struct ldlm_lock *new = req; struct ldlm_lock *new2 = NULL; - ldlm_mode_t mode = req->l_req_mode; + enum ldlm_mode mode = req->l_req_mode; int added = (mode == LCK_NL); int overlaps = 0; int splitted = 0; @@ -159,13 +160,15 @@ static int ldlm_process_flock_lock(struct ldlm_lock *req, __u64 *flags, *err = ELDLM_OK; /* No blocking ASTs are sent to the clients for - * Posix file & record locks */ + * Posix file & record locks + */ req->l_blocking_ast = NULL; reprocess: if ((*flags == LDLM_FL_WAIT_NOREPROC) || (mode == LCK_NL)) { /* This loop determines where this processes locks start - * in the resource lr_granted list. */ + * in the resource lr_granted list. + */ list_for_each(tmp, &res->lr_granted) { lock = list_entry(tmp, struct ldlm_lock, l_res_link); @@ -180,7 +183,8 @@ reprocess: lockmode_verify(mode); /* This loop determines if there are existing locks - * that conflict with the new lock request. */ + * that conflict with the new lock request. + */ list_for_each(tmp, &res->lr_granted) { lock = list_entry(tmp, struct ldlm_lock, l_res_link); @@ -238,8 +242,8 @@ reprocess: } /* Scan the locks owned by this process that overlap this request. - * We may have to merge or split existing locks. */ - + * We may have to merge or split existing locks. + */ if (!ownlocks) ownlocks = &res->lr_granted; @@ -253,7 +257,8 @@ reprocess: /* If the modes are the same then we need to process * locks that overlap OR adjoin the new lock. The extra * logic condition is necessary to deal with arithmetic - * overflow and underflow. */ + * overflow and underflow. + */ if ((new->l_policy_data.l_flock.start > (lock->l_policy_data.l_flock.end + 1)) && (lock->l_policy_data.l_flock.end != @@ -327,11 +332,13 @@ reprocess: * with the request but this would complicate the reply * processing since updates to req get reflected in the * reply. The client side replays the lock request so - * it must see the original lock data in the reply. */ + * it must see the original lock data in the reply. + */ /* XXX - if ldlm_lock_new() can sleep we should * release the lr_lock, allocate the new lock, - * and restart processing this lock. */ + * and restart processing this lock. + */ if (!new2) { unlock_res_and_lock(req); new2 = ldlm_lock_create(ns, &res->lr_name, LDLM_FLOCK, @@ -361,7 +368,7 @@ reprocess: lock->l_policy_data.l_flock.start = new->l_policy_data.l_flock.end + 1; new2->l_conn_export = lock->l_conn_export; - if (lock->l_export != NULL) { + if (lock->l_export) { new2->l_export = class_export_lock_get(lock->l_export, new2); if (new2->l_export->exp_lock_hash && @@ -381,7 +388,7 @@ reprocess: } /* if new2 is created but never used, destroy it*/ - if (splitted == 0 && new2 != NULL) + if (splitted == 0 && new2) ldlm_lock_destroy_nolock(new2); /* At this point we're granting the lock request. */ @@ -396,7 +403,8 @@ reprocess: if (*flags != LDLM_FL_WAIT_NOREPROC) { /* The only one possible case for client-side calls flock * policy function is ldlm_flock_completion_ast inside which - * carries LDLM_FL_WAIT_NOREPROC flag. */ + * carries LDLM_FL_WAIT_NOREPROC flag. + */ CERROR("Illegal parameter for client-side-only module.\n"); LBUG(); } @@ -404,7 +412,8 @@ reprocess: /* In case we're reprocessing the requested lock we can't destroy * it until after calling ldlm_add_ast_work_item() above so that laawi() * can bump the reference count on \a req. Otherwise \a req - * could be freed before the completion AST can be sent. */ + * could be freed before the completion AST can be sent. + */ if (added) ldlm_flock_destroy(req, mode, *flags); @@ -449,7 +458,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) struct obd_import *imp = NULL; struct ldlm_flock_wait_data fwd; struct l_wait_info lwi; - ldlm_error_t err; + enum ldlm_error err; int rc = 0; CDEBUG(D_DLMTRACE, "flags: 0x%llx data: %p getlk: %p\n", @@ -458,12 +467,12 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) /* Import invalidation. We need to actually release the lock * references being held, so that it can go away. No point in * holding the lock even if app still believes it has it, since - * server already dropped it anyway. Only for granted locks too. */ + * server already dropped it anyway. Only for granted locks too. + */ if ((lock->l_flags & (LDLM_FL_FAILED|LDLM_FL_LOCAL_ONLY)) == (LDLM_FL_FAILED|LDLM_FL_LOCAL_ONLY)) { if (lock->l_req_mode == lock->l_granted_mode && - lock->l_granted_mode != LCK_NL && - data == NULL) + lock->l_granted_mode != LCK_NL && !data) ldlm_lock_decref_internal(lock, lock->l_req_mode); /* Need to wake up the waiter if we were evicted */ @@ -475,7 +484,7 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) if (!(flags & (LDLM_FL_BLOCK_WAIT | LDLM_FL_BLOCK_GRANTED | LDLM_FL_BLOCK_CONV))) { - if (data == NULL) + if (!data) /* mds granted the lock in the reply */ goto granted; /* CP AST RPC: lock get granted, wake it up */ @@ -488,10 +497,10 @@ ldlm_flock_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data) obd = class_exp2obd(lock->l_conn_export); /* if this is a local lock, there is no import */ - if (obd != NULL) + if (obd) imp = obd->u.cli.cl_import; - if (imp != NULL) { + if (imp) { spin_lock(&imp->imp_lock); fwd.fwd_generation = imp->imp_generation; spin_unlock(&imp->imp_lock); @@ -540,7 +549,8 @@ granted: } else if (flags & LDLM_FL_TEST_LOCK) { /* fcntl(F_GETLK) request */ /* The old mode was saved in getlk->fl_type so that if the mode - * in the lock changes we can decref the appropriate refcount.*/ + * in the lock changes we can decref the appropriate refcount. + */ ldlm_flock_destroy(lock, getlk->fl_type, LDLM_FL_WAIT_NOREPROC); switch (lock->l_granted_mode) { case LCK_PR: @@ -559,7 +569,8 @@ granted: __u64 noreproc = LDLM_FL_WAIT_NOREPROC; /* We need to reprocess the lock to do merges or splits - * with existing locks owned by this process. */ + * with existing locks owned by this process. + */ ldlm_process_flock_lock(lock, &noreproc, 1, &err, NULL); } unlock_res_and_lock(lock); @@ -576,7 +587,8 @@ void ldlm_flock_policy_wire18_to_local(const ldlm_wire_policy_data_t *wpolicy, lpolicy->l_flock.pid = wpolicy->l_flock.lfw_pid; /* Compat code, old clients had no idea about owner field and * relied solely on pid for ownership. Introduced in LU-104, 2.1, - * April 2011 */ + * April 2011 + */ lpolicy->l_flock.owner = wpolicy->l_flock.lfw_pid; } |