From 91ef66e6da76d8c39492349b4f909a0036fe9d4c Mon Sep 17 00:00:00 2001 From: adilger Date: Thu, 17 Jul 2003 07:57:40 +0000 Subject: [PATCH] Landing statfs cache code. - preliminary for prealloc (bug 974) - preliminary for QOS (bug 855) - speeds up parallel df - speeds up lprocfs Lprocfs underwent a bunch of cleanup (mostly from Intel, partly from me) to remove lots of macros and strangeness w.r.t. per-target statfs values. Still open for discussion is how old the cached statfs values can be. I arbitrarily picked 1 second for client statfs, lprocfs, and target statfs caches. We may want to change that, or allow it to be tunable. Note that this code is different than that in bug 855, in that the max_age parameter is an absolute age in jiffies, whereas the patch in bug 855 used a relative time in seconds. The thing I'm trying to avoid is if we say "I want a result up to 1 second old", but we get delayed during an RPC and we don't know what "1 second old" is related to. --- lustre/cobd/cache_obd.c | 32 ++++++++----------- lustre/cobd/lproc_cache.c | 72 +++++++++++++++++++------------------------ lustre/obdclass/statfs_pack.c | 36 ++-------------------- 3 files changed, 46 insertions(+), 94 deletions(-) diff --git a/lustre/cobd/cache_obd.c b/lustre/cobd/cache_obd.c index f830d41..2d3549b 100644 --- a/lustre/cobd/cache_obd.c +++ b/lustre/cobd/cache_obd.c @@ -37,12 +37,12 @@ static int cobd_attach(struct obd_device *dev, obd_count len, void *data) struct lprocfs_static_vars lvars; lprocfs_init_vars(cobd, &lvars); - return lprocfs_obd_attach(dev, lvars.obd_vars); + return lprocfs_obd_attach(dev, lvars.obd_vars); } static int cobd_detach(struct obd_device *dev) { - return lprocfs_obd_detach(dev); + return lprocfs_obd_detach(dev); } static int @@ -117,10 +117,10 @@ cobd_connect (struct lustre_handle *conn, struct obd_device *obd, static int cobd_disconnect(struct lustre_handle *conn, int flags) { - int rc = class_disconnect(conn, flags); + int rc = class_disconnect(conn, flags); CERROR ("rc %d\n", rc); - return (rc); + return (rc); } static int @@ -142,23 +142,15 @@ cobd_get_info(struct lustre_handle *conn, obd_count keylen, return obd_get_info(&cobd->cobd_target, keylen, key, vallen, val); } -static int cobd_statfs(struct obd_export *exp, struct obd_statfs *osfs) +static int cobd_statfs(struct obd_device *obd, struct obd_statfs *osfs, + unsigned long max_age) { - struct obd_export *cobd_exp; - int rc; - - if (exp->exp_obd == NULL) - return -EINVAL; - - cobd_exp = class_conn2export(&exp->exp_obd->u.cobd.cobd_target); - rc = obd_statfs(cobd_exp, osfs); - class_export_put(cobd_exp); - return rc; + return obd_statfs(class_conn2obd(&obd->u.cobd.cobd_target), osfs, + max_age); } -static int -cobd_getattr(struct lustre_handle *conn, struct obdo *oa, - struct lov_stripe_md *lsm) +static int cobd_getattr(struct lustre_handle *conn, struct obdo *oa, + struct lov_stripe_md *lsm) { struct obd_device *obd = class_conn2obd(conn); struct cache_obd *cobd; @@ -311,7 +303,7 @@ static int __init cobd_init(void) struct lprocfs_static_vars lvars; ENTRY; - printk(KERN_INFO "Lustre Caching OBD driver; info@clusterfs.com\n"); + printk(KERN_INFO "Lustre Caching OBD driver; info@clusterfs.com\n"); lprocfs_init_vars(cobd, &lvars); RETURN(class_register_type(&cobd_ops, lvars.module_vars, @@ -320,7 +312,7 @@ static int __init cobd_init(void) static void /*__exit*/ cobd_exit(void) { - class_unregister_type(OBD_CACHE_DEVICENAME); + class_unregister_type(OBD_CACHE_DEVICENAME); } MODULE_AUTHOR("Cluster File Systems, Inc. "); diff --git a/lustre/cobd/lproc_cache.c b/lustre/cobd/lproc_cache.c index 93729cb..ba9b9cf 100644 --- a/lustre/cobd/lproc_cache.c +++ b/lustre/cobd/lproc_cache.c @@ -29,61 +29,53 @@ static struct lprocfs_vars lprocfs_obd_vars[] = { {0} }; static struct lprocfs_vars lprocfs_module_vars[] = { {0} }; #else /* Common STATUS namespace */ -static int rd_target(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int cobd_rd_target(char *page, char **start, off_t off, int count, + int *eof, void *data) { - struct obd_device *dev = (struct obd_device*)data; - struct lustre_handle *conn; - struct obd_export *exp; - int rc; + struct obd_device *cobd = (struct obd_device *)data; + int rc; - LASSERT(dev != NULL); - conn = &dev->u.cobd.cobd_target; + LASSERT(cobd != NULL); - if (!dev->obd_set_up) { - rc = snprintf (page, count, "not set up\n"); - } else { - exp = class_conn2export(conn); - LASSERT(exp != NULL); - rc = snprintf(page, count, "%s\n", - exp->exp_obd->obd_uuid.uuid); - class_export_put(exp); - } - return (rc); + if (!cobd->obd_set_up) { + rc = snprintf(page, count, "not set up\n"); + } else { + struct obd_device *tgt = + class_conn2obd(&cobd->u.cobd.cobd_target); + LASSERT(tgt != NULL); + rc = snprintf(page, count, "%s\n", tgt->obd_uuid.uuid); + } + return rc; } -static int rd_cache(char *page, char **start, off_t off, int count, - int *eof, void *data) +static int cobd_rd_cache(char *page, char **start, off_t off, int count, + int *eof, void *data) { - struct obd_device *dev = (struct obd_device*)data; - struct lustre_handle *conn; - struct obd_export *exp; - int rc; + struct obd_device *cobd = (struct obd_device*)data; + int rc; - LASSERT(dev != NULL); - conn = &dev->u.cobd.cobd_cache; + LASSERT(cobd != NULL); - if (!dev->obd_set_up) { - rc = snprintf (page, count, "not set up\n"); + if (!cobd->obd_set_up) { + rc = snprintf(page, count, "not set up\n"); } else { - exp = class_conn2export(conn); - LASSERT (exp != NULL); - rc = snprintf(page, count, "%s\n", - exp->exp_obd->obd_uuid.uuid); - class_export_put(exp); - } - return (rc); + struct obd_device *cache = + class_conn2obd(&cobd->u.cobd.cobd_cache); + LASSERT(cache != NULL); + rc = snprintf(page, count, "%s\n", cache->obd_uuid.uuid); + } + return rc; } static struct lprocfs_vars lprocfs_obd_vars[] = { - { "uuid", lprocfs_rd_uuid, 0, 0 }, - { "target_uuid", rd_target, 0, 0 }, - { "cache_uuid", rd_cache, 0, 0 }, + { "uuid", lprocfs_rd_uuid, 0, 0 }, + { "target_uuid", cobd_rd_target, 0, 0 }, + { "cache_uuid", cobd_rd_cache, 0, 0 }, { 0 } }; -static struct lprocfs_vars lprocfs_module_vars[] = { - { "num_refs", lprocfs_rd_numrefs, 0, 0 }, +struct lprocfs_vars lprocfs_module_vars[] = { + { "num_refs", lprocfs_rd_numrefs, 0, 0 }, { 0 } }; #endif /* LPROCFS */ diff --git a/lustre/obdclass/statfs_pack.c b/lustre/obdclass/statfs_pack.c index 5a04110..8bb78cc 100644 --- a/lustre/obdclass/statfs_pack.c +++ b/lustre/obdclass/statfs_pack.c @@ -42,6 +42,7 @@ void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs) { + memset(osfs, 0, sizeof(*osfs)); osfs->os_type = sfs->f_type; osfs->os_blocks = sfs->f_blocks; osfs->os_bfree = sfs->f_bfree; @@ -54,6 +55,7 @@ void statfs_pack(struct obd_statfs *osfs, struct kstatfs *sfs) void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs) { + memset(sfs, 0, sizeof(*sfs)); sfs->f_type = osfs->os_type; sfs->f_blocks = osfs->os_blocks; sfs->f_bfree = osfs->os_bfree; @@ -64,39 +66,5 @@ void statfs_unpack(struct kstatfs *sfs, struct obd_statfs *osfs) sfs->f_namelen = osfs->os_namelen; } -int obd_self_statfs(struct obd_device *obd, struct kstatfs *sfs) -{ - struct obd_export *export, *my_export = NULL; - struct obd_statfs osfs = { 0 }; - int rc; - ENTRY; - - LASSERT( obd != NULL ); - - spin_lock(&obd->obd_dev_lock); - if (list_empty(&obd->obd_exports)) { - spin_unlock(&obd->obd_dev_lock); - export = my_export = class_new_export(obd); - if (export == NULL) - RETURN(-ENOMEM); - } else { - export = list_entry(obd->obd_exports.next, typeof(*export), - exp_obd_chain); - export = class_export_get(export); - spin_unlock(&obd->obd_dev_lock); - } - - rc = obd_statfs(export, &osfs); - if (!rc) - statfs_unpack(sfs, &osfs); - - if (my_export) - class_unlink_export(my_export); - - class_export_put(export); - RETURN(rc); -} - EXPORT_SYMBOL(statfs_pack); EXPORT_SYMBOL(statfs_unpack); -EXPORT_SYMBOL(obd_self_statfs); -- 1.8.3.1