From f212de37cdc1d10fe6a5669814ec2a20c6116d2e Mon Sep 17 00:00:00 2001 From: sageweil Date: Tue, 20 Mar 2007 19:58:39 +0000 Subject: [PATCH] * some client cache tweaks git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1266 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/client/Client.cc | 24 +++++++++++++----------- trunk/ceph/client/Client.h | 2 ++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/trunk/ceph/client/Client.cc b/trunk/ceph/client/Client.cc index 9f6914d33d136..444acd6e48df4 100644 --- a/trunk/ceph/client/Client.cc +++ b/trunk/ceph/client/Client.cc @@ -2280,8 +2280,11 @@ int Client::read(fh_t fh, char *buf, off_t size, off_t offset) Fh *f = fh_map[fh]; Inode *in = f->inode; - if (offset < 0) + bool movepos = false; + if (offset < 0) { offset = f->pos; + movepos = true; + } bool lazy = f->mode == FILE_MODE_LAZY; @@ -2347,9 +2350,11 @@ int Client::read(fh_t fh, char *buf, off_t size, off_t offset) while (!done) cond.Wait(client_lock); } - - // adjust fd pos - f->pos = offset+blist.length(); + + if (movepos) { + // adjust fd pos + f->pos = offset+blist.length(); + } // copy data into caller's char* buf blist.copy(0, blist.length(), buf); @@ -2405,8 +2410,11 @@ int Client::write(fh_t fh, const char *buf, off_t size, off_t offset) Fh *f = fh_map[fh]; Inode *in = f->inode; - if (offset < 0) + if (offset < 0) { offset = f->pos; + // adjust fd pos + f->pos = offset+size; + } bool lazy = f->mode == FILE_MODE_LAZY; @@ -2426,9 +2434,6 @@ int Client::write(fh_t fh, const char *buf, off_t size, off_t offset) // write (this may block!) in->fc.write(offset, size, blist, client_lock); - // adjust fd pos - f->pos = offset+size; - } else { // legacy, inconsistent synchronous write. dout(7) << "synchronous write" << endl; @@ -2462,9 +2467,6 @@ int Client::write(fh_t fh, const char *buf, off_t size, off_t offset) //, 1+((int)g_clock.now()) / 10 //f->pos // hack hack test osd revision snapshots ); - // adjust fd pos - f->pos = offset+size; - while (!done) { cond.Wait(client_lock); dout(20) << " sync write bump " << onfinish << endl; diff --git a/trunk/ceph/client/Client.h b/trunk/ceph/client/Client.h index 4ee04f8003f23..313d0e29dcfcd 100644 --- a/trunk/ceph/client/Client.h +++ b/trunk/ceph/client/Client.h @@ -201,6 +201,8 @@ class Inode { if (num_open_rd) w |= CAP_FILE_RD|CAP_FILE_RDCACHE; if (num_open_wr) w |= CAP_FILE_WR|CAP_FILE_WRBUFFER; if (num_open_lazy) w |= CAP_FILE_LAZYIO; + if (fc.is_dirty()) w |= CAP_FILE_WRBUFFER; + if (fc.is_cached()) w |= CAP_FILE_RDCACHE; return w; } -- 2.39.5