Whamcloud - gitweb
LU-3086 build: fix 'uninitialized variables' errors
[fs/lustre-release.git] / lustre / osc / osc_request.c
index 4422249..4092d93 100644 (file)
@@ -829,13 +829,16 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
                CERROR("dirty %lu - %lu > dirty_max %lu\n",
                       cli->cl_dirty, cli->cl_dirty_transit, cli->cl_dirty_max);
                oa->o_undirty = 0;
-       } else if (unlikely(cfs_atomic_read(&obd_dirty_pages) -
+       } else if (unlikely(cfs_atomic_read(&obd_unstable_pages) +
+                           cfs_atomic_read(&obd_dirty_pages) -
                            cfs_atomic_read(&obd_dirty_transit_pages) >
                            (long)(obd_max_dirty_pages + 1))) {
                /* The cfs_atomic_read() allowing the cfs_atomic_inc() are
                 * not covered by a lock thus they may safely race and trip
                 * this CERROR() unless we add in a small fudge factor (+1). */
-               CERROR("dirty %d - %d > system dirty_max %d\n",
+               CERROR("%s: dirty %d + %d - %d > system dirty_max %d\n",
+                      cli->cl_import->imp_obd->obd_name,
+                      cfs_atomic_read(&obd_unstable_pages),
                       cfs_atomic_read(&obd_dirty_pages),
                       cfs_atomic_read(&obd_dirty_transit_pages),
                       obd_max_dirty_pages);
@@ -1061,12 +1064,12 @@ static void osc_init_grant(struct client_obd *cli, struct obd_connect_data *ocd)
                 cli->cl_avail_grant = ocd->ocd_grant - cli->cl_dirty;
 
         if (cli->cl_avail_grant < 0) {
-                CWARN("%s: available grant < 0, the OSS is probably not running"
-                      " with patch from bug20278 (%ld) \n",
-                      cli->cl_import->imp_obd->obd_name, cli->cl_avail_grant);
-                /* workaround for 1.6 servers which do not have
-                 * the patch from bug20278 */
-                cli->cl_avail_grant = ocd->ocd_grant;
+               CWARN("%s: available grant < 0: avail/ocd/dirty %ld/%u/%ld\n",
+                     cli->cl_import->imp_obd->obd_name, cli->cl_avail_grant,
+                     ocd->ocd_grant, cli->cl_dirty);
+               /* workaround for servers which do not have the patch from
+                * LU-2679 */
+               cli->cl_avail_grant = ocd->ocd_grant;
         }
 
        /* determine the appropriate chunk size used by osc_extent. */
@@ -1211,8 +1214,8 @@ static obd_count osc_checksum_bulk(int nob, obd_count pg_count,
                cfs_crypto_hash_update_page(hdesc, pga[i]->pg,
                                  pga[i]->off & ~CFS_PAGE_MASK,
                                  count);
-               LL_CDEBUG_PAGE(D_PAGE, pga[i]->pg, "off %d checksum %x\n",
-                              (int)(pga[i]->off & ~CFS_PAGE_MASK), cksum);
+               LL_CDEBUG_PAGE(D_PAGE, pga[i]->pg, "off %d\n",
+                              (int)(pga[i]->off & ~CFS_PAGE_MASK));
 
                nob -= pga[i]->count;
                pg_count--;
@@ -1748,6 +1751,7 @@ static int osc_brw_redo_request(struct ptlrpc_request *request,
         aa->aa_resends++;
         new_req->rq_interpret_reply = request->rq_interpret_reply;
         new_req->rq_async_args = request->rq_async_args;
+       new_req->rq_commit_cb = request->rq_commit_cb;
        /* cap resend delay to the current request timeout, this is similar to
         * what ptlrpc does (see after_reply()) */
        if (aa->aa_resends > new_req->rq_timeout)
@@ -2041,6 +2045,20 @@ static int brw_interpret(const struct lu_env *env,
        RETURN(rc);
 }
 
+static void brw_commit(struct ptlrpc_request *req)
+{
+       spin_lock(&req->rq_lock);
+       /* If osc_inc_unstable_pages (via osc_extent_finish) races with
+        * this called via the rq_commit_cb, I need to ensure
+        * osc_dec_unstable_pages is still called. Otherwise unstable
+        * pages may be leaked. */
+       if (req->rq_unstable)
+               osc_dec_unstable_pages(req);
+       else
+               req->rq_committed = 1;
+       spin_unlock(&req->rq_lock);
+}
+
 /**
  * Build an RPC by the list of extent @ext_list. The caller must ensure
  * that the total pages in this list are NOT over max pages per RPC.
@@ -2146,7 +2164,9 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
                GOTO(out, rc);
        }
 
+       req->rq_commit_cb = brw_commit;
        req->rq_interpret_reply = brw_interpret;
+
        if (mem_tight != 0)
                 req->rq_memalloc = 1;