[PVFS2-CVS] commit by slang in pvfs2/src/server: small-io.sm module.mk.in pvfs2-server.c pvfs2-server.h

CVS commit program cvs at parl.clemson.edu
Fri Nov 4 02:14:24 EST 2005


Update of /projects/cvsroot/pvfs2/src/server
In directory parlweb:/tmp/cvs-serv6522/src/server

Modified Files:
      Tag: slang-sio-branch
	module.mk.in pvfs2-server.c pvfs2-server.h 
Added Files:
      Tag: slang-sio-branch
	small-io.sm 
Log Message:
small I/O changes in sio branch for now


--- /dev/null	2003-01-30 05:24:37.000000000 -0500
+++ small-io.sm	2005-11-04 02:14:24.000000000 -0500
@@ -0,0 +1,267 @@
+/* 
+ * (C) 2001 Clemson University and The University of Chicago 
+ *
+ * See COPYING in top-level directory.
+ */
+
+/*
+ *  PVFS2 server state machine for driving I/O operations (read and write).
+ */
+
+#include <string.h>
+#include <assert.h>
+
+#include "server-config.h"
+#include "pvfs2-server.h"
+#include "pvfs2-attr.h"
+#include "pvfs2-request.h"
+#include "pint-distribution.h"
+#include "pint-request.h"
+
+#define SMALL_IO_MAX_REGIONS 64
+
+static int small_io_start_job(PINT_server_op *s_op, job_status_s *js_p);
+static int small_io_send_response(PINT_server_op *s_op, job_status_s *js_p);
+static int small_io_cleanup(PINT_server_op *s_op, job_status_s *js_p);
+static int small_io_release(PINT_server_op *s_op, job_status_s *js_p);
+
+%%
+
+machine pvfs2_small_io_sm(
+    prelude,
+    start_job,
+    send_response,
+    release,
+    cleanup)
+{
+    state prelude
+    {
+	jump pvfs2_prelude_sm;
+	success => start_job;
+	default => cleanup;
+    }
+
+    state start_job 
+    {
+        run small_io_start_job;
+	success => send_response;
+        default => cleanup;
+    }
+
+    state send_response
+    {
+        run small_io_send_response;
+        default => release;
+    }
+    
+    state release
+    {
+        run small_io_release;
+        default => cleanup;
+    }
+
+    state cleanup
+    {
+	run small_io_cleanup;
+	default => terminate;
+    }
+}
+
+%%
+
+static int small_io_start_job(PINT_server_op *s_op, job_status_s *js_p)
+{
+    int ret;
+    job_id_t tmp_id;
+    PINT_Request_state * file_req_state;
+    PINT_request_file_data fdata;
+    PINT_Request_result result;
+    PVFS_size sizes[SMALL_IO_MAX_REGIONS];
+    PVFS_offset offsets[SMALL_IO_MAX_REGIONS];
+    struct filesystem_configuration_s * fs_config;
+    struct server_configuration_s * server_config;
+
+    file_req_state = PINT_new_request_state(
+        s_op->req->u.small_io.file_req);
+    fdata.server_nr = s_op->req->u.small_io.server_nr;
+    fdata.server_ct = s_op->req->u.small_io.server_ct;
+    fdata.dist = s_op->req->u.small_io.dist;
+    result.offset_array = offsets;
+    result.size_array = sizes;
+    result.segmax = SMALL_IO_MAX_REGIONS;
+    result.bytes = 0;
+    result.segs = 0;
+
+    fdata.fsize = s_op->ds_attr.b_size;
+    s_op->resp.u.small_io.bstream_size = s_op->ds_attr.b_size;
+    result.bytemax = s_op->req->u.small_io.aggregate_size;
+
+    fdata.extend_flag = 
+        (s_op->req->u.small_io.io_type == PVFS_IO_WRITE) ? 1 : 0;
+
+    /* set io type in response to io type in request.  This is
+     * needed by the client so it konws how to decode the response
+     * appropriately.
+     */
+    s_op->resp.u.small_io.io_type = s_op->req->u.small_io.io_type;
+
+    /* calculate the offsets and sizes in the datafile for the read or write */
+    ret = PINT_process_request(
+        file_req_state,
+        NULL,
+        &fdata,
+        &result,
+        PINT_SERVER);
+    if(ret < 0)
+    {
+        gossip_err("small_io: Failed to process file request\n");
+        js_p->error_code = ret;
+        return 1;
+    }
+ 
+    /* figure out if the fs config has trove data sync turned on or off
+     */
+    server_config = get_server_config_struct();
+    if(!server_config)
+    {
+        gossip_err("small_io: server config is NULL!\n");
+        js_p->error_code = -PVFS_EINVAL;
+        return 1;
+    }
+    
+    fs_config = PINT_config_find_fs_id(
+        server_config, s_op->req->u.small_io.fs_id);
+    if(!fs_config)
+    {
+        gossip_err("small_io: Failed to get filesystem "
+                   "config from fs_id of: %d\n",
+                   s_op->req->u.small_io.fs_id);
+        js_p->error_code = -PVFS_EINVAL;
+        return 1;
+    }
+
+    if(s_op->req->u.small_io.io_type == PVFS_IO_WRITE)
+    {
+        ret = job_trove_bstream_write_list(
+           s_op->req->u.small_io.fs_id,
+           s_op->req->u.small_io.handle,
+           (char **)&s_op->req->u.small_io.buffer,
+           &s_op->req->u.small_io.aggregate_size,
+           1,
+           offsets,
+           sizes,
+           result.segs,
+           &s_op->resp.u.small_io.result_size,
+           (fs_config->trove_sync_data ? TROVE_SYNC : 0),
+           NULL,
+           s_op,
+           0,
+           js_p,
+           &tmp_id,
+           server_job_context);
+        if(ret < 0)
+        {
+            gossip_err("small_io: Failed to post trove bstream write\n");
+        }
+    }
+    else
+    {
+        /* allocate space for the read in the response buffer */
+        s_op->resp.u.small_io.buffer = BMI_memalloc(
+            s_op->addr, s_op->req->u.small_io.aggregate_size, BMI_SEND);
+        if(!s_op->resp.u.small_io.buffer)
+        {
+            js_p->error_code = -PVFS_ENOMEM;
+            return 1;
+        }
+        
+        ret = job_trove_bstream_read_list(
+            s_op->req->u.small_io.fs_id,
+            s_op->req->u.small_io.handle,
+            (char **)&s_op->resp.u.small_io.buffer,
+            &s_op->req->u.small_io.aggregate_size,
+            1,
+            offsets,
+            sizes,
+            result.segs,
+            &s_op->resp.u.small_io.result_size,
+            (fs_config->trove_sync_data ? TROVE_SYNC : 0),
+            NULL,
+            s_op,
+            0,
+            js_p,
+            &tmp_id,
+            server_job_context);
+        if(ret < 0)
+        {
+            gossip_err("small-io: Failed to post trove bstream read\n");
+            js_p->error_code = ret;
+            return 1;
+        }
+    }
+
+    js_p->error_code = 0;
+    return ret;
+}
+
+static int small_io_send_response(PINT_server_op *s_op, job_status_s *js_p)
+{
+    /* trove I/O has completed, so we can send the response */
+    int err;
+    job_id_t tmp_id;
+    struct server_configuration_s * server_config;
+
+    s_op->resp.status = js_p->error_code;
+
+    server_config = get_server_config_struct();
+    err = PINT_encode(&s_op->resp, PINT_ENCODE_RESP, &(s_op->encoded),
+                      s_op->addr, s_op->decoded.enc_type);
+    if(err < 0)
+    {
+        gossip_lerr("small_io: PINT_encode() failure.\n");
+        js_p->error_code = err;
+        return 1;
+    }
+    
+    err = job_bmi_send_list(
+        s_op->addr, s_op->encoded.buffer_list, s_op->encoded.size_list,
+        s_op->encoded.list_count, s_op->encoded.total_size,
+        s_op->tag, s_op->encoded.buffer_type, 0, s_op, 0, js_p,
+        &tmp_id, server_job_context, server_config->server_job_bmi_timeout);
+
+    return err;
+}
+
+static int small_io_release(PINT_server_op *s_op, job_status_s *js_p)
+{
+    int ret = 0;
+    job_id_t i;
+    if(s_op->scheduled_id)
+    {
+        ret = job_req_sched_release(
+            s_op->scheduled_id, s_op, 0, js_p, &i, server_job_context);
+    }
+    return ret;
+}
+
+static int small_io_cleanup(PINT_server_op *s_op, job_status_s *js_p)
+{
+    if(s_op->req->u.small_io.io_type == PVFS_IO_READ &&
+       s_op->resp.u.small_io.buffer)
+    {
+        BMI_memfree(s_op->addr, s_op->resp.u.small_io.buffer, 
+                    s_op->req->u.small_io.aggregate_size, BMI_SEND);
+    }
+
+    return server_state_machine_complete(s_op);
+}
+
+/*
+ * Local variables:
+ *  mode: c
+ *  c-indent-level: 4
+ *  c-basic-offset: 4
+ * End:
+ *
+ * vim: ft=c ts=8 sts=4 sw=4 expandtab
+ */

Index: module.mk.in
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/server/module.mk.in,v
diff -p -u -r1.45 -r1.45.2.1
--- module.mk.in	27 Oct 2005 18:43:10 -0000	1.45
+++ module.mk.in	4 Nov 2005 07:14:24 -0000	1.45.2.1
@@ -18,6 +18,7 @@ ifdef BUILD_SERVER
 		$(DIR)/rmdirent.c \
 		$(DIR)/chdirent.c \
 		$(DIR)/io.c \
+		$(DIR)/small-io.c \
 		$(DIR)/flush.c \
 		$(DIR)/truncate.c\
 		$(DIR)/noop.c \

Index: pvfs2-server.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/server/pvfs2-server.c,v
diff -p -u -r1.193 -r1.193.2.1
--- pvfs2-server.c	27 Oct 2005 18:43:11 -0000	1.193
+++ pvfs2-server.c	4 Nov 2005 07:14:24 -0000	1.193.2.1
@@ -134,203 +134,243 @@ static void remove_pidfile(void);
 /* table of incoming request types and associated parameters */
 struct PINT_server_req_params PINT_server_req_table[] =
 {
+    /* 0 */
     {PVFS_SERV_INVALID,
         "invalid",
         PINT_SERVER_CHECK_INVALID,
         PINT_SERVER_ATTRIBS_REQUIRED,
         NULL},
 
+    /* 1 */
     {PVFS_SERV_CREATE,
         "create",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_create_sm},
 
+    /* 2 */
     {PVFS_SERV_REMOVE,
         "remove",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_remove_sm},
 
+    /* 3 */
     {PVFS_SERV_IO,
         "io",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_io_sm},
 
+    /* 4 */
     {PVFS_SERV_GETATTR,
         "getattr",
         PINT_SERVER_CHECK_ATTR,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_get_attr_sm},
 
+    /* 5 */
     {PVFS_SERV_SETATTR,
         "setattr",
         PINT_SERVER_CHECK_ATTR,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_set_attr_sm},
 
+    /* 6 */
     {PVFS_SERV_LOOKUP_PATH,
         "lookup_path",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_lookup_sm},
 
+    /* 7 */
     {PVFS_SERV_CRDIRENT,
         "crdirent",
         PINT_SERVER_CHECK_CRDIRENT,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_crdirent_sm},
 
+    /* 8 */
     {PVFS_SERV_RMDIRENT,
         "rmdirent",
         PINT_SERVER_CHECK_WRITE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_rmdirent_sm},
 
+    /* 9 */
     {PVFS_SERV_CHDIRENT,
         "chdirent",
         PINT_SERVER_CHECK_WRITE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_chdirent_sm},
 
+    /* 10 */
     {PVFS_SERV_TRUNCATE,
         "truncate",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_truncate_sm},
 
+    /* 11 */
     {PVFS_SERV_MKDIR,
         "mkdir",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_mkdir_sm},
 
+    /* 12 */
     {PVFS_SERV_READDIR,
         "readdir",
         PINT_SERVER_CHECK_READ,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_readdir_sm},
 
+    /* 13 */
     {PVFS_SERV_GETCONFIG,
         "getconfig",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_get_config_sm},
 
+    /* 14 */
     {PVFS_SERV_WRITE_COMPLETION,
         "write_completion",
         PINT_SERVER_CHECK_INVALID,
         PINT_SERVER_ATTRIBS_REQUIRED,
         NULL},
 
+    /* 15 */
     {PVFS_SERV_FLUSH,
         "flush",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_flush_sm},
 
+    /* 16 */
     {PVFS_SERV_MGMT_SETPARAM,
         "mgmt_setparam",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_setparam_sm},
 
+    /* 17 */
     {PVFS_SERV_MGMT_NOOP,
         "mgmt_noop",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_noop_sm},
 
+    /* 18 */
     {PVFS_SERV_STATFS,
         "statfs",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_statfs_sm},
 
+    /* 19 */
     {PVFS_SERV_PERF_UPDATE,
         "perf_update",
         PINT_SERVER_CHECK_INVALID,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_perf_update_sm},
 
+    /* 20 */
     {PVFS_SERV_MGMT_PERF_MON,
         "mgmt_perf_mon",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_perf_mon_sm},
 
+    /* 21 */
     {PVFS_SERV_MGMT_ITERATE_HANDLES,
         "mgmt_iterate_handles",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_iterate_handles_sm},
 
+    /* 22 */
     {PVFS_SERV_MGMT_DSPACE_INFO_LIST,
         "mgmt_dspace_info_list",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         NULL},
 
+    /* 23 */
     {PVFS_SERV_MGMT_EVENT_MON,
         "mgmt_event_mon",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_event_mon_sm},
 
+    /* 24 */
     {PVFS_SERV_MGMT_REMOVE_OBJECT,
         "mgmt-remove-object",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_mgmt_remove_object_sm},
 
+    /* 25 */
     {PVFS_SERV_MGMT_REMOVE_DIRENT,
         "mgmt-remove-dirent",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_mgmt_remove_dirent_sm},
 
+    /* 26 */
     {PVFS_SERV_MGMT_GET_DIRDATA_HANDLE,
         "mgmt-get-dirdata-handle",
         PINT_SERVER_CHECK_NONE,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_mgmt_get_dirdata_handle_sm},
 
+    /* 27 */
     {PVFS_SERV_JOB_TIMER,
         "job_timer",
         PINT_SERVER_CHECK_INVALID,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_job_timer_sm},
 
+    /* 28 */
     {PVFS_SERV_PROTO_ERROR,
         "proto_error",
         PINT_SERVER_CHECK_INVALID,
         PINT_SERVER_ATTRIBS_REQUIRED,
         &pvfs2_proto_error_sm},
 
+    /* 29 */
     {PVFS_SERV_GETEATTR,
         "geteattr",
         PINT_SERVER_CHECK_ATTR,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_get_eattr_sm},
 
+    /* 30 */
     {PVFS_SERV_SETEATTR,
         "seteattr",
         PINT_SERVER_CHECK_ATTR,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_set_eattr_sm},
 
+    /* 31 */
     {PVFS_SERV_DELEATTR,
         "deleattr",
         PINT_SERVER_CHECK_ATTR,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
         &pvfs2_del_eattr_sm},
 
+    /* 32 */
     {PVFS_SERV_LISTEATTR,
         "listeattr",
         PINT_SERVER_CHECK_ATTR,
         PINT_SERVER_ATTRIBS_NOT_REQUIRED,
-        &pvfs2_list_eattr_sm}
+        &pvfs2_list_eattr_sm},
+
+    /* 33 */
+    {PVFS_SERV_SMALL_IO,
+        "small_io",
+        PINT_SERVER_CHECK_NONE,
+        PINT_SERVER_ATTRIBS_NOT_REQUIRED,
+        &pvfs2_small_io_sm}
 };
 
 int main(int argc, char **argv)
@@ -1589,7 +1629,7 @@ static int server_state_machine_start(
     }
 
     s_op->resp.op = s_op->op;
-    return ((s_op->current_state->state_action))(s_op,js_p);
+    return PINT_state_machine_invoke(s_op,js_p);
 }
 
 /* server_state_machine_alloc_noreq()
@@ -1651,7 +1691,7 @@ int server_state_machine_start_noreq(PIN
     if (new_op)
     {
         /* execute first state */
-        ret = new_op->current_state->state_action(new_op, &tmp_status);
+        ret = PINT_state_machine_invoke(new_op, &tmp_status);
         if (ret < 0)
         {
             gossip_lerr("Error: failed to start state machine.\n");

Index: pvfs2-server.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/server/pvfs2-server.h,v
diff -p -u -r1.123 -r1.123.2.1
--- pvfs2-server.h	27 Oct 2005 18:43:11 -0000	1.123
+++ pvfs2-server.h	4 Nov 2005 07:14:24 -0000	1.123.2.1
@@ -413,6 +413,7 @@ extern struct PINT_state_machine_s pvfs2
 extern struct PINT_state_machine_s pvfs2_readdir_sm;
 extern struct PINT_state_machine_s pvfs2_lookup_sm;
 extern struct PINT_state_machine_s pvfs2_io_sm;
+extern struct PINT_state_machine_s pvfs2_small_io_sm;
 extern struct PINT_state_machine_s pvfs2_remove_sm;
 extern struct PINT_state_machine_s pvfs2_mgmt_remove_object_sm;
 extern struct PINT_state_machine_s pvfs2_mgmt_remove_dirent_sm;



More information about the PVFS2-CVS mailing list