From: Frederic Suter Date: Tue, 28 Nov 2017 09:57:52 +0000 (+0100) Subject: expose direct I/O on storage in MSG X-Git-Tag: v3.18~213 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/98ffb5e655112b4d638cc63a48d5fc4c08ee051d?ds=sidebyside expose direct I/O on storage in MSG modify examples to: - illustrate this and only this in io-storage - preserve coverage in io-remote --- diff --git a/examples/msg/io-remote/io-remote.c b/examples/msg/io-remote/io-remote.c index aaece80b15..010afdb4f6 100644 --- a/examples/msg/io-remote/io-remote.c +++ b/examples/msg/io-remote/io-remote.c @@ -64,13 +64,15 @@ int main(int argc, char **argv) xbt_dynar_t storages = MSG_storages_as_dynar(); xbt_dynar_foreach(storages, cur, st){ - XBT_INFO("Init: %llu MiB used on '%s'", MSG_storage_get_used_size(st)/INMEGA, MSG_storage_get_name(st)); + XBT_INFO("Init: %llu/%llu MiB used/free on '%s'", MSG_storage_get_used_size(st) / INMEGA, + MSG_storage_get_free_size(st) / INMEGA, MSG_storage_get_name(st)); } int res = MSG_main(); xbt_dynar_foreach(storages, cur, st){ - XBT_INFO("Init: %llu MiB used on '%s'", MSG_storage_get_used_size(st)/INMEGA, MSG_storage_get_name(st)); + XBT_INFO("End: %llu/%llu MiB used/free on '%s'", MSG_storage_get_used_size(st) / INMEGA, + MSG_storage_get_free_size(st) / INMEGA, MSG_storage_get_name(st)); } xbt_dynar_free(&storages); diff --git a/examples/msg/io-remote/io-remote.tesh b/examples/msg/io-remote/io-remote.tesh index 390369c62f..7dccf88a96 100644 --- a/examples/msg/io-remote/io-remote.tesh +++ b/examples/msg/io-remote/io-remote.tesh @@ -1,8 +1,8 @@ #! ./tesh $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/../msg/io-remote/io-remote_d.xml "--log=root.fmt:[%10.6r]%e(%i@%5h)%e%m%n" -> [ 0.000000] (0@ ) Init: 12 MiB used on 'Disk1' -> [ 0.000000] (0@ ) Init: 2280 MiB used on 'Disk2' +> [ 0.000000] (0@ ) Init: 12/476824 MiB used/free on 'Disk1' +> [ 0.000000] (0@ ) Init: 2280/474556 MiB used/free on 'Disk2' > [ 0.000000] (1@alice) Opened file 'c:\Windows\setupact.log' > [ 0.000000] (1@alice) File Descriptor information: > Full path: 'c:\Windows\setupact.log' @@ -59,6 +59,6 @@ $ ${bindir:=.}/io-remote$EXEEXT ${srcdir:=.}/storage/remote_io.xml ${srcdir:=.}/ > [ 0.528211] (4@ dave) Move 'c:\Windows\Professional.xml' (of size 32646144) from 'dave' to 'carl' > [ 0.819921] (2@ bob) Have written 17436672 bytes to '/scratch/doc/simgrid/examples/platforms/g5k.xml'. > [ 0.819921] (2@ bob) Copy '/scratch/doc/simgrid/examples/platforms/g5k.xml' (of size 17436672) from 'bob' to 'alice' -> [ 1.843969] (0@ ) Init: 60 MiB used on 'Disk1' -> [ 1.843969] (0@ ) Init: 2297 MiB used on 'Disk2' +> [ 1.843969] (0@ ) End: 60/476776 MiB used/free on 'Disk1' +> [ 1.843969] (0@ ) End: 2297/474539 MiB used/free on 'Disk2' > [ 1.843969] (0@ ) Simulation time 1.84397 diff --git a/examples/msg/io-storage/io-storage.c b/examples/msg/io-storage/io-storage.c index 69d0713305..7d22079814 100644 --- a/examples/msg/io-storage/io-storage.c +++ b/examples/msg/io-storage/io-storage.c @@ -22,67 +22,29 @@ static int host(int argc, char *argv[]){ /* - Retrieve all mount points of current host */ xbt_dict_t storage_list = MSG_host_get_mounted_storage_list(MSG_host_self()); - xbt_dict_foreach(storage_list,cursor,mount_name,storage_name) { + xbt_dict_foreach (storage_list, cursor, mount_name, storage_name) { /* - For each disk mounted on host: - Retrieve disk's information */ XBT_INFO("Storage name: %s, mount name: %s", storage_name, mount_name); storage = MSG_storage_get_by_name(storage_name); - - sg_size_t free_size = MSG_storage_get_free_size(storage); - sg_size_t used_size = MSG_storage_get_used_size(storage); - sg_size_t size = MSG_storage_get_size(storage); - - XBT_INFO("Total size: %llu bytes", size); - XBT_INFO("Free size: %llu bytes", free_size); - XBT_INFO("Used size: %llu bytes", used_size); } xbt_dict_free(&storage_list); - /* - Create a 200,000 bytes file named './tmp/data.txt' on /sd1 */ - char* file_name = xbt_strdup("/home/tmp/data.txt"); + /* - Write 200,000 bytes on Disk4 */ + storage = MSG_storage_get_by_name("Disk4"); /* - Open an non-existing file which amounts to create it. */ - msg_file_t file = MSG_file_open(file_name, NULL); - sg_size_t write = MSG_file_write(file, 200000); // Write 200,000 bytes - XBT_INFO("Create a %llu bytes file named '%s' on /sd1", write, file_name); - MSG_file_dump(file); - - /* - Check that sizes have changed */ - XBT_INFO("Free size: %llu bytes", MSG_storage_get_free_size(storage)); - XBT_INFO("Used size: %llu bytes", MSG_storage_get_used_size(storage)); + sg_size_t write = MSG_storage_write(storage, 200000); // Write 200,000 bytes + XBT_INFO("Wrote %llu bytes on 'Disk4'", write); /* - Retrieve the size of created file and read it completely */ - sg_size_t file_size = MSG_file_get_size(file); - MSG_file_seek(file, 0, SEEK_SET); - sg_size_t read = MSG_file_read(file, file_size); - XBT_INFO("Read %llu bytes on %s", read, file_name); - - /* - Then write 100,000 bytes in tmp/data.txt */ - write = MSG_file_write(file, 100000); // Write 100,000 bytes - XBT_INFO("Write %llu bytes on %s", write, file_name); - MSG_file_dump(file); - - storage_name = xbt_strdup("Disk4"); - storage = MSG_storage_get_by_name(storage_name); - - /* - Move file from ./tmp/data.txt to ./tmp/simgrid.readme */ - XBT_INFO("*** Move '/tmp/data.txt' into '/tmp/simgrid.readme'"); - MSG_file_move(file, "/home/tmp/simgrid.readme"); - - /* - Attach some user data to the file */ - MSG_file_set_data(file, xbt_strdup("777")); - /* - Then retrieve this data */ - char *data = MSG_file_get_data(file); - XBT_INFO("User data attached to the file: %s", data); - xbt_free(data); - - MSG_file_close(file); - free(file_name); + sg_size_t read = MSG_storage_read(storage, 200000); + XBT_INFO("Read %llu bytes on 'Disk4'", read); /* - Attach some user data to disk1 */ - XBT_INFO("*** Get/set data for storage element: %s ***",storage_name); + XBT_INFO("*** Get/set data for storage element: Disk4 ***"); - data = MSG_storage_get_data(storage); + char* data = MSG_storage_get_data(storage); XBT_INFO("Get storage data: '%s'", data); @@ -90,32 +52,13 @@ static int host(int argc, char *argv[]){ data = MSG_storage_get_data(storage); XBT_INFO("Set and get data: '%s'", data); xbt_free(data); - xbt_free(storage_name); - - /* - Finally dump disks contents */ - XBT_INFO("*** Dump content of %s ***",MSG_host_get_name(MSG_host_self())); - xbt_dict_t contents = MSG_host_get_storage_content(MSG_host_self()); // contents is a dict of dicts - xbt_dict_cursor_t curs; - xbt_dict_cursor_t curs2 = NULL; - char* mountname; - xbt_dict_t content; - char* path; - sg_size_t* psize; - xbt_dict_foreach(contents, curs, mountname, content){ - XBT_INFO("Print the content of mount point: %s",mountname); - xbt_dict_foreach (content, curs2, path, psize) { - XBT_INFO("%s size: %llu bytes", path, *psize); - } - xbt_dict_free(&content); - } - xbt_dict_free(&contents); + return 1; } int main(int argc, char *argv[]) { MSG_init(&argc, argv); - MSG_storage_file_system_init(); MSG_create_environment(argv[1]); MSG_function_register("host", host); diff --git a/examples/msg/io-storage/io-storage.tesh b/examples/msg/io-storage/io-storage.tesh index 78cc08df47..2ee80165dd 100644 --- a/examples/msg/io-storage/io-storage.tesh +++ b/examples/msg/io-storage/io-storage.tesh @@ -3,105 +3,10 @@ $ ${bindir:=.}/io-storage$EXEEXT ${srcdir:=.}/storage/storage.xml "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" > [ 0.000000] (1:@denise) *** Storage info on denise *** > [ 0.000000] (1:@denise) Storage name: Disk2, mount name: c: -> [ 0.000000] (1:@denise) Total size: 536870912000 bytes -> [ 0.000000] (1:@denise) Free size: 534479374867 bytes -> [ 0.000000] (1:@denise) Used size: 2391537133 bytes > [ 0.000000] (1:@denise) Storage name: Disk4, mount name: /home -> [ 0.000000] (1:@denise) Total size: 536870912000 bytes -> [ 0.000000] (1:@denise) Free size: 536857690006 bytes -> [ 0.000000] (1:@denise) Used size: 13221994 bytes -> [ 0.003333] (1:@denise) Create a 200000 bytes file named '/home/tmp/data.txt' on /sd1 -> [ 0.003333] (1:@denise) File Descriptor information: -> Full path: '/home/tmp/data.txt' -> Size: 200000 -> Mount point: '/home' -> Storage Id: 'Disk4' -> Storage Type: 'single_SSD' -> File Descriptor Id: 0 -> [ 0.003333] (1:@denise) Free size: 536857490006 bytes -> [ 0.003333] (1:@denise) Used size: 13421994 bytes -> [ 0.004333] (1:@denise) Read 200000 bytes on /home/tmp/data.txt -> [ 0.006000] (1:@denise) Write 100000 bytes on /home/tmp/data.txt -> [ 0.006000] (1:@denise) File Descriptor information: -> Full path: '/home/tmp/data.txt' -> Size: 300000 -> Mount point: '/home' -> Storage Id: 'Disk4' -> Storage Type: 'single_SSD' -> File Descriptor Id: 0 -> [ 0.006000] (1:@denise) *** Move '/tmp/data.txt' into '/tmp/simgrid.readme' -> [ 0.006000] (1:@denise) User data attached to the file: 777 -> [ 0.006000] (1:@denise) *** Get/set data for storage element: Disk4 *** -> [ 0.006000] (1:@denise) Get storage data: '(null)' -> [ 0.006000] (1:@denise) Set and get data: 'Some user data' -> [ 0.006000] (1:@denise) *** Dump content of denise *** -> [ 0.006000] (1:@denise) Print the content of mount point: c: -> [ 0.006000] (1:@denise) \Windows\win.ini size: 92 bytes -> [ 0.006000] (1:@denise) \Windows\mib.bin size: 43131 bytes -> [ 0.006000] (1:@denise) \Windows\DtcInstall.log size: 1955 bytes -> [ 0.006000] (1:@denise) \Windows\vmgcoinstall.log size: 1585 bytes -> [ 0.006000] (1:@denise) \Windows\Starter.xml size: 31537 bytes -> [ 0.006000] (1:@denise) \Windows\_isusr32.dll size: 180320 bytes -> [ 0.006000] (1:@denise) \Windows\winhlp32.exe size: 10752 bytes -> [ 0.006000] (1:@denise) \Windows\setuperr.log size: 0 bytes -> [ 0.006000] (1:@denise) \Windows\system.ini size: 219 bytes -> [ 0.006000] (1:@denise) \Windows\Professional.xml size: 31881 bytes -> [ 0.006000] (1:@denise) \Windows\hapint.exe size: 382056 bytes -> [ 0.006000] (1:@denise) \Windows\regedit.exe size: 159232 bytes -> [ 0.006000] (1:@denise) \Windows\setupact.log size: 101663 bytes -> [ 0.006000] (1:@denise) \Windows\WindowsUpdate.log size: 1518934 bytes -> [ 0.006000] (1:@denise) \Windows\explorer.exe size: 2380944 bytes -> [ 0.006000] (1:@denise) \Windows\DirectX.log size: 10486 bytes -> [ 0.006000] (1:@denise) \Windows\WMSysPr9.prx size: 316640 bytes -> [ 0.006000] (1:@denise) \Windows\PFRO.log size: 6770 bytes -> [ 0.006000] (1:@denise) \Windows\csup.txt size: 12 bytes -> [ 0.006000] (1:@denise) \Windows\WLXPGSS.SCR size: 322048 bytes -> [ 0.006000] (1:@denise) \Windows\avastSS.scr size: 41664 bytes -> [ 0.006000] (1:@denise) \Windows\font1.sii size: 4907 bytes -> [ 0.006000] (1:@denise) \Windows\write.exe size: 10752 bytes -> [ 0.006000] (1:@denise) \Windows\font2.sii size: 8698 bytes -> [ 0.006000] (1:@denise) \Windows\CoreSingleLanguage.xml size: 31497 bytes -> [ 0.006000] (1:@denise) \Windows\dchcfg64.exe size: 335464 bytes -> [ 0.006000] (1:@denise) \Windows\notepad.exe size: 243712 bytes -> [ 0.006000] (1:@denise) \Windows\HelpPane.exe size: 883712 bytes -> [ 0.006000] (1:@denise) \Windows\hh.exe size: 17408 bytes -> [ 0.006000] (1:@denise) \Windows\DPINST.LOG size: 18944 bytes -> [ 0.006000] (1:@denise) \Windows\bfsvc.exe size: 75264 bytes -> [ 0.006000] (1:@denise) \Windows\splwow64.exe size: 126464 bytes -> [ 0.006000] (1:@denise) \Windows\MEMORY.DMP size: 2384027342 bytes -> [ 0.006000] (1:@denise) \Windows\dcmdev64.exe size: 93288 bytes -> [ 0.006000] (1:@denise) \Windows\twain_32.dll size: 50176 bytes -> [ 0.006000] (1:@denise) \Windows\bootstat.dat size: 67584 bytes -> [ 0.006000] (1:@denise) Print the content of mount point: /home -> [ 0.006000] (1:@denise) /include/simix/simix.h size: 13003 bytes -> [ 0.006000] (1:@denise) /include/mc/modelchecker.h size: 96 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/msg/README size: 4805 bytes -> [ 0.006000] (1:@denise) /include/instr/instr.h size: 5750 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/mc_bugged2.c size: 1387 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/html/group__XBT__str.html size: 36192 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/NAS/EP/README size: 347 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/NAS/DT/README size: 999 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/NAS/FT/README size: 276 bytes -> [ 0.006000] (1:@denise) /lib/libsimgrid.so.3.6.2 size: 12710497 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/NAS/sys/README size: 1461 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/msg/alias/masterslave_forwarder_with_alias.c size: 6217 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/NAS/SP/README size: 926 bytes -> [ 0.006000] (1:@denise) /tmp/simgrid.readme size: 300000 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/msg/parallel_task/test_ptask_deployment.xml size: 654 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/msg/icomms/small_platform.xml size: 972 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/NAS/MG/README size: 5465 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/msg/trace/test9.xml size: 598 bytes -> [ 0.006000] (1:@denise) /include/smpi/mpif.h size: 4826 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/NAS/README size: 1857 bytes -> [ 0.006000] (1:@denise) /bin/tesh size: 356434 bytes -> [ 0.006000] (1:@denise) /include/simdag/simdag.h size: 10325 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/xbt/sem_basic.c size: 1970 bytes -> [ 0.006000] (1:@denise) /include/xbt/fifo.h size: 3626 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/NAS/common/randdp.c size: 1441 bytes -> [ 0.006000] (1:@denise) /include/msg/datatypes.h size: 4635 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/NAS/EP/randlc.c size: 3300 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/smpi/NAS/MPI_dummy/README size: 2406 bytes -> [ 0.006000] (1:@denise) /doc/simgrid/examples/platforms/g5k.xml size: 17028 bytes -> [ 0.006000] (1:@denise) /include/surf/simgrid_dtd.h size: 23583 bytes -> [ 0.006000] (1:@denise) /bin/smpicc size: 918 bytes -> [ 0.006000] (0:maestro@) Simulated time: 0.006 +> [ 0.003333] (1:@denise) Wrote 200000 bytes on 'Disk4' +> [ 0.004333] (1:@denise) Read 200000 bytes on 'Disk4' +> [ 0.004333] (1:@denise) *** Get/set data for storage element: Disk4 *** +> [ 0.004333] (1:@denise) Get storage data: '(null)' +> [ 0.004333] (1:@denise) Set and get data: 'Some user data' +> [ 0.004333] (0:maestro@) Simulated time: 0.00433333 diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index b3284ad436..c8af06f4e4 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -246,6 +246,8 @@ XBT_PUBLIC(void *) MSG_storage_get_data(msg_storage_t storage); XBT_PUBLIC(xbt_dict_t) MSG_storage_get_content(msg_storage_t storage); XBT_PUBLIC(sg_size_t) MSG_storage_get_size(msg_storage_t storage); XBT_PUBLIC(const char *) MSG_storage_get_host(msg_storage_t storage); +XBT_PUBLIC(sg_size_t) MSG_storage_read(msg_storage_t storage, sg_size_t size); +XBT_PUBLIC(sg_size_t) MSG_storage_write(msg_storage_t storage, sg_size_t size); /************************** Host handling ***********************************/ XBT_PUBLIC(msg_host_t) MSG_host_by_name(const char *name); diff --git a/src/msg/msg_io.cpp b/src/msg/msg_io.cpp index 10241250d2..394998768c 100644 --- a/src/msg/msg_io.cpp +++ b/src/msg/msg_io.cpp @@ -511,4 +511,14 @@ const char* MSG_storage_get_host(msg_storage_t storage) xbt_assert((storage != nullptr), "Invalid parameters"); return storage->getHost()->getCname(); } + +sg_size_t MSG_storage_read(msg_storage_t storage, sg_size_t size) +{ + return storage->read(size); +} + +sg_size_t MSG_storage_write(msg_storage_t storage, sg_size_t size) +{ + return storage->write(size); +} }