Commit 511e22ca authored by Rob Latham's avatar Rob Latham
Browse files

a 'declare' operation

parent 66e130ff
......@@ -87,6 +87,12 @@ int bv_delete(bv_client_t client, const char *filename);
/* getting file size: on parallel file system file size is expensive so make this a separate routine */
ssize_t bv_getsize(bv_client_t client, const char *filename);
/* operations are on descriptive names but in some situations one might want
* to separate the lookup, creation, or other overheads from the I/O overheads
*/
#define BV_NOCREATE 0
int bv_declare(bv_client_t client, const char *filename, int flags, int mode);
#ifdef __cplusplus
}
#endif
......
......@@ -26,6 +26,7 @@ struct bv_client {
tl::remote_procedure flush_op;
tl::remote_procedure statistics_op;
tl::remote_procedure size_op;
tl::remote_procedure declare_op;
ssg_group_id_t gid; // attaches to this group; not a member
io_stats statistics;
......@@ -48,6 +49,7 @@ struct bv_client {
flush_op(engine->define("flush")),
statistics_op(engine->define("statistics")),
size_op(engine->define("size")),
declare_op(engine->define("declare")),
gid(group) {}
};
......@@ -287,3 +289,18 @@ ssize_t bv_getsize(bv_client_t client, const char *filename)
return size;
}
int bv_declare(bv_client_t client, const char *filename, int flags, int mode)
{
std::vector<tl::async_response> responses;
for (auto target : client->targets)
responses.push_back(client->declare_op.on(target).async(std::string(filename), flags, mode));
int ret = 0;
int result = 0;
for (auto &r : responses) {
result = r.wait();
ret += result;
}
return ret;
}
......@@ -38,16 +38,17 @@ struct bv_svc_provider : public tl::provider<bv_svc_provider>
char *buffer; // intermediate buffer for read/write operations
unsigned int bufsize;
struct io_stats stats;
static const int default_mode = 0644;
tl::mutex op_mutex;
tl::mutex stats_mutex;
// server will maintain a cache of open files
// std::map not great for LRU
int getfd(const std::string &file, int flags) {
int getfd(const std::string &file, int flags, int mode=default_mode) {
int fd=-1;
auto entry = filetable.find(file);
if (entry == filetable.end() ) {
fd = abt_io_open(abt_id, file.c_str(), flags, 0644);
fd = abt_io_open(abt_id, file.c_str(), flags, mode);
filetable[file] = fd;
} else {
fd = entry->second;
......@@ -304,6 +305,15 @@ struct bv_svc_provider : public tl::provider<bv_svc_provider>
lseek(fd, oldpos, SEEK_SET);
return pos;
}
/* operations are on descriptive names but in some situations one might
* want to separate the lookup, creation, or other overheads from the I/O
* overheads */
int declare(const std::string &file, int flags, int mode)
{
int fd = getfd(file, flags, mode);
if (fd == -1) return -errno;
return 1;
}
bv_svc_provider(tl::engine *e, abt_io_instance_id abtio,
......@@ -319,6 +329,7 @@ struct bv_svc_provider : public tl::provider<bv_svc_provider>
define("flush", &bv_svc_provider::flush);
define("statistics", &bv_svc_provider::statistics);
define("size", &bv_svc_provider::getsize);
define("declare", &bv_svc_provider::declare);
}
void dump_io_req(const std::string extra, tl::bulk &client_bulk, std::vector<off_t> &file_starts, std::vector<uint64_t> &file_sizes)
......
......@@ -5,6 +5,11 @@
#include <bv.h>
#include <mpi.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define VERBOSE 1
int main(int argc, char **argv)
......@@ -21,16 +26,19 @@ int main(int argc, char **argv)
char *filename;
ssize_t filesize;
#if 0
printf("delete:\n");
bv_delete(client, filename);
#endif
if (argc == 3)
filename = argv[2];
else
filename = "dummy";
printf("delete:\n");
bv_delete(client, filename);
ret = bv_declare(client, filename, O_RDWR|O_CREAT, 0644);
if (ret != 0) printf("Error in bv_declare\n");
ret -= 1;
printf("stat:");
bv_stat(client, filename, &stats);
printf("got blocksize %ld stripe_count: %d stripe_size: %d from provider\n",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment