summaryrefslogtreecommitdiffstats
path: root/sys/fs/udf
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2009-02-26 12:33:02 +0000
committeravg <avg@FreeBSD.org>2009-02-26 12:33:02 +0000
commit3f68170c35dc93a2bdb94dbd32673d239c3be3ac (patch)
tree33e5da9119a46f61f97acdc02e30171cd11cc8c4 /sys/fs/udf
parent280ef3dd2367a2ffb0c778dfaad55377a0f712f4 (diff)
downloadFreeBSD-src-3f68170c35dc93a2bdb94dbd32673d239c3be3ac.zip
FreeBSD-src-3f68170c35dc93a2bdb94dbd32673d239c3be3ac.tar.gz
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)
Diffstat (limited to 'sys/fs/udf')
-rw-r--r--sys/fs/udf/udf_vnops.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c
index 0ec4816..5570808 100644
--- a/sys/fs/udf/udf_vnops.c
+++ b/sys/fs/udf/udf_vnops.c
@@ -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);
OpenPOWER on IntegriCloud