Lines Matching full:cs
651 static void fuse_copy_init(struct fuse_copy_state *cs, int write, in fuse_copy_init() argument
654 memset(cs, 0, sizeof(*cs)); in fuse_copy_init()
655 cs->write = write; in fuse_copy_init()
656 cs->iter = iter; in fuse_copy_init()
660 static void fuse_copy_finish(struct fuse_copy_state *cs) in fuse_copy_finish() argument
662 if (cs->currbuf) { in fuse_copy_finish()
663 struct pipe_buffer *buf = cs->currbuf; in fuse_copy_finish()
665 if (cs->write) in fuse_copy_finish()
666 buf->len = PAGE_SIZE - cs->len; in fuse_copy_finish()
667 cs->currbuf = NULL; in fuse_copy_finish()
668 } else if (cs->pg) { in fuse_copy_finish()
669 if (cs->write) { in fuse_copy_finish()
670 flush_dcache_page(cs->pg); in fuse_copy_finish()
671 set_page_dirty_lock(cs->pg); in fuse_copy_finish()
673 put_page(cs->pg); in fuse_copy_finish()
675 cs->pg = NULL; in fuse_copy_finish()
682 static int fuse_copy_fill(struct fuse_copy_state *cs) in fuse_copy_fill() argument
687 err = unlock_request(cs->req); in fuse_copy_fill()
691 fuse_copy_finish(cs); in fuse_copy_fill()
692 if (cs->pipebufs) { in fuse_copy_fill()
693 struct pipe_buffer *buf = cs->pipebufs; in fuse_copy_fill()
695 if (!cs->write) { in fuse_copy_fill()
696 err = pipe_buf_confirm(cs->pipe, buf); in fuse_copy_fill()
700 BUG_ON(!cs->nr_segs); in fuse_copy_fill()
701 cs->currbuf = buf; in fuse_copy_fill()
702 cs->pg = buf->page; in fuse_copy_fill()
703 cs->offset = buf->offset; in fuse_copy_fill()
704 cs->len = buf->len; in fuse_copy_fill()
705 cs->pipebufs++; in fuse_copy_fill()
706 cs->nr_segs--; in fuse_copy_fill()
708 if (cs->nr_segs == cs->pipe->buffers) in fuse_copy_fill()
719 cs->currbuf = buf; in fuse_copy_fill()
720 cs->pg = page; in fuse_copy_fill()
721 cs->offset = 0; in fuse_copy_fill()
722 cs->len = PAGE_SIZE; in fuse_copy_fill()
723 cs->pipebufs++; in fuse_copy_fill()
724 cs->nr_segs++; in fuse_copy_fill()
728 err = iov_iter_get_pages(cs->iter, &page, PAGE_SIZE, 1, &off); in fuse_copy_fill()
732 cs->len = err; in fuse_copy_fill()
733 cs->offset = off; in fuse_copy_fill()
734 cs->pg = page; in fuse_copy_fill()
735 iov_iter_advance(cs->iter, err); in fuse_copy_fill()
738 return lock_request(cs->req); in fuse_copy_fill()
742 static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) in fuse_copy_do() argument
744 unsigned ncpy = min(*size, cs->len); in fuse_copy_do()
746 void *pgaddr = kmap_atomic(cs->pg); in fuse_copy_do()
747 void *buf = pgaddr + cs->offset; in fuse_copy_do()
749 if (cs->write) in fuse_copy_do()
758 cs->len -= ncpy; in fuse_copy_do()
759 cs->offset += ncpy; in fuse_copy_do()
782 static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) in fuse_try_move_page() argument
787 struct pipe_buffer *buf = cs->pipebufs; in fuse_try_move_page()
789 err = unlock_request(cs->req); in fuse_try_move_page()
793 fuse_copy_finish(cs); in fuse_try_move_page()
795 err = pipe_buf_confirm(cs->pipe, buf); in fuse_try_move_page()
799 BUG_ON(!cs->nr_segs); in fuse_try_move_page()
800 cs->currbuf = buf; in fuse_try_move_page()
801 cs->len = buf->len; in fuse_try_move_page()
802 cs->pipebufs++; in fuse_try_move_page()
803 cs->nr_segs--; in fuse_try_move_page()
805 if (cs->len != PAGE_SIZE) in fuse_try_move_page()
808 if (pipe_buf_steal(cs->pipe, buf) != 0) in fuse_try_move_page()
846 spin_lock(&cs->req->waitq.lock); in fuse_try_move_page()
847 if (test_bit(FR_ABORTED, &cs->req->flags)) in fuse_try_move_page()
851 spin_unlock(&cs->req->waitq.lock); in fuse_try_move_page()
861 cs->len = 0; in fuse_try_move_page()
868 cs->pg = buf->page; in fuse_try_move_page()
869 cs->offset = buf->offset; in fuse_try_move_page()
871 err = lock_request(cs->req); in fuse_try_move_page()
878 static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page, in fuse_ref_page() argument
884 if (cs->nr_segs == cs->pipe->buffers) in fuse_ref_page()
887 err = unlock_request(cs->req); in fuse_ref_page()
891 fuse_copy_finish(cs); in fuse_ref_page()
893 buf = cs->pipebufs; in fuse_ref_page()
899 cs->pipebufs++; in fuse_ref_page()
900 cs->nr_segs++; in fuse_ref_page()
901 cs->len = 0; in fuse_ref_page()
910 static int fuse_copy_page(struct fuse_copy_state *cs, struct page **pagep, in fuse_copy_page() argument
920 if (cs->write && cs->pipebufs && page) { in fuse_copy_page()
921 return fuse_ref_page(cs, page, offset, count); in fuse_copy_page()
922 } else if (!cs->len) { in fuse_copy_page()
923 if (cs->move_pages && page && in fuse_copy_page()
925 err = fuse_try_move_page(cs, pagep); in fuse_copy_page()
929 err = fuse_copy_fill(cs); in fuse_copy_page()
937 offset += fuse_copy_do(cs, &buf, &count); in fuse_copy_page()
940 offset += fuse_copy_do(cs, NULL, &count); in fuse_copy_page()
942 if (page && !cs->write) in fuse_copy_page()
948 static int fuse_copy_pages(struct fuse_copy_state *cs, unsigned nbytes, in fuse_copy_pages() argument
952 struct fuse_req *req = cs->req; in fuse_copy_pages()
961 err = fuse_copy_page(cs, &ap->pages[i], offset, count, zeroing); in fuse_copy_pages()
971 static int fuse_copy_one(struct fuse_copy_state *cs, void *val, unsigned size) in fuse_copy_one() argument
974 if (!cs->len) { in fuse_copy_one()
975 int err = fuse_copy_fill(cs); in fuse_copy_one()
979 fuse_copy_do(cs, &val, &size); in fuse_copy_one()
985 static int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, in fuse_copy_args() argument
995 err = fuse_copy_pages(cs, arg->size, zeroing); in fuse_copy_args()
997 err = fuse_copy_one(cs, arg->value, arg->size); in fuse_copy_args()
1022 struct fuse_copy_state *cs, in fuse_read_interrupt() argument
1043 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_interrupt()
1045 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_interrupt()
1046 fuse_copy_finish(cs); in fuse_read_interrupt()
1075 struct fuse_copy_state *cs, in fuse_read_single_forget() argument
1096 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_single_forget()
1098 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_single_forget()
1099 fuse_copy_finish(cs); in fuse_read_single_forget()
1108 struct fuse_copy_state *cs, size_t nbytes) in fuse_read_batch_forget() argument
1133 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_batch_forget()
1135 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_batch_forget()
1141 err = fuse_copy_one(cs, &forget->forget_one, in fuse_read_batch_forget()
1148 fuse_copy_finish(cs); in fuse_read_batch_forget()
1157 struct fuse_copy_state *cs, in fuse_read_forget() argument
1162 return fuse_read_single_forget(fiq, cs, nbytes); in fuse_read_forget()
1164 return fuse_read_batch_forget(fiq, cs, nbytes); in fuse_read_forget()
1177 struct fuse_copy_state *cs, size_t nbytes) in fuse_dev_do_read() argument
1229 return fuse_read_interrupt(fiq, cs, nbytes, req); in fuse_dev_do_read()
1234 return fuse_read_forget(fc, fiq, cs, nbytes); in fuse_dev_do_read()
1260 cs->req = req; in fuse_dev_do_read()
1261 err = fuse_copy_one(cs, &req->in.h, sizeof(req->in.h)); in fuse_dev_do_read()
1263 err = fuse_copy_args(cs, args->in_numargs, args->in_pages, in fuse_dev_do_read()
1265 fuse_copy_finish(cs); in fuse_dev_do_read()
1318 struct fuse_copy_state cs; in fuse_dev_read() local
1328 fuse_copy_init(&cs, 1, to); in fuse_dev_read()
1330 return fuse_dev_do_read(fud, file, &cs, iov_iter_count(to)); in fuse_dev_read()
1340 struct fuse_copy_state cs; in fuse_dev_splice_read() local
1351 fuse_copy_init(&cs, 1, NULL); in fuse_dev_splice_read()
1352 cs.pipebufs = bufs; in fuse_dev_splice_read()
1353 cs.pipe = pipe; in fuse_dev_splice_read()
1354 ret = fuse_dev_do_read(fud, in, &cs, len); in fuse_dev_splice_read()
1358 if (pipe->nrbufs + cs.nr_segs > pipe->buffers) { in fuse_dev_splice_read()
1363 for (ret = total = 0; page_nr < cs.nr_segs; total += ret) { in fuse_dev_splice_read()
1377 for (; page_nr < cs.nr_segs; page_nr++) in fuse_dev_splice_read()
1385 struct fuse_copy_state *cs) in fuse_notify_poll() argument
1393 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_poll()
1397 fuse_copy_finish(cs); in fuse_notify_poll()
1401 fuse_copy_finish(cs); in fuse_notify_poll()
1406 struct fuse_copy_state *cs) in fuse_notify_inval_inode() argument
1414 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_inval_inode()
1417 fuse_copy_finish(cs); in fuse_notify_inval_inode()
1429 fuse_copy_finish(cs); in fuse_notify_inval_inode()
1434 struct fuse_copy_state *cs) in fuse_notify_inval_entry() argument
1449 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_inval_entry()
1463 err = fuse_copy_one(cs, buf, outarg.namelen + 1); in fuse_notify_inval_entry()
1466 fuse_copy_finish(cs); in fuse_notify_inval_entry()
1479 fuse_copy_finish(cs); in fuse_notify_inval_entry()
1484 struct fuse_copy_state *cs) in fuse_notify_delete() argument
1499 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_delete()
1513 err = fuse_copy_one(cs, buf, outarg.namelen + 1); in fuse_notify_delete()
1516 fuse_copy_finish(cs); in fuse_notify_delete()
1530 fuse_copy_finish(cs); in fuse_notify_delete()
1535 struct fuse_copy_state *cs) in fuse_notify_store() argument
1552 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_store()
1594 err = fuse_copy_page(cs, &page, offset, this_num, 0); in fuse_notify_store()
1616 fuse_copy_finish(cs); in fuse_notify_store()
1715 struct fuse_copy_state *cs) in fuse_notify_retrieve() argument
1725 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_retrieve()
1729 fuse_copy_finish(cs); in fuse_notify_retrieve()
1747 fuse_copy_finish(cs); in fuse_notify_retrieve()
1752 unsigned int size, struct fuse_copy_state *cs) in fuse_notify() argument
1755 cs->move_pages = 0; in fuse_notify()
1759 return fuse_notify_poll(fc, size, cs); in fuse_notify()
1762 return fuse_notify_inval_inode(fc, size, cs); in fuse_notify()
1765 return fuse_notify_inval_entry(fc, size, cs); in fuse_notify()
1768 return fuse_notify_store(fc, size, cs); in fuse_notify()
1771 return fuse_notify_retrieve(fc, size, cs); in fuse_notify()
1774 return fuse_notify_delete(fc, size, cs); in fuse_notify()
1777 fuse_copy_finish(cs); in fuse_notify()
1795 static int copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, in copy_out_args() argument
1812 return fuse_copy_args(cs, args->out_numargs, args->out_pages, in copy_out_args()
1824 struct fuse_copy_state *cs, size_t nbytes) in fuse_dev_do_write() argument
1836 err = fuse_copy_one(cs, &oh, sizeof(oh)); in fuse_dev_do_write()
1849 err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); in fuse_dev_do_write()
1891 cs->req = req; in fuse_dev_do_write()
1893 cs->move_pages = 0; in fuse_dev_do_write()
1898 err = copy_out_args(cs, req->args, nbytes); in fuse_dev_do_write()
1899 fuse_copy_finish(cs); in fuse_dev_do_write()
1916 fuse_copy_finish(cs); in fuse_dev_do_write()
1922 struct fuse_copy_state cs; in fuse_dev_write() local
1931 fuse_copy_init(&cs, 0, from); in fuse_dev_write()
1933 return fuse_dev_do_write(fud, &cs, iov_iter_count(from)); in fuse_dev_write()
1943 struct fuse_copy_state cs; in fuse_dev_splice_write() local
2000 fuse_copy_init(&cs, 0, NULL); in fuse_dev_splice_write()
2001 cs.pipebufs = bufs; in fuse_dev_splice_write()
2002 cs.nr_segs = nbuf; in fuse_dev_splice_write()
2003 cs.pipe = pipe; in fuse_dev_splice_write()
2006 cs.move_pages = 1; in fuse_dev_splice_write()
2008 ret = fuse_dev_do_write(fud, &cs, len); in fuse_dev_splice_write()