Whamcloud - gitweb
LU-1195 llite: error handling for statahead/AGL start failure
authorFan Yong <yong.fan@whamcloud.com>
Thu, 8 Mar 2012 02:47:07 +0000 (10:47 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 12 Mar 2012 15:26:02 +0000 (11:26 -0400)
Statahead/AGL status will be checked when release ll_statahead_info.
But if some reasons cause statahead/AGL cannot be started, then the
status are undefined. So need proper error handling for such failure
cases.

Signed-off-by: Fan Yong <yong.fan@whamcloud.com>
Change-Id: I4dec58862ad425c19e9c6284b7183b8bcaa449f6
Reviewed-on: http://review.whamcloud.com/2268
Reviewed-by: Bobi Jam <bobijam@whamcloud.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@whamcloud.com>
Reviewed-by: James Simmons <uja.ornl@gmail.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/statahead.c

index 2033633..81d2bd0 100644 (file)
@@ -1075,6 +1075,7 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai)
         rc = cfs_create_thread(ll_agl_thread, parent, 0);
         if (rc < 0) {
                 CERROR("can't start ll_agl thread, rc: %d\n", rc);
         rc = cfs_create_thread(ll_agl_thread, parent, 0);
         if (rc < 0) {
                 CERROR("can't start ll_agl thread, rc: %d\n", rc);
+                thread_set_flags(thread, SVC_STOPPED);
                 RETURN_EXIT;
         }
 
                 RETURN_EXIT;
         }
 
@@ -1093,6 +1094,7 @@ static int ll_statahead_thread(void *arg)
         struct ll_sb_info        *sbi    = ll_i2sbi(dir);
         struct ll_statahead_info *sai    = ll_sai_get(plli->lli_sai);
         struct ptlrpc_thread     *thread = &sai->sai_thread;
         struct ll_sb_info        *sbi    = ll_i2sbi(dir);
         struct ll_statahead_info *sai    = ll_sai_get(plli->lli_sai);
         struct ptlrpc_thread     *thread = &sai->sai_thread;
+        struct ptlrpc_thread *agl_thread = &sai->sai_agl_thread;
         struct page              *page;
         __u64                     pos    = 0;
         int                       first  = 0;
         struct page              *page;
         __u64                     pos    = 0;
         int                       first  = 0;
@@ -1294,8 +1296,6 @@ do_it:
 
 out:
         if (sai->sai_agl_valid) {
 
 out:
         if (sai->sai_agl_valid) {
-                struct ptlrpc_thread *agl_thread = &sai->sai_agl_thread;
-
                 cfs_spin_lock(&plli->lli_agl_lock);
                 thread_set_flags(agl_thread, SVC_STOPPING);
                 cfs_spin_unlock(&plli->lli_agl_lock);
                 cfs_spin_lock(&plli->lli_agl_lock);
                 thread_set_flags(agl_thread, SVC_STOPPING);
                 cfs_spin_unlock(&plli->lli_agl_lock);
@@ -1306,8 +1306,10 @@ out:
                 l_wait_event(agl_thread->t_ctl_waitq,
                              thread_is_stopped(agl_thread),
                              &lwi);
                 l_wait_event(agl_thread->t_ctl_waitq,
                              thread_is_stopped(agl_thread),
                              &lwi);
+        } else {
+                /* Set agl_thread flags anyway. */
+                thread_set_flags(&sai->sai_agl_thread, SVC_STOPPED);
         }
         }
-
         ll_dir_chain_fini(&chain);
         cfs_spin_lock(&plli->lli_sa_lock);
         if (!sa_received_empty(sai)) {
         ll_dir_chain_fini(&chain);
         cfs_spin_lock(&plli->lli_sa_lock);
         if (!sa_received_empty(sai)) {
@@ -1718,6 +1720,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
                 dput(parent);
                 lli->lli_opendir_key = NULL;
                 thread_set_flags(thread, SVC_STOPPED);
                 dput(parent);
                 lli->lli_opendir_key = NULL;
                 thread_set_flags(thread, SVC_STOPPED);
+                thread_set_flags(&sai->sai_agl_thread, SVC_STOPPED);
                 ll_sai_put(sai);
                 LASSERT(lli->lli_sai == NULL);
                 RETURN(-EAGAIN);
                 ll_sai_put(sai);
                 LASSERT(lli->lli_sai == NULL);
                 RETURN(-EAGAIN);