Deleted Added
sdiff udiff text old ( 47967 ) new ( 48225 )
full compact
1/*-
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
4 * Modifications/enhancements:
5 * Copyright (c) 1995 John S. Dyson. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)vfs_cluster.c 8.7 (Berkeley) 2/13/94
36 * $Id: vfs_cluster.c,v 1.82 1999/06/16 15:54:30 dg Exp $
37 */
38
39#include "opt_debug_cluster.h"
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/kernel.h>
44#include <sys/proc.h>

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

134 bp->b_flags &= ~B_RAM;
135 /*
136 * We do the spl here so that there is no window
137 * between the incore and the b_usecount increment
138 * below. We opt to keep the spl out of the loop
139 * for efficiency.
140 */
141 s = splbio();
142 for(i=1;i<maxra;i++) {
143
144 if (!(tbp = incore(vp, lblkno+i))) {
145 break;
146 }
147
148 /*
149 * Set another read-ahead mark so we know to check
150 * again.
151 */
152 if (((i % racluster) == (racluster - 1)) ||
153 (i == (maxra - 1)))
154 tbp->b_flags |= B_RAM;
155
156 if ((tbp->b_usecount < 1) &&
157 ((tbp->b_flags & B_BUSY) == 0) &&
158 (tbp->b_qindex == QUEUE_LRU)) {
159 TAILQ_REMOVE(&bufqueues[QUEUE_LRU], tbp, b_freelist);
160 TAILQ_INSERT_TAIL(&bufqueues[QUEUE_LRU], tbp, b_freelist);
161 }
162 }
163 splx(s);
164 if (i >= maxra) {
165 return 0;

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

247#if defined(CLUSTERDEBUG)
248 if (rcluster)
249 printf("S(%ld,%ld,%d) ",
250 (long)bp->b_lblkno, bp->b_bcount, seqcount);
251#endif
252 if ((bp->b_flags & B_CLUSTER) == 0)
253 vfs_busy_pages(bp, 0);
254 bp->b_flags &= ~(B_ERROR|B_INVAL);
255 error = VOP_STRATEGY(vp, bp);
256 curproc->p_stats->p_ru.ru_inblock++;
257 }
258
259 /*
260 * and if we have read-aheads, do them too
261 */
262 if (rbp) {

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

280 (long)(rbp->b_lblkno - origblkno),
281 seqcount);
282 }
283#endif
284
285 if ((rbp->b_flags & B_CLUSTER) == 0)
286 vfs_busy_pages(rbp, 0);
287 rbp->b_flags &= ~(B_ERROR|B_INVAL);
288 (void) VOP_STRATEGY(vp, rbp);
289 curproc->p_stats->p_ru.ru_inblock++;
290 }
291 }
292 if (reqbp)
293 return (biowait(reqbp));
294 else
295 return (error);

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

341 return tbp;
342
343 bp = trypbuf(&cluster_pbuf_freecnt);
344 if (bp == 0)
345 return tbp;
346
347 bp->b_data = (char *)((vm_offset_t)bp->b_data |
348 ((vm_offset_t)tbp->b_data & PAGE_MASK));
349 bp->b_flags = B_ASYNC | B_READ | B_CALL | B_BUSY | B_CLUSTER | B_VMIO;
350 bp->b_iodone = cluster_callback;
351 bp->b_blkno = blkno;
352 bp->b_lblkno = lbn;
353 bp->b_offset = tbp->b_offset;
354 KASSERT(bp->b_offset != NOOFFSET, ("cluster_rbuild: no buffer offset"));
355 pbgetvp(vp, bp);
356
357 TAILQ_INIT(&bp->b_cluster.cluster_head);

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

365 inc = btodb(size);
366 for (bn = blkno, i = 0; i < run; ++i, bn += inc) {
367 if (i != 0) {
368 if ((bp->b_npages * PAGE_SIZE) +
369 round_page(size) > vp->v_maxio)
370 break;
371
372 if ((tbp = incore(vp, lbn + i)) != NULL) {
373 if (tbp->b_flags & B_BUSY)
374 break;
375
376 for (j = 0; j < tbp->b_npages; j++)
377 if (tbp->b_pages[j]->valid)
378 break;
379
380 if (j != tbp->b_npages)
381 break;
382

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

633 int totalwritten = 0;
634 int dbsize = btodb(size);
635
636 if (vp->v_maxio == 0)
637 vp->v_maxio = DFLTPHYS;
638 while (len > 0) {
639 s = splbio();
640 if (((tbp = gbincore(vp, start_lbn)) == NULL) ||
641 ((tbp->b_flags & (B_INVAL|B_BUSY|B_DELWRI)) != B_DELWRI)) {
642 ++start_lbn;
643 --len;
644 splx(s);
645 continue;
646 }
647 bremfree(tbp);
648 tbp->b_flags |= B_BUSY;
649 tbp->b_flags &= ~B_DONE;
650 splx(s);
651
652 /*
653 * Extra memory in the buffer, punt on this buffer.
654 * XXX we could handle this in most cases, but we would
655 * have to push the extra memory down to after our max
656 * possible cluster size and then potentially pull it back

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

682 crhold(bp->b_wcred);
683 }
684
685 bp->b_blkno = tbp->b_blkno;
686 bp->b_lblkno = tbp->b_lblkno;
687 bp->b_offset = tbp->b_offset;
688 bp->b_data = (char *)((vm_offset_t)bp->b_data |
689 ((vm_offset_t)tbp->b_data & PAGE_MASK));
690 bp->b_flags |= B_CALL | B_BUSY | B_CLUSTER |
691 (tbp->b_flags & (B_VMIO | B_NEEDCOMMIT));
692 bp->b_iodone = cluster_callback;
693 pbgetvp(vp, bp);
694 /*
695 * From this location in the file, scan forward to see
696 * if there are buffers with adjacent data that need to
697 * be written as well.
698 */

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

707 splx(s);
708 break;
709 }
710
711 /*
712 * If it IS in core, but has different
713 * characteristics, don't cluster with it.
714 */
715 if ((tbp->b_flags &
716 (B_VMIO | B_CLUSTEROK | B_INVAL | B_BUSY |
717 B_DELWRI | B_NEEDCOMMIT))
718 != (B_DELWRI | B_CLUSTEROK |
719 (bp->b_flags & (B_VMIO | B_NEEDCOMMIT)))) {
720 splx(s);
721 break;
722 }
723
724 if (tbp->b_wcred != bp->b_wcred) {
725 splx(s);
726 break;
727 }
728
729 /*
730 * Check that the combined cluster
731 * would make sense with regard to pages
732 * and would not be too large
733 */
734 if ((tbp->b_bcount != size) ||
735 ((bp->b_blkno + (dbsize * i)) !=
736 tbp->b_blkno) ||
737 ((tbp->b_npages + bp->b_npages) >
738 (vp->v_maxio / PAGE_SIZE))) {
739 splx(s);
740 break;
741 }
742 /*
743 * Ok, it's passed all the tests,
744 * so remove it from the free list
745 * and mark it busy. We will use it.
746 */
747 bremfree(tbp);
748 tbp->b_flags |= B_BUSY;
749 tbp->b_flags &= ~B_DONE;
750 splx(s);
751 } /* end of code for non-first buffers only */
752 /* check for latent dependencies to be handled */
753 if ((LIST_FIRST(&tbp->b_dep)) != NULL &&
754 bioops.io_start)
755 (*bioops.io_start)(tbp);
756 /*

--- 89 unchanged lines hidden ---