Whamcloud - gitweb
LU-2127 osc: fix wrong osc_announce_cached() msgs
authorBruno Faccini <bfaccini62@gmail.com>
Wed, 10 Oct 2012 17:23:44 +0000 (19:23 +0200)
committerOleg Drokin <green@whamcloud.com>
Tue, 8 Jan 2013 05:12:37 +0000 (00:12 -0500)
In osc_announce_cached() wrong signed/unsigned comparison has been fixed with
a cast.

Unlikely conditions have also been specified, along with some changes to comply
coding rules.

Signed-off-by: Bruno Faccini <bfaccini62@gmail.com>
Change-Id: I8f8f2bdfc673d31054b4db2063d32c3dc34100d8
Reviewed-on: http://review.whamcloud.com/4246
Reviewed-by: Keith Mannthey <keith.mannthey@intel.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Hudson
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Faccini Bruno <bruno.faccini@intel.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
lustre/osc/osc_request.c

index 8988ebd..190c7fd 100644 (file)
@@ -828,28 +828,30 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
         oa->o_valid |= bits;
         client_obd_list_lock(&cli->cl_loi_list_lock);
         oa->o_dirty = cli->cl_dirty;
-        if (cli->cl_dirty - cli->cl_dirty_transit > cli->cl_dirty_max) {
-                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 (cfs_atomic_read(&obd_dirty_pages) -
-                   cfs_atomic_read(&obd_dirty_transit_pages) >
-                   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",
-                       cfs_atomic_read(&obd_dirty_pages),
-                       cfs_atomic_read(&obd_dirty_transit_pages),
-                       obd_max_dirty_pages);
-                oa->o_undirty = 0;
-        } else if (cli->cl_dirty_max - cli->cl_dirty > 0x7fffffff) {
-                CERROR("dirty %lu - dirty_max %lu too big???\n",
-                       cli->cl_dirty, cli->cl_dirty_max);
-                oa->o_undirty = 0;
-        } else {
-                long max_in_flight = (cli->cl_max_pages_per_rpc << CFS_PAGE_SHIFT)*
-                                (cli->cl_max_rpcs_in_flight + 1);
+       if (unlikely(cli->cl_dirty - cli->cl_dirty_transit >
+                    cli->cl_dirty_max)) {
+               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) -
+                           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",
+                      cfs_atomic_read(&obd_dirty_pages),
+                      cfs_atomic_read(&obd_dirty_transit_pages),
+                      obd_max_dirty_pages);
+               oa->o_undirty = 0;
+       } else if (unlikely(cli->cl_dirty_max - cli->cl_dirty > 0x7fffffff)) {
+               CERROR("dirty %lu - dirty_max %lu too big???\n",
+                      cli->cl_dirty, cli->cl_dirty_max);
+               oa->o_undirty = 0;
+       } else {
+               long max_in_flight = (cli->cl_max_pages_per_rpc <<
+                                     CFS_PAGE_SHIFT)*
+                                    (cli->cl_max_rpcs_in_flight + 1);
                 oa->o_undirty = max(cli->cl_dirty_max, max_in_flight);
         }
        oa->o_grant = cli->cl_avail_grant + cli->cl_reserved_grant;