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 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
26 * Copyright (c) 2017 by Delphix. All rights reserved.
27 */
28
29 /*
30 * Vnode operations for the High Sierra filesystem
31 */
32
33 #include <sys/types.h>
34 #include <sys/t_lock.h>
35 #include <sys/param.h>
36 #include <sys/time.h>
37 #include <sys/systm.h>
38 #include <sys/sysmacros.h>
39 #include <sys/resource.h>
40 #include <sys/signal.h>
41 #include <sys/cred.h>
42 #include <sys/user.h>
43 #include <sys/buf.h>
44 #include <sys/vfs.h>
45 #include <sys/vfs_opreg.h>
1144 if (hp->hs_ra_bytes > 0 && chunk_data_bytes != PAGESIZE) {
1145 which_chunk_lbn = (off + len) / chunk_data_bytes;
1146 extension = ((which_chunk_lbn + 1) * chunk_data_bytes) - off;
1147 extension -= (extension % PAGESIZE);
1148 } else {
1149 extension = roundup(len, PAGESIZE);
1150 }
1151
1152 atomic_inc_64(&fsp->total_pages_requested);
1153
1154 pp = NULL;
1155 again:
1156 /* search for page in buffer */
1157 if ((pagefound = page_exists(vp, off)) == 0) {
1158 /*
1159 * Need to really do disk IO to get the page.
1160 */
1161 if (!calcdone) {
1162 extension += hp->hs_ra_bytes;
1163
1164 /*
1165 * Some cd writers don't write sectors that aren't
1166 * used. Also, there's no point in reading sectors
1167 * we'll never look at. So, if we're asked to go
1168 * beyond the end of a file, truncate to the length
1169 * of that file.
1170 *
1171 * Additionally, this behaviour is required by section
1172 * 6.4.5 of ISO 9660:1988(E).
1173 */
1174 len = MIN(extension ? extension : PAGESIZE,
1175 filsiz - off);
1176
1177 /* A little paranoia. */
1178 ASSERT(len > 0);
1179
1180 /*
1181 * After all that, make sure we're asking for things
1182 * in units that bdev_strategy() will understand
1183 * (see bug 4202551).
1184 */
1185 len = roundup(len, DEV_BSIZE);
1186 calcdone = 1;
1187 }
1188
1189 pp = pvn_read_kluster(vp, off, seg, addr, &io_off_tmp,
1190 &io_len_tmp, off, len, 0);
1191
1192 if (pp == NULL) {
1193 /*
1194 * Pressure on memory, roll back readahead
1195 */
1196 hp->hs_num_contig = 0;
1197 hp->hs_ra_bytes = 0;
1198 hp->hs_prev_offset = 0;
1199 goto again;
1200 }
1201
1202 io_off = (uint_t)io_off_tmp;
1203 io_len = (uint_t)io_len_tmp;
|
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 /*
23 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
25 * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
26 * Copyright (c) 2017 by Delphix. All rights reserved.
27 */
28
29 /*
30 * Vnode operations for the High Sierra filesystem
31 */
32
33 #include <sys/types.h>
34 #include <sys/t_lock.h>
35 #include <sys/param.h>
36 #include <sys/time.h>
37 #include <sys/systm.h>
38 #include <sys/sysmacros.h>
39 #include <sys/resource.h>
40 #include <sys/signal.h>
41 #include <sys/cred.h>
42 #include <sys/user.h>
43 #include <sys/buf.h>
44 #include <sys/vfs.h>
45 #include <sys/vfs_opreg.h>
1144 if (hp->hs_ra_bytes > 0 && chunk_data_bytes != PAGESIZE) {
1145 which_chunk_lbn = (off + len) / chunk_data_bytes;
1146 extension = ((which_chunk_lbn + 1) * chunk_data_bytes) - off;
1147 extension -= (extension % PAGESIZE);
1148 } else {
1149 extension = roundup(len, PAGESIZE);
1150 }
1151
1152 atomic_inc_64(&fsp->total_pages_requested);
1153
1154 pp = NULL;
1155 again:
1156 /* search for page in buffer */
1157 if ((pagefound = page_exists(vp, off)) == 0) {
1158 /*
1159 * Need to really do disk IO to get the page.
1160 */
1161 if (!calcdone) {
1162 extension += hp->hs_ra_bytes;
1163
1164 len = (extension != 0) ? extension : PAGESIZE;
1165
1166 /*
1167 * Some cd writers don't write sectors that aren't
1168 * used. Also, there's no point in reading sectors
1169 * we'll never look at. So, if we're asked to go
1170 * beyond the end of a file, truncate to the length
1171 * of that file.
1172 *
1173 * Additionally, this behaviour is required by section
1174 * 6.4.5 of ISO 9660:1988(E).
1175 */
1176 if (off < filsiz && off + len > filsiz)
1177 len = filsiz - off;
1178
1179 /*
1180 * After all that, make sure we're asking for things
1181 * in units that bdev_strategy() will understand.
1182 */
1183 len = roundup(len, DEV_BSIZE);
1184 calcdone = 1;
1185 }
1186
1187 pp = pvn_read_kluster(vp, off, seg, addr, &io_off_tmp,
1188 &io_len_tmp, off, len, 0);
1189
1190 if (pp == NULL) {
1191 /*
1192 * Pressure on memory, roll back readahead
1193 */
1194 hp->hs_num_contig = 0;
1195 hp->hs_ra_bytes = 0;
1196 hp->hs_prev_offset = 0;
1197 goto again;
1198 }
1199
1200 io_off = (uint_t)io_off_tmp;
1201 io_len = (uint_t)io_len_tmp;
|