From: adilger Date: Wed, 30 Mar 2005 04:55:21 +0000 (+0000) Subject: Branch: b1_4 X-Git-Tag: v1_8_0_110~486^7~86 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=23c26d99bbc751b43e933a1c4f06503a529944af;p=fs%2Flustre-release.git Branch: b1_4 For some reason having an inline ll_set_rdonly() with HAVE_OLD_DEV_SET_RDONLY is causing gcc to miscompile and way overstep the array bounds (2 == 1792 in some cases it seems). Move this code to a function. Add some more 64-bit sanity checks (it was do_div() on BGL that broke things previously). --- diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index bfc2ac5..0760eaa 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -149,7 +149,7 @@ static inline int cleanup_group_info(void) #define module_put __MOD_DEC_USE_COUNT #define LTIME_S(time) (time) #if !defined(CONFIG_RH_2_4_20) && !defined(cpu_online) -#define cpu_online(cpu) (cpu_online_map & (1<> 8 != OBD_OBJECT_EOF >> 8) { - CDEBUG(D_ERROR, "__u64 "LPX64"(%d) != 0xffffffffffffffff\n", + CERROR("__u64 "LPX64"(%d) != 0xffffffffffffffff\n", u64val, sizeof(u64val)); - ret = -EINVAL; + return -EOVERFLOW; + } + if (do_div(div64val, 256) != (u64val & 255)) { + CERROR("do_div("LPX64",256) != "LPU64"\n", u64val, u64val &255); + return -EOVERFLOW; + } + if (u64val >> 8 != div64val) { + CERROR("do_div("LPX64",256) "LPU64" != "LPU64"\n", + u64val, div64val, u64val >> 8); + return -EOVERFLOW; } len = snprintf(buf, sizeof(buf), LPX64, u64val); if (len != 18) { - CDEBUG(D_WARNING, "LPX64 wrong length! strlen(%s)=%d != 18\n", - buf, len); + CWARN("LPX64 wrong length! strlen(%s)=%d != 18\n", buf, len); ret = -EINVAL; } len = snprintf(buf, sizeof(buf), LPU64, u64val); if (len != 20) { - CDEBUG(D_WARNING, "LPU64 wrong length! strlen(%s)=%d != 20\n", - buf, len); + CWARN("LPU64 wrong length! strlen(%s)=%d != 20\n", buf, len); ret = -EINVAL; } len = snprintf(buf, sizeof(buf), LPD64, u64val); if (len != 2) { - CDEBUG(D_WARNING, "LPD64 wrong length! strlen(%s)=%d != 2\n", - buf, len); + CWARN("LPD64 wrong length! strlen(%s)=%d != 2\n", buf, len); ret = -EINVAL; } if ((u64val & ~PAGE_MASK) >= PAGE_SIZE) { - CDEBUG(D_WARNING, "mask failed: u64val "LPU64" >= %lu\n", - u64val, PAGE_SIZE); + CWARN("mask failed: u64val "LPU64" >= %lu\n", u64val,PAGE_SIZE); ret = -EINVAL; } @@ -631,6 +661,10 @@ int init_obdclass(void) printk(KERN_INFO "Lustre: OBD class driver Build Version: " BUILD_VERSION", info@clusterfs.com\n"); + err = obd_init_checks(); + if (err == -EOVERFLOW) + return err; + class_init_uuidlist(); err = class_handle_init(); if (err) @@ -656,7 +690,6 @@ int init_obdclass(void) #ifdef __KERNEL__ obd_sysctl_init(); #endif - obd_init_checks(); #ifdef LPROCFS proc_lustre_root = proc_mkdir("lustre", proc_root_fs); diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index f705364..58a0927 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -361,7 +361,7 @@ out: } void class_decref(struct obd_device *obd) -{ +{ if (atomic_dec_and_test(&obd->obd_refcount)) { int err; CDEBUG(D_IOCTL, "finishing cleanup of obd %s (%s)\n", @@ -370,14 +370,14 @@ void class_decref(struct obd_device *obd) if (obd->obd_stopping) { /* If we're not stopping, we never set up */ err = obd_cleanup(obd); - if (err) + if (err) CERROR("Cleanup returned %d\n", err); } err = __class_detach(obd); - if (err) + if (err) CERROR("Detach returned %d\n", err); } -} +} int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg) { @@ -564,8 +564,7 @@ int class_process_config(struct lustre_cfg *lcfg) } case LCFG_SET_TIMEOUT: { CDEBUG(D_IOCTL, "changing lustre timeout from %d to %d\n", - obd_timeout, - lcfg->lcfg_num); + obd_timeout, lcfg->lcfg_num); obd_timeout = lcfg->lcfg_num; GOTO(out, err = 0); }