svn commit: r189067 - head/sys/fs/udf

Andriy Gapon avg at FreeBSD.org
Thu Feb 26 04:33:03 PST 2009


Author: avg
Date: Thu Feb 26 12:33:02 2009
New Revision: 189067
URL: http://svn.freebsd.org/changeset/base/189067

Log:
  udf_strategy: tiny optimization of logic, calculations; extra diagnostics
  
  Use bit-shift instead of division/multiplication.
  Act on error as soon as it is detected.
  Report attempt to read data embedded in file entry via regular way.
  While there, fix lblktosize macro and make use of it.
  
  No functionality should change as a result.
  
  Approved by: jhb (mentor)

Modified:
  head/sys/fs/udf/udf_vnops.c

Modified: head/sys/fs/udf/udf_vnops.c
==============================================================================
--- head/sys/fs/udf/udf_vnops.c	Thu Feb 26 12:12:34 2009	(r189066)
+++ head/sys/fs/udf/udf_vnops.c	Thu Feb 26 12:33:02 2009	(r189067)
@@ -417,7 +417,7 @@ udf_print(struct vop_print_args *ap)
 
 #define lblkno(udfmp, loc)	((loc) >> (udfmp)->bshift)
 #define blkoff(udfmp, loc)	((loc) & (udfmp)->bmask)
-#define lblktosize(imp, blk)	((blk) << (udfmp)->bshift)
+#define lblktosize(udfmp, blk)	((blk) << (udfmp)->bshift)
 
 static int
 udf_read(struct vop_read_args *ap)
@@ -981,10 +981,11 @@ udf_strategy(struct vop_strategy_args *a
 	struct buf *bp;
 	struct vnode *vp;
 	struct udf_node *node;
-	int maxsize;
-	daddr_t sector;
 	struct bufobj *bo;
-	int multiplier;
+	off_t offset;
+	uint32_t maxsize;
+	daddr_t sector;
+	int error;
 
 	bp = a->a_bp;
 	vp = a->a_vp;
@@ -995,20 +996,16 @@ udf_strategy(struct vop_strategy_args *a
 		 * Files that are embedded in the fentry don't translate well
 		 * to a block number.  Reject.
 		 */
-		if (udf_bmap_internal(node, bp->b_lblkno * node->udfmp->bsize,
-		    &sector, &maxsize)) {
+		offset = lblktosize(node->udfmp, bp->b_lblkno);
+		error = udf_bmap_internal(node, offset, &sector, &maxsize);
+		if (error) {
 			clrbuf(bp);
 			bp->b_blkno = -1;
+			bufdone(bp);
+			return (0);
 		}
-
 		/* bmap gives sector numbers, bio works with device blocks */
-		multiplier = node->udfmp->bsize / DEV_BSIZE;
-		bp->b_blkno = sector * multiplier;
-
-	}
-	if ((long)bp->b_blkno == -1) {
-		bufdone(bp);
-		return (0);
+		bp->b_blkno = sector << (node->udfmp->bshift - DEV_BSHIFT);
 	}
 	bo = node->udfmp->im_bo;
 	bp->b_iooffset = dbtob(bp->b_blkno);


More information about the svn-src-all mailing list