Print this page
5253 kmem_alloc/kmem_zalloc won't fail with KM_SLEEP
5254 getrbuf won't fail with KM_SLEEP


1466 {
1467         struct dk_callback *dc = (void *)bp->b_private;
1468 
1469         (*dc->dkc_callback)(dc->dkc_cookie, geterror(bp));
1470         kmem_free(dc, sizeof (*dc));
1471         freerbuf(bp);
1472         return (0);
1473 }
1474 
1475 static int
1476 bd_flush_write_cache(bd_t *bd, struct dk_callback *dkc)
1477 {
1478         buf_t                   *bp;
1479         struct dk_callback      *dc;
1480         bd_xfer_impl_t          *xi;
1481         int                     rv;
1482 
1483         if (bd->d_ops.o_sync_cache == NULL) {
1484                 return (ENOTSUP);
1485         }
1486         if ((bp = getrbuf(KM_SLEEP)) == NULL) {
1487                 return (ENOMEM);
1488         }
1489         bp->b_resid = 0;
1490         bp->b_bcount = 0;
1491 
1492         xi = bd_xfer_alloc(bd, bp, bd->d_ops.o_sync_cache, KM_SLEEP);
1493         if (xi == NULL) {
1494                 rv = geterror(bp);
1495                 freerbuf(bp);
1496                 return (rv);
1497         }
1498 
1499         /* Make an asynchronous flush, but only if there is a callback */
1500         if (dkc != NULL && dkc->dkc_callback != NULL) {
1501                 /* Make a private copy of the callback structure */
1502                 dc = kmem_alloc(sizeof (*dc), KM_SLEEP);
1503                 *dc = *dkc;
1504                 bp->b_private = dc;
1505                 bp->b_iodone = bd_flush_write_cache_done;
1506 
1507                 bd_submit(bd, xi);
1508                 return (0);




1466 {
1467         struct dk_callback *dc = (void *)bp->b_private;
1468 
1469         (*dc->dkc_callback)(dc->dkc_cookie, geterror(bp));
1470         kmem_free(dc, sizeof (*dc));
1471         freerbuf(bp);
1472         return (0);
1473 }
1474 
1475 static int
1476 bd_flush_write_cache(bd_t *bd, struct dk_callback *dkc)
1477 {
1478         buf_t                   *bp;
1479         struct dk_callback      *dc;
1480         bd_xfer_impl_t          *xi;
1481         int                     rv;
1482 
1483         if (bd->d_ops.o_sync_cache == NULL) {
1484                 return (ENOTSUP);
1485         }
1486         bp = getrbuf(KM_SLEEP);


1487         bp->b_resid = 0;
1488         bp->b_bcount = 0;
1489 
1490         xi = bd_xfer_alloc(bd, bp, bd->d_ops.o_sync_cache, KM_SLEEP);
1491         if (xi == NULL) {
1492                 rv = geterror(bp);
1493                 freerbuf(bp);
1494                 return (rv);
1495         }
1496 
1497         /* Make an asynchronous flush, but only if there is a callback */
1498         if (dkc != NULL && dkc->dkc_callback != NULL) {
1499                 /* Make a private copy of the callback structure */
1500                 dc = kmem_alloc(sizeof (*dc), KM_SLEEP);
1501                 *dc = *dkc;
1502                 bp->b_private = dc;
1503                 bp->b_iodone = bd_flush_write_cache_done;
1504 
1505                 bd_submit(bd, xi);
1506                 return (0);