Whamcloud - gitweb
LU-12820 osc: remove 'transient' arg from osc_enter_cache_try 18/39518/7
authorMr NeilBrown <neilb@suse.de>
Sun, 29 Sep 2019 23:09:54 +0000 (09:09 +1000)
committerOleg Drokin <green@whamcloud.com>
Tue, 6 Oct 2020 00:57:52 +0000 (00:57 +0000)
This arg is always '0', so remove it.
Consequently, OBD_BRW_NOCACHE is never set, and
cl_dirty_transit and obd_dirty_transit_pages
are never non-zero, so they can be removed as well.

Lustre-change: https://review.whamcloud.com/36319
Lustre-commit: 524deb6f985beb512a4499501fd7275ecb77f815

Patch also includes changes for atomic ops optimization
to keep in sync with master branch:

Lustre-change: https://review.whamcloud.com/33859
Lustre-commit: 8b364fbd6bd9e0088440e6d6837861a641b923a0

Signed-off-by: Mikhail Pershin <mpershin@whamcloud.com>
Change-Id: Ia047affc33fb9277e6c28a8f6d7d088c385b51a8
Reviewed-on: https://review.whamcloud.com/39518
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Olaf Faaland-LLNL <faaland1@llnl.gov>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/obd.h
lustre/include/obd_support.h
lustre/obdclass/class_obd.c
lustre/osc/osc_cache.c
lustre/osc/osc_request.c

index 2b5fb97..8545fd4 100644 (file)
@@ -204,7 +204,6 @@ struct client_obd {
        /* the grant values are protected by loi_list_lock below */
        unsigned long            cl_dirty_pages;      /* all _dirty_ in pages */
        unsigned long            cl_dirty_max_pages;  /* allowed w/o rpc */
-       unsigned long            cl_dirty_transit;    /* dirty synchronous */
        unsigned long            cl_avail_grant;   /* bytes of credit for ost */
        unsigned long            cl_lost_grant;    /* lost credits (trunc) */
        /* grant consumed for dirty pages */
index 5a35482..1327843 100644 (file)
@@ -68,7 +68,6 @@ extern int at_early_margin;
 extern int at_extra;
 extern unsigned long obd_max_dirty_pages;
 extern atomic_long_t obd_dirty_pages;
-extern atomic_long_t obd_dirty_transit_pages;
 extern char obd_jobid_var[];
 
 /* Some hash init argument constants */
index d408915..43eb96c 100644 (file)
@@ -98,9 +98,6 @@ EXPORT_SYMBOL(at_early_margin);
 int at_extra = 30;
 EXPORT_SYMBOL(at_extra);
 
-atomic_long_t obd_dirty_transit_pages;
-EXPORT_SYMBOL(obd_dirty_transit_pages);
-
 #ifdef CONFIG_PROC_FS
 struct lprocfs_stats *obd_memory = NULL;
 EXPORT_SYMBOL(obd_memory);
index 6182090..41d5b66 100644 (file)
@@ -1402,7 +1402,6 @@ static void osc_consume_write_grant(struct client_obd *cli,
 {
        assert_spin_locked(&cli->cl_loi_list_lock);
        LASSERT(!(pga->flag & OBD_BRW_FROM_GRANT));
-       atomic_long_inc(&obd_dirty_pages);
        cli->cl_dirty_pages++;
        pga->flag |= OBD_BRW_FROM_GRANT;
        CDEBUG(D_CACHE, "using %lu grant credits for brw %p page %p\n",
@@ -1426,11 +1425,6 @@ static void osc_release_write_grant(struct client_obd *cli,
        pga->flag &= ~OBD_BRW_FROM_GRANT;
        atomic_long_dec(&obd_dirty_pages);
        cli->cl_dirty_pages--;
-       if (pga->flag & OBD_BRW_NOCACHE) {
-               pga->flag &= ~OBD_BRW_NOCACHE;
-               atomic_long_dec(&obd_dirty_transit_pages);
-               cli->cl_dirty_transit--;
-       }
        EXIT;
 }
 
@@ -1536,7 +1530,7 @@ static void osc_exit_cache(struct client_obd *cli, struct osc_async_page *oap)
  */
 static int osc_enter_cache_try(struct client_obd *cli,
                               struct osc_async_page *oap,
-                              int bytes, int transient)
+                              int bytes)
 {
        int rc;
 
@@ -1546,20 +1540,16 @@ static int osc_enter_cache_try(struct client_obd *cli,
        if (rc < 0)
                return 0;
 
-       if (cli->cl_dirty_pages < cli->cl_dirty_max_pages &&
-           1 + atomic_long_read(&obd_dirty_pages) <= obd_max_dirty_pages) {
-               osc_consume_write_grant(cli, &oap->oap_brw_page);
-               if (transient) {
-                       cli->cl_dirty_transit++;
-                       atomic_long_inc(&obd_dirty_transit_pages);
-                       oap->oap_brw_flags |= OBD_BRW_NOCACHE;
+       if (cli->cl_dirty_pages < cli->cl_dirty_max_pages) {
+               if (atomic_long_add_return(1, &obd_dirty_pages) <=
+                   obd_max_dirty_pages) {
+                       osc_consume_write_grant(cli, &oap->oap_brw_page);
+                       return 1;
                }
-               rc = 1;
-       } else {
-               __osc_unreserve_grant(cli, bytes, bytes);
-               rc = 0;
+               atomic_long_dec(&obd_dirty_pages);
        }
-       return rc;
+       __osc_unreserve_grant(cli, bytes, bytes);
+       return 0;
 }
 
 /* Following two inlines exist to pass code fragments
@@ -1634,7 +1624,7 @@ static int osc_enter_cache(const struct lu_env *env, struct client_obd *cli,
         */
        remain = wait_event_idle_exclusive_timeout_cmd(
                cli->cl_cache_waiters,
-               (entered = osc_enter_cache_try(cli, oap, bytes, 0)) ||
+               (entered = osc_enter_cache_try(cli, oap, bytes)) ||
                (cli->cl_dirty_pages == 0 && cli->cl_w_in_flight == 0),
                timeout,
                cli_unlock_and_unplug(env, cli, oap),
@@ -2415,7 +2405,7 @@ int osc_queue_async_io(const struct lu_env *env, struct cl_io *io,
 
                /* it doesn't need any grant to dirty this page */
                spin_lock(&cli->cl_loi_list_lock);
-               rc = osc_enter_cache_try(cli, oap, grants, 0);
+               rc = osc_enter_cache_try(cli, oap, grants);
                spin_unlock(&cli->cl_loi_list_lock);
                if (rc == 0) { /* try failed */
                        grants = 0;
index f0660f4..b4ff264 100644 (file)
@@ -651,21 +651,18 @@ static void osc_announce_cached(struct client_obd *cli, struct obdo *oa,
                oa->o_dirty = cli->cl_dirty_grant;
        else
                oa->o_dirty = cli->cl_dirty_pages << PAGE_SHIFT;
-       if (unlikely(cli->cl_dirty_pages - cli->cl_dirty_transit >
-                    cli->cl_dirty_max_pages)) {
-               CERROR("dirty %lu - %lu > dirty_max %lu\n",
-                      cli->cl_dirty_pages, cli->cl_dirty_transit,
+       if (unlikely(cli->cl_dirty_pages > cli->cl_dirty_max_pages)) {
+               CERROR("dirty %lu > dirty_max %lu\n",
+                      cli->cl_dirty_pages,
                       cli->cl_dirty_max_pages);
                oa->o_undirty = 0;
-       } else if (unlikely(atomic_long_read(&obd_dirty_pages) -
-                           atomic_long_read(&obd_dirty_transit_pages) >
+       } else if (unlikely(atomic_long_read(&obd_dirty_pages) >
                            (long)(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 %ld - %ld > system dirty_max %ld\n",
+               CERROR("%s: dirty %ld > system dirty_max %ld\n",
                       cli_name(cli), 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 >
@@ -1093,9 +1090,9 @@ static int check_write_rcs(struct ptlrpc_request *req,
 static inline int can_merge_pages(struct brw_page *p1, struct brw_page *p2)
 {
         if (p1->flag != p2->flag) {
-               unsigned mask = ~(OBD_BRW_FROM_GRANT | OBD_BRW_NOCACHE |
-                                 OBD_BRW_SYNC       | OBD_BRW_ASYNC   |
-                                 OBD_BRW_NOQUOTA    | OBD_BRW_SOFT_SYNC);
+               unsigned mask = ~(OBD_BRW_FROM_GRANT | OBD_BRW_SYNC |
+                                 OBD_BRW_ASYNC | OBD_BRW_NOQUOTA |
+                                 OBD_BRW_SOFT_SYNC);
 
                 /* warn if we try to combine flags that we don't know to be
                  * safe to combine */