Date: Wed, 11 Jul 2012 21:35:54 +0000 From: oleksandr@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r239283 - soc2012/oleksandr/udf-head/sys/fs/udf2 Message-ID: <20120711213554.100B3106566C@hub.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: oleksandr Date: Wed Jul 11 21:35:53 2012 New Revision: 239283 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=239283 Log: Clean code, add debug printf and KASSERTS Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c ============================================================================== --- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c Wed Jul 11 20:17:14 2012 (r239282) +++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_subr.c Wed Jul 11 21:35:53 2012 (r239283) @@ -31,11 +31,11 @@ #include <sys/cdefs.h> #include <sys/endian.h> #include <sys/param.h> -#include <sys/systm.h> /* KASSERT */ +#include <sys/systm.h> #include <sys/vnode.h> #include <sys/malloc.h> #include <sys/stat.h> -#include <sys/mount.h> /* We shouldn't be, but are dependent on this header. */ +#include <sys/mount.h> #include <sys/iconv.h> #include "ecma167-udf.h" #include "udf.h" @@ -353,7 +353,7 @@ return (EINVAL); } -/* assert(*last_tracknr >= *first_tracknr); */ + KASSERT(*last_tracknr >= *first_tracknr, ("udf_search_tracks: sanity check failed")); return (0); } @@ -1151,8 +1151,8 @@ free(dscr, M_UDFTEMP); break; } - /* assert((dscr_size % sector_size) == 0); */ - + KASSERT(!(dscr_size % sector_size), ("udf_read_vds_extent:" + "wrong descriptor sze")); len -= dscr_size; loc += dscr_size / sector_size; } @@ -1181,6 +1181,7 @@ anchor = ump->anchors[0]; anchor2 = ump->anchors[1]; + KASSERT(anchor, ("udf_read_vds_space: anchor is not valid")); if (anchor2) { size = sizeof(struct extent_ad); @@ -2075,7 +2076,8 @@ maps_on = ump->vtop[log_part]; switch (ump->vtop_tp[log_part]) { case UDF_VTOP_TYPE_PHYS : - KASSERT(maps_on == log_part, (" maps_on != log_part")); + KASSERT(maps_on == log_part, ("udf_process_vds: logical" + "partition do not equal vpartnr translations\n")); ump->vtop_alloc[log_part] = UDF_ALLOC_SPACEMAP; break; case UDF_VTOP_TYPE_VIRT : @@ -2083,7 +2085,8 @@ ump->vtop_alloc[maps_on] = UDF_ALLOC_SEQUENTIAL; break; case UDF_VTOP_TYPE_SPARABLE : - KASSERT(maps_on == log_part, ("maps_on != log_part")); + KASSERT(maps_on == log_part, ("udf_process_vds: logical" + "partition do not equal vpartnr translations\n")); ump->vtop_alloc[log_part] = UDF_ALLOC_SPACEMAP; break; case UDF_VTOP_TYPE_META : @@ -2937,8 +2940,9 @@ sector_size = le32toh(ump->logical_vol->lb_size); /* check assertions */ - /* assert(vat_node->fe || vat_node->efe); */ - /* assert(ump->logvol_integrity); */ + KASSERT(vat_node->fe || vat_node->efe, ("udf_check_for_vat:" + "Extended File Entry or File Entry is null\n")); + KASSERT(ump->logvol_integrity, ("udf_check_for_vat: invalid current integrity")); /* set vnode type to regular file or we can't read from it! */ /* vat_node->vnode->v_type = VREG; */ @@ -3037,7 +3041,7 @@ vat_offset = vat->header_len; vat_entries = (vat_length - vat_offset)/4; - /* assert(lvinfo); */ + KASSERT(lvinfo, ("udf_check_for_vat: invalid integrity descriptor")); lvinfo->num_files = vat->num_files; lvinfo->num_directories = vat->num_directories; lvinfo->min_udf_readver = vat->min_udf_readver; @@ -3134,15 +3138,16 @@ if (file_type == 248) { + DPRINTF(VOLUMES, ("Checking for VAT at sector %d\n", vat_loc)); icb_loc.loc.part_num = htole16(UDF_VTOP_RAWPART); icb_loc.loc.lb_num = htole32(vat_loc); ino = udf_get_node_id(&icb_loc); error = udf_get_node(ump, ino, &vat_node); - /* error = udf_vget(ump->vfs_mountp, ino, LK_EXCLUSIVE, &vp); */ - /* vat_node = VTOI(vp); */ if (!error) { error = udf_check_for_vat(vat_node); + DPRINTFIF(VOLUMES, !error, + ("VAT accepted at %d\n", vat_loc)); if (!error) break; } @@ -4496,15 +4501,16 @@ struct extfile_entry *efe = dir_node->efe; struct fileid_desc *fid; struct dirent *dirent; - uint64_t file_size, pre_diroffset, diroffset; + uint64_t file_size, pre_diroffset, diroffset = 0; uint32_t lb_size; - int error; + int error = 0; /* make sure we have a dirhash to work on */ dirh = dir_node->dir_hash; - KASSERT(dirh); - KASSERT(dirh->refcnt > 0); + KASSERT(dirh, ("dirhash_fill: dirhash is null")); + KASSERT(dirh->dn_refcount > 0, ("dirhash_fill: dirhash does not have reference")); +#if 0 if (dirh->flags & DIRH_BROKEN) return (EIO); if (dirh->flags & DIRH_COMPLETE) @@ -4512,12 +4518,13 @@ /* make sure we have a clean dirhash to add to */ dirhash_purge_entries(dirh); +#endif /* get directory filesize */ if (fe) { file_size = le64toh(fe->inf_len); } else { - assert(efe); + KASSERT(node->efe, ("Extended File Entry is null")); file_size = le64toh(efe->inf_len); } @@ -4528,8 +4535,6 @@ /* allocate temporary space for dirent */ dirent = malloc(sizeof(struct dirent), M_UDFTEMP, M_WAITOK); - error = 0; - diroffset = 0; while (diroffset < file_size) { /* transfer a new fid/dirent */ pre_diroffset = diroffset; @@ -5293,48 +5298,6 @@ #endif /* --------------------------------------------------------------------- */ -#if 0 -int -udf_vget(struct mount *mp, ino_t ino, int flags, struct vnode **vpp) -{ - printf("%s ran\n", __func__); - - int error; - struct udf_node *unode; - struct udf_mount *ump; - struct vnode *nvp; - struct long_ad node_icb_loc; - int udf_file_type; - - unode = uma_zalloc(udf_zone_node, M_WAITOK | M_ZERO); - unode = udf_alloc_node() - - unode->hash_id = ino; - - lockmgr(nvp->v_vnlock, LK_EXCLUSIVE, NULL); - if ((error = insmntque(nvp, mp)) != 0) { - uma_zfree(udf_zone_node, unode); - return (error); - } - - /* TODO: Does this leak unode or vnodes? */ - error = vfs_hash_insert(nvp, ino, flags, curthread, vpp, NULL, NULL); - if (error || *vpp != NULL) - return (error); - - /* - * Load read and set up the unode structure. - */ - udf_get_node_longad(ino, &node_icb_loc); - error = udf_get_node(ump, &node_icb_loc, unode); - if (error) { - vgone(nvp); - vput(nvp); - ungetnewvnode(nvp); - } - return -} -#endif /* * Each node can have an attached streamdir node though not recursively. These @@ -5363,6 +5326,8 @@ uint32_t lb_size, sector, dummy; uint8_t *file_data; + DPRINTF(NODE, ("udf_get_node called\n")); + udf_get_node_longad(ino, &icb_loc); @@ -6221,12 +6186,13 @@ int enough, error; uint32_t fid_size, lb_size; -/* assert(fid); - assert(dirent); - assert(dir_node); - assert(offset); - assert(*offset != 1); */ + KASSERT(fid, ("udf_read_fid_stream: File Identifier Descriptor is null")); + /* KASSERT(dirent, ("dirent == null")); */ + KASSERT(dir_node, ("udf_read_fid_stream: udf_node is null")); + KASSERT(offset, ("udf_read_fid_stream: offset == 0")); + KASSERT(*offset != 1, ("udf_read_fid_stream: offset != 1")); + DPRINTF(FIDS, ("read_fid_stream called at offset %llu\n", *offset)); /* check if we're past the end of the directory */ if (fe) { file_size = le64toh(fe->inf_len); @@ -6259,6 +6225,7 @@ if (error) return (error); + DPRINTF(FIDS, ("\tfid piece read in fine\n")); /* * Check if we got a whole descriptor. * TODO Try to `resync' directory stream when something is very wrong. @@ -6269,11 +6236,13 @@ if (error) { goto brokendir; } + DPRINTF(FIDS, ("\ttag check ok\n")); if (le16toh(fid->tag.id) != TAGID_FID) { error = EIO; goto brokendir; } + DPRINTF(FIDS, ("\ttag checked ok: got TAGID_FID\n")); /* check for length */ fid_size = udf_fidsize(fid); @@ -6282,16 +6251,22 @@ error = EIO; goto brokendir; } + DPRINTF(FIDS, ("\tthe complete fid is read in\n")); /* check FID contents */ error = udf_check_tag_payload((union dscrptr *) fid, lb_size); brokendir: if (error) { /* note that is sometimes a bit quick to report */ + printf("UDF: BROKEN DIRECTORY ENTRY\n"); /* RESYNC? */ /* TODO: use udf_resync_fid_stream */ return (EIO); } + DPRINTF(FIDS, ("\tplayload checked ok\n")); + + /* we got a whole and valid descriptor! */ + DPRINTF(FIDS, ("\tinterpret FID\n")); /* advance */ *offset += fid_size; Modified: soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c ============================================================================== --- soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Wed Jul 11 20:17:14 2012 (r239282) +++ soc2012/oleksandr/udf-head/sys/fs/udf2/udf_vnops.c Wed Jul 11 21:35:53 2012 (r239283) @@ -520,8 +520,8 @@ /* bp->b_lblkno = bp->b_blkno; */ /* check assertions: we OUGHT to always get multiples of this */ - KASSERT(sectors * lb_size == bp->b_bcount, ("udf_strategy: wrong length - to fetch/store in sectors")); + KASSERT(sectors * lb_size == bp->b_bcount, ("udf_strategy: wrong length" + "to fetch/store in sectors")); if (bp->b_blkno == bp->b_lblkno) { /* get logical block and run */ error = udf_bmap_translate(udf_node, bp->b_lblkno, &lsector, &maxblks);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120711213554.100B3106566C>