Whamcloud - gitweb
LU-4856 misc: Reduce exposure to overflow on page counters.
[fs/lustre-release.git] / lustre / osc / osc_request.c
index 773cfb2..06c458c 100644 (file)
@@ -811,16 +811,16 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
                       cli->cl_dirty_pages, cli->cl_dirty_transit,
                       cli->cl_dirty_max_pages);
                oa->o_undirty = 0;
-       } else if (unlikely(atomic_read(&obd_dirty_pages) -
-                           atomic_read(&obd_dirty_transit_pages) >
-                           (long)(obd_max_dirty_pages + 1))) {
+       } else if (unlikely(atomic_long_read(&obd_dirty_pages) -
+                           atomic_long_read(&obd_dirty_transit_pages) >
+                           (obd_max_dirty_pages + 1))) {
                /* The atomic_read() allowing the 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("%s: dirty %d - %d > system dirty_max %d\n",
+               CERROR("%s: dirty %ld - %ld > system dirty_max %lu\n",
                       cli->cl_import->imp_obd->obd_name,
-                      atomic_read(&obd_dirty_pages),
-                      atomic_read(&obd_dirty_transit_pages),
+                      atomic_long_read(&obd_dirty_pages),
+                      atomic_long_read(&obd_dirty_transit_pages),
                       obd_max_dirty_pages);
                oa->o_undirty = 0;
        } else if (unlikely(cli->cl_dirty_max_pages - cli->cl_dirty_pages >
@@ -2837,11 +2837,11 @@ static int osc_set_info_async(const struct lu_env *env, struct obd_export *exp,
 
        if (KEY_IS(KEY_CACHE_LRU_SHRINK)) {
                struct client_obd *cli = &obd->u.cli;
-               int nr = atomic_read(&cli->cl_lru_in_list) >> 1;
-               int target = *(int *)val;
+               long nr = atomic_long_read(&cli->cl_lru_in_list) >> 1;
+               long target = *(long *)val;
 
                nr = osc_lru_shrink(env, cli, min(nr, target), true);
-               *(int *)val -= nr;
+               *(long *)val -= nr;
                RETURN(0);
        }