diff --git a/trunk/ceph/client/fuse.cc b/trunk/ceph/client/fuse.cc index f4a1c2d3f77..2feb7472d1c 100644 --- a/trunk/ceph/client/fuse.cc +++ b/trunk/ceph/client/fuse.cc @@ -177,13 +177,12 @@ static int ceph_write(const char *path, const char *buf, size_t size, return client->write(fh, buf, size, offset); } -/* static int ceph_flush(const char *path, struct fuse_file_info *fi) { - fh_t fh = fi->fh; - return client->flush(fh); +//fh_t fh = fi->fh; + //return client->flush(fh); + return 0; } -*/ static int ceph_statfs(const char *path, struct statvfs *stbuf) @@ -227,7 +226,7 @@ static struct fuse_operations ceph_oper = { read: ceph_read, write: ceph_write, statfs: ceph_statfs, - flush: 0, //ceph_flush, + flush: ceph_flush, release: ceph_release, fsync: ceph_fsync }; diff --git a/trunk/ceph/mds/Capability.h b/trunk/ceph/mds/Capability.h index e011dbe43e8..25e658b0131 100644 --- a/trunk/ceph/mds/Capability.h +++ b/trunk/ceph/mds/Capability.h @@ -71,7 +71,7 @@ public: bool is_suppress() { return suppress; } void set_suppress(bool b) { suppress = b; } - bool is_null() { return cap_history.empty(); } + bool is_null() { return cap_history.empty() && wanted_caps == 0; } // most recently issued caps. int pending() { diff --git a/trunk/ceph/mds/Locker.cc b/trunk/ceph/mds/Locker.cc index d60f58011ef..7b47861331f 100644 --- a/trunk/ceph/mds/Locker.cc +++ b/trunk/ceph/mds/Locker.cc @@ -937,6 +937,8 @@ void Locker::inode_file_read_finish(CInode *in) bool Locker::inode_file_write_start(CInode *in, MClientRequest *m) { + dout(7) << "inode_file_write_start on " << *in << endl; + // can't write? if (!in->filelock.can_write(in->is_auth())) { @@ -990,7 +992,7 @@ bool Locker::inode_file_write_start(CInode *in, MClientRequest *m) void Locker::inode_file_write_finish(CInode *in) { // drop ref - assert(in->filelock.can_write(in->is_auth())); + //assert(in->filelock.can_write(in->is_auth())); in->filelock.put_write(); dout(7) << "inode_file_write_finish on " << *in << ", filelock=" << in->filelock << endl; diff --git a/trunk/ceph/mds/Server.cc b/trunk/ceph/mds/Server.cc index b7178e31a4d..736913f301c 100644 --- a/trunk/ceph/mds/Server.cc +++ b/trunk/ceph/mds/Server.cc @@ -2265,6 +2265,19 @@ void Server::handle_client_open(MClientRequest *req, return; } + // O_TRUNC + if (flags & O_TRUNC) { + // write + if (!mds->locker->inode_file_write_start(cur, req)) + return; // fw or (wait for) lock + + // do update + cur->inode.size = req->get_sizearg(); + cur->_mark_dirty(); // fixme + + mds->locker->inode_file_write_finish(cur); + } + // hmm, check permissions or something.