Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 26 Feb 2009 12:33:02 +0000 (UTC)
From:      Andriy Gapon <avg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r189067 - head/sys/fs/udf
Message-ID:  <200902261233.n1QCX2rs027710@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902261233.n1QCX2rs027710>