Deleted Added
sdiff udiff text old ( 185029 ) new ( 209962 )
full compact
1/*
2 * CDDL HEADER START
3 *
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

--- 5 unchanged lines hidden (view full) ---

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 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26#include <sys/zfs_context.h>
27#include <sys/spa.h>
28#include <sys/vdev_impl.h>
29#include <sys/zio.h>
30#include <sys/avl.h>

--- 12 unchanged lines hidden (view full) ---

43
44/* deadline = pri + (LBOLT >> time_shift) */
45int zfs_vdev_time_shift = 6;
46
47/* exponential I/O issue ramp-up rate */
48int zfs_vdev_ramp_rate = 2;
49
50/*
51 * i/os will be aggregated into a single large i/o up to
52 * zfs_vdev_aggregation_limit bytes long.
53 */
54int zfs_vdev_aggregation_limit = SPA_MAXBLOCKSIZE;
55
56SYSCTL_DECL(_vfs_zfs_vdev);
57TUNABLE_INT("vfs.zfs.vdev.max_pending", &zfs_vdev_max_pending);
58SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, max_pending, CTLFLAG_RDTUN,
59 &zfs_vdev_max_pending, 0, "Maximum I/O requests pending on each device");
60TUNABLE_INT("vfs.zfs.vdev.min_pending", &zfs_vdev_min_pending);
61SYSCTL_INT(_vfs_zfs_vdev, OID_AUTO, min_pending, CTLFLAG_RDTUN,
62 &zfs_vdev_min_pending, 0,

--- 100 unchanged lines hidden (view full) ---

163{
164 avl_remove(&vq->vq_deadline_tree, zio);
165 avl_remove(zio->io_vdev_tree, zio);
166}
167
168static void
169vdev_queue_agg_io_done(zio_t *aio)
170{
171 zio_t *dio;
172 uint64_t offset = 0;
173
174 while ((dio = aio->io_delegate_list) != NULL) {
175 if (aio->io_type == ZIO_TYPE_READ)
176 bcopy((char *)aio->io_data + offset, dio->io_data,
177 dio->io_size);
178 offset += dio->io_size;
179 aio->io_delegate_list = dio->io_delegate_next;
180 dio->io_delegate_next = NULL;
181 dio->io_error = aio->io_error;
182 zio_execute(dio);
183 }
184 ASSERT3U(offset, ==, aio->io_size);
185
186 zio_buf_free(aio->io_data, aio->io_size);
187}
188
189#define IS_ADJACENT(io, nio) \
190 ((io)->io_offset + (io)->io_size == (nio)->io_offset)
191
192static zio_t *
193vdev_queue_io_to_issue(vdev_queue_t *vq, uint64_t pending_limit)
194{
195 zio_t *fio, *lio, *aio, *dio;
196 avl_tree_t *tree;
197 uint64_t size;
198
199 ASSERT(MUTEX_HELD(&vq->vq_lock));
200
201 if (avl_numnodes(&vq->vq_pending_tree) >= pending_limit ||
202 avl_numnodes(&vq->vq_deadline_tree) == 0)
203 return (NULL);
204
205 fio = lio = avl_first(&vq->vq_deadline_tree);
206
207 tree = fio->io_vdev_tree;
208 size = fio->io_size;
209
210 while ((dio = AVL_PREV(tree, fio)) != NULL && IS_ADJACENT(dio, fio) &&
211 !((dio->io_flags | fio->io_flags) & ZIO_FLAG_DONT_AGGREGATE) &&
212 size + dio->io_size <= zfs_vdev_aggregation_limit) {
213 dio->io_delegate_next = fio;
214 fio = dio;
215 size += dio->io_size;
216 }
217
218 while ((dio = AVL_NEXT(tree, lio)) != NULL && IS_ADJACENT(lio, dio) &&
219 !((lio->io_flags | dio->io_flags) & ZIO_FLAG_DONT_AGGREGATE) &&
220 size + dio->io_size <= zfs_vdev_aggregation_limit) {
221 lio->io_delegate_next = dio;
222 lio = dio;
223 size += dio->io_size;
224 }
225
226 if (fio != lio) {
227 char *buf = zio_buf_alloc(size);
228 uint64_t offset = 0;
229
230 ASSERT(size <= zfs_vdev_aggregation_limit);
231
232 aio = zio_vdev_delegated_io(fio->io_vd, fio->io_offset,
233 buf, size, fio->io_type, ZIO_PRIORITY_NOW,
234 ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_QUEUE,
235 vdev_queue_agg_io_done, NULL);
236
237 aio->io_delegate_list = fio;
238
239 for (dio = fio; dio != NULL; dio = dio->io_delegate_next) {
240 ASSERT(dio->io_type == aio->io_type);
241 ASSERT(dio->io_vdev_tree == tree);
242 if (dio->io_type == ZIO_TYPE_WRITE)
243 bcopy(dio->io_data, buf + offset, dio->io_size);
244 offset += dio->io_size;
245 vdev_queue_io_remove(vq, dio);
246 zio_vdev_io_bypass(dio);
247 }
248
249 ASSERT(offset == size);
250
251 avl_add(&vq->vq_pending_tree, aio);
252
253 return (aio);
254 }
255
256 ASSERT(fio->io_vdev_tree == tree);
257 vdev_queue_io_remove(vq, fio);
258
259 avl_add(&vq->vq_pending_tree, fio);
260
261 return (fio);
262}
263
264zio_t *

--- 63 unchanged lines hidden ---