Whamcloud - gitweb
LU-1684 ldlm: move ldlm flags not sent through wire to upper 32bits
[fs/lustre-release.git] / lustre / llite / statahead.c
index df14fd5..5cf4b9c 100644 (file)
@@ -37,7 +37,6 @@
 #include <linux/fs.h>
 #include <linux/sched.h>
 #include <linux/mm.h>
-#include <linux/smp_lock.h>
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
 
@@ -46,7 +45,6 @@
 #include <obd_support.h>
 #include <lustre_lite.h>
 #include <lustre_dlm.h>
-#include <linux/lustre_version.h>
 #include "llite_internal.h"
 
 #define SA_OMITTED_ENTRY_MAX 8ULL
@@ -85,7 +83,7 @@ struct ll_sa_entry {
 };
 
 static unsigned int sai_generation = 0;
-static cfs_spinlock_t sai_generation_lock = CFS_SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(sai_generation_lock);
 
 static inline int ll_sa_entry_unlinked(struct ll_sa_entry *entry)
 {
@@ -140,10 +138,10 @@ ll_sa_entry_unhash(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
 static inline int agl_should_run(struct ll_statahead_info *sai,
                                  struct inode *inode)
 {
-        if (inode != NULL && S_ISREG(inode->i_mode) &&
-            ll_i2info(inode)->lli_smd != NULL && sai->sai_agl_valid)
-                return 1;
-        return 0;
+       if (inode != NULL && S_ISREG(inode->i_mode) &&
+           ll_i2info(inode)->lli_has_smd && sai->sai_agl_valid)
+               return 1;
+       return 0;
 }
 
 static inline struct ll_sa_entry *
@@ -1119,9 +1117,8 @@ static int ll_statahead_thread(void *arg)
         cfs_spin_unlock(&plli->lli_sa_lock);
         cfs_waitq_signal(&thread->t_ctl_waitq);
 
-        plli->lli_sa_pos = 0;
         ll_dir_chain_init(&chain);
-        page = ll_get_dir_page(NULL, dir, pos, &chain);
+       page = ll_get_dir_page(dir, pos, &chain);
 
         while (1) {
                 struct lu_dirpage *dp;
@@ -1278,9 +1275,8 @@ do_it:
                          */
                         ll_release_page(page, le32_to_cpu(dp->ldp_flags) &
                                               LDF_COLLIDE);
-                        plli->lli_sa_pos = pos;
                         sai->sai_in_readpage = 1;
-                        page = ll_get_dir_page(NULL, dir, pos, &chain);
+                       page = ll_get_dir_page(dir, pos, &chain);
                         sai->sai_in_readpage = 0;
                 } else {
                         LASSERT(le32_to_cpu(dp->ldp_flags) & LDF_COLLIDE);
@@ -1396,7 +1392,6 @@ enum {
 
 static int is_first_dirent(struct inode *dir, struct dentry *dentry)
 {
-        struct ll_inode_info *lli    = ll_i2info(dir);
         struct ll_dir_chain   chain;
         struct qstr          *target = &dentry->d_name;
         struct page          *page;
@@ -1405,9 +1400,8 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry)
         int                   rc     = LS_NONE_FIRST_DE;
         ENTRY;
 
-        lli->lli_sa_pos = 0;
         ll_dir_chain_init(&chain);
-        page = ll_get_dir_page(NULL, dir, pos, &chain);
+       page = ll_get_dir_page(dir, pos, &chain);
 
         while (1) {
                 struct lu_dirpage *dp;
@@ -1494,8 +1488,7 @@ static int is_first_dirent(struct inode *dir, struct dentry *dentry)
                          */
                         ll_release_page(page, le32_to_cpu(dp->ldp_flags) &
                                               LDF_COLLIDE);
-                        lli->lli_sa_pos = pos;
-                        page = ll_get_dir_page(NULL, dir, pos, &chain);
+                       page = ll_get_dir_page(dir, pos, &chain);
                 } else {
                         /*
                          * go into overflow page.
@@ -1646,18 +1639,14 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
                         struct lookup_intent it = { .it_op = IT_GETATTR,
                                                     .d.lustre.it_lock_handle =
                                                      entry->se_handle };
-                        struct ll_dentry_data *lld;
-                        __u64 bits;
-
-                        rc = md_revalidate_lock(ll_i2mdexp(dir), &it,
-                                                ll_inode2fid(inode), &bits);
-                        if (rc == 1) {
-                                if ((*dentryp)->d_inode == NULL) {
-                                        *dentryp = ll_find_alias(inode,
-                                                                 *dentryp);
-                                        lld = ll_d2d(*dentryp);
-                                        if (unlikely(lld == NULL))
-                                                ll_dops_init(*dentryp, 1, 1);
+                       __u64 bits;
+
+                       rc = md_revalidate_lock(ll_i2mdexp(dir), &it,
+                                               ll_inode2fid(inode), &bits);
+                       if (rc == 1) {
+                               if ((*dentryp)->d_inode == NULL) {
+                                       *dentryp = ll_splice_alias(inode,
+                                                                  *dentryp);
                                 } else if ((*dentryp)->d_inode != inode) {
                                         /* revalidate, but inode is recreated */
                                         CDEBUG(D_READA,
@@ -1672,12 +1661,13 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
                                         ll_sai_unplug(sai, entry);
                                         RETURN(-ESTALE);
                                 } else {
-                                        ll_dentry_rehash(*dentryp, 0);
-                                        iput(inode);
-                                }
-                                entry->se_inode = NULL;
+                                       iput(inode);
+                               }
+                               entry->se_inode = NULL;
 
-                                ll_dentry_reset_flags(*dentryp, bits);
+                               if ((bits & MDS_INODELOCK_LOOKUP) &&
+                                   d_lustre_invalid(*dentryp))
+                                       d_lustre_revalidate(*dentryp);
                                 ll_intent_release(&it);
                         }
                 }