ctl_backend_block.c (289702) | ctl_backend_block.c (292384) |
---|---|
1/*- 2 * Copyright (c) 2003 Silicon Graphics International Corp. 3 * Copyright (c) 2009-2011 Spectra Logic Corporation 4 * Copyright (c) 2012 The FreeBSD Foundation 5 * Copyright (c) 2014-2015 Alexander Motin <mav@FreeBSD.org> 6 * All rights reserved. 7 * 8 * Portions of this software were developed by Edward Tomasz Napierala --- 27 unchanged lines hidden (view full) --- 36 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_backend_block.c#5 $ 37 */ 38/* 39 * CAM Target Layer driver backend for block devices. 40 * 41 * Author: Ken Merry <ken@FreeBSD.org> 42 */ 43#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003 Silicon Graphics International Corp. 3 * Copyright (c) 2009-2011 Spectra Logic Corporation 4 * Copyright (c) 2012 The FreeBSD Foundation 5 * Copyright (c) 2014-2015 Alexander Motin <mav@FreeBSD.org> 6 * All rights reserved. 7 * 8 * Portions of this software were developed by Edward Tomasz Napierala --- 27 unchanged lines hidden (view full) --- 36 * $Id: //depot/users/kenm/FreeBSD-test2/sys/cam/ctl/ctl_backend_block.c#5 $ 37 */ 38/* 39 * CAM Target Layer driver backend for block devices. 40 * 41 * Author: Ken Merry <ken@FreeBSD.org> 42 */ 43#include <sys/cdefs.h> |
44__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_backend_block.c 289702 2015-10-21 15:31:26Z mav $"); | 44__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_backend_block.c 292384 2015-12-16 23:39:27Z markj $"); |
45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/kernel.h> 49#include <sys/types.h> 50#include <sys/kthread.h> 51#include <sys/bio.h> 52#include <sys/fcntl.h> --- 552 unchanged lines hidden (view full) --- 605 ctl_set_internal_failure(&io->scsiio, 606 /*sks_valid*/ 1, 607 /*retry_count*/ 0xbad1); 608 } 609 610 ctl_complete_beio(beio); 611} 612 | 45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/kernel.h> 49#include <sys/types.h> 50#include <sys/kthread.h> 51#include <sys/bio.h> 52#include <sys/fcntl.h> --- 552 unchanged lines hidden (view full) --- 605 ctl_set_internal_failure(&io->scsiio, 606 /*sks_valid*/ 1, 607 /*retry_count*/ 0xbad1); 608 } 609 610 ctl_complete_beio(beio); 611} 612 |
613SDT_PROBE_DEFINE1(cbb, kernel, read, file_start, "uint64_t"); 614SDT_PROBE_DEFINE1(cbb, kernel, write, file_start, "uint64_t"); 615SDT_PROBE_DEFINE1(cbb, kernel, read, file_done,"uint64_t"); 616SDT_PROBE_DEFINE1(cbb, kernel, write, file_done, "uint64_t"); | 613SDT_PROBE_DEFINE1(cbb, , read, file_start, "uint64_t"); 614SDT_PROBE_DEFINE1(cbb, , write, file_start, "uint64_t"); 615SDT_PROBE_DEFINE1(cbb, , read, file_done,"uint64_t"); 616SDT_PROBE_DEFINE1(cbb, , write, file_done, "uint64_t"); |
617 618static void 619ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun, 620 struct ctl_be_block_io *beio) 621{ 622 struct ctl_be_block_filedata *file_data; 623 union ctl_io *io; 624 struct uio xuio; --- 8 unchanged lines hidden (view full) --- 633 flags = 0; 634 if (ARGS(io)->flags & CTL_LLF_DPO) 635 flags |= IO_DIRECT; 636 if (beio->bio_cmd == BIO_WRITE && ARGS(io)->flags & CTL_LLF_FUA) 637 flags |= IO_SYNC; 638 639 bzero(&xuio, sizeof(xuio)); 640 if (beio->bio_cmd == BIO_READ) { | 617 618static void 619ctl_be_block_dispatch_file(struct ctl_be_block_lun *be_lun, 620 struct ctl_be_block_io *beio) 621{ 622 struct ctl_be_block_filedata *file_data; 623 union ctl_io *io; 624 struct uio xuio; --- 8 unchanged lines hidden (view full) --- 633 flags = 0; 634 if (ARGS(io)->flags & CTL_LLF_DPO) 635 flags |= IO_DIRECT; 636 if (beio->bio_cmd == BIO_WRITE && ARGS(io)->flags & CTL_LLF_FUA) 637 flags |= IO_SYNC; 638 639 bzero(&xuio, sizeof(xuio)); 640 if (beio->bio_cmd == BIO_READ) { |
641 SDT_PROBE(cbb, kernel, read, file_start, 0, 0, 0, 0, 0); | 641 SDT_PROBE0(cbb, , read, file_start); |
642 xuio.uio_rw = UIO_READ; 643 } else { | 642 xuio.uio_rw = UIO_READ; 643 } else { |
644 SDT_PROBE(cbb, kernel, write, file_start, 0, 0, 0, 0, 0); | 644 SDT_PROBE0(cbb, , write, file_start); |
645 xuio.uio_rw = UIO_WRITE; 646 } 647 xuio.uio_offset = beio->io_offset; 648 xuio.uio_resid = beio->io_len; 649 xuio.uio_segflg = UIO_SYSSPACE; 650 xuio.uio_iov = beio->xiovecs; 651 xuio.uio_iovcnt = beio->num_segs; 652 xuio.uio_td = curthread; --- 26 unchanged lines hidden (view full) --- 679 * 680 * ZFS pays attention to IO_SYNC (which translates into the 681 * Solaris define FRSYNC for zfs_read()) for reads. It 682 * attempts to sync the file before reading. 683 */ 684 error = VOP_READ(be_lun->vn, &xuio, flags, file_data->cred); 685 686 VOP_UNLOCK(be_lun->vn, 0); | 645 xuio.uio_rw = UIO_WRITE; 646 } 647 xuio.uio_offset = beio->io_offset; 648 xuio.uio_resid = beio->io_len; 649 xuio.uio_segflg = UIO_SYSSPACE; 650 xuio.uio_iov = beio->xiovecs; 651 xuio.uio_iovcnt = beio->num_segs; 652 xuio.uio_td = curthread; --- 26 unchanged lines hidden (view full) --- 679 * 680 * ZFS pays attention to IO_SYNC (which translates into the 681 * Solaris define FRSYNC for zfs_read()) for reads. It 682 * attempts to sync the file before reading. 683 */ 684 error = VOP_READ(be_lun->vn, &xuio, flags, file_data->cred); 685 686 VOP_UNLOCK(be_lun->vn, 0); |
687 SDT_PROBE(cbb, kernel, read, file_done, 0, 0, 0, 0, 0); | 687 SDT_PROBE0(cbb, , read, file_done); |
688 if (error == 0 && xuio.uio_resid > 0) { 689 /* 690 * If we red less then requested (EOF), then 691 * we should clean the rest of the buffer. 692 */ 693 s = beio->io_len - xuio.uio_resid; 694 for (i = 0; i < beio->num_segs; i++) { 695 if (s >= beio->sg_segs[i].len) { --- 32 unchanged lines hidden (view full) --- 728 * ZFS pays attention to IO_SYNC (a.k.a. FSYNC or FRSYNC) 729 * for writes. It will flush the transaction from the 730 * cache before returning. 731 */ 732 error = VOP_WRITE(be_lun->vn, &xuio, flags, file_data->cred); 733 VOP_UNLOCK(be_lun->vn, 0); 734 735 vn_finished_write(mountpoint); | 688 if (error == 0 && xuio.uio_resid > 0) { 689 /* 690 * If we red less then requested (EOF), then 691 * we should clean the rest of the buffer. 692 */ 693 s = beio->io_len - xuio.uio_resid; 694 for (i = 0; i < beio->num_segs; i++) { 695 if (s >= beio->sg_segs[i].len) { --- 32 unchanged lines hidden (view full) --- 728 * ZFS pays attention to IO_SYNC (a.k.a. FSYNC or FRSYNC) 729 * for writes. It will flush the transaction from the 730 * cache before returning. 731 */ 732 error = VOP_WRITE(be_lun->vn, &xuio, flags, file_data->cred); 733 VOP_UNLOCK(be_lun->vn, 0); 734 735 vn_finished_write(mountpoint); |
736 SDT_PROBE(cbb, kernel, write, file_done, 0, 0, 0, 0, 0); | 736 SDT_PROBE0(cbb, , write, file_done); |
737 } 738 739 mtx_lock(&be_lun->io_lock); 740 devstat_end_transaction(beio->lun->disk_stats, beio->io_len, 741 beio->ds_tag_type, beio->ds_trans_type, 742 /*now*/ NULL, /*then*/&beio->ds_t0); 743 mtx_unlock(&be_lun->io_lock); 744 --- 119 unchanged lines hidden (view full) --- 864 flags = 0; 865 if (ARGS(io)->flags & CTL_LLF_DPO) 866 flags |= IO_DIRECT; 867 if (beio->bio_cmd == BIO_WRITE && ARGS(io)->flags & CTL_LLF_FUA) 868 flags |= IO_SYNC; 869 870 bzero(&xuio, sizeof(xuio)); 871 if (beio->bio_cmd == BIO_READ) { | 737 } 738 739 mtx_lock(&be_lun->io_lock); 740 devstat_end_transaction(beio->lun->disk_stats, beio->io_len, 741 beio->ds_tag_type, beio->ds_trans_type, 742 /*now*/ NULL, /*then*/&beio->ds_t0); 743 mtx_unlock(&be_lun->io_lock); 744 --- 119 unchanged lines hidden (view full) --- 864 flags = 0; 865 if (ARGS(io)->flags & CTL_LLF_DPO) 866 flags |= IO_DIRECT; 867 if (beio->bio_cmd == BIO_WRITE && ARGS(io)->flags & CTL_LLF_FUA) 868 flags |= IO_SYNC; 869 870 bzero(&xuio, sizeof(xuio)); 871 if (beio->bio_cmd == BIO_READ) { |
872 SDT_PROBE(cbb, kernel, read, file_start, 0, 0, 0, 0, 0); | 872 SDT_PROBE0(cbb, , read, file_start); |
873 xuio.uio_rw = UIO_READ; 874 } else { | 873 xuio.uio_rw = UIO_READ; 874 } else { |
875 SDT_PROBE(cbb, kernel, write, file_start, 0, 0, 0, 0, 0); | 875 SDT_PROBE0(cbb, , write, file_start); |
876 xuio.uio_rw = UIO_WRITE; 877 } 878 xuio.uio_offset = beio->io_offset; 879 xuio.uio_resid = beio->io_len; 880 xuio.uio_segflg = UIO_SYSSPACE; 881 xuio.uio_iov = beio->xiovecs; 882 xuio.uio_iovcnt = beio->num_segs; 883 xuio.uio_td = curthread; --- 14 unchanged lines hidden (view full) --- 898 error = csw->d_read(dev, &xuio, flags); 899 else 900 error = csw->d_write(dev, &xuio, flags); 901 dev_relthread(dev, ref); 902 } else 903 error = ENXIO; 904 905 if (beio->bio_cmd == BIO_READ) | 876 xuio.uio_rw = UIO_WRITE; 877 } 878 xuio.uio_offset = beio->io_offset; 879 xuio.uio_resid = beio->io_len; 880 xuio.uio_segflg = UIO_SYSSPACE; 881 xuio.uio_iov = beio->xiovecs; 882 xuio.uio_iovcnt = beio->num_segs; 883 xuio.uio_td = curthread; --- 14 unchanged lines hidden (view full) --- 898 error = csw->d_read(dev, &xuio, flags); 899 else 900 error = csw->d_write(dev, &xuio, flags); 901 dev_relthread(dev, ref); 902 } else 903 error = ENXIO; 904 905 if (beio->bio_cmd == BIO_READ) |
906 SDT_PROBE(cbb, kernel, read, file_done, 0, 0, 0, 0, 0); | 906 SDT_PROBE0(cbb, , read, file_done); |
907 else | 907 else |
908 SDT_PROBE(cbb, kernel, write, file_done, 0, 0, 0, 0, 0); | 908 SDT_PROBE0(cbb, , write, file_done); |
909 910 mtx_lock(&be_lun->io_lock); 911 devstat_end_transaction(beio->lun->disk_stats, beio->io_len, 912 beio->ds_tag_type, beio->ds_trans_type, 913 /*now*/ NULL, /*then*/&beio->ds_t0); 914 mtx_unlock(&be_lun->io_lock); 915 916 /* --- 579 unchanged lines hidden (view full) --- 1496 ctl_be_block_cw_dispatch_unmap(be_lun, io); 1497 break; 1498 default: 1499 panic("Unhandled CDB type %#x", io->scsiio.cdb[0]); 1500 break; 1501 } 1502} 1503 | 909 910 mtx_lock(&be_lun->io_lock); 911 devstat_end_transaction(beio->lun->disk_stats, beio->io_len, 912 beio->ds_tag_type, beio->ds_trans_type, 913 /*now*/ NULL, /*then*/&beio->ds_t0); 914 mtx_unlock(&be_lun->io_lock); 915 916 /* --- 579 unchanged lines hidden (view full) --- 1496 ctl_be_block_cw_dispatch_unmap(be_lun, io); 1497 break; 1498 default: 1499 panic("Unhandled CDB type %#x", io->scsiio.cdb[0]); 1500 break; 1501 } 1502} 1503 |
1504SDT_PROBE_DEFINE1(cbb, kernel, read, start, "uint64_t"); 1505SDT_PROBE_DEFINE1(cbb, kernel, write, start, "uint64_t"); 1506SDT_PROBE_DEFINE1(cbb, kernel, read, alloc_done, "uint64_t"); 1507SDT_PROBE_DEFINE1(cbb, kernel, write, alloc_done, "uint64_t"); | 1504SDT_PROBE_DEFINE1(cbb, , read, start, "uint64_t"); 1505SDT_PROBE_DEFINE1(cbb, , write, start, "uint64_t"); 1506SDT_PROBE_DEFINE1(cbb, , read, alloc_done, "uint64_t"); 1507SDT_PROBE_DEFINE1(cbb, , write, alloc_done, "uint64_t"); |
1508 1509static void 1510ctl_be_block_next(struct ctl_be_block_io *beio) 1511{ 1512 struct ctl_be_block_lun *be_lun; 1513 union ctl_io *io; 1514 1515 io = beio->io; --- 28 unchanged lines hidden (view full) --- 1544 int i; 1545 1546 softc = be_lun->softc; 1547 1548 DPRINTF("entered\n"); 1549 1550 lbalen = ARGS(io); 1551 if (lbalen->flags & CTL_LLF_WRITE) { | 1508 1509static void 1510ctl_be_block_next(struct ctl_be_block_io *beio) 1511{ 1512 struct ctl_be_block_lun *be_lun; 1513 union ctl_io *io; 1514 1515 io = beio->io; --- 28 unchanged lines hidden (view full) --- 1544 int i; 1545 1546 softc = be_lun->softc; 1547 1548 DPRINTF("entered\n"); 1549 1550 lbalen = ARGS(io); 1551 if (lbalen->flags & CTL_LLF_WRITE) { |
1552 SDT_PROBE(cbb, kernel, write, start, 0, 0, 0, 0, 0); | 1552 SDT_PROBE0(cbb, , write, start); |
1553 } else { | 1553 } else { |
1554 SDT_PROBE(cbb, kernel, read, start, 0, 0, 0, 0, 0); | 1554 SDT_PROBE0(cbb, , read, start); |
1555 } 1556 1557 beio = ctl_alloc_beio(softc); 1558 beio->io = io; 1559 beio->lun = be_lun; 1560 bptrlen = PRIV(io); 1561 bptrlen->ptr = (void *)beio; 1562 --- 70 unchanged lines hidden (view full) --- 1633 io->io_hdr.flags |= CTL_FLAG_ALLOCATED; 1634 1635 /* 1636 * For the read case, we need to read the data into our buffers and 1637 * then we can send it back to the user. For the write case, we 1638 * need to get the data from the user first. 1639 */ 1640 if (beio->bio_cmd == BIO_READ) { | 1555 } 1556 1557 beio = ctl_alloc_beio(softc); 1558 beio->io = io; 1559 beio->lun = be_lun; 1560 bptrlen = PRIV(io); 1561 bptrlen->ptr = (void *)beio; 1562 --- 70 unchanged lines hidden (view full) --- 1633 io->io_hdr.flags |= CTL_FLAG_ALLOCATED; 1634 1635 /* 1636 * For the read case, we need to read the data into our buffers and 1637 * then we can send it back to the user. For the write case, we 1638 * need to get the data from the user first. 1639 */ 1640 if (beio->bio_cmd == BIO_READ) { |
1641 SDT_PROBE(cbb, kernel, read, alloc_done, 0, 0, 0, 0, 0); | 1641 SDT_PROBE0(cbb, , read, alloc_done); |
1642 be_lun->dispatch(be_lun, beio); 1643 } else { | 1642 be_lun->dispatch(be_lun, beio); 1643 } else { |
1644 SDT_PROBE(cbb, kernel, write, alloc_done, 0, 0, 0, 0, 0); | 1644 SDT_PROBE0(cbb, , write, alloc_done); |
1645#ifdef CTL_TIME_IO 1646 getbinuptime(&io->io_hdr.dma_start_bt); 1647#endif 1648 ctl_datamove(io); 1649 } 1650} 1651 1652static void --- 1228 unchanged lines hidden --- | 1645#ifdef CTL_TIME_IO 1646 getbinuptime(&io->io_hdr.dma_start_bt); 1647#endif 1648 ctl_datamove(io); 1649 } 1650} 1651 1652static void --- 1228 unchanged lines hidden --- |