Whamcloud - gitweb
b=24097 move upcall_cache from lvfs to libcfs
authorLiuYing <emoly.liu@oracle.com>
Fri, 3 Dec 2010 02:03:30 +0000 (10:03 +0800)
committerVitaly Fertman <vitaly.fertman@oracle.com>
Fri, 3 Dec 2010 19:38:06 +0000 (22:38 +0300)
part of params_tree platform-independent code

i=andreas
i=alexg

libcfs/include/libcfs/Makefile.am
libcfs/include/libcfs/lucache.h [moved from lustre/include/lustre_ucache.h with 95% similarity]
libcfs/libcfs/Makefile.in
libcfs/libcfs/upcall_cache.c [moved from lustre/lvfs/upcall_cache.c with 92% similarity]
lustre/include/Makefile.am
lustre/include/lvfs.h
lustre/lvfs/Makefile.in
lustre/mdt/mdt_identity.c
lustre/mdt/mdt_idmap.c
lustre/mdt/mdt_lproc.c

index 7cb850b..f84ed14 100644 (file)
@@ -10,5 +10,5 @@ EXTRA_DIST := curproc.h libcfs_private.h libcfs.h list.h lltrace.h \
                libcfs_prim.h libcfs_time.h libcfs_hash.h \
                libcfs_debug.h libcfsutil.h libcfs_ioctl.h \
                libcfs_pack.h libcfs_unpack.h libcfs_string.h \
                libcfs_prim.h libcfs_time.h libcfs_hash.h \
                libcfs_debug.h libcfsutil.h libcfs_ioctl.h \
                libcfs_pack.h libcfs_unpack.h libcfs_string.h \
-               libcfs_kernelcomm.h libcfs_workitem.h \
+               libcfs_kernelcomm.h libcfs_workitem.h lucache.h \
                params_tree.h
                params_tree.h
similarity index 95%
rename from lustre/include/lustre_ucache.h
rename to libcfs/include/libcfs/lucache.h
index c81a548..9307505 100644 (file)
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
  * Lustre is a trademark of Sun Microsystems, Inc.
  */
 
-#ifndef _UPCALL_CACHE_H
-#define _UPCALL_CACHE_H
+#ifndef _LUCACHE_H
+#define _LUCACHE_H
+
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
+
+#include <libcfs/libcfs.h>
 
 /** \defgroup ucache ucache
  *
 
 /** \defgroup ucache ucache
  *
@@ -122,8 +128,8 @@ struct upcall_cache {
 
         char                    uc_name[40];            /* for upcall */
         char                    uc_upcall[UC_CACHE_UPCALL_MAXPATH];
 
         char                    uc_name[40];            /* for upcall */
         char                    uc_upcall[UC_CACHE_UPCALL_MAXPATH];
-        cfs_time_t              uc_acquire_expire;      /* jiffies */
-        cfs_time_t              uc_entry_expire;        /* jiffies */
+        int                     uc_acquire_expire;      /* seconds */
+        int                     uc_entry_expire;        /* seconds */
         struct upcall_cache_ops *uc_ops;
 };
 
         struct upcall_cache_ops *uc_ops;
 };
 
@@ -157,4 +163,4 @@ void upcall_cache_cleanup(struct upcall_cache *hash);
 
 /** @} ucache */
 
 
 /** @} ucache */
 
-#endif /* _UPCALL_CACHE_H */
+#endif /* _LUCACHE_H */
index b794923..2537b0a 100644 (file)
@@ -25,7 +25,8 @@ sources:
 endif
 
 libcfs-all-objs := debug.o nidstrings.o lwt.o module.o tracefile.o watchdog.o \
 endif
 
 libcfs-all-objs := debug.o nidstrings.o lwt.o module.o tracefile.o watchdog.o \
-       libcfs_string.o hash.o kernel_user_comm.o prng.o workitem.o
+               libcfs_string.o hash.o kernel_user_comm.o prng.o workitem.o \
+               upcall_cache.o
 
 libcfs-objs := $(libcfs-linux-objs) $(libcfs-all-objs)
 
 
 libcfs-objs := $(libcfs-linux-objs) $(libcfs-all-objs)
 
similarity index 92%
rename from lustre/lvfs/upcall_cache.c
rename to libcfs/libcfs/upcall_cache.c
index 5e08659..49031d7 100644 (file)
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  *
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  *
- * lustre/lvfs/upcall_cache.c
+ * libcfs/libcfs/upcall_cache.c
  *
  * Supplementary groups cache.
  */
  *
  * Supplementary groups cache.
  */
-
 #define DEBUG_SUBSYSTEM S_SEC
 
 #define DEBUG_SUBSYSTEM S_SEC
 
-#ifndef AUTOCONF_INCLUDED
-#include <linux/config.h>
-#endif
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mm.h>
-#include <linux/kmod.h>
-#include <linux/string.h>
-#include <linux/stat.h>
-#include <linux/errno.h>
-#include <linux/version.h>
-#include <linux/unistd.h>
-
-#include <asm/system.h>
-#include <asm/uaccess.h>
-
-#include <linux/fs.h>
-#include <linux/stat.h>
-#include <asm/uaccess.h>
-#include <linux/slab.h>
-
-#include <obd_support.h>
-#include <lustre_lib.h>
+#include <libcfs/lucache.h>
 
 static struct upcall_cache_entry *alloc_entry(struct upcall_cache *cache,
                                               __u64 key, void *args)
 {
         struct upcall_cache_entry *entry;
 
 
 static struct upcall_cache_entry *alloc_entry(struct upcall_cache *cache,
                                               __u64 key, void *args)
 {
         struct upcall_cache_entry *entry;
 
-        OBD_ALLOC_PTR(entry);
+        LIBCFS_ALLOC(entry, sizeof(*entry));
         if (!entry)
                 return NULL;
 
         if (!entry)
                 return NULL;
 
@@ -93,7 +70,7 @@ static void free_entry(struct upcall_cache *cache,
         cfs_list_del(&entry->ue_hash);
         CDEBUG(D_OTHER, "destroy cache entry %p for key "LPU64"\n",
                entry, entry->ue_key);
         cfs_list_del(&entry->ue_hash);
         CDEBUG(D_OTHER, "destroy cache entry %p for key "LPU64"\n",
                entry, entry->ue_key);
-        OBD_FREE_PTR(entry);
+        LIBCFS_FREE(entry, sizeof(*entry));
 }
 
 static inline int upcall_compare(struct upcall_cache *cache,
 }
 
 static inline int upcall_compare(struct upcall_cache *cache,
@@ -140,12 +117,13 @@ static int check_unlink_entry(struct upcall_cache *cache,
                               struct upcall_cache_entry *entry)
 {
         if (UC_CACHE_IS_VALID(entry) &&
                               struct upcall_cache_entry *entry)
 {
         if (UC_CACHE_IS_VALID(entry) &&
-            cfs_time_before(jiffies, entry->ue_expire))
+            cfs_time_before(cfs_time_current(), entry->ue_expire))
                 return 0;
 
         if (UC_CACHE_IS_ACQUIRING(entry)) {
                 if (entry->ue_acquire_expire == 0 ||
                 return 0;
 
         if (UC_CACHE_IS_ACQUIRING(entry)) {
                 if (entry->ue_acquire_expire == 0 ||
-                    cfs_time_before(jiffies, entry->ue_acquire_expire))
+                    cfs_time_before(cfs_time_current(),
+                                    entry->ue_acquire_expire))
                         return 0;
 
                 UC_CACHE_SET_EXPIRED(entry);
                         return 0;
 
                 UC_CACHE_SET_EXPIRED(entry);
@@ -221,7 +199,8 @@ find_again:
                 cfs_spin_unlock(&cache->uc_lock);
                 rc = refresh_entry(cache, entry);
                 cfs_spin_lock(&cache->uc_lock);
                 cfs_spin_unlock(&cache->uc_lock);
                 rc = refresh_entry(cache, entry);
                 cfs_spin_lock(&cache->uc_lock);
-                entry->ue_acquire_expire = jiffies + cache->uc_acquire_expire;
+                entry->ue_acquire_expire =
+                        cfs_time_shift(cache->uc_acquire_expire);
                 if (rc < 0) {
                         UC_CACHE_CLEAR_ACQUIRING(entry);
                         UC_CACHE_SET_INVALID(entry);
                 if (rc < 0) {
                         UC_CACHE_CLEAR_ACQUIRING(entry);
                         UC_CACHE_SET_INVALID(entry);
@@ -232,12 +211,12 @@ find_again:
                         }
                 }
         }
                         }
                 }
         }
-
         /* someone (and only one) is doing upcall upon this item,
          * wait it to complete */
         if (UC_CACHE_IS_ACQUIRING(entry)) {
         /* someone (and only one) is doing upcall upon this item,
          * wait it to complete */
         if (UC_CACHE_IS_ACQUIRING(entry)) {
-                long expiry = (entry == new) ? cache->uc_acquire_expire :
-                                               CFS_MAX_SCHEDULE_TIMEOUT;
+                long expiry = (entry == new) ?
+                              cfs_time_seconds(cache->uc_acquire_expire) :
+                              CFS_MAX_SCHEDULE_TIMEOUT;
                 long left;
 
                 cfs_waitlink_init(&wait);
                 long left;
 
                 cfs_waitlink_init(&wait);
@@ -363,7 +342,7 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key,
         if (rc)
                 GOTO(out, rc);
 
         if (rc)
                 GOTO(out, rc);
 
-        entry->ue_expire = jiffies + cache->uc_entry_expire;
+        entry->ue_expire = cfs_time_shift(cache->uc_entry_expire);
         UC_CACHE_SET_VALID(entry);
         CDEBUG(D_OTHER, "%s: created upcall cache entry %p for key "LPU64"\n",
                cache->uc_name, entry, entry->ue_key);
         UC_CACHE_SET_VALID(entry);
         CDEBUG(D_OTHER, "%s: created upcall cache entry %p for key "LPU64"\n",
                cache->uc_name, entry, entry->ue_key);
@@ -437,7 +416,7 @@ void upcall_cache_flush_one(struct upcall_cache *cache, __u64 key, void *args)
                       "cur %lu, ex %ld/%ld\n",
                       cache->uc_name, entry, entry->ue_key,
                       cfs_atomic_read(&entry->ue_refcount), entry->ue_flags,
                       "cur %lu, ex %ld/%ld\n",
                       cache->uc_name, entry, entry->ue_key,
                       cfs_atomic_read(&entry->ue_refcount), entry->ue_flags,
-                      get_seconds(), entry->ue_acquire_expire,
+                      cfs_time_current_sec(), entry->ue_acquire_expire,
                       entry->ue_expire);
                 UC_CACHE_SET_EXPIRED(entry);
                 if (!cfs_atomic_read(&entry->ue_refcount))
                       entry->ue_expire);
                 UC_CACHE_SET_EXPIRED(entry);
                 if (!cfs_atomic_read(&entry->ue_refcount))
@@ -454,7 +433,7 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall,
         int i;
         ENTRY;
 
         int i;
         ENTRY;
 
-        OBD_ALLOC(cache, sizeof(*cache));
+        LIBCFS_ALLOC(cache, sizeof(*cache));
         if (!cache)
                 RETURN(ERR_PTR(-ENOMEM));
 
         if (!cache)
                 RETURN(ERR_PTR(-ENOMEM));
 
@@ -465,8 +444,8 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall,
         strncpy(cache->uc_name, name, sizeof(cache->uc_name) - 1);
         /* upcall pathname proc tunable */
         strncpy(cache->uc_upcall, upcall, sizeof(cache->uc_upcall) - 1);
         strncpy(cache->uc_name, name, sizeof(cache->uc_name) - 1);
         /* upcall pathname proc tunable */
         strncpy(cache->uc_upcall, upcall, sizeof(cache->uc_upcall) - 1);
-        cache->uc_entry_expire = 20 * 60 * CFS_HZ;
-        cache->uc_acquire_expire = 30 * CFS_HZ;
+        cache->uc_entry_expire = 20 * 60;
+        cache->uc_acquire_expire = 30;
         cache->uc_ops = ops;
 
         RETURN(cache);
         cache->uc_ops = ops;
 
         RETURN(cache);
@@ -478,6 +457,6 @@ void upcall_cache_cleanup(struct upcall_cache *cache)
         if (!cache)
                 return;
         upcall_cache_flush_all(cache);
         if (!cache)
                 return;
         upcall_cache_flush_all(cache);
-        OBD_FREE(cache, sizeof(*cache));
+        LIBCFS_FREE(cache, sizeof(*cache));
 }
 EXPORT_SYMBOL(upcall_cache_cleanup);
 }
 EXPORT_SYMBOL(upcall_cache_cleanup);
index cc95bb3..19d45ac 100644 (file)
@@ -40,7 +40,7 @@ EXTRA_DIST = ioctl.h liblustre.h lprocfs_status.h lustre_cfg.h        \
             lustre_debug.h lustre_disk.h lustre_dlm.h lustre_export.h \
              lustre_fsfilt.h lustre_ha.h lustre_handles.h lustre_import.h \
              lustre_lib.h lustre_sec.h lustre_lite.h lustre_log.h lustre_mds.h \
             lustre_debug.h lustre_disk.h lustre_dlm.h lustre_export.h \
              lustre_fsfilt.h lustre_ha.h lustre_handles.h lustre_import.h \
              lustre_lib.h lustre_sec.h lustre_lite.h lustre_log.h lustre_mds.h \
-             lustre_mdc.h lustre_net.h lustre_quota.h lustre_ucache.h lvfs.h \
+             lustre_mdc.h lustre_net.h lustre_quota.h lvfs.h \
              obd_cache.h obd_class.h obd.h obd_lov.h \
             obd_ost.h obd_support.h lustre_ver.h lu_object.h lu_time.h  \
              md_object.h dt_object.h lustre_param.h lustre_mdt.h \
              obd_cache.h obd_class.h obd.h obd_lov.h \
             obd_ost.h obd_support.h lustre_ver.h lu_object.h lu_time.h  \
              md_object.h dt_object.h lustre_param.h lustre_mdt.h \
index fb02ac9..f8a48d9 100644 (file)
@@ -54,7 +54,7 @@
 #error Unsupported operating system.
 #endif
 
 #error Unsupported operating system.
 #endif
 
-#include <lustre_ucache.h>
+#include <libcfs/lucache.h>
 
 
 #ifdef LIBLUSTRE
 
 
 #ifdef LIBLUSTRE
index 4321250..1fcacb1 100644 (file)
@@ -2,7 +2,7 @@ MODULES := lvfs
 @SERVER_TRUE@MODULES += fsfilt_@BACKINGFS@
 @QUOTA_TRUE@MODULES += quotafmt_test
 
 @SERVER_TRUE@MODULES += fsfilt_@BACKINGFS@
 @QUOTA_TRUE@MODULES += quotafmt_test
 
-lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o upcall_cache.o lvfs_lib.o
+lvfs-objs := lvfs_common.o lvfs_linux.o fsfilt.o lvfs_lib.o
 
 @QUOTA_TRUE@quotafmt-objs := quotafmt_test.o
 
 
 @QUOTA_TRUE@quotafmt-objs := quotafmt_test.o
 
index 434ddbd..f731044 100644 (file)
@@ -64,6 +64,7 @@
 #include <linux/slab.h>
 
 #include <libcfs/libcfs.h>
 #include <linux/slab.h>
 
 #include <libcfs/libcfs.h>
+#include <libcfs/lucache.h>
 #include <obd.h>
 #include <obd_class.h>
 #include <obd_support.h>
 #include <obd.h>
 #include <obd_class.h>
 #include <obd_support.h>
@@ -71,7 +72,6 @@
 #include <lustre_import.h>
 #include <lustre_dlm.h>
 #include <lustre_lib.h>
 #include <lustre_import.h>
 #include <lustre_dlm.h>
 #include <lustre_lib.h>
-#include <lustre_ucache.h>
 
 #include "mdt_internal.h"
 
 
 #include "mdt_internal.h"
 
index ad1bdb5..1d1005c 100644 (file)
@@ -64,6 +64,7 @@
 #include <linux/slab.h>
 
 #include <libcfs/libcfs.h>
 #include <linux/slab.h>
 
 #include <libcfs/libcfs.h>
+#include <libcfs/lucache.h>
 #include <obd.h>
 #include <obd_class.h>
 #include <obd_support.h>
 #include <obd.h>
 #include <obd_class.h>
 #include <obd_support.h>
@@ -72,7 +73,6 @@
 #include <lustre_dlm.h>
 #include <lustre_sec.h>
 #include <lustre_lib.h>
 #include <lustre_dlm.h>
 #include <lustre_sec.h>
 #include <lustre_lib.h>
-#include <lustre_ucache.h>
 
 #include "mdt_internal.h"
 
 
 #include "mdt_internal.h"
 
index 534b268..c2929c6 100644 (file)
@@ -156,8 +156,8 @@ static int lprocfs_rd_identity_expire(char *page, char **start, off_t off,
         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
 
         *eof = 1;
         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
 
         *eof = 1;
-        return snprintf(page, count, "%lu\n",
-                        mdt->mdt_identity_cache->uc_entry_expire / CFS_HZ);
+        return snprintf(page, count, "%u\n",
+                        mdt->mdt_identity_cache->uc_entry_expire);
 }
 
 static int lprocfs_wr_identity_expire(struct file *file, const char *buffer,
 }
 
 static int lprocfs_wr_identity_expire(struct file *file, const char *buffer,
@@ -171,7 +171,7 @@ static int lprocfs_wr_identity_expire(struct file *file, const char *buffer,
         if (rc)
                 return rc;
 
         if (rc)
                 return rc;
 
-        mdt->mdt_identity_cache->uc_entry_expire = val * CFS_HZ;
+        mdt->mdt_identity_cache->uc_entry_expire = val;
         return count;
 }
 
         return count;
 }
 
@@ -183,8 +183,8 @@ static int lprocfs_rd_identity_acquire_expire(char *page, char **start,
         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
 
         *eof = 1;
         struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev);
 
         *eof = 1;
-        return snprintf(page, count, "%lu\n",
-                        mdt->mdt_identity_cache->uc_acquire_expire / CFS_HZ);
+        return snprintf(page, count, "%u\n",
+                        mdt->mdt_identity_cache->uc_acquire_expire);
 }
 
 static int lprocfs_wr_identity_acquire_expire(struct file *file,
 }
 
 static int lprocfs_wr_identity_acquire_expire(struct file *file,
@@ -200,7 +200,7 @@ static int lprocfs_wr_identity_acquire_expire(struct file *file,
         if (rc)
                 return rc;
 
         if (rc)
                 return rc;
 
-        mdt->mdt_identity_cache->uc_acquire_expire = val * CFS_HZ;
+        mdt->mdt_identity_cache->uc_acquire_expire = val;
         return count;
 }
 
         return count;
 }