Author: mav
Date: Thu Feb  6 03:54:58 2014
New Revision: 261538
URL: http://svnweb.freebsd.org/changeset/base/261538

Log:
  Make CTL block backend return proper error code for operations unsupposed
  by the underlying device.
  
  MFC after:    2 weeks

Modified:
  head/sys/cam/ctl/ctl_backend_block.c

Modified: head/sys/cam/ctl/ctl_backend_block.c
==============================================================================
--- head/sys/cam/ctl/ctl_backend_block.c        Thu Feb  6 03:30:12 2014        
(r261537)
+++ head/sys/cam/ctl/ctl_backend_block.c        Thu Feb  6 03:54:58 2014        
(r261538)
@@ -510,6 +510,7 @@ ctl_be_block_biodone(struct bio *bio)
        struct ctl_be_block_io *beio;
        struct ctl_be_block_lun *be_lun;
        union ctl_io *io;
+       int error;
 
        beio = bio->bio_caller1;
        be_lun = beio->lun;
@@ -517,8 +518,9 @@ ctl_be_block_biodone(struct bio *bio)
 
        DPRINTF("entered\n");
 
+       error = bio->bio_error;
        mtx_lock(&be_lun->lock);
-       if (bio->bio_error != 0)
+       if (error != 0)
                beio->num_errors++;
 
        beio->num_bios_done++;
@@ -550,7 +552,9 @@ ctl_be_block_biodone(struct bio *bio)
         * entire I/O with a medium error.
         */
        if (beio->num_errors > 0) {
-               if (beio->bio_cmd == BIO_FLUSH) {
+               if (error == EOPNOTSUPP) {
+                       ctl_set_invalid_opcode(&io->scsiio);
+               } else if (beio->bio_cmd == BIO_FLUSH) {
                        /* XXX KDM is there is a better error here? */
                        ctl_set_internal_failure(&io->scsiio,
                                                 /*sks_valid*/ 1,
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to