From: LiuYing Date: Fri, 3 Dec 2010 02:03:30 +0000 (+0800) Subject: b=24097 move upcall_cache from lvfs to libcfs X-Git-Tag: 2.1.57.0~5 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=82af026a4b6c22b680929ca7b6db45b0c6a55171 b=24097 move upcall_cache from lvfs to libcfs part of params_tree platform-independent code i=andreas i=alexg --- diff --git a/libcfs/include/libcfs/Makefile.am b/libcfs/include/libcfs/Makefile.am index 7cb850b..f84ed14 100644 --- a/libcfs/include/libcfs/Makefile.am +++ b/libcfs/include/libcfs/Makefile.am @@ -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_kernelcomm.h libcfs_workitem.h \ + libcfs_kernelcomm.h libcfs_workitem.h lucache.h \ params_tree.h diff --git a/lustre/include/lustre_ucache.h b/libcfs/include/libcfs/lucache.h similarity index 95% rename from lustre/include/lustre_ucache.h rename to libcfs/include/libcfs/lucache.h index c81a548..9307505 100644 --- a/lustre/include/lustre_ucache.h +++ b/libcfs/include/libcfs/lucache.h @@ -34,8 +34,14 @@ * 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 /** \defgroup ucache ucache * @@ -122,8 +128,8 @@ struct upcall_cache { 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; }; @@ -157,4 +163,4 @@ void upcall_cache_cleanup(struct upcall_cache *hash); /** @} ucache */ -#endif /* _UPCALL_CACHE_H */ +#endif /* _LUCACHE_H */ diff --git a/libcfs/libcfs/Makefile.in b/libcfs/libcfs/Makefile.in index b794923..2537b0a 100644 --- a/libcfs/libcfs/Makefile.in +++ b/libcfs/libcfs/Makefile.in @@ -25,7 +25,8 @@ sources: 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) diff --git a/lustre/lvfs/upcall_cache.c b/libcfs/libcfs/upcall_cache.c similarity index 92% rename from lustre/lvfs/upcall_cache.c rename to libcfs/libcfs/upcall_cache.c index 5e08659..49031d7 100644 --- a/lustre/lvfs/upcall_cache.c +++ b/libcfs/libcfs/upcall_cache.c @@ -33,43 +33,20 @@ * 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. */ - #define DEBUG_SUBSYSTEM S_SEC -#ifndef AUTOCONF_INCLUDED -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include +#include 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; @@ -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); - OBD_FREE_PTR(entry); + LIBCFS_FREE(entry, sizeof(*entry)); } 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) && - 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 || - 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); @@ -221,7 +199,8 @@ find_again: 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); @@ -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)) { - 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); @@ -363,7 +342,7 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, 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); @@ -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, - 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)) @@ -454,7 +433,7 @@ struct upcall_cache *upcall_cache_init(const char *name, const char *upcall, int i; ENTRY; - OBD_ALLOC(cache, sizeof(*cache)); + LIBCFS_ALLOC(cache, sizeof(*cache)); 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); - 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); @@ -478,6 +457,6 @@ void upcall_cache_cleanup(struct upcall_cache *cache) if (!cache) return; upcall_cache_flush_all(cache); - OBD_FREE(cache, sizeof(*cache)); + LIBCFS_FREE(cache, sizeof(*cache)); } EXPORT_SYMBOL(upcall_cache_cleanup); diff --git a/lustre/include/Makefile.am b/lustre/include/Makefile.am index cc95bb3..19d45ac 100644 --- a/lustre/include/Makefile.am +++ b/lustre/include/Makefile.am @@ -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_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 \ diff --git a/lustre/include/lvfs.h b/lustre/include/lvfs.h index fb02ac9..f8a48d91 100644 --- a/lustre/include/lvfs.h +++ b/lustre/include/lvfs.h @@ -54,7 +54,7 @@ #error Unsupported operating system. #endif -#include +#include #ifdef LIBLUSTRE diff --git a/lustre/lvfs/Makefile.in b/lustre/lvfs/Makefile.in index 4321250f..1fcacb1 100644 --- a/lustre/lvfs/Makefile.in +++ b/lustre/lvfs/Makefile.in @@ -2,7 +2,7 @@ MODULES := lvfs @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 diff --git a/lustre/mdt/mdt_identity.c b/lustre/mdt/mdt_identity.c index 434ddbd..f731044 100644 --- a/lustre/mdt/mdt_identity.c +++ b/lustre/mdt/mdt_identity.c @@ -64,6 +64,7 @@ #include #include +#include #include #include #include @@ -71,7 +72,6 @@ #include #include #include -#include #include "mdt_internal.h" diff --git a/lustre/mdt/mdt_idmap.c b/lustre/mdt/mdt_idmap.c index ad1bdb5..1d1005c 100644 --- a/lustre/mdt/mdt_idmap.c +++ b/lustre/mdt/mdt_idmap.c @@ -64,6 +64,7 @@ #include #include +#include #include #include #include @@ -72,7 +73,6 @@ #include #include #include -#include #include "mdt_internal.h" diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index 534b268..c2929c6 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -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; - 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, @@ -171,7 +171,7 @@ static int lprocfs_wr_identity_expire(struct file *file, const char *buffer, if (rc) return rc; - mdt->mdt_identity_cache->uc_entry_expire = val * CFS_HZ; + mdt->mdt_identity_cache->uc_entry_expire = val; 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; - 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, @@ -200,7 +200,7 @@ static int lprocfs_wr_identity_acquire_expire(struct file *file, if (rc) return rc; - mdt->mdt_identity_cache->uc_acquire_expire = val * CFS_HZ; + mdt->mdt_identity_cache->uc_acquire_expire = val; return count; }