- scst_user docs updated
authorvlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Tue, 17 Mar 2009 18:07:36 +0000 (18:07 +0000)
committervlnb <vlnb@d57e44dd-8a1f-0410-8b47-8ef2f437770f>
Tue, 17 Mar 2009 18:07:36 +0000 (18:07 +0000)
 - Added notification about device change in fileio_tgt

git-svn-id: https://scst.svn.sourceforge.net/svnroot/scst/trunk@700 d57e44dd-8a1f-0410-8b47-8ef2f437770f

doc/scst_user_spec.txt
usr/fileio/common.c
usr/fileio/fileio.c

index 2a1d519..a7e0e36 100644 (file)
@@ -829,6 +829,20 @@ SCST_USER_FLUSH_CACHE returns 0 on success or -1 in case of error,
 and errno is set appropriately.
 
 
+               7. SCST_USER_DEVICE_CAPACITY_CHANGED
+
+SCST_USER_DEVICE_CAPACITY_CHANGED - queues CAPACITY DATA HAS CHANGED
+Unit Attention or corresponding Asynchronous Event to the corresponding
+virtual device. It will notify remote initiators, connected to the
+device, and allow them to automatically refresh new device size. You
+should use SCST_USER_DEVICE_CAPACITY_CHANGED after resize of the device.
+
+SCST_USER_DEVICE_CAPACITY_CHANGED doesn't have any parameters.
+
+SCST_USER_DEVICE_CAPACITY_CHANGED returns 0 on success or -1 in case of
+error, and errno is set appropriately.
+
+
                IV. Commands processing flow example.
 
 As the example consider a simple synchronous VTL, which serves one
index 67619d7..3111fb6 100644 (file)
@@ -125,14 +125,18 @@ static inline void set_cmd_error_status(struct scst_user_scsi_cmd_reply_exec *re
 
 static int set_sense(uint8_t *buffer, int len, int key, int asc, int ascq)
 {
-       int res = 14;
+       int res = SCST_STANDARD_SENSE_LEN;
+
        EXTRACHECKS_BUG_ON(len < res);
+
        memset(buffer, 0, res);
+
        buffer[0] = 0x70;       /* Error Code                   */
        buffer[2] = key;        /* Sense Key                    */
        buffer[7] = 0x0a;       /* Additional Sense Length      */
        buffer[12] = asc;       /* ASC                          */
        buffer[13] = ascq;      /* ASCQ                         */
+
        TRACE_BUFFER("Sense set", buffer, res);
        return res;
 }
index b04cbf8..a902d6c 100644 (file)
@@ -189,6 +189,28 @@ out:
        return;
 }
 
+void sigusr1_handler(int signo)
+{
+       int res;
+
+       TRACE_ENTRY();
+
+       TRACE_MGMT_DBG("%s", "Capacity data changed...");
+
+       res = ioctl(dev.scst_usr_fd, SCST_USER_DEVICE_CAPACITY_CHANGED, NULL);
+       if (res != 0) {
+               res = errno;
+               PRINT_ERROR("Capacity data changed failed: %s", strerror(res));
+               goto out;
+       }
+
+       TRACE_DBG("%s", "Capacity data changed done.");
+
+out:
+       TRACE_EXIT();
+       return;
+}
+
 int main(int argc, char **argv)
 {
        int res = 0;
@@ -480,6 +502,19 @@ int main(int argc, char **argv)
                pthread_t thread[threads];
                int i, j, rc;
                void *rc1;
+               struct sigaction act;
+
+               memset(&act, 0, sizeof(act));
+               act.sa_handler = sigusr1_handler;
+               act.sa_flags = SA_RESTART;
+               sigemptyset(&act.sa_mask);
+               res = sigaction(SIGUSR1, &act, NULL);
+               if (res != 0) {
+                       res = errno;
+                       PRINT_ERROR("sigaction() failed: %s",
+                               strerror(res));
+                       /* don't do anything */
+               }       
 
                for(i = 0; i < threads; i++) {
                        rc = pthread_create(&thread[i], NULL, main_loop, &dev);
@@ -492,8 +527,6 @@ int main(int argc, char **argv)
                }
 
                if (flush_interval != 0) {
-                       struct sigaction act;
-
                        memset(&act, 0, sizeof(act));
                        act.sa_handler = sigalrm_handler;
                        act.sa_flags = SA_RESTART;