diff options
author | Andriy Gapon <avg@FreeBSD.org> | 2009-02-26 12:33:02 +0000 |
---|---|---|
committer | Andriy Gapon <avg@FreeBSD.org> | 2009-02-26 12:33:02 +0000 |
commit | 5792e04db9e9de5f9c71ab29ac5a6c2024edaa70 (patch) | |
tree | 33e5da9119a46f61f97acdc02e30171cd11cc8c4 | |
parent | 2bbada90c87d3ba8505d0398233060a57b1731e9 (diff) | |
download | src-5792e04db9e9de5f9c71ab29ac5a6c2024edaa70.tar.gz src-5792e04db9e9de5f9c71ab29ac5a6c2024edaa70.zip |
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)
Notes
Notes:
svn path=/head/; revision=189067
-rw-r--r-- | sys/fs/udf/udf_vnops.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c index 0ec481631c0d..557080855fd8 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, - §or, &maxsize)) { + offset = lblktosize(node->udfmp, bp->b_lblkno); + error = udf_bmap_internal(node, offset, §or, &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); |