From: Sage Weil Date: Tue, 1 Apr 2008 15:17:30 +0000 (-0700) Subject: mds: fix O_CREAT on existing file trace behavior X-Git-Tag: v0.2~229^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bc2ad228ab54d219a8bbb21e8c2e643787d26419;p=ceph.git mds: fix O_CREAT on existing file trace behavior --- diff --git a/src/client/SyntheticClient.cc b/src/client/SyntheticClient.cc index f040f520686..61dd8287bbe 100644 --- a/src/client/SyntheticClient.cc +++ b/src/client/SyntheticClient.cc @@ -2626,6 +2626,19 @@ void SyntheticClient::make_dir_mess(const char *basedir, int n) void SyntheticClient::foo() { + if (1) { + dout(0) << "first" << dendl; + int fd = client->open("tester", O_WRONLY|O_CREAT); + client->write(fd, "hi there", 0, 8); + client->close(fd); + dout(0) << "sleep" << dendl; + sleep(10); + dout(0) << "again" << dendl; + fd = client->open("tester", O_WRONLY|O_CREAT); + client->write(fd, "hi there", 0, 8); + client->close(fd); + return; + } if (1) { // open some files srand(0); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 5579e9793a6..c101c943a10 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -676,9 +676,6 @@ void Server::handle_client_request(MClientRequest *req) // they have a high request rate. } - // okay, i want - CInode *ref = 0; - // retry? if (req->get_retry_attempt()) { assert(session); @@ -700,12 +697,6 @@ void Server::handle_client_request(MClientRequest *req) if (!mdr) return; mdr->session = session; - if (ref) { - dout(10) << "inode op on ref " << *ref << dendl; - mdr->ref = ref; - mdr->pin(ref); - } - dispatch_client_request(mdr); return; } @@ -1232,9 +1223,17 @@ CDir *Server::traverse_to_auth_dir(MDRequest *mdr, vector &trace, file CInode* Server::rdlock_path_pin_ref(MDRequest *mdr, bool want_auth) { + dout(10) << "rdlock_path_pin_ref " << *mdr << dendl; + // already got ref? - if (mdr->ref) + if (mdr->ref) { + if (mdr->trace.size()) { + CDentry *last = mdr->trace[mdr->trace.size()-1]; + assert(last->get_inode() == mdr->ref); + } + dout(10) << "rdlock_path_pin_ref had " << *mdr->ref << dendl; return mdr->ref; + } MClientRequest *req = mdr->client_request; @@ -1330,6 +1329,15 @@ CDentry* Server::rdlock_path_xlock_dentry(MDRequest *mdr, bool okexist, bool mus { MClientRequest *req = mdr->client_request; + dout(10) << "rdlock_path_xlock_dentry " << *mdr << dendl; + + if (mdr->ref) { + CDentry *last = mdr->trace[mdr->trace.size()-1]; + assert(last->get_inode() == mdr->ref); + dout(10) << "rdlock_path_xlock_dentry had " << *last << " " << *mdr->ref << dendl; + return last; + } + vector trace; CDir *dir = traverse_to_auth_dir(mdr, trace, req->get_filepath()); if (!dir) return 0; @@ -3900,6 +3908,8 @@ void Server::handle_client_open(MDRequest *mdr) bool need_auth = !file_mode_is_readonly(cmode) || (flags & O_TRUNC); + dout(7) << "open on " << req->get_filepath() << dendl; + CInode *cur = rdlock_path_pin_ref(mdr, need_auth); if (!cur) return; @@ -4123,6 +4133,8 @@ void Server::handle_client_openc(MDRequest *mdr) } // pass to regular open handler. + mdr->trace.push_back(dn); + mdr->ref = dn->get_inode(); handle_client_open(mdr); return; }