client: basic O_APPEND support

This commit is contained in:
Sage Weil 2008-04-10 09:59:31 -07:00
parent 6e5b2927e4
commit 0734aae2b0
2 changed files with 10 additions and 1 deletions

View 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);

View 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) {}
};