From: yangsheng Date: Mon, 2 Mar 2009 09:06:40 +0000 (+0000) Subject: Branch HEAD X-Git-Tag: v1_9_164~43 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=8faf82a6b002ecab7eaf4c6a0ccfaa72ecdd0154 Branch HEAD b=17954 i=bobijam, deen Coveirty fixes. Author: Jim Garlick(LLNL). --- diff --git a/lustre/ldlm/ldlm_resource.c b/lustre/ldlm/ldlm_resource.c index 1a1c67e..e5caa7b 100644 --- a/lustre/ldlm/ldlm_resource.c +++ b/lustre/ldlm/ldlm_resource.c @@ -688,7 +688,6 @@ void ldlm_namespace_free(struct ldlm_namespace *ns, void ldlm_namespace_get_locked(struct ldlm_namespace *ns) { - LASSERT(ns->ns_refcount >= 0); ns->ns_refcount++; } diff --git a/lustre/llite/dcache.c b/lustre/llite/dcache.c index 31fdff5..0f7c7e6 100644 --- a/lustre/llite/dcache.c +++ b/lustre/llite/dcache.c @@ -761,16 +761,20 @@ int ll_revalidate_nd(struct dentry *dentry, struct nameidata *nd) (struct ptlrpc_request *) it->d.lustre.it_data); } else { - struct file *filp; - - nd->intent.open.file->private_data = it; - filp = lookup_instantiate_filp(nd, dentry,NULL); #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)) /* 2.6.1[456] have a bug in open_namei() that forgets to check * nd->intent.open.file for error, so we need to return it as lookup's result * instead */ - if (IS_ERR(filp)) + struct file *filp; + + nd->intent.open.file->private_data = it; + filp = lookup_instantiate_filp(nd, dentry,NULL); + if (IS_ERR(filp)) { rc = PTR_ERR(filp); + } +#else + nd->intent.open.file->private_data = it; + (void)lookup_instantiate_filp(nd, dentry,NULL); #endif } #else diff --git a/lustre/llite/file.c b/lustre/llite/file.c index e9d3c87..e1b1cbd 100644 --- a/lustre/llite/file.c +++ b/lustre/llite/file.c @@ -1527,7 +1527,7 @@ static int ll_file_join(struct inode *head, struct file *filp, struct file *tail_filp, *first_filp, *second_filp; struct ll_lock_tree first_tree, second_tree; struct ll_lock_tree_node *first_node, *second_node; - struct ll_inode_info *hlli = ll_i2info(head), *tlli; + struct ll_inode_info *hlli = ll_i2info(head); int rc = 0, cleanup_phase = 0; ENTRY; @@ -1542,7 +1542,6 @@ static int ll_file_join(struct inode *head, struct file *filp, } tail = igrab(tail_filp->f_dentry->d_inode); - tlli = ll_i2info(tail); tail_dentry = tail_filp->f_dentry; LASSERT(tail_dentry); cleanup_phase = 1; diff --git a/lustre/llite/namei.c b/lustre/llite/namei.c index 91c81c3..ad0a8d6 100644 --- a/lustre/llite/namei.c +++ b/lustre/llite/namei.c @@ -660,19 +660,23 @@ static struct dentry *ll_lookup_nd(struct inode *parent, struct dentry *dentry, (struct ptlrpc_request *) it->d.lustre.it_data); } else { - struct file *filp; - nd->intent.open.file->private_data = it; - filp =lookup_instantiate_filp(nd,dentry, - NULL); #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,17)) /* 2.6.1[456] have a bug in open_namei() that forgets to check * nd->intent.open.file for error, so we need to return it as lookup's result * instead */ + struct file *filp; + nd->intent.open.file->private_data = it; + filp =lookup_instantiate_filp(nd,dentry, + NULL); if (IS_ERR(filp)) { if (de) dput(de); de = (struct dentry *) filp; } +#else + nd->intent.open.file->private_data = it; + (void)lookup_instantiate_filp(nd,dentry, + NULL); #endif } diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index 4fb44d13..f7876ed 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -890,16 +890,15 @@ static void ras_stride_increase_window(struct ll_readahead_state *ras, unsigned long stride_len; LASSERT(ras->ras_stride_length > 0); + LASSERTF(ras->ras_window_start + ras->ras_window_len + >= ras->ras_stride_offset, "window_start %lu, window_len %lu" + " stride_offset %lu\n", ras->ras_window_start, + ras->ras_window_len, ras->ras_stride_offset); stride_len = ras->ras_window_start + ras->ras_window_len - ras->ras_stride_offset; - LASSERTF(stride_len >= 0, "window_start %lu, window_len %lu" - " stride_offset %lu\n", ras->ras_window_start, - ras->ras_window_len, ras->ras_stride_offset); - left = stride_len % ras->ras_stride_length; - window_len = ras->ras_window_len - left; if (left < ras->ras_stride_pages) diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index bdbe9e6..0d4fe78 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1751,7 +1751,7 @@ static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm, struct obd_info oinfo; struct lov_request *req; struct list_head *pos; - struct lov_obd *lov = &exp->exp_obd->u.lov; + struct lov_obd *lov; struct lustre_handle *lov_lockhp; int err = 0, rc = 0; ENTRY; @@ -2367,7 +2367,7 @@ static int lov_fiemap(struct lov_obd *lov, __u32 keylen, void *key, GOTO(out, rc = -EINVAL); /* If OST is inactive, return extent with UNKNOWN flag */ - if (lov && !lov->lov_tgts[ost_index]->ltd_active) { + if (!lov->lov_tgts[ost_index]->ltd_active) { fm_local->fm_flags |= FIEMAP_EXTENT_LAST; fm_local->fm_mapped_extents = 1; diff --git a/lustre/obdfilter/filter.c b/lustre/obdfilter/filter.c index fdccecc..7ed88fc 100644 --- a/lustre/obdfilter/filter.c +++ b/lustre/obdfilter/filter.c @@ -373,13 +373,13 @@ static int filter_client_free(struct obd_export *exp) if (strcmp(fed->fed_lcd->lcd_uuid, obd->obd_uuid.uuid ) == 0) GOTO(free, 0); - CDEBUG(D_INFO, "freeing client at idx %u, offset %lld with UUID '%s'\n", - fed->fed_lr_idx, fed->fed_lr_off, fed->fed_lcd->lcd_uuid); - LASSERT(filter->fo_last_rcvd_slots != NULL); off = fed->fed_lr_off; + CDEBUG(D_INFO, "freeing client at idx %u, offset %lld with UUID '%s'\n", + fed->fed_lr_idx, fed->fed_lr_off, fed->fed_lcd->lcd_uuid); + /* Don't clear fed_lr_idx here as it is likely also unset. At worst * we leak a client slot that will be cleaned on the next recovery. */ if (off <= 0) { diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index b8ee00a..e041b19 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -1778,15 +1778,18 @@ static int osc_brw(int cmd, struct obd_export *exp, struct obd_info *oinfo, struct obdo *saved_oa = NULL; struct brw_page **ppga, **orig; struct obd_import *imp = class_exp2cliimp(exp); - struct client_obd *cli = &imp->imp_obd->u.cli; + struct client_obd *cli; int rc, page_count_orig; ENTRY; + LASSERT((imp != NULL) && (imp->imp_obd != NULL)); + cli = &imp->imp_obd->u.cli; + if (cmd & OBD_BRW_CHECK) { /* The caller just wants to know if there's a chance that this * I/O can succeed */ - if (imp == NULL || imp->imp_invalid) + if (imp->imp_invalid) RETURN(-EIO); RETURN(0); } diff --git a/lustre/tests/iopentest2.c b/lustre/tests/iopentest2.c index d38d395..396bb3f 100644 --- a/lustre/tests/iopentest2.c +++ b/lustre/tests/iopentest2.c @@ -95,13 +95,12 @@ static char *get_iname(char *fname, const char *mtpt) int main(int argc, char *argv[]) { - char *fname, *mtpt, *pname; + char *fname, *mtpt; char *fname_iname, *dir; char *dir_iname = NULL, *foo = NULL, *bar = NULL; int rc, fd, i, thread = 0; int pidlist[10]; - pname = strdup(argv[0]); progname = basename(argv[0]); if (argc != 2) { diff --git a/lustre/tests/it_test.c b/lustre/tests/it_test.c index 714828a..39ae318 100644 --- a/lustre/tests/it_test.c +++ b/lustre/tests/it_test.c @@ -84,11 +84,9 @@ static enum interval_iter cb(struct interval_node *n, void *args) static int count = 1; if (node->hit == 1) { - dprintf("NODE "__S" has ever been accessed\n", - __F(&n->in_extent)); + error("A duplicate node "__S" access found\n", + __F(&n->in_extent)); return INTERVAL_ITER_CONT; - error("duplicate node accessing found\n"); - return INTERVAL_ITER_STOP; } if (node->valid == 0) { diff --git a/lustre/tests/multiop.c b/lustre/tests/multiop.c index 1152dc0..e906af6 100755 --- a/lustre/tests/multiop.c +++ b/lustre/tests/multiop.c @@ -187,6 +187,7 @@ int main(int argc, char **argv) exit(1); } + memset(&st, 0, sizeof(st)); signal(SIGUSR1, usr1_handler); fname = argv[1]; @@ -265,6 +266,11 @@ int main(int argc, char **argv) } break; case 'M': + if (st.st_size == 0) { + fprintf(stderr, "mmap without preceeding stat, or on" + " zero length file.\n"); + exit(-1); + } mmap_len = st.st_size; mmap_ptr = mmap(NULL, mmap_len, PROT_WRITE | PROT_READ, MAP_SHARED, fd, 0); diff --git a/lustre/tests/writemany.c b/lustre/tests/writemany.c index c9db9f9..707ab8d 100644 --- a/lustre/tests/writemany.c +++ b/lustre/tests/writemany.c @@ -178,6 +178,7 @@ int run_one_child(char *file, int thread, int seconds) maxrand *= 10; gettimeofday(&start, NULL); + cur = start; while(!rc) { if (usr1_received) @@ -233,7 +234,8 @@ int run_one_child(char *file, int thread, int seconds) printf("%s: %7ld files, %4ld MB in %.2fs (%7.2f files/s, " "%5.2f MB/s): rc = %d\n", cmdname, nfiles, nbytes >> 20, diff, - (double)nfiles / diff, (double)nbytes/1024/1024 / diff, + diff == 0 ? (double)0 : (double)nfiles / diff, + diff == 0 ? (double)0 : (double)nbytes/1024/1024 / diff, rc); return rc; diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index 8bfddf2..87543eb 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -163,6 +163,11 @@ static char *convert_hostnames(char *s1) lnet_nid_t nid; converted = malloc(left); + if (converted == NULL) { + fprintf(stderr, "out of memory: needed %d bytes\n", + MAXNIDSTR); + return NULL; + } c = converted; while ((left > 0) && (*s1 != '/')) { s2 = strpbrk(s1, ",:"); @@ -329,7 +334,7 @@ int set_tunables(char *source, int src_len) glob_t glob_info; struct stat stat_buf; char *chk_major, *chk_minor; - char *savept, *dev, *s2 = 0; + char *savept, *dev; char *ret_path; char buf[PATH_MAX] = {'\0'}, path[PATH_MAX] = {'\0'}; char real_path[PATH_MAX] = {'\0'}; @@ -352,7 +357,7 @@ int set_tunables(char *source, int src_len) if (strncmp(real_path, "/dev/loop", 9) == 0) return 0; - if ((real_path[0] != '/') && ((s2 = strpbrk(real_path, ",:")) != NULL)) + if ((real_path[0] != '/') && (strpbrk(real_path, ",:") != NULL)) return 0; dev = real_path + src_len - 1; @@ -516,7 +521,15 @@ int main(int argc, char *const argv[]) } usource = argv[optind]; + if (!usource) { + usage(stderr); + } + source = convert_hostnames(usource); + if (!source) { + usage(stderr); + } + target = argv[optind + 1]; ptr = target + strlen(target) - 1; while ((ptr > target) && (*ptr == '/')) { @@ -524,10 +537,6 @@ int main(int argc, char *const argv[]) ptr--; } - if (!usource || !source) { - usage(stderr); - } - if (verbose) { for (i = 0; i < argc; i++) printf("arg[%d] = %s\n", i, argv[i]); @@ -537,6 +546,10 @@ int main(int argc, char *const argv[]) } options = malloc(strlen(orig_options) + 1); + if (options == NULL) { + fprintf(stderr, "can't allocate memory for options\n"); + return -1; + } strcpy(options, orig_options); rc = parse_options(options, &flags); if (rc) { @@ -575,6 +588,10 @@ int main(int argc, char *const argv[]) functions. So we'll stick it on the end of the options. */ optlen = strlen(options) + strlen(",device=") + strlen(source) + 1; optcopy = malloc(optlen); + if (optcopy == NULL) { + fprintf(stderr, "can't allocate memory to optcopy\n"); + return -1; + } strcpy(optcopy, options); if (*optcopy) strcat(optcopy, ",");