Whamcloud - gitweb
b=22190 return error on write if rdonly mode is on, don't reply if umount
[fs/lustre-release.git] / lustre / obdclass / cl_lock.c
index 575a54d..0726ab6 100644 (file)
@@ -1927,6 +1927,7 @@ int cl_lock_page_out(const struct lu_env *env, struct cl_lock *lock,
         struct cl_2queue      *queue = &info->clt_queue;
         struct cl_lock_descr  *descr = &lock->cll_descr;
         long page_count;
+        int nonblock = 1, resched;
         int result;
 
         LINVRNT(cl_lock_invariant(env, lock));
@@ -1934,13 +1935,14 @@ int cl_lock_page_out(const struct lu_env *env, struct cl_lock *lock,
 
         io->ci_obj = cl_object_top(descr->cld_obj);
         result = cl_io_init(env, io, CIT_MISC, io->ci_obj);
-        if (result == 0) {
-                int nonblock = 1;
+        if (result != 0)
+                GOTO(out, result);
 
-restart:
+        do {
                 cl_2queue_init(queue);
                 cl_page_gang_lookup(env, descr->cld_obj, io, descr->cld_start,
-                                    descr->cld_end, &queue->c2_qin, nonblock);
+                                    descr->cld_end, &queue->c2_qin, nonblock,
+                                    &resched);
                 page_count = queue->c2_qin.pl_nr;
                 if (page_count > 0) {
                         result = cl_page_list_unmap(env, io, &queue->c2_qin);
@@ -1963,11 +1965,10 @@ restart:
                 }
                 cl_2queue_fini(env, queue);
 
-                if (nonblock) {
-                        nonblock = 0;
-                        goto restart;
-                }
-        }
+                if (resched)
+                        cfs_cond_resched();
+        } while (resched || nonblock--);
+out:
         cl_io_fini(env, io);
         RETURN(result);
 }
@@ -2092,14 +2093,10 @@ struct cl_lock *cl_lock_request(const struct lu_env *env, struct cl_io *io,
                                 const char *scope, const void *source)
 {
         struct cl_lock       *lock;
-        const struct lu_fid  *fid;
         int                   rc;
-        int                   iter;
         __u32                 enqflags = need->cld_enq_flags;
 
         ENTRY;
-        fid = lu_object_fid(&io->ci_obj->co_lu);
-        iter = 0;
         do {
                 lock = cl_lock_hold_mutex(env, io, need, scope, source);
                 if (!IS_ERR(lock)) {
@@ -2121,7 +2118,6 @@ struct cl_lock *cl_lock_request(const struct lu_env *env, struct cl_io *io,
                         lock = ERR_PTR(rc);
                 } else
                         rc = PTR_ERR(lock);
-                iter++;
         } while (rc == 0);
         RETURN(lock);
 }