From: sage Date: Tue, 5 Jul 2005 20:22:17 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: v0.1~1981 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4c9ee7cd0e326c00d5190d04a1220097959fe77b;p=ceph.git *** empty log message *** git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@400 29311d96-e01e-0410-9327-a35deaab8ce9 --- diff --git a/ceph/include/types.h b/ceph/include/types.h index ea1e70d7d3e..dd9d7164b2a 100644 --- a/ceph/include/types.h +++ b/ceph/include/types.h @@ -92,6 +92,7 @@ struct inode_t { unsigned char hash_seed; // 0 if not hashed. int nlink; bool anchored; + __uint64_t file_data_version; }; diff --git a/ceph/mds/MDCache.cc b/ceph/mds/MDCache.cc index 58c4f5f0cf8..57b651414f2 100644 --- a/ceph/mds/MDCache.cc +++ b/ceph/mds/MDCache.cc @@ -3237,6 +3237,11 @@ void MDCache::handle_rename_notify(MRenameNotify *m) // file i/o ----------------------------------------- +__uint64_t MDCache::issue_file_data_version(CInode *in) +{ + dout(7) << "issue_file_data_version on " << *in << endl; + return in->inode.file_data_version; +} int MDCache::issue_file_caps(CInode *in, @@ -3296,6 +3301,13 @@ int MDCache::issue_file_caps(CInode *in, dout(7) << " issuing caps " << caps << " (i want " << my_want << ", allowed " << allowed << ")" << endl; assert(caps > 0); + // issuing new write permissions? + if ((issued & CFILE_CAP_WR) == 0 && + ( caps & CFILE_CAP_WR) != 0) { + dout(7) << " incrementing file_data_version for " << *in << endl; + in->inode.file_data_version++; + } + return caps; } diff --git a/ceph/mds/MDCache.h b/ceph/mds/MDCache.h index 994f7c31c3e..dafcd638a68 100644 --- a/ceph/mds/MDCache.h +++ b/ceph/mds/MDCache.h @@ -271,6 +271,7 @@ class MDCache { // -- file i/o -- + __uint64_t issue_file_data_version(CInode *in); int issue_file_caps(CInode *in, int mode, MClientRequest *req); void eval_file_caps(CInode *in); void handle_client_file_caps(class MClientFileCaps *m); diff --git a/ceph/mds/MDS.cc b/ceph/mds/MDS.cc index f3440a9de8e..f85f753d185 100644 --- a/ceph/mds/MDS.cc +++ b/ceph/mds/MDS.cc @@ -2258,6 +2258,7 @@ void MDS::handle_client_open(MClientRequest *req, // can we issue the caps they want? + __uint64_t fdv = mdcache->issue_file_data_version(cur); int caps = mdcache->issue_file_caps(cur, mode, req); if (!caps) return; // can't issue (yet), so wait! @@ -2282,6 +2283,7 @@ void MDS::handle_client_open(MClientRequest *req, // reply MClientReply *reply = new MClientReply(req, f->fh); // fh # is return code reply->set_file_caps(caps); + reply->set_file_data_version(fdv); reply_request(req, reply, cur); } @@ -2350,7 +2352,16 @@ void MDS::handle_client_close(MClientRequest *req, CInode *cur) } // atime? **** - + + // were we writing? + int had_caps = f->pending_caps & f->confirmed_caps; // safe set of caps the client can assume it had + + if ((f->confirmed_caps | f->pending_caps) & CFILE_CAP_WR != 0) { + // inc file_data_version + dout(7) << " incrementing file_data_version for " << *cur << endl; + cur->inode.file_data_version++; + } + // close it. cur->remove_fh(f); @@ -2372,8 +2383,15 @@ void MDS::handle_client_close(MClientRequest *req, CInode *cur) // XXX what about atime? + + // give back a file_data_version to client + MClientReply *reply = new MClientReply(req, 0); + __uint64_t fdv = mdcache->issue_file_data_version(cur); + reply->set_file_caps(had_caps); + reply->set_file_data_version(fdv); + // commit - commit_request(req, new MClientReply(req, 0), cur, + commit_request(req, reply, cur, new EInodeUpdate(cur)); // FIXME wrong message? } diff --git a/ceph/messages/MClientReply.h b/ceph/messages/MClientReply.h index da3e8a3489d..dfb316e7531 100644 --- a/ceph/messages/MClientReply.h +++ b/ceph/messages/MClientReply.h @@ -95,6 +95,7 @@ typedef struct { int trace_depth; int dir_size; unsigned char file_caps; // for open + __uint64_t file_data_version; // for client buffercache consistency } MClientReply_st; class MClientReply : public Message { @@ -117,9 +118,11 @@ class MClientReply : public Message { const vector& get_trace() { return trace; } vector& get_dir_contents() { return dir_contents; } unsigned char get_file_caps() { return st.file_caps; } + __uint64_t get_file_data_version() { return st.file_data_version; } void set_result(int r) { st.result = r; } void set_file_caps(unsigned char c) { st.file_caps = c; } + void set_file_data_version(__uint64_t v) { st.file_data_version = v; } MClientReply() {}; MClientReply(MClientRequest *req, int result = 0) :