X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=inline;f=lustre%2Fobdclass%2Fclass_obd.c;h=cf38cde7b1656b66fc2df0939e174bcec8832160;hb=8eca92b365fd3efd1541a48b1bb239926838d947;hp=3f857fd614d0c3b3c10f6aa537c8491656695954;hpb=e655d8abdcecc60c80ff43ac291943d4da1488b5;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 3f857fd..cf38cde 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -15,11 +15,7 @@ * * You should have received a copy of the GNU General Public License * version 2 along with this program; If not, see - * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf - * - * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, - * CA 95054 USA or visit www.sun.com if you need additional information or - * have any questions. + * http://www.gnu.org/licenses/gpl-2.0.html * * GPL HEADER END */ @@ -27,7 +23,7 @@ * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2014, Intel Corporation. + * Copyright (c) 2011, 2015, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -41,14 +37,14 @@ # include #endif #include +#include #include #include #include #include #include -#include -#include +#include #include #ifdef HAVE_SERVER_SUPPORT # include @@ -113,6 +109,8 @@ struct lprocfs_stats *obd_memory = NULL; EXPORT_SYMBOL(obd_memory); #endif +char obd_jobid_node[LUSTRE_JOBID_SIZE + 1]; + /* Get jobid of current process by reading the environment variable * stored in between the "env_start" & "env_end" of task struct. * @@ -128,23 +126,29 @@ EXPORT_SYMBOL(obd_memory); int lustre_get_jobid(char *jobid) { int jobid_len = LUSTRE_JOBID_SIZE; + char tmp_jobid[LUSTRE_JOBID_SIZE] = { 0 }; int rc = 0; ENTRY; - memset(jobid, 0, LUSTRE_JOBID_SIZE); /* Jobstats isn't enabled */ if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0) - RETURN(0); + GOTO(out, rc = 0); + + /* Whole node dedicated to single job */ + if (strcmp(obd_jobid_var, JOBSTATS_NODELOCAL) == 0) { + memcpy(tmp_jobid, obd_jobid_node, LUSTRE_JOBID_SIZE); + GOTO(out, rc = 0); + } /* Use process name + fsuid as jobid */ if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) { - snprintf(jobid, LUSTRE_JOBID_SIZE, "%s.%u", + snprintf(tmp_jobid, LUSTRE_JOBID_SIZE, "%s.%u", current_comm(), from_kuid(&init_user_ns, current_fsuid())); - RETURN(0); + GOTO(out, rc = 0); } - rc = cfs_get_environ(obd_jobid_var, jobid, &jobid_len); + rc = cfs_get_environ(obd_jobid_var, tmp_jobid, &jobid_len); if (rc) { if (rc == -EOVERFLOW) { /* For the PBS_JOBID and LOADL_STEP_ID keys (which are @@ -168,7 +172,16 @@ int lustre_get_jobid(char *jobid) obd_jobid_var, rc); } } - RETURN(rc); + +out: + if (rc != 0) + RETURN(rc); + + /* Only replace the job ID if it changed. */ + if (strcmp(jobid, tmp_jobid) != 0) + memcpy(jobid, tmp_jobid, jobid_len); + + RETURN(0); } EXPORT_SYMBOL(lustre_get_jobid); @@ -247,24 +260,24 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) GOTO(out, err); } - case OBD_GET_VERSION: - if (!data->ioc_inlbuf1) { - CERROR("No buffer passed in ioctl\n"); - GOTO(out, err = -EINVAL); - } + case OBD_GET_VERSION: + if (!data->ioc_inlbuf1) { + CERROR("No buffer passed in ioctl\n"); + GOTO(out, err = -EINVAL); + } - if (strlen(BUILD_VERSION) + 1 > data->ioc_inllen1) { - CERROR("ioctl buffer too small to hold version\n"); - GOTO(out, err = -EINVAL); - } + if (strlen(LUSTRE_VERSION_STRING) + 1 > data->ioc_inllen1) { + CERROR("ioctl buffer too small to hold version\n"); + GOTO(out, err = -EINVAL); + } - memcpy(data->ioc_bulk, BUILD_VERSION, - strlen(BUILD_VERSION) + 1); + memcpy(data->ioc_bulk, LUSTRE_VERSION_STRING, + strlen(LUSTRE_VERSION_STRING) + 1); err = obd_ioctl_popdata((void __user *)arg, data, len); - if (err) - err = -EFAULT; - GOTO(out, err); + if (err) + err = -EFAULT; + GOTO(out, err); case OBD_IOC_NAME2DEV: { /* Resolve a device name. This does not change the @@ -419,62 +432,60 @@ static int obd_init_checks(void) char buf[64]; int len, ret = 0; - CDEBUG(D_INFO, "LPU64=%s, LPD64=%s, LPX64=%s\n", LPU64, LPD64, LPX64); - - CDEBUG(D_INFO, "OBD_OBJECT_EOF = "LPX64"\n", (__u64)OBD_OBJECT_EOF); + CDEBUG(D_INFO, "OBD_OBJECT_EOF = %#llx\n", (__u64)OBD_OBJECT_EOF); u64val = OBD_OBJECT_EOF; - CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = "LPX64"\n", u64val); + CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = %#llx\n", u64val); if (u64val != OBD_OBJECT_EOF) { - CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n", + CERROR("__u64 %#llx(%d) != 0xffffffffffffffff\n", u64val, (int)sizeof(u64val)); ret = -EINVAL; } - len = snprintf(buf, sizeof(buf), LPX64, u64val); + len = snprintf(buf, sizeof(buf), "%#llx", u64val); if (len != 18) { - CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len); + CWARN("u64 hex wrong length! strlen(%s)=%d != 18\n", buf, len); ret = -EINVAL; } div64val = OBD_OBJECT_EOF; - CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = "LPX64"\n", u64val); + CDEBUG(D_INFO, "u64val OBD_OBJECT_EOF = %#llx\n", u64val); if (u64val != OBD_OBJECT_EOF) { - CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n", + CERROR("__u64 %#llx(%d) != 0xffffffffffffffff\n", u64val, (int)sizeof(u64val)); ret = -EOVERFLOW; } if (u64val >> 8 != OBD_OBJECT_EOF >> 8) { - CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n", + CERROR("__u64 %#llx(%d) != 0xffffffffffffffff\n", u64val, (int)sizeof(u64val)); return -EOVERFLOW; } if (do_div(div64val, 256) != (u64val & 255)) { - CERROR("do_div("LPX64",256) != "LPU64"\n", u64val, u64val &255); + CERROR("do_div(%#llx,256) != %llu\n", u64val, u64val & 255); return -EOVERFLOW; } if (u64val >> 8 != div64val) { - CERROR("do_div("LPX64",256) "LPU64" != "LPU64"\n", + CERROR("do_div(%#llx,256) %llu != %llu\n", u64val, div64val, u64val >> 8); return -EOVERFLOW; } - len = snprintf(buf, sizeof(buf), LPX64, u64val); + len = snprintf(buf, sizeof(buf), "%#llx", u64val); if (len != 18) { - CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len); + CWARN("u64 hex wrong length! strlen(%s)=%d != 18\n", buf, len); ret = -EINVAL; } - len = snprintf(buf, sizeof(buf), LPU64, u64val); + len = snprintf(buf, sizeof(buf), "%llu", u64val); if (len != 20) { - CWARN("LPU64 wrong length! strlen(%s)=%d != 20\n", buf, len); + CWARN("u64 wrong length! strlen(%s)=%d != 20\n", buf, len); ret = -EINVAL; } - len = snprintf(buf, sizeof(buf), LPD64, u64val); + len = snprintf(buf, sizeof(buf), "%lld", u64val); if (len != 2) { - CWARN("LPD64 wrong length! strlen(%s)=%d != 2\n", buf, len); + CWARN("s64 wrong length! strlen(%s)=%d != 2\n", buf, len); ret = -EINVAL; } - if ((u64val & ~PAGE_CACHE_MASK) >= PAGE_CACHE_SIZE) { - CWARN("mask failed: u64val "LPU64" >= "LPU64"\n", u64val, - (__u64)PAGE_CACHE_SIZE); + if ((u64val & ~PAGE_MASK) >= PAGE_SIZE) { + CWARN("mask failed: u64val %llu >= %llu\n", u64val, + (__u64)PAGE_SIZE); ret = -EINVAL; } @@ -484,7 +495,7 @@ static int obd_init_checks(void) #define obd_init_checks() do {} while(0) #endif -static int __init init_obdclass(void) +static int __init obdclass_init(void) { int i, err; @@ -492,7 +503,7 @@ static int __init init_obdclass(void) INIT_LIST_HEAD(&obd_stale_exports); atomic_set(&obd_stale_export_num, 0); - LCONSOLE_INFO("Lustre: Build Version: "BUILD_VERSION"\n"); + LCONSOLE_INFO("Lustre: Build Version: "LUSTRE_VERSION_STRING"\n"); spin_lock_init(&obd_types_lock); obd_zombie_impexp_init(); @@ -533,7 +544,7 @@ static int __init init_obdclass(void) /* Default the dirty page cache cap to 1/2 of system memory. * For clients with less memory, a larger fraction is needed * for other purposes (mostly for BGL). */ - if (totalram_pages <= 512 << (20 - PAGE_CACHE_SHIFT)) + if (totalram_pages <= 512 << (20 - PAGE_SHIFT)) obd_max_dirty_pages = totalram_pages / 4; else obd_max_dirty_pages = totalram_pages / 2; @@ -599,9 +610,7 @@ __u64 obd_memory_max(void) } #endif /* CONFIG_PROC_FS */ -/* liblustre doesn't call cleanup_obdclass, apparently. we carry on in this - * ifdef to the end of the file to cover module and versioning goo.*/ -static void cleanup_obdclass(void) +static void __exit obdclass_exit(void) { __u64 memory_leaked; __u64 memory_max; @@ -634,16 +643,16 @@ static void cleanup_obdclass(void) lprocfs_free_stats(&obd_memory); CDEBUG((memory_leaked) ? D_ERROR : D_INFO, - "obd_memory max: "LPU64", leaked: "LPU64"\n", + "obd_memory max: %llu, leaked: %llu\n", memory_max, memory_leaked); EXIT; } MODULE_AUTHOR("OpenSFS, Inc. "); -MODULE_DESCRIPTION("Lustre Class Driver Build Version: " BUILD_VERSION); +MODULE_DESCRIPTION("Lustre Class Driver"); MODULE_VERSION(LUSTRE_VERSION_STRING); MODULE_LICENSE("GPL"); -module_init(init_obdclass); -module_exit(cleanup_obdclass); +module_init(obdclass_init); +module_exit(obdclass_exit);