Whamcloud - gitweb
Branch b1_6
authoryangsheng <yangsheng>
Mon, 2 Mar 2009 06:22:21 +0000 (06:22 +0000)
committeryangsheng <yangsheng>
Mon, 2 Mar 2009 06:22:21 +0000 (06:22 +0000)
b=17954

i=bobijam, deen

Coverity fixes.
Author: Jim Garlick(LLNL)

20 files changed:
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_request.c
lustre/ldlm/ldlm_resource.c
lustre/llite/dcache.c
lustre/llite/file.c
lustre/llite/namei.c
lustre/llite/rw.c
lustre/lov/lov_obd.c
lustre/mds/handler.c
lustre/mgs/mgs_handler.c
lustre/obdclass/llog_obd.c
lustre/obdfilter/filter.c
lustre/osc/osc_request.c
lustre/tests/iopentest2.c
lustre/tests/it_test.c
lustre/tests/multiop.c
lustre/tests/writemany.c
lustre/utils/lustre_cfg.c
lustre/utils/mkfs_lustre.c
lustre/utils/mount_lustre.c

index 85d0f2d..9816ff9 100644 (file)
@@ -902,7 +902,7 @@ int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data)
         int rc = 0;
         ENTRY;
 
-        LASSERT(lock != NULL);
+        LASSERT(lock != NULL && lock->l_export != NULL);
 
         req = ptlrpc_prep_req(lock->l_export->exp_imp_reverse,
                               LUSTRE_DLM_VERSION, LDLM_GL_CALLBACK, 2, size,
index 7ea3533..5e67ce6 100644 (file)
@@ -956,9 +956,8 @@ int ldlm_cli_cancel_req(struct obd_export *exp,
                         struct list_head *cancels, int count)
 {
         struct ptlrpc_request *req = NULL;
-        struct ldlm_request *body;
         __u32 size[2] = { [MSG_PTLRPC_BODY_OFF] = sizeof(struct ptlrpc_body),
-                        [DLM_LOCKREQ_OFF]     = sizeof(*body) };
+                        [DLM_LOCKREQ_OFF]     = sizeof(struct ldlm_request) };
         struct obd_import *imp;
         int free, sent = 0;
         int rc = 0;
@@ -997,8 +996,10 @@ int ldlm_cli_cancel_req(struct obd_export *exp,
                 req->rq_reply_portal = LDLM_CANCEL_REPLY_PORTAL;
                 ptlrpc_at_set_req_timeout(req);
 
+                /*
                 body = lustre_msg_buf(req->rq_reqmsg, DLM_LOCKREQ_OFF,
                                       sizeof(*body));
+                */
                 ldlm_cancel_pack(req, DLM_LOCKREQ_OFF, cancels, count);
 
                 ptlrpc_req_set_repsize(req, 1, NULL);
index 52a6054..dfe92c5 100644 (file)
@@ -655,7 +655,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++;
 }
 
index 931213d..06eac36 100644 (file)
@@ -725,16 +725,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 = 0;
+                                }
+#else
+                                nd->intent.open.file->private_data = it;
+                                (void)lookup_instantiate_filp(nd, dentry,NULL);
 #endif
                         }
 #else
index fb5b54f..5130368 100644 (file)
@@ -2433,7 +2433,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;
 
@@ -2448,7 +2448,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;
index 3c577ff..77c6cdd 100644 (file)
@@ -701,19 +701,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
 
                                 }
index 0b647a2..240f2ee 100644 (file)
@@ -1550,16 +1550,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)
index 69680ce..85449dd 100644 (file)
@@ -2045,7 +2045,7 @@ static int lov_match(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 lov_flags, rc = 0;
         ENTRY;
@@ -2120,7 +2120,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;
         ldlm_mode_t this_mode;
         int err = 0, rc = 0;
@@ -2672,7 +2672,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;
 
index 101f3eb..e599e3b 100644 (file)
@@ -1648,9 +1648,8 @@ int mds_handle(struct ptlrpc_request *req)
                 OBD_FAIL_RETURN(OBD_FAIL_MDS_CONNECT_NET, 0);
                 rc = target_handle_connect(req, mds_handle);
                 if (!rc) {
-                        /* Now that we have an export, set mds. */
+                        /* Now that we have an export, set obd. */
                         obd = req->rq_export->exp_obd;
-                        mds = mds_req2mds(req);
                 }
                 break;
 
@@ -1741,9 +1740,8 @@ int mds_handle(struct ptlrpc_request *req)
                         __swab32s(&opc);
 
                 DEBUG_REQ(D_INODE, req, "reint %d (%s)", opc,
-                          (opc < sizeof(reint_names) / sizeof(reint_names[0]) ||
-                           reint_names[opc] == NULL) ? reint_names[opc] :
-                                                       "unknown opcode");
+                          (opc < REINT_MAX) ? reint_names[opc] :
+                          "unknown opcode");
 
                 switch (opc) {
                 case REINT_CREATE:
index 219e0bf..b03fd39 100644 (file)
@@ -386,6 +386,7 @@ static int mgs_handle_target_reg(struct ptlrpc_request *req)
 
         mti = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*mti),
                                  lustre_swab_mgs_target_info);
+        LASSERT(mti);
 
         if (!(mti->mti_flags & (LDD_F_WRITECONF | LDD_F_UPGRADE14 |
                                 LDD_F_UPDATE))) {
index b03b3f6..e2be6c8 100644 (file)
@@ -109,7 +109,7 @@ EXPORT_SYMBOL(__llog_ctxt_put);
 int llog_cleanup(struct llog_ctxt *ctxt)
 {
         struct l_wait_info lwi = LWI_INTR(LWI_ON_SIGNAL_NOOP, NULL);
-        struct obd_device *obd = ctxt->loc_obd;
+        struct obd_device *obd;
         int rc, idx;
         ENTRY;
 
@@ -117,6 +117,7 @@ int llog_cleanup(struct llog_ctxt *ctxt)
                 CERROR("No ctxt\n");
                 RETURN(-ENODEV);
         }
+        obd = ctxt->loc_obd;
 
         /*banlance the ctxt get when calling llog_cleanup */
         llog_ctxt_put(ctxt);
index 329e513..01370ad 100644 (file)
@@ -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) {
index 2731cc6..7210f9e 100644 (file)
@@ -1708,15 +1708,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);
         }
index d38d395..396bb3f 100644 (file)
@@ -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) {
index adaccde..a2997a7 100644 (file)
@@ -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) {
index b5f745d..3df19c4 100755 (executable)
@@ -185,6 +185,7 @@ int main(int argc, char **argv)
                 exit(1);
         }
 
+        memset(&st, 0, sizeof(st));
         signal(SIGUSR1, usr1_handler);
 
         fname = argv[1];
@@ -263,6 +264,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);
index c9db9f9..707ab8d 100644 (file)
@@ -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;
index 9844c13..6a94953 100644 (file)
@@ -366,36 +366,12 @@ int jt_lcfg_del_mount_option(int argc, char **argv)
 
 int jt_lcfg_set_timeout(int argc, char **argv)
 {
-        int rc;
-        struct lustre_cfg_bufs bufs;
-        struct lustre_cfg *lcfg;
-
         fprintf(stderr, "%s has been deprecated. Use conf_param instead.\n"
                 "e.g. conf_param lustre-MDT0000 obd_timeout=50\n",
                 jt_cmdname(argv[0]));
         return CMD_HELP;
-
-
-        if (argc != 2)
-                return CMD_HELP;
-
-        lustre_cfg_bufs_reset(&bufs, lcfg_devname);
-        lcfg = lustre_cfg_new(LCFG_SET_TIMEOUT, &bufs);
-        lcfg->lcfg_num = atoi(argv[1]);
-        
-        rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg);
-        //rc = lcfg_mgs_ioctl(argv[0], OBD_DEV_ID, lcfg);
-
-        lustre_cfg_free(lcfg);
-        if (rc < 0) {
-                fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
-                        strerror(rc = errno));
-        }
-        return rc;
 }
 
-
-
 int jt_lcfg_add_conn(int argc, char **argv)
 {
         struct lustre_cfg_bufs bufs;
index 6835d05..8b772e4 100644 (file)
@@ -1080,6 +1080,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;
+        }
         end = s1 + strlen(s1);
         c = converted;
         while ((left > 0) && (s1 < end)) {
index 191918e..22a0b93 100644 (file)
@@ -161,6 +161,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, ",:");
@@ -326,7 +331,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'};
@@ -349,7 +354,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;
@@ -513,7 +518,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 == '/')) {
@@ -521,10 +534,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]);
@@ -534,6 +543,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) {
@@ -572,6 +585,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, ",");