| 12669 | } |
| 12670 | |
| 12671 | int64_t Client::_write(Fh *f, int64_t offset, uint64_t size, bufferlist bl, |
| 12672 | Context *onfinish, bool do_fsync, bool syncdataonly) |
| 12673 | { |
| 12674 | ceph_assert(ceph_mutex_is_locked_by_me(client_lock)); |
| 12675 | |
| 12676 | uint64_t fpos = 0; |
| 12677 | Inode *in = f->inode.get(); |
| 12678 | std::unique_ptr<C_SaferCond> onuninline = nullptr; |
| 12679 | CWF_iofinish *cwf_iofinish = NULL; |
| 12680 | C_SaferCond *cond_iofinish = NULL; |
| 12681 | |
| 12682 | if (size < 1) { // zero bytes write is not supported by osd |
| 12683 | return -EINVAL; |
| 12684 | } |
| 12685 | |
| 12686 | if ( (uint64_t)(offset+size) > mdsmap->get_max_filesize() && //exceeds config |
| 12687 | (uint64_t)(offset+size) > in->size ) { //exceeds filesize |
| 12688 | return -EFBIG; |
| 12689 | } |
| 12690 | ldout(cct, 7) << "_write fh " << f << " size " << size << " offset " << offset << dendl; |
| 12691 | |
| 12692 | if (objecter->osdmap_pool_full(in->layout.pool_id)) { |
| 12693 | return -ENOSPC; |
| 12694 | } |
| 12695 | |
| 12696 | ceph_assert(in->snapid == CEPH_NOSNAP); |
| 12697 | |
| 12698 | // was Fh opened as writeable? |
| 12699 | if ((f->mode & CEPH_FILE_MODE_WR) == 0) |
| 12700 | return -EBADF; |
| 12701 | |
| 12702 | // use/adjust fd pos? |
| 12703 | if (offset < 0) { |
| 12704 | lock_fh_pos(f); |
| 12705 | /* |
| 12706 | * FIXME: this is racy in that we may block _after_ this point waiting for caps, and size may |
| 12707 | * change out from under us. |
| 12708 | */ |
| 12709 | if (f->flags & O_APPEND) { |
| 12710 | auto r = _lseek(f, 0, SEEK_END); |
| 12711 | if (r < 0) { |
| 12712 | unlock_fh_pos(f); |
| 12713 | return r; |
| 12714 | } |
| 12715 | } |
| 12716 | offset = f->pos; |
| 12717 | fpos = offset+size; |
| 12718 | unlock_fh_pos(f); |
| 12719 | } |
| 12720 | |
| 12721 | // check quota |
| 12722 | uint64_t endoff = offset + size; |
| 12723 | if (endoff > in->size && is_quota_bytes_exceeded(in, endoff - in->size, |
| 12724 | f->actor_perms)) { |
| 12725 | return -EDQUOT; |
| 12726 | } |
| 12727 | |
| 12728 | //bool lazy = f->mode == CEPH_FILE_MODE_LAZY; |
nothing calls this directly
no test coverage detected