mirror of
https://github.com/ceph/ceph
synced 2025-01-10 05:00:59 +00:00
client: basic O_APPEND support
This commit is contained in:
parent
6e5b2927e4
commit
0734aae2b0
@ -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);
|
||||
|
@ -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) {}
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user