*/
#include <sys/stat.h>
+#include <sys/utsname.h>
#include <iostream>
#include <string>
using namespace std;
// we need to handle the forking ourselves.
int fd[2] = {0, 0}; // parent's, child's
pid_t childpid = 0;
+ int tester_r = 0;
+ void *tester_rp = NULL;
bool restart_log = false;
if (g_conf->daemonize) {
int r = socketpair(AF_UNIX, SOCK_STREAM, 0, fd);
if (restart_log)
g_ceph_context->_log->start();
+ class RemountTest : public Thread {
+ public:
+ CephFuse *cfuse;
+ Client *client;
+ RemountTest() : Thread() {}
+ void init(CephFuse *cf, Client *cl) {
+ cfuse = cf;
+ client = cl;
+ }
+ virtual ~RemountTest() {}
+ virtual void *entry() {
+ struct utsname os_info;
+ int tr = uname(&os_info);
+ assert(tr == 0);
+ assert(memcmp(os_info.sysname, "Linux", 5) == 0);
+ int major, minor;
+ char *end_num;
+ major = strtol(os_info.release, &end_num, 10);
+ assert(major > 0);
+ ++end_num;
+ minor = strtol(end_num, NULL, 10);
+ bool can_invalidate_dentries = g_conf->client_try_dentry_invalidate &&
+ (major < 3 ||
+ (major == 3 && minor < 18));
+ tr = client->test_dentry_handling(can_invalidate_dentries);
+ if (tr != 0) {
+ cerr << "ceph-fuse[" << getpid()
+ << "]: fuse failed dentry invalidate/remount test with error "
+ << cpp_strerror(tr) << ", stopping" << std::endl;
+
+ char buf[5050];
+ string mountpoint = cfuse->get_mount_point();
+ snprintf(buf, 5049, "fusermount -u -z %s", mountpoint.c_str());
+ system(buf);
+ }
+ return reinterpret_cast<void*>(tr);
+ }
+ } tester;
+
+
// get monmap
Messenger *messenger = NULL;
Client *client;
CephFuse *cfuse;
- MonClient mc(g_ceph_context);
- int r = mc.build_initial_monmap();
+ MonClient *mc = new MonClient(g_ceph_context);
+ int r = mc->build_initial_monmap();
if (r == -EINVAL)
usage();
if (r < 0)
messenger->set_policy(entity_name_t::TYPE_MDS,
Messenger::Policy::lossless_client(0, 0));
- client = new Client(messenger, &mc);
+ client = new Client(messenger, mc);
if (filer_flags) {
client->set_filer_flags(filer_flags);
}
cerr << "ceph-fuse[" << getpid() << "]: fuse failed to start" << std::endl;
goto out_client_unmount;
}
+
cerr << "ceph-fuse[" << getpid() << "]: starting fuse" << std::endl;
+ tester.init(cfuse, client);
+ tester.create();
r = cfuse->loop();
- cerr << "ceph-fuse[" << getpid() << "]: fuse finished with error " << r << std::endl;
-
+ tester.join(&tester_rp);
+ tester_r = static_cast<int>(reinterpret_cast<uint64_t>(tester_rp));
+ cerr << "ceph-fuse[" << getpid() << "]: fuse finished with error " << r
+ << " and tester_r " << tester_r <<std::endl;
+
+
out_client_unmount:
client->unmount();
//cout << "unmounted" << std::endl;
-
+
cfuse->finalize();
delete cfuse;
-
+
out_shutdown:
client->shutdown();
out_init_failed:
out_messenger_start_failed:
delete client;
out_mc_start_failed:
-
+
if (g_conf->daemonize) {
//cout << "child signalling parent with " << r << std::endl;
static int foo = 0;
foo += ::write(fd[1], &r, sizeof(r));
}
-
+
delete messenger;
g_ceph_context->put();
free(newargv);
-
+
+ delete mc;
+
//cout << "child done" << std::endl;
return r;
} else {