4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2011 Joyent, Inc. All rights reserved.
25 */
26
27 /*
28 * Copyright (c) 2016 by Delphix. All rights reserved.
29 */
30
31 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
32 /* All Rights Reserved */
33
34 /*
35 * University Copyright- Copyright (c) 1982, 1986, 1988
36 * The Regents of the University of California
37 * All Rights Reserved
38 *
39 * University Acknowledgment- Portions of this document are derived from
40 * software developed by the University of California, Berkeley, and its
41 * contributors.
42 */
43
44 #include <sys/types.h>
1363 /* Kernel probe */
1364 TNF_PROBE_3(pagein, "vm pageio io", /* CSTYLED */,
1365 tnf_opaque, vnode, pp->p_vnode,
1366 tnf_offset, offset, pp->p_offset,
1367 tnf_size, size, len);
1368 }
1369
1370 bp = kmem_zalloc(sizeof (struct buf), KM_SLEEP);
1371 bp->b_bcount = len;
1372 bp->b_bufsize = len;
1373 bp->b_pages = pp;
1374 bp->b_flags = B_PAGEIO | B_NOCACHE | B_BUSY | flags;
1375 bp->b_offset = -1;
1376 sema_init(&bp->b_io, 0, NULL, SEMA_DEFAULT, NULL);
1377
1378 /* Initialize bp->b_sem in "locked" state */
1379 sema_init(&bp->b_sem, 0, NULL, SEMA_DEFAULT, NULL);
1380
1381 VN_HOLD(vp);
1382 bp->b_vp = vp;
1383 THREAD_KPRI_RELEASE_N(btopr(len)); /* release kpri from page_locks */
1384
1385 /*
1386 * Caller sets dev & blkno and can adjust
1387 * b_addr for page offset and can use bp_mapin
1388 * to make pages kernel addressable.
1389 */
1390 return (bp);
1391 }
1392
1393 void
1394 pageio_done(struct buf *bp)
1395 {
1396 ASSERT(SEMA_HELD(&bp->b_sem));
1397 if (bp->b_flags & B_REMAPPED)
1398 bp_mapout(bp);
1399 VN_RELE(bp->b_vp);
1400 bp->b_vp = NULL;
1401 ASSERT((bp->b_flags & B_NOCACHE) != 0);
1402
1403 /* A sema_v(bp->b_sem) is implied if we are destroying it */
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 * Copyright 2019 Joyent, Inc.
25 */
26
27 /*
28 * Copyright (c) 2016 by Delphix. All rights reserved.
29 */
30
31 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
32 /* All Rights Reserved */
33
34 /*
35 * University Copyright- Copyright (c) 1982, 1986, 1988
36 * The Regents of the University of California
37 * All Rights Reserved
38 *
39 * University Acknowledgment- Portions of this document are derived from
40 * software developed by the University of California, Berkeley, and its
41 * contributors.
42 */
43
44 #include <sys/types.h>
1363 /* Kernel probe */
1364 TNF_PROBE_3(pagein, "vm pageio io", /* CSTYLED */,
1365 tnf_opaque, vnode, pp->p_vnode,
1366 tnf_offset, offset, pp->p_offset,
1367 tnf_size, size, len);
1368 }
1369
1370 bp = kmem_zalloc(sizeof (struct buf), KM_SLEEP);
1371 bp->b_bcount = len;
1372 bp->b_bufsize = len;
1373 bp->b_pages = pp;
1374 bp->b_flags = B_PAGEIO | B_NOCACHE | B_BUSY | flags;
1375 bp->b_offset = -1;
1376 sema_init(&bp->b_io, 0, NULL, SEMA_DEFAULT, NULL);
1377
1378 /* Initialize bp->b_sem in "locked" state */
1379 sema_init(&bp->b_sem, 0, NULL, SEMA_DEFAULT, NULL);
1380
1381 VN_HOLD(vp);
1382 bp->b_vp = vp;
1383
1384 /*
1385 * Caller sets dev & blkno and can adjust
1386 * b_addr for page offset and can use bp_mapin
1387 * to make pages kernel addressable.
1388 */
1389 return (bp);
1390 }
1391
1392 void
1393 pageio_done(struct buf *bp)
1394 {
1395 ASSERT(SEMA_HELD(&bp->b_sem));
1396 if (bp->b_flags & B_REMAPPED)
1397 bp_mapout(bp);
1398 VN_RELE(bp->b_vp);
1399 bp->b_vp = NULL;
1400 ASSERT((bp->b_flags & B_NOCACHE) != 0);
1401
1402 /* A sema_v(bp->b_sem) is implied if we are destroying it */
|