Whamcloud - gitweb
LU-2779 osc: osc_extent_wait() shouldn't be interruptible
[fs/lustre-release.git] / lustre / llite / statahead.c
index d8d2187..3bb99ac 100644 (file)
@@ -458,20 +458,20 @@ static void ll_agl_add(struct ll_statahead_info *sai,
        }
 
        if (added > 0)
-               cfs_waitq_signal(&sai->sai_agl_thread.t_ctl_waitq);
+               wake_up(&sai->sai_agl_thread.t_ctl_waitq);
 }
 
 static struct ll_statahead_info *ll_sai_alloc(void)
 {
-        struct ll_statahead_info *sai;
-        int                       i;
-        ENTRY;
+       struct ll_statahead_info *sai;
+       int                       i;
+       ENTRY;
 
-        OBD_ALLOC_PTR(sai);
-        if (!sai)
-                RETURN(NULL);
+       OBD_ALLOC_PTR(sai);
+       if (!sai)
+               RETURN(NULL);
 
-        cfs_atomic_set(&sai->sai_refcount, 1);
+       cfs_atomic_set(&sai->sai_refcount, 1);
 
        spin_lock(&sai_generation_lock);
        sai->sai_generation = ++sai_generation;
@@ -479,24 +479,24 @@ static struct ll_statahead_info *ll_sai_alloc(void)
                sai->sai_generation = ++sai_generation;
        spin_unlock(&sai_generation_lock);
 
-        sai->sai_max = LL_SA_RPC_MIN;
-        sai->sai_index = 1;
-        cfs_waitq_init(&sai->sai_waitq);
-        cfs_waitq_init(&sai->sai_thread.t_ctl_waitq);
-        cfs_waitq_init(&sai->sai_agl_thread.t_ctl_waitq);
+       sai->sai_max = LL_SA_RPC_MIN;
+       sai->sai_index = 1;
+       init_waitqueue_head(&sai->sai_waitq);
+       init_waitqueue_head(&sai->sai_thread.t_ctl_waitq);
+       init_waitqueue_head(&sai->sai_agl_thread.t_ctl_waitq);
 
        CFS_INIT_LIST_HEAD(&sai->sai_entries);
-        CFS_INIT_LIST_HEAD(&sai->sai_entries_received);
-        CFS_INIT_LIST_HEAD(&sai->sai_entries_stated);
-        CFS_INIT_LIST_HEAD(&sai->sai_entries_agl);
+       CFS_INIT_LIST_HEAD(&sai->sai_entries_received);
+       CFS_INIT_LIST_HEAD(&sai->sai_entries_stated);
+       CFS_INIT_LIST_HEAD(&sai->sai_entries_agl);
 
-        for (i = 0; i < LL_SA_CACHE_SIZE; i++) {
-                CFS_INIT_LIST_HEAD(&sai->sai_cache[i]);
+       for (i = 0; i < LL_SA_CACHE_SIZE; i++) {
+               CFS_INIT_LIST_HEAD(&sai->sai_cache[i]);
                spin_lock_init(&sai->sai_cache_lock[i]);
-        }
-        cfs_atomic_set(&sai->sai_cache_count, 0);
+       }
+       cfs_atomic_set(&sai->sai_cache_count, 0);
 
-        RETURN(sai);
+       RETURN(sai);
 }
 
 static inline struct ll_statahead_info *
@@ -693,15 +693,15 @@ static void ll_post_statahead(struct ll_statahead_info *sai)
         EXIT;
 
 out:
-        /* The "ll_sa_entry_to_stated()" will drop related ldlm ibits lock
-         * reference count by calling "ll_intent_drop_lock()" in spite of the
-         * above operations failed or not. Do not worry about calling
-         * "ll_intent_drop_lock()" more than once. */
+       /* The "ll_sa_entry_to_stated()" will drop related ldlm ibits lock
+        * reference count by calling "ll_intent_drop_lock()" in spite of the
+        * above operations failed or not. Do not worry about calling
+        * "ll_intent_drop_lock()" more than once. */
        rc = ll_sa_entry_to_stated(sai, entry,
                                   rc < 0 ? SA_ENTRY_INVA : SA_ENTRY_SUCC);
        if (rc == 0 && entry->se_index == sai->sai_index_wait)
-                cfs_waitq_signal(&sai->sai_waitq);
-        ll_sa_entry_put(sai, entry);
+               wake_up(&sai->sai_waitq);
+       ll_sa_entry_put(sai, entry);
 }
 
 static int ll_statahead_interpret(struct ptlrpc_request *req,
@@ -760,7 +760,7 @@ static int ll_statahead_interpret(struct ptlrpc_request *req,
 
                ll_sa_entry_put(sai, entry);
                if (wakeup)
-                       cfs_waitq_signal(&sai->sai_thread.t_ctl_waitq);
+                       wake_up(&sai->sai_thread.t_ctl_waitq);
         }
 
         EXIT;
@@ -950,14 +950,14 @@ static void ll_statahead_one(struct dentry *parent, const char* entry_name,
         if (dentry != NULL)
                 dput(dentry);
 
-        if (rc) {
-                rc1 = ll_sa_entry_to_stated(sai, entry,
-                                        rc < 0 ? SA_ENTRY_INVA : SA_ENTRY_SUCC);
-                if (rc1 == 0 && entry->se_index == sai->sai_index_wait)
-                        cfs_waitq_signal(&sai->sai_waitq);
-        } else {
-                sai->sai_sent++;
-        }
+       if (rc) {
+               rc1 = ll_sa_entry_to_stated(sai, entry,
+                                       rc < 0 ? SA_ENTRY_INVA : SA_ENTRY_SUCC);
+               if (rc1 == 0 && entry->se_index == sai->sai_index_wait)
+                       wake_up(&sai->sai_waitq);
+       } else {
+               sai->sai_sent++;
+       }
 
         sai->sai_index++;
         /* drop one refcount on entry by ll_sa_entry_alloc */
@@ -978,15 +978,15 @@ static int ll_agl_thread(void *arg)
         struct l_wait_info        lwi    = { 0 };
         ENTRY;
 
-        CDEBUG(D_READA, "agl thread started: [pid %d] [parent %.*s]\n",
-               cfs_curproc_pid(), parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "agl thread started: [pid %d] [parent %.*s]\n",
+              current_pid(), parent->d_name.len, parent->d_name.name);
 
-        atomic_inc(&sbi->ll_agl_total);
+       atomic_inc(&sbi->ll_agl_total);
        spin_lock(&plli->lli_agl_lock);
        sai->sai_agl_valid = 1;
        thread_set_flags(thread, SVC_RUNNING);
        spin_unlock(&plli->lli_agl_lock);
-        cfs_waitq_signal(&thread->t_ctl_waitq);
+       wake_up(&thread->t_ctl_waitq);
 
         while (1) {
                 l_wait_event(thread->t_ctl_waitq,
@@ -1022,10 +1022,10 @@ static int ll_agl_thread(void *arg)
        }
        thread_set_flags(thread, SVC_STOPPED);
        spin_unlock(&plli->lli_agl_lock);
-       cfs_waitq_signal(&thread->t_ctl_waitq);
+       wake_up(&thread->t_ctl_waitq);
        ll_sai_put(sai);
        CDEBUG(D_READA, "agl thread stopped: [pid %d] [parent %.*s]\n",
-              cfs_curproc_pid(), parent->d_name.len, parent->d_name.name);
+              current_pid(), parent->d_name.len, parent->d_name.name);
        RETURN(0);
 }
 
@@ -1038,7 +1038,7 @@ static void ll_start_agl(struct dentry *parent, struct ll_statahead_info *sai)
        ENTRY;
 
        CDEBUG(D_READA, "start agl thread: [pid %d] [parent %.*s]\n",
-              cfs_curproc_pid(), parent->d_name.len, parent->d_name.name);
+              current_pid(), parent->d_name.len, parent->d_name.name);
 
        plli = ll_i2info(parent->d_inode);
        task = kthread_run(ll_agl_thread, parent,
@@ -1073,17 +1073,17 @@ static int ll_statahead_thread(void *arg)
         struct l_wait_info        lwi    = { 0 };
         ENTRY;
 
-        CDEBUG(D_READA, "statahead thread started: [pid %d] [parent %.*s]\n",
-               cfs_curproc_pid(), parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "statahead thread started: [pid %d] [parent %.*s]\n",
+              current_pid(), parent->d_name.len, parent->d_name.name);
 
-        if (sbi->ll_flags & LL_SBI_AGL_ENABLED)
-                ll_start_agl(parent, sai);
+       if (sbi->ll_flags & LL_SBI_AGL_ENABLED)
+               ll_start_agl(parent, sai);
 
-        atomic_inc(&sbi->ll_sa_total);
+       atomic_inc(&sbi->ll_sa_total);
        spin_lock(&plli->lli_sa_lock);
        thread_set_flags(thread, SVC_RUNNING);
        spin_unlock(&plli->lli_sa_lock);
-       cfs_waitq_signal(&thread->t_ctl_waitq);
+       wake_up(&thread->t_ctl_waitq);
 
        ll_dir_chain_init(&chain);
        page = ll_get_dir_page(dir, pos, &chain);
@@ -1261,13 +1261,13 @@ out:
                spin_lock(&plli->lli_agl_lock);
                thread_set_flags(agl_thread, SVC_STOPPING);
                spin_unlock(&plli->lli_agl_lock);
-                cfs_waitq_signal(&agl_thread->t_ctl_waitq);
+               wake_up(&agl_thread->t_ctl_waitq);
 
-                CDEBUG(D_READA, "stop agl thread: [pid %d]\n",
-                       cfs_curproc_pid());
-                l_wait_event(agl_thread->t_ctl_waitq,
-                             thread_is_stopped(agl_thread),
-                             &lwi);
+               CDEBUG(D_READA, "stop agl thread: [pid %d]\n",
+                      current_pid());
+               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);
@@ -1286,13 +1286,13 @@ out:
        }
        thread_set_flags(thread, SVC_STOPPED);
        spin_unlock(&plli->lli_sa_lock);
-        cfs_waitq_signal(&sai->sai_waitq);
-        cfs_waitq_signal(&thread->t_ctl_waitq);
+       wake_up(&sai->sai_waitq);
+       wake_up(&thread->t_ctl_waitq);
         ll_sai_put(sai);
         dput(parent);
-        CDEBUG(D_READA, "statahead thread stopped: [pid %d] [parent %.*s]\n",
-               cfs_curproc_pid(), parent->d_name.len, parent->d_name.name);
-        return rc;
+       CDEBUG(D_READA, "statahead thread stopped: [pid %d] [parent %.*s]\n",
+              current_pid(), parent->d_name.len, parent->d_name.name);
+       return rc;
 }
 
 /**
@@ -1320,10 +1320,10 @@ void ll_stop_statahead(struct inode *dir, void *key)
                 if (!thread_is_stopped(thread)) {
                         thread_set_flags(thread, SVC_STOPPING);
                        spin_unlock(&lli->lli_sa_lock);
-                       cfs_waitq_signal(&thread->t_ctl_waitq);
+                       wake_up(&thread->t_ctl_waitq);
 
                        CDEBUG(D_READA, "stop statahead thread: [pid %d]\n",
-                              cfs_curproc_pid());
+                              current_pid());
                        l_wait_event(thread->t_ctl_waitq,
                                     thread_is_stopped(thread),
                                     &lwi);
@@ -1497,13 +1497,13 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
                 sai->sai_consecutive_miss++;
                 if (sa_low_hit(sai) && thread_is_running(thread)) {
                         atomic_inc(&sbi->ll_sa_wrong);
-                        CDEBUG(D_READA, "Statahead for dir "DFID" hit "
-                               "ratio too low: hit/miss "LPU64"/"LPU64
-                               ", sent/replied "LPU64"/"LPU64", stopping "
-                               "statahead thread: pid %d\n",
-                               PFID(&lli->lli_fid), sai->sai_hit,
-                               sai->sai_miss, sai->sai_sent,
-                               sai->sai_replied, cfs_curproc_pid());
+                       CDEBUG(D_READA, "Statahead for dir "DFID" hit "
+                              "ratio too low: hit/miss "LPU64"/"LPU64
+                              ", sent/replied "LPU64"/"LPU64", stopping "
+                              "statahead thread: pid %d\n",
+                              PFID(&lli->lli_fid), sai->sai_hit,
+                              sai->sai_miss, sai->sai_sent,
+                              sai->sai_replied, current_pid());
                        spin_lock(&lli->lli_sa_lock);
                        if (!thread_is_stopped(thread))
                                thread_set_flags(thread, SVC_STOPPING);
@@ -1512,7 +1512,7 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
        }
 
        if (!thread_is_stopped(thread))
-               cfs_waitq_signal(&thread->t_ctl_waitq);
+               wake_up(&thread->t_ctl_waitq);
 
        EXIT;
 }
@@ -1529,17 +1529,17 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
 int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
                        int only_unplug)
 {
-        struct ll_inode_info     *lli   = ll_i2info(dir);
-        struct ll_statahead_info *sai   = lli->lli_sai;
-        struct dentry            *parent;
-        struct ll_sa_entry       *entry;
-        struct ptlrpc_thread     *thread;
-        struct l_wait_info        lwi   = { 0 };
-        int                       rc    = 0;
-       struct ll_inode_info     *plli;
-        ENTRY;
+       struct ll_inode_info            *lli = ll_i2info(dir);
+       struct ll_statahead_info        *sai = lli->lli_sai;
+       struct dentry                   *parent;
+       struct ll_sa_entry              *entry;
+       struct ptlrpc_thread            *thread;
+       struct l_wait_info               lwi = { 0 };
+       int                              rc = 0;
+       struct ll_inode_info            *plli;
+       ENTRY;
 
-        LASSERT(lli->lli_opendir_pid == cfs_curproc_pid());
+       LASSERT(lli->lli_opendir_pid == current_pid());
 
         if (sai) {
                 thread = &sai->sai_thread;
@@ -1615,12 +1615,15 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
                                                ll_inode2fid(inode), &bits);
                        if (rc == 1) {
                                if ((*dentryp)->d_inode == NULL) {
-                                       *dentryp = ll_splice_alias(inode,
-                                                                  *dentryp);
-                                       if (IS_ERR(*dentryp)) {
+                                       struct dentry *alias;
+
+                                       alias = ll_splice_alias(inode,
+                                                               *dentryp);
+                                       if (IS_ERR(alias)) {
                                                ll_sai_unplug(sai, entry);
-                                               RETURN(PTR_ERR(*dentryp));
+                                               RETURN(PTR_ERR(alias));
                                        }
+                                       *dentryp = alias;
                                 } else if ((*dentryp)->d_inode != inode) {
                                         /* revalidate, but inode is recreated */
                                         CDEBUG(D_READA,
@@ -1682,8 +1685,8 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
                 GOTO(out, rc = -EAGAIN);
         }
 
-        CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %.*s]\n",
-               cfs_curproc_pid(), parent->d_name.len, parent->d_name.name);
+       CDEBUG(D_READA, "start statahead thread: [pid %d] [parent %.*s]\n",
+              current_pid(), parent->d_name.len, parent->d_name.name);
 
         lli->lli_sai = sai;