Whamcloud - gitweb
Add timestamp for remote client permission, reduce unnecessary checking.
authorfanyong <fanyong>
Sat, 21 Oct 2006 14:50:04 +0000 (14:50 +0000)
committerfanyong <fanyong>
Sat, 21 Oct 2006 14:50:04 +0000 (14:50 +0000)
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/remote_perm.c

index 19f10a1..4480edb 100644 (file)
@@ -113,6 +113,7 @@ struct ll_inode_info {
 
         /* remote permission hash */
         struct hlist_head      *lli_remote_perms;
+        unsigned long           lli_rmtperm_utime;
         struct semaphore        lli_rmtperm_sem;
 
         struct list_head        lli_dead_list;
index 04358e1..3a8e89c 100644 (file)
@@ -789,6 +789,7 @@ void ll_lli_init(struct ll_inode_info *lli)
         lli->lli_open_fd_exec_count = 0;
         INIT_LIST_HEAD(&lli->lli_dead_list);
         lli->lli_remote_perms = NULL;
+        lli->lli_rmtperm_utime = 0;
         sema_init(&lli->lli_rmtperm_sem, 1);
         INIT_LIST_HEAD(&lli->lli_oss_capas);
 }
index d472951..9b70f4f 100644 (file)
@@ -215,6 +215,7 @@ again:
         lrp->lrp_access_perm = perm->rp_access_perm;
         if (lrp != tmp)
                 hlist_add_head(&lrp->lrp_list, head);
+        lli->lli_rmtperm_utime = jiffies;
         spin_unlock(&lli->lli_lock);
 
         CDEBUG(D_SEC, "new remote perm@%p: %u/%u/%u/%u - %#x\n",
@@ -231,10 +232,12 @@ int lustre_check_remote_perm(struct inode *inode, int mask)
         struct ptlrpc_request *req = NULL;
         struct mdt_remote_perm *perm;
         struct obd_capa *oc;
+        unsigned long utime;
         int i = 0, rc;
         ENTRY;
 
 check:
+        utime = lli->lli_rmtperm_utime;
         rc = do_check_remote_perm(lli, mask);
         if (!rc || ((rc != -ENOENT) && i))
                 RETURN(rc);
@@ -243,10 +246,12 @@ check:
 
         down(&lli->lli_rmtperm_sem);
         /* check again */
-        rc = do_check_remote_perm(lli, mask);
-        if (!rc || ((rc != -ENOENT) && i)) {
-                up(&lli->lli_rmtperm_sem);
-                RETURN(rc);
+        if (utime != lli->lli_rmtperm_utime) {
+                rc = do_check_remote_perm(lli, mask);
+                if (!rc || ((rc != -ENOENT) && i)) {
+                        up(&lli->lli_rmtperm_sem);
+                        RETURN(rc);
+                }
         }
 
         if (i++ > 5) {