Home | History | Annotate | Line # | Download | only in udf
udf_strat_direct.c revision 1.6
      1  1.6  reinoud /* $NetBSD: udf_strat_direct.c,v 1.6 2008/11/28 15:29:47 reinoud Exp $ */
      2  1.1  reinoud 
      3  1.1  reinoud /*
      4  1.1  reinoud  * Copyright (c) 2006, 2008 Reinoud Zandijk
      5  1.1  reinoud  * All rights reserved.
      6  1.1  reinoud  *
      7  1.1  reinoud  * Redistribution and use in source and binary forms, with or without
      8  1.1  reinoud  * modification, are permitted provided that the following conditions
      9  1.1  reinoud  * are met:
     10  1.1  reinoud  * 1. Redistributions of source code must retain the above copyright
     11  1.1  reinoud  *    notice, this list of conditions and the following disclaimer.
     12  1.1  reinoud  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  reinoud  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  reinoud  *    documentation and/or other materials provided with the distribution.
     15  1.1  reinoud  *
     16  1.1  reinoud  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1  reinoud  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.1  reinoud  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.1  reinoud  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  1.1  reinoud  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21  1.1  reinoud  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22  1.1  reinoud  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23  1.1  reinoud  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  1.1  reinoud  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25  1.1  reinoud  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26  1.1  reinoud  *
     27  1.1  reinoud  */
     28  1.1  reinoud 
     29  1.1  reinoud #include <sys/cdefs.h>
     30  1.1  reinoud #ifndef lint
     31  1.6  reinoud __KERNEL_RCSID(0, "$NetBSD: udf_strat_direct.c,v 1.6 2008/11/28 15:29:47 reinoud Exp $");
     32  1.1  reinoud #endif /* not lint */
     33  1.1  reinoud 
     34  1.1  reinoud 
     35  1.1  reinoud #if defined(_KERNEL_OPT)
     36  1.1  reinoud #include "opt_quota.h"
     37  1.1  reinoud #include "opt_compat_netbsd.h"
     38  1.1  reinoud #endif
     39  1.1  reinoud 
     40  1.1  reinoud #include <sys/param.h>
     41  1.1  reinoud #include <sys/systm.h>
     42  1.1  reinoud #include <sys/sysctl.h>
     43  1.1  reinoud #include <sys/namei.h>
     44  1.1  reinoud #include <sys/proc.h>
     45  1.1  reinoud #include <sys/kernel.h>
     46  1.1  reinoud #include <sys/vnode.h>
     47  1.1  reinoud #include <miscfs/genfs/genfs_node.h>
     48  1.1  reinoud #include <sys/mount.h>
     49  1.1  reinoud #include <sys/buf.h>
     50  1.1  reinoud #include <sys/file.h>
     51  1.1  reinoud #include <sys/device.h>
     52  1.1  reinoud #include <sys/disklabel.h>
     53  1.1  reinoud #include <sys/ioctl.h>
     54  1.1  reinoud #include <sys/malloc.h>
     55  1.1  reinoud #include <sys/dirent.h>
     56  1.1  reinoud #include <sys/stat.h>
     57  1.1  reinoud #include <sys/conf.h>
     58  1.1  reinoud #include <sys/kauth.h>
     59  1.1  reinoud #include <sys/kthread.h>
     60  1.1  reinoud #include <dev/clock_subr.h>
     61  1.1  reinoud 
     62  1.1  reinoud #include <fs/udf/ecma167-udf.h>
     63  1.1  reinoud #include <fs/udf/udf_mount.h>
     64  1.1  reinoud 
     65  1.1  reinoud #include "udf.h"
     66  1.1  reinoud #include "udf_subr.h"
     67  1.1  reinoud #include "udf_bswap.h"
     68  1.1  reinoud 
     69  1.1  reinoud 
     70  1.1  reinoud #define VTOI(vnode) ((struct udf_node *) vnode->v_data)
     71  1.1  reinoud #define PRIV(ump) ((struct strat_private *) ump->strategy_private)
     72  1.1  reinoud 
     73  1.1  reinoud /* --------------------------------------------------------------------- */
     74  1.1  reinoud 
     75  1.1  reinoud /* BUFQ's */
     76  1.1  reinoud #define UDF_SHED_MAX 3
     77  1.1  reinoud 
     78  1.1  reinoud #define UDF_SHED_READING	0
     79  1.1  reinoud #define UDF_SHED_WRITING	1
     80  1.1  reinoud #define UDF_SHED_SEQWRITING	2
     81  1.1  reinoud 
     82  1.1  reinoud 
     83  1.1  reinoud struct strat_private {
     84  1.1  reinoud 	struct pool		desc_pool;	 /* node descriptors */
     85  1.1  reinoud };
     86  1.1  reinoud 
     87  1.1  reinoud /* --------------------------------------------------------------------- */
     88  1.1  reinoud 
     89  1.1  reinoud static void
     90  1.1  reinoud udf_wr_nodedscr_callback(struct buf *buf)
     91  1.1  reinoud {
     92  1.1  reinoud 	struct udf_node *udf_node;
     93  1.1  reinoud 
     94  1.1  reinoud 	KASSERT(buf);
     95  1.1  reinoud 	KASSERT(buf->b_data);
     96  1.1  reinoud 
     97  1.1  reinoud 	/* called when write action is done */
     98  1.1  reinoud 	DPRINTF(WRITE, ("udf_wr_nodedscr_callback(): node written out\n"));
     99  1.1  reinoud 
    100  1.1  reinoud 	udf_node = VTOI(buf->b_vp);
    101  1.1  reinoud 	if (udf_node == NULL) {
    102  1.1  reinoud 		putiobuf(buf);
    103  1.1  reinoud 		printf("udf_wr_node_callback: NULL node?\n");
    104  1.1  reinoud 		return;
    105  1.1  reinoud 	}
    106  1.1  reinoud 
    107  1.1  reinoud 	/* XXX right flags to mark dirty again on error? */
    108  1.1  reinoud 	if (buf->b_error) {
    109  1.1  reinoud 		/* write error on `defect free' media??? how to solve? */
    110  1.1  reinoud 		/* XXX lookup UDF standard for unallocatable space */
    111  1.1  reinoud 		udf_node->i_flags |= IN_MODIFIED | IN_ACCESSED;
    112  1.1  reinoud 	}
    113  1.1  reinoud 
    114  1.2  reinoud 	/* decrement outstanding_nodedscr */
    115  1.2  reinoud 	KASSERT(udf_node->outstanding_nodedscr >= 1);
    116  1.2  reinoud 	udf_node->outstanding_nodedscr--;
    117  1.2  reinoud 	if (udf_node->outstanding_nodedscr == 0) {
    118  1.2  reinoud 		/* unlock the node */
    119  1.2  reinoud 		KASSERT(udf_node->i_flags & IN_CALLBACK_ULK);
    120  1.2  reinoud 		UDF_UNLOCK_NODE(udf_node, IN_CALLBACK_ULK);
    121  1.1  reinoud 
    122  1.2  reinoud 		wakeup(&udf_node->outstanding_nodedscr);
    123  1.2  reinoud 	}
    124  1.1  reinoud 	/* unreference the vnode so it can be recycled */
    125  1.1  reinoud 	holdrele(udf_node->vnode);
    126  1.1  reinoud 
    127  1.1  reinoud 	putiobuf(buf);
    128  1.1  reinoud }
    129  1.1  reinoud 
    130  1.1  reinoud /* --------------------------------------------------------------------- */
    131  1.1  reinoud 
    132  1.1  reinoud static int
    133  1.1  reinoud udf_getblank_nodedscr_direct(struct udf_strat_args *args)
    134  1.1  reinoud {
    135  1.1  reinoud 	union dscrptr   **dscrptr = &args->dscr;
    136  1.1  reinoud 	struct udf_mount *ump = args->ump;
    137  1.1  reinoud 	struct strat_private *priv = PRIV(ump);
    138  1.1  reinoud 	uint32_t lb_size;
    139  1.1  reinoud 
    140  1.1  reinoud 	lb_size = udf_rw32(ump->logical_vol->lb_size);
    141  1.1  reinoud 	*dscrptr = pool_get(&priv->desc_pool, PR_WAITOK);
    142  1.1  reinoud 	memset(*dscrptr, 0, lb_size);
    143  1.1  reinoud 
    144  1.1  reinoud 	return 0;
    145  1.1  reinoud }
    146  1.1  reinoud 
    147  1.1  reinoud 
    148  1.1  reinoud static void
    149  1.1  reinoud udf_free_nodedscr_direct(struct udf_strat_args *args)
    150  1.1  reinoud {
    151  1.1  reinoud 	union dscrptr    *dscr = args->dscr;
    152  1.1  reinoud 	struct udf_mount *ump  = args->ump;
    153  1.1  reinoud 	struct strat_private *priv = PRIV(ump);
    154  1.1  reinoud 
    155  1.1  reinoud 	pool_put(&priv->desc_pool, dscr);
    156  1.1  reinoud }
    157  1.1  reinoud 
    158  1.1  reinoud 
    159  1.1  reinoud static int
    160  1.1  reinoud udf_read_nodedscr_direct(struct udf_strat_args *args)
    161  1.1  reinoud {
    162  1.1  reinoud 	union dscrptr   **dscrptr = &args->dscr;
    163  1.1  reinoud 	union dscrptr    *tmpdscr;
    164  1.1  reinoud 	struct udf_mount *ump = args->ump;
    165  1.1  reinoud 	struct long_ad   *icb = args->icb;
    166  1.1  reinoud 	struct strat_private *priv = PRIV(ump);
    167  1.1  reinoud 	uint32_t lb_size;
    168  1.1  reinoud 	uint32_t sector, dummy;
    169  1.1  reinoud 	int error;
    170  1.1  reinoud 
    171  1.1  reinoud 	lb_size = udf_rw32(ump->logical_vol->lb_size);
    172  1.1  reinoud 
    173  1.1  reinoud 	error = udf_translate_vtop(ump, icb, &sector, &dummy);
    174  1.1  reinoud 	if (error)
    175  1.1  reinoud 		return error;
    176  1.1  reinoud 
    177  1.1  reinoud 	/* try to read in fe/efe */
    178  1.1  reinoud 	error = udf_read_phys_dscr(ump, sector, M_UDFTEMP, &tmpdscr);
    179  1.1  reinoud 	if (error)
    180  1.1  reinoud 		return error;
    181  1.1  reinoud 
    182  1.1  reinoud 	*dscrptr = pool_get(&priv->desc_pool, PR_WAITOK);
    183  1.1  reinoud 	memcpy(*dscrptr, tmpdscr, lb_size);
    184  1.1  reinoud 	free(tmpdscr, M_UDFTEMP);
    185  1.1  reinoud 
    186  1.1  reinoud 	return 0;
    187  1.1  reinoud }
    188  1.1  reinoud 
    189  1.1  reinoud 
    190  1.1  reinoud static int
    191  1.1  reinoud udf_write_nodedscr_direct(struct udf_strat_args *args)
    192  1.1  reinoud {
    193  1.1  reinoud 	struct udf_mount *ump      = args->ump;
    194  1.1  reinoud 	struct udf_node  *udf_node = args->udf_node;
    195  1.1  reinoud 	union dscrptr    *dscr     = args->dscr;
    196  1.1  reinoud 	struct long_ad   *icb      = args->icb;
    197  1.1  reinoud 	int               waitfor  = args->waitfor;
    198  1.1  reinoud 	uint32_t logsector, sector, dummy;
    199  1.1  reinoud 	int error, vpart;
    200  1.1  reinoud 
    201  1.1  reinoud 	/*
    202  1.1  reinoud 	 * we have to decide if we write it out sequential or at its fixed
    203  1.1  reinoud 	 * position by examining the partition its (to be) written on.
    204  1.1  reinoud 	 */
    205  1.1  reinoud 	vpart     = udf_rw16(udf_node->loc.loc.part_num);
    206  1.1  reinoud 	logsector = udf_rw32(icb->loc.lb_num);
    207  1.1  reinoud 	KASSERT(ump->vtop_tp[vpart] != UDF_VTOP_TYPE_VIRT);
    208  1.1  reinoud 
    209  1.1  reinoud 	sector = 0;
    210  1.1  reinoud 	error  = udf_translate_vtop(ump, icb, &sector, &dummy);
    211  1.1  reinoud 	if (error)
    212  1.2  reinoud 		goto out;
    213  1.1  reinoud 
    214  1.2  reinoud 	/* add reference to the vnode to prevent recycling */
    215  1.2  reinoud 	vhold(udf_node->vnode);
    216  1.1  reinoud 
    217  1.1  reinoud 	if (waitfor) {
    218  1.1  reinoud 		DPRINTF(WRITE, ("udf_write_nodedscr: sync write\n"));
    219  1.1  reinoud 
    220  1.1  reinoud 		error = udf_write_phys_dscr_sync(ump, udf_node, UDF_C_NODE,
    221  1.1  reinoud 			dscr, sector, logsector);
    222  1.1  reinoud 	} else {
    223  1.1  reinoud 		DPRINTF(WRITE, ("udf_write_nodedscr: no wait, async write\n"));
    224  1.1  reinoud 
    225  1.1  reinoud 		error = udf_write_phys_dscr_async(ump, udf_node, UDF_C_NODE,
    226  1.1  reinoud 			dscr, sector, logsector, udf_wr_nodedscr_callback);
    227  1.1  reinoud 		/* will be UNLOCKED in call back */
    228  1.2  reinoud 		return error;
    229  1.1  reinoud 	}
    230  1.2  reinoud 
    231  1.2  reinoud 	holdrele(udf_node->vnode);
    232  1.2  reinoud out:
    233  1.2  reinoud 	udf_node->outstanding_nodedscr--;
    234  1.2  reinoud 	if (udf_node->outstanding_nodedscr == 0) {
    235  1.2  reinoud 		UDF_UNLOCK_NODE(udf_node, 0);
    236  1.2  reinoud 		wakeup(&udf_node->outstanding_nodedscr);
    237  1.2  reinoud 	}
    238  1.2  reinoud 
    239  1.1  reinoud 	return error;
    240  1.1  reinoud }
    241  1.1  reinoud 
    242  1.1  reinoud /* --------------------------------------------------------------------- */
    243  1.1  reinoud 
    244  1.1  reinoud static void
    245  1.1  reinoud udf_queue_buf_direct(struct udf_strat_args *args)
    246  1.1  reinoud {
    247  1.1  reinoud 	struct udf_mount *ump = args->ump;
    248  1.1  reinoud 	struct buf *buf = args->nestbuf;
    249  1.1  reinoud 	struct buf *nestbuf;
    250  1.3  reinoud 	struct desc_tag *tag;
    251  1.1  reinoud 	struct long_ad *node_ad_cpy;
    252  1.1  reinoud 	uint64_t *lmapping, *pmapping, *lmappos, blknr, run_start;
    253  1.1  reinoud 	uint32_t our_sectornr, sectornr;
    254  1.1  reinoud 	uint32_t lb_size, buf_offset, rbuflen, bpos;
    255  1.3  reinoud 	uint16_t vpart_num;
    256  1.1  reinoud 	uint8_t *fidblk;
    257  1.1  reinoud 	off_t rblk;
    258  1.1  reinoud 	int sector_size = ump->discinfo.sector_size;
    259  1.1  reinoud 	int blks = sector_size / DEV_BSIZE;
    260  1.1  reinoud 	int len, buf_len, sector, sectors, run_length;
    261  1.1  reinoud 	int what, class, queue;
    262  1.1  reinoud 
    263  1.1  reinoud 	KASSERT(ump);
    264  1.1  reinoud 	KASSERT(buf);
    265  1.1  reinoud 	KASSERT(buf->b_iodone == nestiobuf_iodone);
    266  1.1  reinoud 
    267  1.1  reinoud 	what = buf->b_udf_c_type;
    268  1.1  reinoud 	queue = UDF_SHED_READING;
    269  1.1  reinoud 	if ((buf->b_flags & B_READ) == 0) {
    270  1.1  reinoud 		/* writing */
    271  1.1  reinoud 		queue = UDF_SHED_SEQWRITING;
    272  1.1  reinoud 		if (what == UDF_C_DSCR)
    273  1.1  reinoud 			queue = UDF_SHED_WRITING;
    274  1.1  reinoud 		if (what == UDF_C_NODE)
    275  1.1  reinoud 			queue = UDF_SHED_WRITING;
    276  1.1  reinoud 	}
    277  1.1  reinoud 
    278  1.1  reinoud 	/* use disc sheduler */
    279  1.1  reinoud 	class = ump->discinfo.mmc_class;
    280  1.1  reinoud 	KASSERT((class == MMC_CLASS_UNKN) || (class == MMC_CLASS_DISC) ||
    281  1.6  reinoud 		(ump->discinfo.mmc_cur & MMC_CAP_HW_DEFECTFREE) ||
    282  1.6  reinoud 		(ump->vfs_mountp->mnt_flag & MNT_RDONLY));
    283  1.1  reinoud 
    284  1.1  reinoud 	if (queue == UDF_SHED_READING) {
    285  1.1  reinoud 		DPRINTF(SHEDULE, ("\nudf_issue_buf READ %p : sector %d type %d,"
    286  1.1  reinoud 			"b_resid %d, b_bcount %d, b_bufsize %d\n",
    287  1.1  reinoud 			buf, (uint32_t) buf->b_blkno / blks, buf->b_udf_c_type,
    288  1.1  reinoud 			buf->b_resid, buf->b_bcount, buf->b_bufsize));
    289  1.1  reinoud 		VOP_STRATEGY(ump->devvp, buf);
    290  1.1  reinoud 		return;
    291  1.1  reinoud 	}
    292  1.1  reinoud 
    293  1.1  reinoud 	/* (sectorsize == lb_size) for UDF */
    294  1.1  reinoud 	lb_size      = udf_rw32(ump->logical_vol->lb_size);
    295  1.1  reinoud 	blknr        = buf->b_blkno;
    296  1.1  reinoud 	our_sectornr = blknr / blks;
    297  1.1  reinoud 
    298  1.1  reinoud 	if (queue == UDF_SHED_WRITING) {
    299  1.1  reinoud 		DPRINTF(SHEDULE, ("\nudf_issue_buf WRITE %p : sector %d "
    300  1.1  reinoud 			"type %d, b_resid %d, b_bcount %d, b_bufsize %d\n",
    301  1.1  reinoud 			buf, (uint32_t) buf->b_blkno / blks, buf->b_udf_c_type,
    302  1.1  reinoud 			buf->b_resid, buf->b_bcount, buf->b_bufsize));
    303  1.1  reinoud 		/* if we have FIDs fixup using buffer's sector number(s) */
    304  1.1  reinoud 		if (buf->b_udf_c_type == UDF_C_FIDS) {
    305  1.1  reinoud 			panic("UDF_C_FIDS in SHED_WRITING!\n");
    306  1.1  reinoud 			buf_len = buf->b_bcount;
    307  1.1  reinoud 			sectornr = our_sectornr;
    308  1.1  reinoud 			bpos = 0;
    309  1.1  reinoud 			while (buf_len) {
    310  1.1  reinoud 				len = MIN(buf_len, sector_size);
    311  1.1  reinoud 				fidblk = (uint8_t *) buf->b_data + bpos;
    312  1.1  reinoud 				udf_fixup_fid_block(fidblk, sector_size,
    313  1.1  reinoud 					0, len, sectornr);
    314  1.1  reinoud 				sectornr++;
    315  1.1  reinoud 				bpos += len;
    316  1.1  reinoud 				buf_len -= len;
    317  1.1  reinoud 			}
    318  1.1  reinoud 		}
    319  1.1  reinoud 		udf_fixup_node_internals(ump, buf->b_data, buf->b_udf_c_type);
    320  1.1  reinoud 		VOP_STRATEGY(ump->devvp, buf);
    321  1.1  reinoud 		return;
    322  1.1  reinoud 	}
    323  1.1  reinoud 
    324  1.1  reinoud 	/* UDF_SHED_SEQWRITING */
    325  1.1  reinoud 	KASSERT(queue == UDF_SHED_SEQWRITING);
    326  1.1  reinoud 	DPRINTF(SHEDULE, ("\nudf_issue_buf SEQWRITE %p : sector XXXX "
    327  1.1  reinoud 		"type %d, b_resid %d, b_bcount %d, b_bufsize %d\n",
    328  1.1  reinoud 		buf, buf->b_udf_c_type, buf->b_resid, buf->b_bcount,
    329  1.1  reinoud 		buf->b_bufsize));
    330  1.1  reinoud 
    331  1.1  reinoud 	/*
    332  1.1  reinoud 	 * Buffers should not have been allocated to disc addresses yet on
    333  1.1  reinoud 	 * this queue. Note that a buffer can get multiple extents allocated.
    334  1.1  reinoud 	 *
    335  1.1  reinoud 	 * lmapping contains lb_num relative to base partition.
    336  1.1  reinoud 	 */
    337  1.1  reinoud 	lmapping    = ump->la_lmapping;
    338  1.1  reinoud 	node_ad_cpy = ump->la_node_ad_cpy;
    339  1.1  reinoud 
    340  1.3  reinoud 	/* logically allocate buf and map it in the file */
    341  1.3  reinoud 	udf_late_allocate_buf(ump, buf, lmapping, node_ad_cpy, &vpart_num);
    342  1.1  reinoud 
    343  1.1  reinoud 	/* if we have FIDs, fixup using the new allocation table */
    344  1.1  reinoud 	if (buf->b_udf_c_type == UDF_C_FIDS) {
    345  1.1  reinoud 		buf_len = buf->b_bcount;
    346  1.1  reinoud 		bpos = 0;
    347  1.1  reinoud 		lmappos = lmapping;
    348  1.1  reinoud 		while (buf_len) {
    349  1.1  reinoud 			sectornr = *lmappos++;
    350  1.1  reinoud 			len = MIN(buf_len, sector_size);
    351  1.1  reinoud 			fidblk = (uint8_t *) buf->b_data + bpos;
    352  1.1  reinoud 			udf_fixup_fid_block(fidblk, sector_size,
    353  1.1  reinoud 				0, len, sectornr);
    354  1.1  reinoud 			bpos += len;
    355  1.1  reinoud 			buf_len -= len;
    356  1.1  reinoud 		}
    357  1.1  reinoud 	}
    358  1.3  reinoud 	if (buf->b_udf_c_type == UDF_C_METADATA_SBM) {
    359  1.3  reinoud 		if (buf->b_lblkno == 0) {
    360  1.3  reinoud 			/* update the tag location inside */
    361  1.3  reinoud 			tag = (struct desc_tag *) buf->b_data;
    362  1.4  reinoud 			tag->tag_loc = udf_rw32(*lmapping);
    363  1.3  reinoud 			udf_validate_tag_and_crc_sums(buf->b_data);
    364  1.3  reinoud 		}
    365  1.3  reinoud 	}
    366  1.1  reinoud 	udf_fixup_node_internals(ump, buf->b_data, buf->b_udf_c_type);
    367  1.1  reinoud 
    368  1.3  reinoud 	/*
    369  1.3  reinoud 	 * Translate new mappings in lmapping to pmappings and try to
    370  1.3  reinoud 	 * conglomerate extents to reduce the number of writes.
    371  1.3  reinoud 	 *
    372  1.3  reinoud 	 * pmapping to contain lb_nums as used for disc adressing.
    373  1.3  reinoud 	 */
    374  1.3  reinoud 	pmapping = ump->la_pmapping;
    375  1.3  reinoud 	sectors  = (buf->b_bcount + sector_size -1) / sector_size;
    376  1.3  reinoud 	udf_translate_vtop_list(ump, sectors, vpart_num, lmapping, pmapping);
    377  1.3  reinoud 
    378  1.1  reinoud 	for (sector = 0; sector < sectors; sector++) {
    379  1.1  reinoud 		buf_offset = sector * sector_size;
    380  1.1  reinoud 		DPRINTF(WRITE, ("\tprocessing rel sector %d\n", sector));
    381  1.1  reinoud 
    382  1.1  reinoud 		DPRINTF(WRITE, ("\tissue write sector %"PRIu64"\n",
    383  1.1  reinoud 			pmapping[sector]));
    384  1.1  reinoud 
    385  1.1  reinoud 		run_start  = pmapping[sector];
    386  1.1  reinoud 		run_length = 1;
    387  1.1  reinoud 		while (sector < sectors-1) {
    388  1.1  reinoud 			if (pmapping[sector+1] != pmapping[sector]+1)
    389  1.1  reinoud 				break;
    390  1.1  reinoud 			run_length++;
    391  1.1  reinoud 			sector++;
    392  1.1  reinoud 		}
    393  1.1  reinoud 
    394  1.1  reinoud 		/* nest an iobuf for the extent */
    395  1.1  reinoud 		rbuflen = run_length *  sector_size;
    396  1.1  reinoud 		rblk    = run_start  * (sector_size/DEV_BSIZE);
    397  1.1  reinoud 
    398  1.1  reinoud 		nestbuf = getiobuf(NULL, true);
    399  1.1  reinoud 		nestiobuf_setup(buf, nestbuf, buf_offset, rbuflen);
    400  1.1  reinoud 		/* nestbuf is B_ASYNC */
    401  1.1  reinoud 
    402  1.1  reinoud 		/* identify this nestbuf */
    403  1.1  reinoud 		nestbuf->b_lblkno   = sector;
    404  1.1  reinoud 		assert(nestbuf->b_vp == buf->b_vp);
    405  1.1  reinoud 
    406  1.1  reinoud 		/* CD shedules on raw blkno */
    407  1.1  reinoud 		nestbuf->b_blkno      = rblk;
    408  1.1  reinoud 		nestbuf->b_proc       = NULL;
    409  1.1  reinoud 		nestbuf->b_rawblkno   = rblk;
    410  1.1  reinoud 		nestbuf->b_udf_c_type = UDF_C_PROCESSED;
    411  1.1  reinoud 
    412  1.1  reinoud 		VOP_STRATEGY(ump->devvp, nestbuf);
    413  1.1  reinoud 	}
    414  1.1  reinoud }
    415  1.1  reinoud 
    416  1.1  reinoud 
    417  1.1  reinoud static void
    418  1.1  reinoud udf_discstrat_init_direct(struct udf_strat_args *args)
    419  1.1  reinoud {
    420  1.1  reinoud 	struct udf_mount  *ump = args->ump;
    421  1.1  reinoud 	struct strat_private *priv = PRIV(ump);
    422  1.1  reinoud 	uint32_t lb_size;
    423  1.1  reinoud 
    424  1.1  reinoud 	KASSERT(priv == NULL);
    425  1.1  reinoud 	ump->strategy_private = malloc(sizeof(struct strat_private),
    426  1.1  reinoud 		M_UDFTEMP, M_WAITOK);
    427  1.1  reinoud 	priv = ump->strategy_private;
    428  1.1  reinoud 	memset(priv, 0 , sizeof(struct strat_private));
    429  1.1  reinoud 
    430  1.1  reinoud 	/*
    431  1.1  reinoud 	 * Initialise pool for descriptors associated with nodes. This is done
    432  1.1  reinoud 	 * in lb_size units though currently lb_size is dictated to be
    433  1.1  reinoud 	 * sector_size.
    434  1.1  reinoud 	 */
    435  1.1  reinoud 	memset(&priv->desc_pool, 0, sizeof(struct pool));
    436  1.1  reinoud 
    437  1.1  reinoud 	lb_size = udf_rw32(ump->logical_vol->lb_size);
    438  1.1  reinoud 	pool_init(&priv->desc_pool, lb_size, 0, 0, 0, "udf_desc_pool", NULL,
    439  1.1  reinoud 	    IPL_NONE);
    440  1.1  reinoud }
    441  1.1  reinoud 
    442  1.1  reinoud 
    443  1.1  reinoud static void
    444  1.1  reinoud udf_discstrat_finish_direct(struct udf_strat_args *args)
    445  1.1  reinoud {
    446  1.1  reinoud 	struct udf_mount *ump = args->ump;
    447  1.1  reinoud 	struct strat_private *priv = PRIV(ump);
    448  1.1  reinoud 
    449  1.1  reinoud 	/* destroy our pool */
    450  1.1  reinoud 	pool_destroy(&priv->desc_pool);
    451  1.1  reinoud 
    452  1.1  reinoud 	/* free our private space */
    453  1.1  reinoud 	free(ump->strategy_private, M_UDFTEMP);
    454  1.1  reinoud 	ump->strategy_private = NULL;
    455  1.1  reinoud }
    456  1.1  reinoud 
    457  1.1  reinoud /* --------------------------------------------------------------------- */
    458  1.1  reinoud 
    459  1.1  reinoud struct udf_strategy udf_strat_direct =
    460  1.1  reinoud {
    461  1.1  reinoud 	udf_getblank_nodedscr_direct,
    462  1.1  reinoud 	udf_free_nodedscr_direct,
    463  1.1  reinoud 	udf_read_nodedscr_direct,
    464  1.1  reinoud 	udf_write_nodedscr_direct,
    465  1.1  reinoud 	udf_queue_buf_direct,
    466  1.1  reinoud 	udf_discstrat_init_direct,
    467  1.1  reinoud 	udf_discstrat_finish_direct
    468  1.1  reinoud };
    469  1.1  reinoud 
    470