From: xie xingguo Date: Wed, 8 Jun 2016 06:53:23 +0000 (+0800) Subject: client: add check for _lseek() during _write() process X-Git-Tag: v11.0.0~187^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=717d3a0c5a0d9033ac96dcb01ff6210308deeec2;p=ceph.git client: add check for _lseek() during _write() process The _lseek() call may fail, which can cause uncertain behaviour if the process goes on instead of returning immediately. Signed-off-by: xie xingguo --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 31cc936bce8d..aa4b111f7394 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -8323,8 +8323,13 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf, * FIXME: this is racy in that we may block _after_ this point waiting for caps, and size may * change out from under us. */ - if (f->flags & O_APPEND) - _lseek(f, 0, SEEK_END); + if (f->flags & O_APPEND) { + int r = _lseek(f, 0, SEEK_END); + if (r < 0) { + unlock_fh_pos(f); + return r; + } + } offset = f->pos; f->pos = offset+size; unlock_fh_pos(f);