From e84caa437b274e35c4cf0a9b720cd8e5b8595728 Mon Sep 17 00:00:00 2001 From: sageweil Date: Tue, 14 Aug 2007 23:51:31 +0000 Subject: [PATCH] client tweaks, small mds bugfix, improved ll_lookup git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1635 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/mds/client/Client.cc | 51 ++++++++------------- branches/sage/mds/client/FileCache.cc | 22 +++++---- branches/sage/mds/client/SyntheticClient.cc | 4 ++ branches/sage/mds/mds/CDir.cc | 2 +- branches/sage/mds/mds/Locker.cc | 2 +- 5 files changed, 37 insertions(+), 44 deletions(-) diff --git a/branches/sage/mds/client/Client.cc b/branches/sage/mds/client/Client.cc index 6f38f2bf8225e..a903d6417efb5 100644 --- a/branches/sage/mds/client/Client.cc +++ b/branches/sage/mds/client/Client.cc @@ -1370,12 +1370,11 @@ int Client::mount() << " and mdsmap " << mdsmap->get_epoch() << endl; - /* - // hack: get+pin root inode + // hack: get+pin root inode. + // fuse assumes it's always there. Inode *root; _do_lstat("/", STAT_MASK_ALL, &root); _ll_get(root); - */ // trace? if (g_conf.client_trace) { @@ -2890,7 +2889,8 @@ int Client::_write(Fh *f, off_t offset, off_t size, const char *buf) utime_t start = g_clock.real_now(); // copy into fresh buffer (since our write may be resub, async) - bufferptr bp = buffer::copy(buf, size); + bufferptr bp; + if (size > 0) bp = buffer::copy(buf, size); bufferlist blist; blist.push_back( bp ); @@ -3254,55 +3254,40 @@ int Client::ll_lookup(inodeno_t parent, const char *name, struct stat *attr) string dname = name; Inode *diri = 0; + Inode *in = 0; int r = 0; if (inode_map.count(parent) == 0) { - tout << 0 << endl; dout(1) << "ll_lookup " << parent << " " << name << " -> ENOENT (parent DNE... WTF)" << endl; r = -ENOENT; + attr->st_ino = 0; goto out; } diri = inode_map[parent]; if (!diri->inode.is_dir()) { - tout << 0 << endl; dout(1) << "ll_lookup " << parent << " " << name << " -> ENOTDIR (parent not a dir... WTF)" << endl; r = -ENOTDIR; + attr->st_ino = 0; goto out; } - - // refresh the dir? - // FIXME: this is the hackish way. - if (!diri->dir || - diri->dir->dentries.count(dname) == 0) { + // get the inode + if (diri->dir && + diri->dir->dentries.count(dname)) { + in = diri->dir->dentries[dname]->inode; + } else { string path; diri->make_path(path); - DirResult *dirp = new DirResult(path, diri); - - while (1) { - hash H; - dirp->set_frag(diri->dirfragtree[H(dname)]); - - dout(10) << "ll_lookup fetching frag " << dirp->frag() << " for " << name << endl; - int r = _readdir_get_frag(dirp); - if (r < 0) return r; - - if (dirp->buffer.count(diri->dirfragtree[H(dname)])) break; - dirp->buffer.clear(); - } - - _closedir(dirp); + path += "/"; + path += name; + _do_lstat(path.c_str(), 0, &in); } - - // do we have it? - if (diri->dir && - diri->dir->dentries.count(dname)) { - Inode *in = diri->dir->dentries[dname]->inode; + if (in) { fill_stat(in, attr); _ll_get(in); - assert(inode_map[in->inode.ino] == in); } else { r = -ENOENT; + attr->st_ino = 0; } out: @@ -3706,6 +3691,8 @@ int Client::ll_create(inodeno_t parent, const char *name, mode_t mode, int flags Inode *in = (*fhp)->inode; fill_stat(in, attr); _ll_get(in); + } else { + attr->st_ino = 0; } tout << (unsigned long)*fhp << endl; tout << attr->st_ino << endl; diff --git a/branches/sage/mds/client/FileCache.cc b/branches/sage/mds/client/FileCache.cc index 0c5b6b1c9440a..33f1cf4bfd0b8 100644 --- a/branches/sage/mds/client/FileCache.cc +++ b/branches/sage/mds/client/FileCache.cc @@ -232,16 +232,18 @@ void FileCache::write(off_t offset, size_t size, bufferlist& blist, Mutex& clien // inc writing counter num_writing++; - if (latest_caps & CAP_FILE_WRBUFFER) { // caps buffered write? - // wait? (this may block!) - oc->wait_for_write(size, client_lock); - - // async, caching, non-blocking. - oc->file_write(inode, offset, size, blist); - } else { - // atomic, synchronous, blocking. - oc->file_atomic_sync_write(inode, offset, size, blist, client_lock); - } + if (size > 0) { + if (latest_caps & CAP_FILE_WRBUFFER) { // caps buffered write? + // wait? (this may block!) + oc->wait_for_write(size, client_lock); + + // async, caching, non-blocking. + oc->file_write(inode, offset, size, blist); + } else { + // atomic, synchronous, blocking. + oc->file_atomic_sync_write(inode, offset, size, blist, client_lock); + } + } // dec writing counter num_writing--; diff --git a/branches/sage/mds/client/SyntheticClient.cc b/branches/sage/mds/client/SyntheticClient.cc index 6e8b2da099f23..68d3f3daf787c 100644 --- a/branches/sage/mds/client/SyntheticClient.cc +++ b/branches/sage/mds/client/SyntheticClient.cc @@ -830,6 +830,8 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) memset(b, 1, size); // let's write 1's! client->write(fd, b, size, off); delete[] b; + } else { + client->write(fd, NULL, 0, size+off); } } else if (strcmp(op, "truncate") == 0) { const char *a = t.get_string(buf, p); @@ -982,6 +984,8 @@ int SyntheticClient::play_trace(Trace& t, string& prefix, bool metadata_only) bl.push_back(bp); bp.zero(); client->ll_write(fh, off, size, bl.c_str()); + } else { + client->ll_write(fh, off+size, 0, NULL); } } else if (strcmp(op, "ll_release") == 0) { int64_t f = t.get_int(); diff --git a/branches/sage/mds/mds/CDir.cc b/branches/sage/mds/mds/CDir.cc index b74d99c699695..c14d9de225f4f 100644 --- a/branches/sage/mds/mds/CDir.cc +++ b/branches/sage/mds/mds/CDir.cc @@ -931,7 +931,7 @@ void CDir::_fetched(bufferlist &bl) } } } - assert(off == len); + //assert(off == len); no, directories may shrink. add this back in when we properly truncate objects on write. // take the loaded version? // only if we are a fresh CDir* with no prior state. diff --git a/branches/sage/mds/mds/Locker.cc b/branches/sage/mds/mds/Locker.cc index ea87fe8569b0b..653f73154d101 100644 --- a/branches/sage/mds/mds/Locker.cc +++ b/branches/sage/mds/mds/Locker.cc @@ -688,7 +688,7 @@ void Locker::handle_client_file_caps(MClientFileCaps *m) so, we don't want wanted reductions to clobber mds's notion of wanted unless we're sure the client has seen all the latest caps. */ - dout(-10) << "handle_client_file_caps ignoring wanted " << cap_string(m->get_wanted()) + dout(10) << "handle_client_file_caps ignoring wanted " << cap_string(m->get_wanted()) << " bc seq " << m->get_seq() << " < " << cap->get_last_seq() << endl; } else { cap->set_wanted(wanted); -- 2.39.5