From owner-svn-src-head@FreeBSD.ORG Thu Mar 31 16:14:35 2011 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BB5EE106564A; Thu, 31 Mar 2011 16:14:35 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A0EBF8FC08; Thu, 31 Mar 2011 16:14:35 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2VGEZbQ011874; Thu, 31 Mar 2011 16:14:35 GMT (envelope-from mav@svn.freebsd.org) Received: (from mav@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2VGEZZb011867; Thu, 31 Mar 2011 16:14:35 GMT (envelope-from mav@svn.freebsd.org) Message-Id: <201103311614.p2VGEZZb011867@svn.freebsd.org> From: Alexander Motin Date: Thu, 31 Mar 2011 16:14:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220209 - head/sys/geom/raid X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2011 16:14:35 -0000 Author: mav Date: Thu Mar 31 16:14:35 2011 New Revision: 220209 URL: http://svn.freebsd.org/changeset/base/220209 Log: Bunch of small bugfixes and cleanups. Found with: Coverity Prevent(tm) CID: 9656, 9658, 9693, 9705, 9706, 9707, 9808, 9809, 9810, 9711, 9712, 9713, 9714 Modified: head/sys/geom/raid/md_intel.c head/sys/geom/raid/md_jmicron.c head/sys/geom/raid/md_nvidia.c head/sys/geom/raid/md_promise.c head/sys/geom/raid/md_sii.c head/sys/geom/raid/tr_raid1.c Modified: head/sys/geom/raid/md_intel.c ============================================================================== --- head/sys/geom/raid/md_intel.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_intel.c Thu Mar 31 16:14:35 2011 (r220209) @@ -541,9 +541,9 @@ intel_meta_write_spare(struct g_consumer /* Fill anchor and single disk. */ meta = malloc(INTEL_MAX_MD_SIZE(1), M_MD_INTEL, M_WAITOK | M_ZERO); - memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC)); + memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC) - 1); memcpy(&meta->version[0], INTEL_VERSION_1000, - sizeof(INTEL_VERSION_1000)); + sizeof(INTEL_VERSION_1000) - 1); meta->config_size = INTEL_MAX_MD_SIZE(1); meta->config_id = arc4random(); meta->generation = 1; @@ -1881,10 +1881,8 @@ g_raid_md_ctl_intel(struct g_raid_md_obj /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); @@ -2049,7 +2047,7 @@ g_raid_md_write_intel(struct g_raid_md_o /* Fill anchor and disks. */ meta = malloc(INTEL_MAX_MD_SIZE(numdisks), M_MD_INTEL, M_WAITOK | M_ZERO); - memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC)); + memcpy(&meta->intel_id[0], INTEL_MAGIC, sizeof(INTEL_MAGIC) - 1); meta->config_size = INTEL_MAX_MD_SIZE(numdisks); meta->config_id = mdi->mdio_config_id; meta->generation = mdi->mdio_generation; @@ -2214,7 +2212,7 @@ g_raid_md_write_intel(struct g_raid_md_o meta->total_volumes = vi; if (strcmp(version, INTEL_VERSION_1300) != 0) meta->attributes &= INTEL_ATTR_CHECKSUM; - memcpy(&meta->version[0], version, sizeof(INTEL_VERSION_1000)); + memcpy(&meta->version[0], version, sizeof(INTEL_VERSION_1000) - 1); /* We are done. Print meta data and store them to disks. */ g_raid_md_intel_print(meta); Modified: head/sys/geom/raid/md_jmicron.c ============================================================================== --- head/sys/geom/raid/md_jmicron.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_jmicron.c Thu Mar 31 16:14:35 2011 (r220209) @@ -431,7 +431,10 @@ g_raid_md_jmicron_start_disk(struct g_ra olddisk = NULL; /* Find disk position in metadata by it's serial. */ - disk_pos = jmicron_meta_find_disk(meta, pd->pd_disk_id); + if (pd->pd_meta != NULL) + disk_pos = jmicron_meta_find_disk(meta, pd->pd_disk_id); + else + disk_pos = -1; if (disk_pos < 0) { G_RAID_DEBUG1(1, sc, "Unknown, probably new or stale disk"); /* If we are in the start process, that's all for now. */ @@ -522,7 +525,7 @@ nofit: * Different disks may have different sizes/offsets, * especially in concat mode. Update. */ - if (pd->pd_meta != NULL && !resurrection) { + if (!resurrection) { sd->sd_offset = (off_t)pd->pd_meta->offset * 16 * 512; //ZZZ sd->sd_size = @@ -1300,10 +1303,8 @@ g_raid_md_ctl_jmicron(struct g_raid_md_o /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); Modified: head/sys/geom/raid/md_nvidia.c ============================================================================== --- head/sys/geom/raid/md_nvidia.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_nvidia.c Thu Mar 31 16:14:35 2011 (r220209) @@ -1311,10 +1311,8 @@ g_raid_md_ctl_nvidia(struct g_raid_md_ob /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); @@ -1435,7 +1433,7 @@ g_raid_md_write_nvidia(struct g_raid_md_ meta = malloc(sizeof(*meta), M_MD_NVIDIA, M_WAITOK | M_ZERO); if (mdi->mdio_meta) memcpy(meta, mdi->mdio_meta, sizeof(*meta)); - memcpy(meta->nvidia_id, NVIDIA_MAGIC, sizeof(NVIDIA_MAGIC)); + memcpy(meta->nvidia_id, NVIDIA_MAGIC, sizeof(NVIDIA_MAGIC) - 1); meta->config_size = 30; meta->version = 0x0064; meta->total_sectors = vol->v_mediasize / vol->v_sectorsize; Modified: head/sys/geom/raid/md_promise.c ============================================================================== --- head/sys/geom/raid/md_promise.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_promise.c Thu Mar 31 16:14:35 2011 (r220209) @@ -398,7 +398,8 @@ next: &off, &size)) { /* Optionally add record for unused space. */ meta = (struct promise_raid_conf *)buf; - memcpy(&meta->promise_id[0], PROMISE_MAGIC, sizeof(PROMISE_MAGIC)); + memcpy(&meta->promise_id[0], PROMISE_MAGIC, + sizeof(PROMISE_MAGIC) - 1); meta->dummy_0 = 0x00020000; meta->integrity = PROMISE_I_VALID; meta->disk.flags = PROMISE_F_ONLINE | PROMISE_F_VALID; @@ -462,7 +463,7 @@ promise_meta_write_spare(struct g_consum int error; meta = malloc(sizeof(*meta), M_MD_PROMISE, M_WAITOK | M_ZERO); - memcpy(&meta->promise_id[0], PROMISE_MAGIC, sizeof(PROMISE_MAGIC)); + memcpy(&meta->promise_id[0], PROMISE_MAGIC, sizeof(PROMISE_MAGIC) - 1); meta->dummy_0 = 0x00020000; meta->integrity = PROMISE_I_VALID; meta->disk.flags = PROMISE_F_SPARE | PROMISE_F_ONLINE | PROMISE_F_VALID; @@ -818,10 +819,10 @@ restart: } else update = 0; if (update) { + updated = 1; g_raid_md_write_promise(md, vol, NULL, disk); break; } - updated += update; } } if (updated) @@ -1684,7 +1685,8 @@ g_raid_md_write_promise(struct g_raid_md meta = malloc(sizeof(*meta), M_MD_PROMISE, M_WAITOK | M_ZERO); if (pv->pv_meta != NULL) memcpy(meta, pv->pv_meta, sizeof(*meta)); - memcpy(meta->promise_id, PROMISE_MAGIC, sizeof(PROMISE_MAGIC)); + memcpy(meta->promise_id, PROMISE_MAGIC, + sizeof(PROMISE_MAGIC) - 1); meta->dummy_0 = 0x00020000; meta->integrity = PROMISE_I_VALID; Modified: head/sys/geom/raid/md_sii.c ============================================================================== --- head/sys/geom/raid/md_sii.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/md_sii.c Thu Mar 31 16:14:35 2011 (r220209) @@ -1389,10 +1389,8 @@ g_raid_md_ctl_sii(struct g_raid_md_objec /* If disk was assigned, just update statuses. */ if (pd->pd_disk_pos >= 0) { g_raid_change_disk_state(disk, G_RAID_DISK_S_OFFLINE); - if (disk->d_consumer) { - g_raid_kill_consumer(sc, disk->d_consumer); - disk->d_consumer = NULL; - } + g_raid_kill_consumer(sc, disk->d_consumer); + disk->d_consumer = NULL; TAILQ_FOREACH(sd, &disk->d_subdisks, sd_next) { g_raid_change_subdisk_state(sd, G_RAID_SUBDISK_S_NONE); Modified: head/sys/geom/raid/tr_raid1.c ============================================================================== --- head/sys/geom/raid/tr_raid1.c Thu Mar 31 15:52:12 2011 (r220208) +++ head/sys/geom/raid/tr_raid1.c Thu Mar 31 16:14:35 2011 (r220209) @@ -720,8 +720,6 @@ g_raid_tr_iodone_raid1(struct g_raid_tr_ bp->bio_error); bp->bio_cmd = BIO_WRITE; bp->bio_cflags = G_RAID_BIO_FLAG_SYNC; - bp->bio_offset = bp->bio_offset; - bp->bio_length = bp->bio_length; G_RAID_LOGREQ(4, bp, "Queueing rebuild write."); g_raid_subdisk_iostart(trs->trso_failed_sd, bp); } else {