diff --git a/lib/scsi/scsi_bdev.c b/lib/scsi/scsi_bdev.c index 289d86268..a929ebe42 100644 --- a/lib/scsi/scsi_bdev.c +++ b/lib/scsi/scsi_bdev.c @@ -1221,7 +1221,7 @@ spdk_bdev_scsi_mode_select_page(struct spdk_bdev *bdev, switch (page) { case 0x08: { /* Caching */ - //int wce; + /* int wce; */ SPDK_DEBUGLOG(SPDK_LOG_SCSI, "MODE_SELECT Caching\n"); if (subpage != 0x00) { @@ -1233,22 +1233,24 @@ spdk_bdev_scsi_mode_select_page(struct spdk_bdev *bdev, break; } - // TODO: - //wce = data[2] & 0x4; /* WCE */ + /* TODO: */ +#if 0 + wce = data[2] & 0x4; /* WCE */ - //fd = bdev->fd; - // - //rc = fcntl(fd, F_GETFL, 0); - //if (rc != -1) { - // if (wce) { - // SPDK_DEBUGLOG(SPDK_LOG_SCSI, "MODE_SELECT Writeback cache enable\n"); - // rc = fcntl(fd, F_SETFL, (rc & ~O_FSYNC)); - // bdev->write_cache = 1; - // } else { - // rc = fcntl(fd, F_SETFL, (rc | O_FSYNC)); - // bdev->write_cache = 0; - // } - //} + fd = bdev->fd; + + rc = fcntl(fd, F_GETFL, 0); + if (rc != -1) { + if (wce) { + SPDK_DEBUGLOG(SPDK_LOG_SCSI, "MODE_SELECT Writeback cache enable\n"); + rc = fcntl(fd, F_SETFL, (rc & ~O_FSYNC)); + bdev->write_cache = 1; + } else { + rc = fcntl(fd, F_SETFL, (rc | O_FSYNC)); + bdev->write_cache = 0; + } + } +#endif break; } diff --git a/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c b/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c index 4deb2cec4..a1737f951 100644 --- a/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c +++ b/test/unit/lib/scsi/scsi_bdev.c/scsi_bdev_ut.c @@ -476,8 +476,8 @@ inquiry_evpd_test(void) ut_init_task(&task); cdb[0] = 0x12; - cdb[1] = 0x00; // EVPD = 0 - cdb[2] = 0xff; // PageCode non-zero + cdb[1] = 0x00; /* EVPD = 0 */ + cdb[2] = 0xff; /* PageCode non-zero */ cdb[3] = 0x00; cdb[4] = 0xff; cdb[5] = 0x00; @@ -518,10 +518,10 @@ inquiry_standard_test(void) ut_init_task(&task); cdb[0] = 0x12; - cdb[1] = 0x00; // EVPD = 0 - cdb[2] = 0x00; // PageCode zero - requesting standard inquiry + cdb[1] = 0x00; /* EVPD = 0 */ + cdb[2] = 0x00; /* PageCode zero - requesting standard inquiry */ cdb[3] = 0x00; - cdb[4] = 0xff; // Indicate data size used by conformance test + cdb[4] = 0xff; /* Indicate data size used by conformance test */ cdb[5] = 0x00; task.cdb = cdb; @@ -556,10 +556,10 @@ _inquiry_overflow_test(uint8_t alloc_len) ut_init_task(&task); cdb[0] = 0x12; - cdb[1] = 0x00; // EVPD = 0 - cdb[2] = 0x00; // PageCode zero - requesting standard inquiry + cdb[1] = 0x00; /* EVPD = 0 */ + cdb[2] = 0x00; /* PageCode zero - requesting standard inquiry */ cdb[3] = 0x00; - cdb[4] = alloc_len; // Indicate data size used by conformance test + cdb[4] = alloc_len; /* Indicate data size used by conformance test */ cdb[5] = 0x00; task.cdb = cdb;