]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: basic O_APPEND support
authorSage Weil <sage@newdream.net>
Thu, 10 Apr 2008 16:59:31 +0000 (09:59 -0700)
committerSage Weil <sage@newdream.net>
Thu, 10 Apr 2008 17:06:05 +0000 (10:06 -0700)
src/client/Client.cc
src/client/Client.h

index eea9fd497ea634190ea8a5ca92aff14ff622022f..e93b4d825d7182164dbd629317524a67409bf263 100644 (file)
@@ -2788,6 +2788,8 @@ int Client::_open(const char *path, int flags, mode_t mode, Fh **fhp)
     Fh *f = new Fh;
     if (fhp) *fhp = f;
     f->mode = cmode;
+    if (flags & O_APPEND)
+      f->append = true;
 
     // inode
     assert(in);
@@ -3185,6 +3187,12 @@ int Client::_write(Fh *f, off_t offset, off_t size, const char *buf)
   // use/adjust fd pos?
   if (offset < 0) {
     lock_fh_pos(f);
+    /* 
+     * FIXME: this is racy in that we may block _after_ this point waiting for caps, and inode.size may
+     * change out from under us.
+     */
+    if (f->append)
+      f->pos = in->inode.size;   // O_APPEND.
     offset = f->pos;
     f->pos = offset+size;    
     unlock_fh_pos(f);
index 57fe0f7e50c67ab52a24802a9ef2c25f095d4f4b..967e8a4c34ec5035c8bce17ebece4c6dfad6d620 100644 (file)
@@ -355,10 +355,11 @@ struct Fh {
 
   bool is_lazy() { return mode & O_LAZY; }
 
+  bool append;
   bool pos_locked;           // pos is currently in use
   list<Cond*> pos_waiters;   // waiters for pos
 
-  Fh() : inode(0), pos(0), mds(0), mode(0), pos_locked(false) {}
+  Fh() : inode(0), pos(0), mds(0), mode(0), append(false), pos_locked(false) {}
 };