Whamcloud - gitweb
Branch HEAD
authorvitaly <vitaly>
Wed, 8 Jul 2009 23:30:02 +0000 (23:30 +0000)
committervitaly <vitaly>
Wed, 8 Jul 2009 23:30:02 +0000 (23:30 +0000)
b=18619
i=green
i=panda

oap_async_flags protection

lustre/osc/osc_io.c
lustre/osc/osc_page.c
lustre/osc/osc_request.c

index ba068a8..bdd9681 100644 (file)
@@ -149,8 +149,11 @@ static int osc_io_submit(const struct lu_env *env,
                 osc = cl2osc(opg->ops_cl.cpl_obj);
                 exp = osc_export(osc);
 
                 osc = cl2osc(opg->ops_cl.cpl_obj);
                 exp = osc_export(osc);
 
-                if (priority > CRP_NORMAL)
+                if (priority > CRP_NORMAL) {
+                        spin_lock(&oap->oap_lock);
                         oap->oap_async_flags |= ASYNC_HP;
                         oap->oap_async_flags |= ASYNC_HP;
+                        spin_unlock(&oap->oap_lock);
+                }
                 /*
                  * This can be checked without cli->cl_loi_list_lock, because
                  * ->oap_*_item are always manipulated when the page is owned.
                 /*
                  * This can be checked without cli->cl_loi_list_lock, because
                  * ->oap_*_item are always manipulated when the page is owned.
index b880749..958f856 100644 (file)
@@ -344,7 +344,9 @@ void osc_page_clip(const struct lu_env *env, const struct cl_page_slice *slice,
 
         opg->ops_from = from;
         opg->ops_to   = to;
 
         opg->ops_from = from;
         opg->ops_to   = to;
+        spin_lock(&oap->oap_lock);
         oap->oap_async_flags |= ASYNC_COUNT_STABLE;
         oap->oap_async_flags |= ASYNC_COUNT_STABLE;
+        spin_unlock(&oap->oap_lock);
 }
 
 static int osc_page_cancel(const struct lu_env *env,
 }
 
 static int osc_page_cancel(const struct lu_env *env,
@@ -460,7 +462,9 @@ static int osc_completion(const struct lu_env *env,
         LASSERT(page->cp_req == NULL);
 
         /* As the transfer for this page is being done, clear the flags */
         LASSERT(page->cp_req == NULL);
 
         /* As the transfer for this page is being done, clear the flags */
+        spin_lock(&oap->oap_lock);
         oap->oap_async_flags = 0;
         oap->oap_async_flags = 0;
+        spin_unlock(&oap->oap_lock);
 
         crt = cmd == OBD_BRW_READ ? CRT_READ : CRT_WRITE;
         /* Clear opg->ops_transfer_pinned before VM lock is released. */
 
         crt = cmd == OBD_BRW_READ ? CRT_READ : CRT_WRITE;
         /* Clear opg->ops_transfer_pinned before VM lock is released. */
@@ -553,6 +557,7 @@ void osc_io_submit_page(const struct lu_env *env,
 {
         struct osc_async_page *oap = &opg->ops_oap;
         struct client_obd     *cli = oap->oap_cli;
 {
         struct osc_async_page *oap = &opg->ops_oap;
         struct client_obd     *cli = oap->oap_cli;
+        int flags = 0;
 
         LINVRNT(osc_page_protected(env, opg,
                                    crt == CRT_WRITE ? CLM_WRITE : CLM_READ, 1));
 
         LINVRNT(osc_page_protected(env, opg,
                                    crt == CRT_WRITE ? CLM_WRITE : CLM_READ, 1));
@@ -573,12 +578,15 @@ void osc_io_submit_page(const struct lu_env *env,
                 oap->oap_cmd |= OBD_BRW_NOQUOTA;
         }
 
                 oap->oap_cmd |= OBD_BRW_NOQUOTA;
         }
 
-        oap->oap_async_flags |= OSC_FLAGS;
         if (oap->oap_cmd & OBD_BRW_READ)
         if (oap->oap_cmd & OBD_BRW_READ)
-                oap->oap_async_flags |= ASYNC_COUNT_STABLE;
+                flags = ASYNC_COUNT_STABLE;
         else if (!(oap->oap_brw_page.flag & OBD_BRW_FROM_GRANT))
                 osc_enter_cache_try(env, cli, oap->oap_loi, oap, 1);
 
         else if (!(oap->oap_brw_page.flag & OBD_BRW_FROM_GRANT))
                 osc_enter_cache_try(env, cli, oap->oap_loi, oap, 1);
 
+        spin_lock(&oap->oap_lock);
+        oap->oap_async_flags |= OSC_FLAGS | flags;
+        spin_unlock(&oap->oap_lock);
+
         osc_oap_to_pending(oap);
         osc_page_transfer_get(opg, "transfer\0imm");
         osc_page_transfer_add(env, opg, crt);
         osc_oap_to_pending(oap);
         osc_page_transfer_get(opg, "transfer\0imm");
         osc_page_transfer_add(env, opg, crt);
index f2a163d..10b27ba 100644 (file)
@@ -2108,7 +2108,9 @@ static void osc_ap_completion(const struct lu_env *env,
                 oap->oap_request = NULL;
         }
 
                 oap->oap_request = NULL;
         }
 
+        spin_lock(&oap->oap_lock);
         oap->oap_async_flags = 0;
         oap->oap_async_flags = 0;
+        spin_unlock(&oap->oap_lock);
         oap->oap_interrupted = 0;
 
         if (oap->oap_cmd & OBD_BRW_WRITE) {
         oap->oap_interrupted = 0;
 
         if (oap->oap_cmd & OBD_BRW_WRITE) {
@@ -2411,11 +2413,15 @@ osc_send_oap_rpc(const struct lu_env *env, struct client_obd *cli,
                         case -EINTR:
                                 /* the io isn't needed.. tell the checks
                                  * below to complete the rpc with EINTR */
                         case -EINTR:
                                 /* the io isn't needed.. tell the checks
                                  * below to complete the rpc with EINTR */
+                                spin_lock(&oap->oap_lock);
                                 oap->oap_async_flags |= ASYNC_COUNT_STABLE;
                                 oap->oap_async_flags |= ASYNC_COUNT_STABLE;
+                                spin_unlock(&oap->oap_lock);
                                 oap->oap_count = -EINTR;
                                 break;
                         case 0:
                                 oap->oap_count = -EINTR;
                                 break;
                         case 0:
+                                spin_lock(&oap->oap_lock);
                                 oap->oap_async_flags |= ASYNC_READY;
                                 oap->oap_async_flags |= ASYNC_READY;
+                                spin_unlock(&oap->oap_lock);
                                 break;
                         default:
                                 LASSERTF(0, "oap %p page %p returned %d "
                                 break;
                         default:
                                 LASSERTF(0, "oap %p page %p returned %d "
@@ -2900,7 +2906,9 @@ int osc_queue_async_io(const struct lu_env *env,
         /* Give a hint to OST that requests are coming from kswapd - bug19529 */
         if (libcfs_memory_pressure_get())
                 oap->oap_brw_flags |= OBD_BRW_MEMALLOC;
         /* Give a hint to OST that requests are coming from kswapd - bug19529 */
         if (libcfs_memory_pressure_get())
                 oap->oap_brw_flags |= OBD_BRW_MEMALLOC;
+        spin_lock(&oap->oap_lock);
         oap->oap_async_flags = async_flags;
         oap->oap_async_flags = async_flags;
+        spin_unlock(&oap->oap_lock);
 
         if (cmd & OBD_BRW_WRITE) {
                 rc = osc_enter_cache(env, cli, loi, oap);
 
         if (cmd & OBD_BRW_WRITE) {
                 rc = osc_enter_cache(env, cli, loi, oap);
@@ -2930,6 +2938,7 @@ int osc_set_async_flags_base(struct client_obd *cli,
                              obd_flag async_flags)
 {
         struct loi_oap_pages *lop;
                              obd_flag async_flags)
 {
         struct loi_oap_pages *lop;
+        int flags = 0;
         ENTRY;
 
         LASSERT(!list_empty(&oap->oap_pending_item));
         ENTRY;
 
         LASSERT(!list_empty(&oap->oap_pending_item));
@@ -2944,7 +2953,7 @@ int osc_set_async_flags_base(struct client_obd *cli,
                 RETURN(0);
 
         if (SETTING(oap->oap_async_flags, async_flags, ASYNC_READY))
                 RETURN(0);
 
         if (SETTING(oap->oap_async_flags, async_flags, ASYNC_READY))
-                oap->oap_async_flags |= ASYNC_READY;
+                flags |= ASYNC_READY;
 
         if (SETTING(oap->oap_async_flags, async_flags, ASYNC_URGENT) &&
             list_empty(&oap->oap_rpc_item)) {
 
         if (SETTING(oap->oap_async_flags, async_flags, ASYNC_URGENT) &&
             list_empty(&oap->oap_rpc_item)) {
@@ -2952,9 +2961,12 @@ int osc_set_async_flags_base(struct client_obd *cli,
                         list_add(&oap->oap_urgent_item, &lop->lop_urgent);
                 else
                         list_add_tail(&oap->oap_urgent_item, &lop->lop_urgent);
                         list_add(&oap->oap_urgent_item, &lop->lop_urgent);
                 else
                         list_add_tail(&oap->oap_urgent_item, &lop->lop_urgent);
-                oap->oap_async_flags |= ASYNC_URGENT;
+                flags |= ASYNC_URGENT;
                 loi_list_maint(cli, loi);
         }
                 loi_list_maint(cli, loi);
         }
+        spin_lock(&oap->oap_lock);
+        oap->oap_async_flags |= flags;
+        spin_unlock(&oap->oap_lock);
 
         LOI_DEBUG(loi, "oap %p page %p has flags %x\n", oap, oap->oap_page,
                         oap->oap_async_flags);
 
         LOI_DEBUG(loi, "oap %p page %p has flags %x\n", oap, oap->oap_page,
                         oap->oap_async_flags);
@@ -2994,7 +3006,9 @@ int osc_teardown_async_page(struct obd_export *exp,
 
         if (!list_empty(&oap->oap_urgent_item)) {
                 list_del_init(&oap->oap_urgent_item);
 
         if (!list_empty(&oap->oap_urgent_item)) {
                 list_del_init(&oap->oap_urgent_item);
+                spin_lock(&oap->oap_lock);
                 oap->oap_async_flags &= ~(ASYNC_URGENT | ASYNC_HP);
                 oap->oap_async_flags &= ~(ASYNC_URGENT | ASYNC_HP);
+                spin_unlock(&oap->oap_lock);
         }
         if (!list_empty(&oap->oap_pending_item)) {
                 list_del_init(&oap->oap_pending_item);
         }
         if (!list_empty(&oap->oap_pending_item)) {
                 list_del_init(&oap->oap_pending_item);