Whamcloud - gitweb
LU-8680 osc: soft lock - osc_makes_rpc() 26/23326/6
authorBobi Jam <bobijam.xu@intel.com>
Mon, 24 Oct 2016 05:11:25 +0000 (13:11 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Fri, 28 Oct 2016 23:49:32 +0000 (23:49 +0000)
It is possible that an osc_extent contains more than 256 chunks, and
the IO engine won't add this extent in one RPC
(try_to_add_extent_for_io) so that osc_check_rpcs() run into a loop
upon this extent and never break.

This patch changes osc_max_write_chunks() to make sure the value
can cover all possible osc_extent, so that all osc_extent will be
added into one RPC.

This patch also add another field erd_max_extents in extent_rpc_data
to make sure not to add too many fragments in a single RPC.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Change-Id: Icf58a6bd04655bb9aa5589dd002e118c21ed932d
Reviewed-on: http://review.whamcloud.com/23326
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/osc/osc_cache.c

index 33b9272..236263c 100644 (file)
@@ -1884,6 +1884,7 @@ struct extent_rpc_data {
        unsigned int            erd_page_count;
        unsigned int            erd_max_pages;
        unsigned int            erd_max_chunks;
+       unsigned int            erd_max_extents;
 };
 
 static inline unsigned osc_extent_chunks(const struct osc_extent *ext)
@@ -1913,11 +1914,24 @@ static int try_to_add_extent_for_io(struct client_obd *cli,
        EASSERT((ext->oe_state == OES_CACHE || ext->oe_state == OES_LOCK_DONE),
                ext);
 
+       if (data->erd_max_extents == 0)
+               RETURN(0);
+
        chunk_count = osc_extent_chunks(ext);
+       EASSERTF(data->erd_page_count != 0 ||
+                chunk_count <= data->erd_max_chunks, ext,
+                "The first extent to be fit in a RPC contains %u chunks, "
+                "which is over the limit %u.\n", chunk_count,
+                data->erd_max_chunks);
        if (chunk_count > data->erd_max_chunks)
                RETURN(0);
 
        data->erd_max_pages = max(ext->oe_mppr, data->erd_max_pages);
+       EASSERTF(data->erd_page_count != 0 ||
+               ext->oe_nr_pages <= data->erd_max_pages, ext,
+               "The first extent to be fit in a RPC contains %u pages, "
+               "which is over the limit %u.\n", ext->oe_nr_pages,
+               data->erd_max_pages);
        if (data->erd_page_count + ext->oe_nr_pages > data->erd_max_pages)
                RETURN(0);
 
@@ -1947,6 +1961,7 @@ static int try_to_add_extent_for_io(struct client_obd *cli,
                break;
        }
 
+       data->erd_max_extents--;
        data->erd_max_chunks -= chunk_count;
        data->erd_page_count += ext->oe_nr_pages;
        list_move_tail(&ext->oe_link, data->erd_rpc_list);
@@ -1976,10 +1991,12 @@ static inline unsigned osc_max_write_chunks(const struct client_obd *cli)
         *
         * This limitation doesn't apply to ldiskfs, which allows as many
         * chunks in one RPC as we want. However, it won't have any benefits
-        * to have too many discontiguous pages in one RPC. Therefore, it
-        * can only have 256 chunks at most in one RPC.
+        * to have too many discontiguous pages in one RPC.
+        *
+        * An osc_extent won't cover over a RPC size, so the chunks in an
+        * osc_extent won't bigger than PTLRPC_MAX_BRW_SIZE >> chunkbits.
         */
-       return min(PTLRPC_MAX_BRW_SIZE >> cli->cl_chunkbits, 256);
+       return PTLRPC_MAX_BRW_SIZE >> cli->cl_chunkbits;
 }
 
 /**
@@ -2005,6 +2022,7 @@ static unsigned int get_write_extents(struct osc_object *obj,
                .erd_page_count = 0,
                .erd_max_pages  = cli->cl_max_pages_per_rpc,
                .erd_max_chunks = osc_max_write_chunks(cli),
+               .erd_max_extents = 256,
        };
 
        LASSERT(osc_object_is_locked(obj));
@@ -2145,6 +2163,7 @@ __must_hold(osc)
                .erd_page_count = 0,
                .erd_max_pages  = cli->cl_max_pages_per_rpc,
                .erd_max_chunks = UINT_MAX,
+               .erd_max_extents = UINT_MAX,
        };
        int rc = 0;
        ENTRY;