• Home
  • Raw
  • Download

Lines Matching refs:cs

657 static void fuse_copy_init(struct fuse_copy_state *cs, struct fuse_conn *fc,  in fuse_copy_init()  argument
661 memset(cs, 0, sizeof(*cs)); in fuse_copy_init()
662 cs->fc = fc; in fuse_copy_init()
663 cs->write = write; in fuse_copy_init()
664 cs->iov = iov; in fuse_copy_init()
665 cs->nr_segs = nr_segs; in fuse_copy_init()
669 static void fuse_copy_finish(struct fuse_copy_state *cs) in fuse_copy_finish() argument
671 if (cs->currbuf) { in fuse_copy_finish()
672 struct pipe_buffer *buf = cs->currbuf; in fuse_copy_finish()
674 if (!cs->write) { in fuse_copy_finish()
675 buf->ops->unmap(cs->pipe, buf, cs->mapaddr); in fuse_copy_finish()
678 buf->len = PAGE_SIZE - cs->len; in fuse_copy_finish()
680 cs->currbuf = NULL; in fuse_copy_finish()
681 cs->mapaddr = NULL; in fuse_copy_finish()
682 } else if (cs->mapaddr) { in fuse_copy_finish()
683 kunmap(cs->pg); in fuse_copy_finish()
684 if (cs->write) { in fuse_copy_finish()
685 flush_dcache_page(cs->pg); in fuse_copy_finish()
686 set_page_dirty_lock(cs->pg); in fuse_copy_finish()
688 put_page(cs->pg); in fuse_copy_finish()
689 cs->mapaddr = NULL; in fuse_copy_finish()
697 static int fuse_copy_fill(struct fuse_copy_state *cs) in fuse_copy_fill() argument
702 unlock_request(cs->fc, cs->req); in fuse_copy_fill()
703 fuse_copy_finish(cs); in fuse_copy_fill()
704 if (cs->pipebufs) { in fuse_copy_fill()
705 struct pipe_buffer *buf = cs->pipebufs; in fuse_copy_fill()
707 if (!cs->write) { in fuse_copy_fill()
708 err = buf->ops->confirm(cs->pipe, buf); in fuse_copy_fill()
712 BUG_ON(!cs->nr_segs); in fuse_copy_fill()
713 cs->currbuf = buf; in fuse_copy_fill()
714 cs->mapaddr = buf->ops->map(cs->pipe, buf, 0); in fuse_copy_fill()
715 cs->len = buf->len; in fuse_copy_fill()
716 cs->buf = cs->mapaddr + buf->offset; in fuse_copy_fill()
717 cs->pipebufs++; in fuse_copy_fill()
718 cs->nr_segs--; in fuse_copy_fill()
722 if (cs->nr_segs == cs->pipe->buffers) in fuse_copy_fill()
733 cs->currbuf = buf; in fuse_copy_fill()
734 cs->mapaddr = kmap(page); in fuse_copy_fill()
735 cs->buf = cs->mapaddr; in fuse_copy_fill()
736 cs->len = PAGE_SIZE; in fuse_copy_fill()
737 cs->pipebufs++; in fuse_copy_fill()
738 cs->nr_segs++; in fuse_copy_fill()
741 if (!cs->seglen) { in fuse_copy_fill()
742 BUG_ON(!cs->nr_segs); in fuse_copy_fill()
743 cs->seglen = cs->iov[0].iov_len; in fuse_copy_fill()
744 cs->addr = (unsigned long) cs->iov[0].iov_base; in fuse_copy_fill()
745 cs->iov++; in fuse_copy_fill()
746 cs->nr_segs--; in fuse_copy_fill()
748 err = get_user_pages_fast(cs->addr, 1, cs->write, &cs->pg); in fuse_copy_fill()
752 offset = cs->addr % PAGE_SIZE; in fuse_copy_fill()
753 cs->mapaddr = kmap(cs->pg); in fuse_copy_fill()
754 cs->buf = cs->mapaddr + offset; in fuse_copy_fill()
755 cs->len = min(PAGE_SIZE - offset, cs->seglen); in fuse_copy_fill()
756 cs->seglen -= cs->len; in fuse_copy_fill()
757 cs->addr += cs->len; in fuse_copy_fill()
760 return lock_request(cs->fc, cs->req); in fuse_copy_fill()
764 static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) in fuse_copy_do() argument
766 unsigned ncpy = min(*size, cs->len); in fuse_copy_do()
768 if (cs->write) in fuse_copy_do()
769 memcpy(cs->buf, *val, ncpy); in fuse_copy_do()
771 memcpy(*val, cs->buf, ncpy); in fuse_copy_do()
775 cs->len -= ncpy; in fuse_copy_do()
776 cs->buf += ncpy; in fuse_copy_do()
799 static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) in fuse_try_move_page() argument
804 struct pipe_buffer *buf = cs->pipebufs; in fuse_try_move_page()
806 unlock_request(cs->fc, cs->req); in fuse_try_move_page()
807 fuse_copy_finish(cs); in fuse_try_move_page()
809 err = buf->ops->confirm(cs->pipe, buf); in fuse_try_move_page()
813 BUG_ON(!cs->nr_segs); in fuse_try_move_page()
814 cs->currbuf = buf; in fuse_try_move_page()
815 cs->len = buf->len; in fuse_try_move_page()
816 cs->pipebufs++; in fuse_try_move_page()
817 cs->nr_segs--; in fuse_try_move_page()
819 if (cs->len != PAGE_SIZE) in fuse_try_move_page()
822 if (buf->ops->steal(cs->pipe, buf) != 0) in fuse_try_move_page()
860 spin_lock(&cs->fc->lock); in fuse_try_move_page()
861 if (cs->req->aborted) in fuse_try_move_page()
865 spin_unlock(&cs->fc->lock); in fuse_try_move_page()
875 cs->len = 0; in fuse_try_move_page()
882 cs->mapaddr = buf->ops->map(cs->pipe, buf, 1); in fuse_try_move_page()
883 cs->buf = cs->mapaddr + buf->offset; in fuse_try_move_page()
885 err = lock_request(cs->fc, cs->req); in fuse_try_move_page()
892 static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page, in fuse_ref_page() argument
897 if (cs->nr_segs == cs->pipe->buffers) in fuse_ref_page()
900 unlock_request(cs->fc, cs->req); in fuse_ref_page()
901 fuse_copy_finish(cs); in fuse_ref_page()
903 buf = cs->pipebufs; in fuse_ref_page()
909 cs->pipebufs++; in fuse_ref_page()
910 cs->nr_segs++; in fuse_ref_page()
911 cs->len = 0; in fuse_ref_page()
920 static int fuse_copy_page(struct fuse_copy_state *cs, struct page **pagep, in fuse_copy_page() argument
930 if (cs->write && cs->pipebufs && page) { in fuse_copy_page()
931 return fuse_ref_page(cs, page, offset, count); in fuse_copy_page()
932 } else if (!cs->len) { in fuse_copy_page()
933 if (cs->move_pages && page && in fuse_copy_page()
935 err = fuse_try_move_page(cs, pagep); in fuse_copy_page()
939 err = fuse_copy_fill(cs); in fuse_copy_page()
947 offset += fuse_copy_do(cs, &buf, &count); in fuse_copy_page()
950 offset += fuse_copy_do(cs, NULL, &count); in fuse_copy_page()
952 if (page && !cs->write) in fuse_copy_page()
958 static int fuse_copy_pages(struct fuse_copy_state *cs, unsigned nbytes, in fuse_copy_pages() argument
962 struct fuse_req *req = cs->req; in fuse_copy_pages()
969 err = fuse_copy_page(cs, &req->pages[i], offset, count, in fuse_copy_pages()
980 static int fuse_copy_one(struct fuse_copy_state *cs, void *val, unsigned size) in fuse_copy_one() argument
983 if (!cs->len) { in fuse_copy_one()
984 int err = fuse_copy_fill(cs); in fuse_copy_one()
988 fuse_copy_do(cs, &val, &size); in fuse_copy_one()
994 static int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, in fuse_copy_args() argument
1004 err = fuse_copy_pages(cs, arg->size, zeroing); in fuse_copy_args()
1006 err = fuse_copy_one(cs, arg->value, arg->size); in fuse_copy_args()
1051 static int fuse_read_interrupt(struct fuse_conn *fc, struct fuse_copy_state *cs, in fuse_read_interrupt() argument
1073 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_interrupt()
1075 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_interrupt()
1076 fuse_copy_finish(cs); in fuse_read_interrupt()
1104 struct fuse_copy_state *cs, in fuse_read_single_forget() argument
1125 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_single_forget()
1127 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_single_forget()
1128 fuse_copy_finish(cs); in fuse_read_single_forget()
1137 struct fuse_copy_state *cs, size_t nbytes) in fuse_read_batch_forget() argument
1162 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_batch_forget()
1164 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_batch_forget()
1170 err = fuse_copy_one(cs, &forget->forget_one, in fuse_read_batch_forget()
1177 fuse_copy_finish(cs); in fuse_read_batch_forget()
1185 static int fuse_read_forget(struct fuse_conn *fc, struct fuse_copy_state *cs, in fuse_read_forget() argument
1190 return fuse_read_single_forget(fc, cs, nbytes); in fuse_read_forget()
1192 return fuse_read_batch_forget(fc, cs, nbytes); in fuse_read_forget()
1205 struct fuse_copy_state *cs, size_t nbytes) in fuse_dev_do_read() argument
1230 return fuse_read_interrupt(fc, cs, nbytes, req); in fuse_dev_do_read()
1235 return fuse_read_forget(fc, cs, nbytes); in fuse_dev_do_read()
1257 cs->req = req; in fuse_dev_do_read()
1258 err = fuse_copy_one(cs, &in->h, sizeof(in->h)); in fuse_dev_do_read()
1260 err = fuse_copy_args(cs, in->numargs, in->argpages, in fuse_dev_do_read()
1262 fuse_copy_finish(cs); in fuse_dev_do_read()
1293 struct fuse_copy_state cs; in fuse_dev_read() local
1299 fuse_copy_init(&cs, fc, 1, iov, nr_segs); in fuse_dev_read()
1301 return fuse_dev_do_read(fc, file, &cs, iov_length(iov, nr_segs)); in fuse_dev_read()
1328 struct fuse_copy_state cs; in fuse_dev_splice_read() local
1337 fuse_copy_init(&cs, fc, 1, NULL, 0); in fuse_dev_splice_read()
1338 cs.pipebufs = bufs; in fuse_dev_splice_read()
1339 cs.pipe = pipe; in fuse_dev_splice_read()
1340 ret = fuse_dev_do_read(fc, in, &cs, len); in fuse_dev_splice_read()
1354 if (pipe->nrbufs + cs.nr_segs > pipe->buffers) { in fuse_dev_splice_read()
1359 while (page_nr < cs.nr_segs) { in fuse_dev_splice_read()
1387 for (; page_nr < cs.nr_segs; page_nr++) in fuse_dev_splice_read()
1395 struct fuse_copy_state *cs) in fuse_notify_poll() argument
1403 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_poll()
1407 fuse_copy_finish(cs); in fuse_notify_poll()
1411 fuse_copy_finish(cs); in fuse_notify_poll()
1416 struct fuse_copy_state *cs) in fuse_notify_inval_inode() argument
1424 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_inval_inode()
1427 fuse_copy_finish(cs); in fuse_notify_inval_inode()
1439 fuse_copy_finish(cs); in fuse_notify_inval_inode()
1444 struct fuse_copy_state *cs) in fuse_notify_inval_entry() argument
1459 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_inval_entry()
1473 err = fuse_copy_one(cs, buf, outarg.namelen + 1); in fuse_notify_inval_entry()
1476 fuse_copy_finish(cs); in fuse_notify_inval_entry()
1490 fuse_copy_finish(cs); in fuse_notify_inval_entry()
1495 struct fuse_copy_state *cs) in fuse_notify_delete() argument
1510 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_delete()
1524 err = fuse_copy_one(cs, buf, outarg.namelen + 1); in fuse_notify_delete()
1527 fuse_copy_finish(cs); in fuse_notify_delete()
1542 fuse_copy_finish(cs); in fuse_notify_delete()
1547 struct fuse_copy_state *cs) in fuse_notify_store() argument
1564 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_store()
1606 err = fuse_copy_page(cs, &page, offset, this_num, 0); in fuse_notify_store()
1627 fuse_copy_finish(cs); in fuse_notify_store()
1706 struct fuse_copy_state *cs) in fuse_notify_retrieve() argument
1716 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_retrieve()
1720 fuse_copy_finish(cs); in fuse_notify_retrieve()
1738 fuse_copy_finish(cs); in fuse_notify_retrieve()
1743 unsigned int size, struct fuse_copy_state *cs) in fuse_notify() argument
1747 return fuse_notify_poll(fc, size, cs); in fuse_notify()
1750 return fuse_notify_inval_inode(fc, size, cs); in fuse_notify()
1753 return fuse_notify_inval_entry(fc, size, cs); in fuse_notify()
1756 return fuse_notify_store(fc, size, cs); in fuse_notify()
1759 return fuse_notify_retrieve(fc, size, cs); in fuse_notify()
1762 return fuse_notify_delete(fc, size, cs); in fuse_notify()
1765 fuse_copy_finish(cs); in fuse_notify()
1784 static int copy_out_args(struct fuse_copy_state *cs, struct fuse_out *out, in copy_out_args() argument
1803 return fuse_copy_args(cs, out->numargs, out->argpages, out->args, in copy_out_args()
1815 struct fuse_copy_state *cs, size_t nbytes) in fuse_dev_do_write() argument
1824 err = fuse_copy_one(cs, &oh, sizeof(oh)); in fuse_dev_do_write()
1837 err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); in fuse_dev_do_write()
1856 fuse_copy_finish(cs); in fuse_dev_do_write()
1873 fuse_copy_finish(cs); in fuse_dev_do_write()
1881 cs->req = req; in fuse_dev_do_write()
1883 cs->move_pages = 0; in fuse_dev_do_write()
1886 err = copy_out_args(cs, &req->out, nbytes); in fuse_dev_do_write()
1891 fuse_copy_finish(cs); in fuse_dev_do_write()
1907 fuse_copy_finish(cs); in fuse_dev_do_write()
1914 struct fuse_copy_state cs; in fuse_dev_write() local
1919 fuse_copy_init(&cs, fc, 0, iov, nr_segs); in fuse_dev_write()
1921 return fuse_dev_do_write(fc, &cs, iov_length(iov, nr_segs)); in fuse_dev_write()
1931 struct fuse_copy_state cs; in fuse_dev_splice_write() local
1984 fuse_copy_init(&cs, fc, 0, NULL, nbuf); in fuse_dev_splice_write()
1985 cs.pipebufs = bufs; in fuse_dev_splice_write()
1986 cs.pipe = pipe; in fuse_dev_splice_write()
1989 cs.move_pages = 1; in fuse_dev_splice_write()
1991 ret = fuse_dev_do_write(fc, &cs, len); in fuse_dev_splice_write()