staging/lustre/osc: Fix reverted condition in osc_lock_weight
[deliverable/linux.git] / drivers / staging / lustre / lustre / osc / osc_lock.c
index 16f9cd9d3b12bfbe7aba3a4e691fb2371f06c7a7..5455d9de045b29896dee81df443518714c2fd960 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
@@ -638,11 +634,10 @@ static int weigh_cb(const struct lu_env *env, struct cl_io *io,
 
        if (cl_page_is_vmlocked(env, page) ||
            PageDirty(page->cp_vmpage) || PageWriteback(page->cp_vmpage)
-          ) {
-               (*(unsigned long *)cbdata)++;
+          )
                return CLP_GANG_ABORT;
-       }
 
+       *(pgoff_t *)cbdata = osc_index(ops) + 1;
        return CLP_GANG_OKAY;
 }
 
@@ -652,7 +647,7 @@ static unsigned long osc_lock_weight(const struct lu_env *env,
 {
        struct cl_io *io = &osc_env_info(env)->oti_io;
        struct cl_object *obj = cl_object_top(&oscobj->oo_cl);
-       unsigned long npages = 0;
+       pgoff_t page_index;
        int result;
 
        io->ci_obj = obj;
@@ -661,11 +656,12 @@ static unsigned long osc_lock_weight(const struct lu_env *env,
        if (result != 0)
                return result;
 
+       page_index = cl_index(obj, extent->start);
        do {
                result = osc_page_gang_lookup(env, io, oscobj,
-                                             cl_index(obj, extent->start),
+                                             page_index,
                                              cl_index(obj, extent->end),
-                                             weigh_cb, (void *)&npages);
+                                             weigh_cb, (void *)&page_index);
                if (result == CLP_GANG_ABORT)
                        break;
                if (result == CLP_GANG_RESCHED)
@@ -673,7 +669,7 @@ static unsigned long osc_lock_weight(const struct lu_env *env,
        } while (result != CLP_GANG_OKAY);
        cl_io_fini(env, io);
 
-       return npages;
+       return result == CLP_GANG_ABORT ? 1 : 0;
 }
 
 /**
@@ -703,7 +699,7 @@ unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock)
 
        LASSERT(dlmlock->l_resource->lr_type == LDLM_EXTENT);
        obj = dlmlock->l_ast_data;
-       if (obj) {
+       if (!obj) {
                weight = 1;
                goto out;
        }
@@ -1120,7 +1116,8 @@ static void osc_lock_set_writer(const struct lu_env *env,
                }
        } else {
                LASSERT(cl_io_is_mkwrite(io));
-               io_start = io_end = io->u.ci_fault.ft_index;
+               io_start = io->u.ci_fault.ft_index;
+               io_end = io->u.ci_fault.ft_index;
        }
 
        if (descr->cld_mode >= CLM_WRITE &&
This page took 0.027278 seconds and 5 git commands to generate.