From 0763dc57439009a70623482e714ab61415289bc9 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Tue, 14 Oct 2014 11:47:36 +0200 Subject: [PATCH] libiscsi: Clear PS bit before sending MODE SELECT A quote from SPC-4: "When using the MODE SENSE command, a parameters saveable (PS) bit set to one indicates that the mode page may be saved by the logical unit in a nonvolatile, vendor specific location. A PS bit set to zero indicates that the device server is not able to save the supported parameters. When using the MODE SELECT command, the PS bit is reserved." Hence clear the PS bit after having queried a mode page via MODE SENSE and before changing it via MODE SELECT. Signed-off-by: Bart Van Assche --- test-tool/iscsi-support.c | 6 ++++++ utils/iscsi-swp.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index 2b4c75e..c009d70 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -2461,6 +2461,9 @@ int set_swp(struct scsi_device *sdev) goto finished; } + /* For MODE SELECT PS is reserved and hence must be cleared */ + mp->ps = 0; + logging(LOG_VERBOSE, "Turn SWP ON"); mp->control.swp = 1; @@ -2510,6 +2513,9 @@ int clear_swp(struct scsi_device *sdev) goto finished; } + /* For MODE SELECT PS is reserved and hence must be cleared */ + mp->ps = 0; + logging(LOG_VERBOSE, "Turn SWP OFF"); mp->control.swp = 0; diff --git a/utils/iscsi-swp.c b/utils/iscsi-swp.c index fc34281..c282df4 100644 --- a/utils/iscsi-swp.c +++ b/utils/iscsi-swp.c @@ -206,6 +206,9 @@ int main(int argc, char *argv[]) goto finished; } + /* For MODE SELECT PS is reserved and hence must be cleared */ + mp->ps = 0; + printf("SWP:%d\n", mp->control.swp); switch (swp) {