From 95be0dc46778a6473d1f92ce93f6418d7241819b Mon Sep 17 00:00:00 2001 From: sageweil Date: Sat, 3 Mar 2007 01:58:35 +0000 Subject: [PATCH] client describe_layout interface; monitorstore fuse-changes-cwd workaround; osdc debug printer cleanup git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1167 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/client/Client.cc | 59 +++++++++++++++++++++++++++++++++ trunk/ceph/client/Client.h | 9 ++++- trunk/ceph/client/fuse.cc | 5 ++- trunk/ceph/config.cc | 1 + trunk/ceph/config.h | 1 + trunk/ceph/fakefuse.cc | 3 ++ trunk/ceph/mon/Monitor.cc | 6 ++-- trunk/ceph/mon/MonitorStore.cc | 11 +++++- trunk/ceph/osd/OSD.cc | 2 +- trunk/ceph/osdc/Filer.cc | 2 +- trunk/ceph/osdc/Journaler.cc | 4 +-- trunk/ceph/osdc/ObjectCacher.cc | 4 +-- trunk/ceph/osdc/Objecter.cc | 4 +-- 13 files changed, 97 insertions(+), 14 deletions(-) diff --git a/trunk/ceph/client/Client.cc b/trunk/ceph/client/Client.cc index 4c1edd0afa1..72de4379443 100644 --- a/trunk/ceph/client/Client.cc +++ b/trunk/ceph/client/Client.cc @@ -2651,6 +2651,65 @@ int Client::lazyio_synchronize(int fd, off_t offset, size_t count) } +// ========================================= +// layout + + +int Client::describe_layout(int fh, FileLayout *lp) +{ + client_lock.Lock(); + dout(3) << "op: client->describe_layout(" << fh << ");" << endl; + + assert(fh_map.count(fh)); + Fh *f = fh_map[fh]; + Inode *in = f->inode; + + *lp = in->inode.layout; + + client_lock.Unlock(); + return 0; +} + +int Client::get_stripe_unit(int fd) +{ + FileLayout layout; + describe_layout(fd, &layout); + return layout.stripe_size; +} + +int Client::get_stripe_width(int fd) +{ + FileLayout layout; + describe_layout(fd, &layout); + return layout.stripe_size*layout.stripe_count; +} + +int Client::get_stripe_period(int fd) +{ + FileLayout layout; + describe_layout(fd, &layout); + return layout.period(); +} + +int Client::enumerate_layout(int fh, list& result, + off_t length, off_t offset) +{ + client_lock.Lock(); + dout(3) << "op: client->enumerate_layout(" << fh << ", " << length << ", " << offset << ");" << endl; + + assert(fh_map.count(fh)); + Fh *f = fh_map[fh]; + Inode *in = f->inode; + + // map to a list of extents + filer->file_to_extents(in->inode, offset, length, result); + + client_lock.Unlock(); + return 0; +} + + + void Client::ms_handle_failure(Message *m, const entity_inst_t& inst) { entity_name_t dest = inst.name; diff --git a/trunk/ceph/client/Client.h b/trunk/ceph/client/Client.h index acefbe417a1..4ee04f8003f 100644 --- a/trunk/ceph/client/Client.h +++ b/trunk/ceph/client/Client.h @@ -582,8 +582,15 @@ protected: int lazyio_propogate(int fd, off_t offset, size_t count); int lazyio_synchronize(int fd, off_t offset, size_t count); - int describe_layout(char *fn, list& result); + // expose file layout + int describe_layout(int fd, FileLayout* layout); + int get_stripe_unit(int fd); + int get_stripe_width(int fd); + int get_stripe_period(int fd); + int enumerate_layout(int fd, list& result, + off_t length, off_t offset); + // failure void ms_handle_failure(Message*, const entity_inst_t& inst); }; diff --git a/trunk/ceph/client/fuse.cc b/trunk/ceph/client/fuse.cc index 64497820f38..86a2ce36023 100644 --- a/trunk/ceph/client/fuse.cc +++ b/trunk/ceph/client/fuse.cc @@ -276,5 +276,8 @@ int ceph_fuse_main(Client *c, int argc, char *argv[]) // go fuse go cout << "ok, calling fuse_main" << endl; - return fuse_main(newargc, newargv, &ceph_oper); + cout << "cwd was " << get_current_dir_name() << endl; + int r = fuse_main(newargc, newargv, &ceph_oper); + cout << "cwd now " << get_current_dir_name() << endl; + return r; } diff --git a/trunk/ceph/config.cc b/trunk/ceph/config.cc index 207bf2e8236..7fe1ae9b67f 100644 --- a/trunk/ceph/config.cc +++ b/trunk/ceph/config.cc @@ -130,6 +130,7 @@ md_config_t g_conf = { mon_osd_down_out_interval: 5, // seconds mon_lease: 2.000, // seconds mon_stop_with_last_mds: true, + mon_store_abspath: false, // make monitorstore use absolute path (to workaround fakefuse idiocy) // --- client --- client_cache_size: 300, diff --git a/trunk/ceph/config.h b/trunk/ceph/config.h index a39f280d77f..4cdc8b92da9 100644 --- a/trunk/ceph/config.h +++ b/trunk/ceph/config.h @@ -108,6 +108,7 @@ struct md_config_t { int mon_osd_down_out_interval; float mon_lease; bool mon_stop_with_last_mds; + bool mon_store_abspath; // client int client_cache_size; diff --git a/trunk/ceph/fakefuse.cc b/trunk/ceph/fakefuse.cc index f021d83bac0..1b8c5260697 100644 --- a/trunk/ceph/fakefuse.cc +++ b/trunk/ceph/fakefuse.cc @@ -75,6 +75,9 @@ int main(int argc, char **argv) { args = nargs; vec_to_argv(args, argc, argv); + // make monitorstore use abspath, since fuse seems to screw with the cwd + g_conf.mon_store_abspath = true; + MonMap *monmap = new MonMap(g_conf.num_mon); Monitor *mon[g_conf.num_mon]; diff --git a/trunk/ceph/mon/Monitor.cc b/trunk/ceph/mon/Monitor.cc index 57be61def3d..8bf1d2f0cfe 100644 --- a/trunk/ceph/mon/Monitor.cc +++ b/trunk/ceph/mon/Monitor.cc @@ -53,10 +53,10 @@ void Monitor::init() sprintf(s, "mondata/mon%d", whoami); store = new MonitorStore(s); - if (g_conf.mkfs) + if (g_conf.mkfs) store->mkfs(); - else - store->mount(); + + store->mount(); // create osdmon = new OSDMonitor(this, messenger, lock); diff --git a/trunk/ceph/mon/MonitorStore.cc b/trunk/ceph/mon/MonitorStore.cc index 35822d2db4e..5185eb8206d 100644 --- a/trunk/ceph/mon/MonitorStore.cc +++ b/trunk/ceph/mon/MonitorStore.cc @@ -23,7 +23,7 @@ #include #include #include - +#include void MonitorStore::mount() { @@ -35,6 +35,14 @@ void MonitorStore::mount() assert(0); } ::closedir(d); + + if (g_conf.mon_store_abspath) { + // combine it with the cwd, in case fuse screws things up (i.e. fakefuse) + string old = dir; + dir = get_current_dir_name(); + dir += "/"; + dir += old; + } } @@ -99,6 +107,7 @@ void MonitorStore::put_int(version_t val, const char *a, const char *b) sprintf(tfn, "%s.new", fn); int fd = ::open(tfn, O_WRONLY|O_CREAT); + dout(0) << " fd " << fd << " tfn " << tfn << " " << errno << " " << strerror(errno) << " " << get_current_dir_name() << endl; assert(fd > 0); ::fchmod(fd, 0644); ::write(fd, vs, strlen(vs)); diff --git a/trunk/ceph/osd/OSD.cc b/trunk/ceph/osd/OSD.cc index 0d075ff4123..4404822fb5e 100644 --- a/trunk/ceph/osd/OSD.cc +++ b/trunk/ceph/osd/OSD.cc @@ -143,7 +143,7 @@ OSD::OSD(int id, Messenger *m, MonMap *mm, char *dev) : timer(osd_lock) gethostname(hostname,100); sprintf(dev_path, "%s/osd%d", ebofs_base_path, whoami); - + struct stat sta; if (::lstat(dev_path, &sta) != 0) sprintf(dev_path, "%s/osd.%s", ebofs_base_path, hostname); diff --git a/trunk/ceph/osdc/Filer.cc b/trunk/ceph/osdc/Filer.cc index 47094a30568..2a2871e5b9e 100644 --- a/trunk/ceph/osdc/Filer.cc +++ b/trunk/ceph/osdc/Filer.cc @@ -31,7 +31,7 @@ #include "config.h" #undef dout -#define dout(x) if (x <= g_conf.debug || x <= g_conf.debug_filer) cout << g_clock.now() << " " << objecter->messenger->get_myaddr() << ".filer " +#define dout(x) if (x <= g_conf.debug || x <= g_conf.debug_filer) cout << g_clock.now() << " " << objecter->messenger->get_myname() << ".filer " class Filer::C_Probe : public Context { diff --git a/trunk/ceph/osdc/Journaler.cc b/trunk/ceph/osdc/Journaler.cc index 3d9621185d9..c77c7e7d0ab 100644 --- a/trunk/ceph/osdc/Journaler.cc +++ b/trunk/ceph/osdc/Journaler.cc @@ -19,8 +19,8 @@ #include "config.h" #undef dout -#define dout(x) if (x <= g_conf.debug || x <= g_conf.debug_objecter) cout << g_clock.now() << " " << objecter->messenger->get_myaddr() << ".journaler " -#define derr(x) if (x <= g_conf.debug || x <= g_conf.debug_objecter) cerr << g_clock.now() << " " << objecter->messenger->get_myaddr() << ".journaler " +#define dout(x) if (x <= g_conf.debug || x <= g_conf.debug_objecter) cout << g_clock.now() << " " << objecter->messenger->get_myname() << ".journaler " +#define derr(x) if (x <= g_conf.debug || x <= g_conf.debug_objecter) cerr << g_clock.now() << " " << objecter->messenger->get_myname() << ".journaler " diff --git a/trunk/ceph/osdc/ObjectCacher.cc b/trunk/ceph/osdc/ObjectCacher.cc index 46bd1fb416c..cb8db645f49 100644 --- a/trunk/ceph/osdc/ObjectCacher.cc +++ b/trunk/ceph/osdc/ObjectCacher.cc @@ -11,7 +11,7 @@ /*** ObjectCacher::Object ***/ #undef dout -#define dout(l) if (l<=g_conf.debug || l<=g_conf.debug_objectcacher) cout << oc->objecter->messenger->get_myaddr() << ".objectcacher.object(" << oid << ") " +#define dout(l) if (l<=g_conf.debug || l<=g_conf.debug_objectcacher) cout << g_clock.now() << " " << oc->objecter->messenger->get_myname() << ".objectcacher.object(" << oid << ") " ObjectCacher::BufferHead *ObjectCacher::Object::split(BufferHead *bh, off_t off) @@ -371,7 +371,7 @@ ObjectCacher::BufferHead *ObjectCacher::Object::map_write(Objecter::OSDWrite *wr /*** ObjectCacher ***/ #undef dout -#define dout(l) if (l<=g_conf.debug || l<=g_conf.debug_objectcacher) cout << objecter->messenger->get_myaddr() << ".objectcacher " +#define dout(l) if (l<=g_conf.debug || l<=g_conf.debug_objectcacher) cout << g_clock.now() << " " << objecter->messenger->get_myname() << ".objectcacher " /* private */ diff --git a/trunk/ceph/osdc/Objecter.cc b/trunk/ceph/osdc/Objecter.cc index c531a840803..ddd22325747 100644 --- a/trunk/ceph/osdc/Objecter.cc +++ b/trunk/ceph/osdc/Objecter.cc @@ -17,8 +17,8 @@ #include "config.h" #undef dout -#define dout(x) if (x <= g_conf.debug || x <= g_conf.debug_objecter) cout << g_clock.now() << " " << messenger->get_myaddr() << ".objecter " -#define derr(x) if (x <= g_conf.debug || x <= g_conf.debug_objecter) cerr << g_clock.now() << " " << messenger->get_myaddr() << ".objecter " +#define dout(x) if (x <= g_conf.debug || x <= g_conf.debug_objecter) cout << g_clock.now() << " " << messenger->get_myname() << ".objecter " +#define derr(x) if (x <= g_conf.debug || x <= g_conf.debug_objecter) cerr << g_clock.now() << " " << messenger->get_myname() << ".objecter " // messages ------------------------------