Deleted Added
full compact
vfs_bio.c (29654) vfs_bio.c (29680)
1/*
2 * Copyright (c) 1994 John S. Dyson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

13 * documentation and/or other materials provided with the distribution.
14 * 3. Absolutely no warranty of function or purpose is made by the author
15 * John S. Dyson.
16 * 4. This work was done expressly for inclusion into FreeBSD. Other use
17 * is allowed if this notation is included.
18 * 5. Modifications may be freely made to this file if the above conditions
19 * are met.
20 *
1/*
2 * Copyright (c) 1994 John S. Dyson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

13 * documentation and/or other materials provided with the distribution.
14 * 3. Absolutely no warranty of function or purpose is made by the author
15 * John S. Dyson.
16 * 4. This work was done expressly for inclusion into FreeBSD. Other use
17 * is allowed if this notation is included.
18 * 5. Modifications may be freely made to this file if the above conditions
19 * are met.
20 *
21 * $Id: vfs_bio.c,v 1.126 1997/09/10 20:09:22 phk Exp $
21 * $Id: vfs_bio.c,v 1.127 1997/09/21 04:49:30 dyson Exp $
22 */
23
24/*
25 * this file contains a new buffer I/O scheme implementing a coherent
26 * VM object and buffer cache scheme. Pains have been taken to make
27 * sure that the performance degradation associated with schemes such
28 * as this is not realized.
29 *

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

378 }
379
380 bp->b_vp->v_numoutput++;
381 vfs_busy_pages(bp, 1);
382 if (curproc != NULL)
383 curproc->p_stats->p_ru.ru_oublock++;
384 VOP_STRATEGY(bp);
385
22 */
23
24/*
25 * this file contains a new buffer I/O scheme implementing a coherent
26 * VM object and buffer cache scheme. Pains have been taken to make
27 * sure that the performance degradation associated with schemes such
28 * as this is not realized.
29 *

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

378 }
379
380 bp->b_vp->v_numoutput++;
381 vfs_busy_pages(bp, 1);
382 if (curproc != NULL)
383 curproc->p_stats->p_ru.ru_oublock++;
384 VOP_STRATEGY(bp);
385
386 /*
387 * Handle ordered writes here.
388 * If the write was originally flagged as ordered,
389 * then we check to see if it was converted to async.
390 * If it was converted to async, and is done now, then
391 * we release the buffer. Otherwise we clear the
392 * ordered flag because it is not needed anymore.
393 *
394 * Note that biodone has been modified so that it does
395 * not release ordered buffers. This allows us to have
396 * a chance to determine whether or not the driver
397 * has set the async flag in the strategy routine. Otherwise
398 * if biodone was not modified, then the buffer may have been
399 * reused before we have had a chance to check the flag.
400 */
401
402 if ((oldflags & B_ORDERED) == B_ORDERED) {
403 int s;
404 s = splbio();
405 if (bp->b_flags & B_ASYNC) {
406 if ((bp->b_flags & B_DONE)) {
407 if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR | B_RELBUF)) != 0)
408 brelse(bp);
409 else
410 bqrelse(bp);
411 }
412 splx(s);
413 return (0);
414 } else {
415 bp->b_flags &= ~B_ORDERED;
416 }
417 splx(s);
418 }
419
420 if ((oldflags & B_ASYNC) == 0) {
421 int rtval = biowait(bp);
422
423 if (oldflags & B_DELWRI) {
424 reassignbuf(bp, bp->b_vp);
425 }
426 brelse(bp);
427 return (rtval);

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

484 * This bmap keeps the system from needing to do the bmap later,
485 * perhaps when the system is attempting to do a sync. Since it
486 * is likely that the indirect block -- or whatever other datastructure
487 * that the filesystem needs is still in memory now, it is a good
488 * thing to do this. Note also, that if the pageout daemon is
489 * requesting a sync -- there might not be enough memory to do
490 * the bmap then... So, this is important to do.
491 */
386 if ((oldflags & B_ASYNC) == 0) {
387 int rtval = biowait(bp);
388
389 if (oldflags & B_DELWRI) {
390 reassignbuf(bp, bp->b_vp);
391 }
392 brelse(bp);
393 return (rtval);

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

450 * This bmap keeps the system from needing to do the bmap later,
451 * perhaps when the system is attempting to do a sync. Since it
452 * is likely that the indirect block -- or whatever other datastructure
453 * that the filesystem needs is still in memory now, it is a good
454 * thing to do this. Note also, that if the pageout daemon is
455 * requesting a sync -- there might not be enough memory to do
456 * the bmap then... So, this is important to do.
457 */
492 if( bp->b_lblkno == bp->b_blkno) {
458 if (bp->b_lblkno == bp->b_blkno) {
493 VOP_BMAP(bp->b_vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL, NULL);
494 }
495
496 /*
497 * Set the *dirty* buffer range based upon the VM system dirty pages.
498 */
499 vfs_setdirty(bp);
500

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

532 * output device cannot guarantee ordering in some other way. Devices
533 * that can perform asynchronous ordered writes will set the B_ASYNC
534 * flag in their strategy routine.
535 * The buffer is released when the output completes.
536 */
537int
538bowrite(struct buf * bp)
539{
459 VOP_BMAP(bp->b_vp, bp->b_lblkno, NULL, &bp->b_blkno, NULL, NULL);
460 }
461
462 /*
463 * Set the *dirty* buffer range based upon the VM system dirty pages.
464 */
465 vfs_setdirty(bp);
466

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

498 * output device cannot guarantee ordering in some other way. Devices
499 * that can perform asynchronous ordered writes will set the B_ASYNC
500 * flag in their strategy routine.
501 * The buffer is released when the output completes.
502 */
503int
504bowrite(struct buf * bp)
505{
506 /*
507 * XXX Add in B_ASYNC once the SCSI
508 * layer can deal with ordered
509 * writes properly.
510 */
540 bp->b_flags |= B_ORDERED;
541 return (VOP_BWRITE(bp));
542}
543
544/*
545 * Release a buffer.
546 */
547void

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

1350
1351 splx(s);
1352 return (struct buf *) NULL;
1353 }
1354 bp->b_flags |= B_BUSY | B_CACHE;
1355 bremfree(bp);
1356
1357 /*
511 bp->b_flags |= B_ORDERED;
512 return (VOP_BWRITE(bp));
513}
514
515/*
516 * Release a buffer.
517 */
518void

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

1321
1322 splx(s);
1323 return (struct buf *) NULL;
1324 }
1325 bp->b_flags |= B_BUSY | B_CACHE;
1326 bremfree(bp);
1327
1328 /*
1358 * check for size inconsistancies (note that they shouldn't happen
1359 * but do when filesystems don't handle the size changes correctly.)
1360 * We are conservative on metadata and don't just extend the buffer
1361 * but write and re-constitute it.
1329 * check for size inconsistancies (note that they shouldn't
1330 * happen but do when filesystems don't handle the size changes
1331 * correctly.) We are conservative on metadata and don't just
1332 * extend the buffer but write and re-constitute it.
1362 */
1363
1364 if (bp->b_bcount != size) {
1365 if ((bp->b_flags & B_VMIO) && (size <= bp->b_kvasize)) {
1366 allocbuf(bp, size);
1367 } else {
1368 bp->b_flags |= B_NOCACHE;
1369 VOP_BWRITE(bp);

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

1896 }
1897 /*
1898 * For asynchronous completions, release the buffer now. The brelse
1899 * checks for B_WANTED and will do the wakeup there if necessary - so
1900 * no need to do a wakeup here in the async case.
1901 */
1902
1903 if (bp->b_flags & B_ASYNC) {
1333 */
1334
1335 if (bp->b_bcount != size) {
1336 if ((bp->b_flags & B_VMIO) && (size <= bp->b_kvasize)) {
1337 allocbuf(bp, size);
1338 } else {
1339 bp->b_flags |= B_NOCACHE;
1340 VOP_BWRITE(bp);

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

1867 }
1868 /*
1869 * For asynchronous completions, release the buffer now. The brelse
1870 * checks for B_WANTED and will do the wakeup there if necessary - so
1871 * no need to do a wakeup here in the async case.
1872 */
1873
1874 if (bp->b_flags & B_ASYNC) {
1904 if ((bp->b_flags & B_ORDERED) == 0) {
1905 if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR | B_RELBUF)) != 0)
1906 brelse(bp);
1907 else
1908 bqrelse(bp);
1909 }
1875 if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR | B_RELBUF)) != 0)
1876 brelse(bp);
1877 else
1878 bqrelse(bp);
1910 } else {
1911 bp->b_flags &= ~B_WANTED;
1912 wakeup(bp);
1913 }
1914 splx(s);
1915}
1916
1917int

--- 373 unchanged lines hidden ---
1879 } else {
1880 bp->b_flags &= ~B_WANTED;
1881 wakeup(bp);
1882 }
1883 splx(s);
1884}
1885
1886int

--- 373 unchanged lines hidden ---