Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-8926 llite: reduce jobstats race window
[fs/lustre-release.git]
/
lustre
/
obdclass
/
class_obd.c
diff --git
a/lustre/obdclass/class_obd.c
b/lustre/obdclass/class_obd.c
index
3f857fd
..
cf38cde
100644
(file)
--- 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
*
* 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
*/
*
* 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) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 201
4
, Intel Corporation.
+ * Copyright (c) 2011, 201
5
, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
*/
/*
* This file is part of Lustre, http://www.lustre.org/
@@
-41,14
+37,14
@@
# include <linux/uidgid.h>
#endif
#include <linux/atomic.h>
# include <linux/uidgid.h>
#endif
#include <linux/atomic.h>
+#include <linux/list.h>
#include <obd_support.h>
#include <obd_class.h>
#include <lnet/lnetctl.h>
#include <lustre_debug.h>
#include <lprocfs_status.h>
#include <obd_support.h>
#include <obd_class.h>
#include <lnet/lnetctl.h>
#include <lustre_debug.h>
#include <lprocfs_status.h>
-#include <lustre/lustre_build_version.h>
-#include <libcfs/list.h>
+#include <lustre_ver.h>
#include <cl_object.h>
#ifdef HAVE_SERVER_SUPPORT
# include <dt_object.h>
#include <cl_object.h>
#ifdef HAVE_SERVER_SUPPORT
# include <dt_object.h>
@@
-113,6
+109,8
@@
struct lprocfs_stats *obd_memory = NULL;
EXPORT_SYMBOL(obd_memory);
#endif
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.
*
/* 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;
int lustre_get_jobid(char *jobid)
{
int jobid_len = LUSTRE_JOBID_SIZE;
+ char tmp_jobid[LUSTRE_JOBID_SIZE] = { 0 };
int rc = 0;
ENTRY;
int rc = 0;
ENTRY;
- memset(jobid, 0, LUSTRE_JOBID_SIZE);
/* Jobstats isn't enabled */
if (strcmp(obd_jobid_var, JOBSTATS_DISABLE) == 0)
/* 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) {
/* 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()));
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
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);
}
}
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);
}
EXPORT_SYMBOL(lustre_get_jobid);
@@
-247,24
+260,24
@@
int class_handle_ioctl(unsigned int cmd, unsigned long arg)
GOTO(out, err);
}
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);
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
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;
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;
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) {
if (u64val != OBD_OBJECT_EOF) {
-
CERROR("__u64 "LPX64"
(%d) != 0xffffffffffffffff\n",
+
CERROR("__u64 %#llx
(%d) != 0xffffffffffffffff\n",
u64val, (int)sizeof(u64val));
ret = -EINVAL;
}
u64val, (int)sizeof(u64val));
ret = -EINVAL;
}
-
len = snprintf(buf, sizeof(buf), LPX64
, u64val);
+
len = snprintf(buf, sizeof(buf), "%#llx"
, u64val);
if (len != 18) {
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;
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) {
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) {
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)) {
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) {
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;
}
u64val, div64val, u64val >> 8);
return -EOVERFLOW;
}
-
len = snprintf(buf, sizeof(buf), LPX64
, u64val);
+
len = snprintf(buf, sizeof(buf), "%#llx"
, u64val);
if (len != 18) {
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;
}
ret = -EINVAL;
}
-
len = snprintf(buf, sizeof(buf), LPU64
, u64val);
+
len = snprintf(buf, sizeof(buf), "%llu"
, u64val);
if (len != 20) {
if (len != 20) {
-
CWARN("LPU
64 wrong length! strlen(%s)=%d != 20\n", buf, len);
+
CWARN("u
64 wrong length! strlen(%s)=%d != 20\n", buf, len);
ret = -EINVAL;
}
ret = -EINVAL;
}
-
len = snprintf(buf, sizeof(buf), LPD64
, u64val);
+
len = snprintf(buf, sizeof(buf), "%lld"
, u64val);
if (len != 2) {
if (len != 2) {
-
CWARN("LPD
64 wrong length! strlen(%s)=%d != 2\n", buf, len);
+
CWARN("s
64 wrong length! strlen(%s)=%d != 2\n", buf, len);
ret = -EINVAL;
}
ret = -EINVAL;
}
- if ((u64val & ~PAGE_
CACHE_MASK) >= PAGE_CACH
E_SIZE) {
-
CWARN("mask failed: u64val "LPU64" >= "LPU64"
\n", u64val,
- (__u64)PAGE_
CACHE_
SIZE);
+ if ((u64val & ~PAGE_
MASK) >= PAG
E_SIZE) {
+
CWARN("mask failed: u64val %llu >= %llu
\n", u64val,
+ (__u64)PAGE_SIZE);
ret = -EINVAL;
}
ret = -EINVAL;
}
@@
-484,7
+495,7
@@
static int obd_init_checks(void)
#define obd_init_checks() do {} while(0)
#endif
#define obd_init_checks() do {} while(0)
#endif
-static int __init
init_obdclass
(void)
+static int __init
obdclass_init
(void)
{
int i, err;
{
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);
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();
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). */
/* 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;
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 */
}
#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;
{
__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,
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. <http://www.lustre.org/>");
memory_max, memory_leaked);
EXIT;
}
MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
-MODULE_DESCRIPTION("Lustre Class Driver
Build Version: " BUILD_VERSION
);
+MODULE_DESCRIPTION("Lustre Class Driver
"
);
MODULE_VERSION(LUSTRE_VERSION_STRING);
MODULE_LICENSE("GPL");
MODULE_VERSION(LUSTRE_VERSION_STRING);
MODULE_LICENSE("GPL");
-module_init(
init_obdclass
);
-module_exit(
cleanup_obdclass
);
+module_init(
obdclass_init
);
+module_exit(
obdclass_exit
);