Lines Matching refs:cs

710 static void fuse_copy_init(struct fuse_copy_state *cs, int write,  in fuse_copy_init()  argument
713 memset(cs, 0, sizeof(*cs)); in fuse_copy_init()
714 cs->write = write; in fuse_copy_init()
715 cs->iter = iter; in fuse_copy_init()
719 static void fuse_copy_finish(struct fuse_copy_state *cs) in fuse_copy_finish() argument
721 if (cs->currbuf) { in fuse_copy_finish()
722 struct pipe_buffer *buf = cs->currbuf; in fuse_copy_finish()
724 if (cs->write) in fuse_copy_finish()
725 buf->len = PAGE_SIZE - cs->len; in fuse_copy_finish()
726 cs->currbuf = NULL; in fuse_copy_finish()
727 } else if (cs->pg) { in fuse_copy_finish()
728 if (cs->write) { in fuse_copy_finish()
729 flush_dcache_page(cs->pg); in fuse_copy_finish()
730 set_page_dirty_lock(cs->pg); in fuse_copy_finish()
732 put_page(cs->pg); in fuse_copy_finish()
734 cs->pg = NULL; in fuse_copy_finish()
741 static int fuse_copy_fill(struct fuse_copy_state *cs) in fuse_copy_fill() argument
746 err = unlock_request(cs->req); in fuse_copy_fill()
750 fuse_copy_finish(cs); in fuse_copy_fill()
751 if (cs->pipebufs) { in fuse_copy_fill()
752 struct pipe_buffer *buf = cs->pipebufs; in fuse_copy_fill()
754 if (!cs->write) { in fuse_copy_fill()
755 err = buf->ops->confirm(cs->pipe, buf); in fuse_copy_fill()
759 BUG_ON(!cs->nr_segs); in fuse_copy_fill()
760 cs->currbuf = buf; in fuse_copy_fill()
761 cs->pg = buf->page; in fuse_copy_fill()
762 cs->offset = buf->offset; in fuse_copy_fill()
763 cs->len = buf->len; in fuse_copy_fill()
764 cs->pipebufs++; in fuse_copy_fill()
765 cs->nr_segs--; in fuse_copy_fill()
767 if (cs->nr_segs == cs->pipe->buffers) in fuse_copy_fill()
778 cs->currbuf = buf; in fuse_copy_fill()
779 cs->pg = page; in fuse_copy_fill()
780 cs->offset = 0; in fuse_copy_fill()
781 cs->len = PAGE_SIZE; in fuse_copy_fill()
782 cs->pipebufs++; in fuse_copy_fill()
783 cs->nr_segs++; in fuse_copy_fill()
787 err = iov_iter_get_pages(cs->iter, &page, PAGE_SIZE, 1, &off); in fuse_copy_fill()
791 cs->len = err; in fuse_copy_fill()
792 cs->offset = off; in fuse_copy_fill()
793 cs->pg = page; in fuse_copy_fill()
794 cs->offset = off; in fuse_copy_fill()
795 iov_iter_advance(cs->iter, err); in fuse_copy_fill()
798 return lock_request(cs->req); in fuse_copy_fill()
802 static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) in fuse_copy_do() argument
804 unsigned ncpy = min(*size, cs->len); in fuse_copy_do()
806 void *pgaddr = kmap_atomic(cs->pg); in fuse_copy_do()
807 void *buf = pgaddr + cs->offset; in fuse_copy_do()
809 if (cs->write) in fuse_copy_do()
818 cs->len -= ncpy; in fuse_copy_do()
819 cs->offset += ncpy; in fuse_copy_do()
842 static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) in fuse_try_move_page() argument
847 struct pipe_buffer *buf = cs->pipebufs; in fuse_try_move_page()
849 err = unlock_request(cs->req); in fuse_try_move_page()
853 fuse_copy_finish(cs); in fuse_try_move_page()
855 err = buf->ops->confirm(cs->pipe, buf); in fuse_try_move_page()
859 BUG_ON(!cs->nr_segs); in fuse_try_move_page()
860 cs->currbuf = buf; in fuse_try_move_page()
861 cs->len = buf->len; in fuse_try_move_page()
862 cs->pipebufs++; in fuse_try_move_page()
863 cs->nr_segs--; in fuse_try_move_page()
865 if (cs->len != PAGE_SIZE) in fuse_try_move_page()
868 if (buf->ops->steal(cs->pipe, buf) != 0) in fuse_try_move_page()
906 spin_lock(&cs->req->waitq.lock); in fuse_try_move_page()
907 if (test_bit(FR_ABORTED, &cs->req->flags)) in fuse_try_move_page()
911 spin_unlock(&cs->req->waitq.lock); in fuse_try_move_page()
921 cs->len = 0; in fuse_try_move_page()
928 cs->pg = buf->page; in fuse_try_move_page()
929 cs->offset = buf->offset; in fuse_try_move_page()
931 err = lock_request(cs->req); in fuse_try_move_page()
938 static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page, in fuse_ref_page() argument
944 if (cs->nr_segs == cs->pipe->buffers) in fuse_ref_page()
947 err = unlock_request(cs->req); in fuse_ref_page()
951 fuse_copy_finish(cs); in fuse_ref_page()
953 buf = cs->pipebufs; in fuse_ref_page()
959 cs->pipebufs++; in fuse_ref_page()
960 cs->nr_segs++; in fuse_ref_page()
961 cs->len = 0; in fuse_ref_page()
970 static int fuse_copy_page(struct fuse_copy_state *cs, struct page **pagep, in fuse_copy_page() argument
980 if (cs->write && cs->pipebufs && page) { in fuse_copy_page()
981 return fuse_ref_page(cs, page, offset, count); in fuse_copy_page()
982 } else if (!cs->len) { in fuse_copy_page()
983 if (cs->move_pages && page && in fuse_copy_page()
985 err = fuse_try_move_page(cs, pagep); in fuse_copy_page()
989 err = fuse_copy_fill(cs); in fuse_copy_page()
997 offset += fuse_copy_do(cs, &buf, &count); in fuse_copy_page()
1000 offset += fuse_copy_do(cs, NULL, &count); in fuse_copy_page()
1002 if (page && !cs->write) in fuse_copy_page()
1008 static int fuse_copy_pages(struct fuse_copy_state *cs, unsigned nbytes, in fuse_copy_pages() argument
1012 struct fuse_req *req = cs->req; in fuse_copy_pages()
1019 err = fuse_copy_page(cs, &req->pages[i], offset, count, in fuse_copy_pages()
1030 static int fuse_copy_one(struct fuse_copy_state *cs, void *val, unsigned size) in fuse_copy_one() argument
1033 if (!cs->len) { in fuse_copy_one()
1034 int err = fuse_copy_fill(cs); in fuse_copy_one()
1038 fuse_copy_do(cs, &val, &size); in fuse_copy_one()
1044 static int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, in fuse_copy_args() argument
1054 err = fuse_copy_pages(cs, arg->size, zeroing); in fuse_copy_args()
1056 err = fuse_copy_one(cs, arg->value, arg->size); in fuse_copy_args()
1081 struct fuse_copy_state *cs, in fuse_read_interrupt() argument
1103 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_interrupt()
1105 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_interrupt()
1106 fuse_copy_finish(cs); in fuse_read_interrupt()
1134 struct fuse_copy_state *cs, in fuse_read_single_forget() argument
1155 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_single_forget()
1157 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_single_forget()
1158 fuse_copy_finish(cs); in fuse_read_single_forget()
1167 struct fuse_copy_state *cs, size_t nbytes) in fuse_read_batch_forget() argument
1192 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_batch_forget()
1194 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_batch_forget()
1200 err = fuse_copy_one(cs, &forget->forget_one, in fuse_read_batch_forget()
1207 fuse_copy_finish(cs); in fuse_read_batch_forget()
1216 struct fuse_copy_state *cs, in fuse_read_forget() argument
1221 return fuse_read_single_forget(fiq, cs, nbytes); in fuse_read_forget()
1223 return fuse_read_batch_forget(fiq, cs, nbytes); in fuse_read_forget()
1236 struct fuse_copy_state *cs, size_t nbytes) in fuse_dev_do_read() argument
1265 return fuse_read_interrupt(fiq, cs, nbytes, req); in fuse_dev_do_read()
1270 return fuse_read_forget(fc, fiq, cs, nbytes); in fuse_dev_do_read()
1295 cs->req = req; in fuse_dev_do_read()
1296 err = fuse_copy_one(cs, &in->h, sizeof(in->h)); in fuse_dev_do_read()
1298 err = fuse_copy_args(cs, in->numargs, in->argpages, in fuse_dev_do_read()
1300 fuse_copy_finish(cs); in fuse_dev_do_read()
1350 struct fuse_copy_state cs; in fuse_dev_read() local
1360 fuse_copy_init(&cs, 1, to); in fuse_dev_read()
1362 return fuse_dev_do_read(fud, file, &cs, iov_iter_count(to)); in fuse_dev_read()
1373 struct fuse_copy_state cs; in fuse_dev_splice_read() local
1383 fuse_copy_init(&cs, 1, NULL); in fuse_dev_splice_read()
1384 cs.pipebufs = bufs; in fuse_dev_splice_read()
1385 cs.pipe = pipe; in fuse_dev_splice_read()
1386 ret = fuse_dev_do_read(fud, in, &cs, len); in fuse_dev_splice_read()
1400 if (pipe->nrbufs + cs.nr_segs > pipe->buffers) { in fuse_dev_splice_read()
1405 while (page_nr < cs.nr_segs) { in fuse_dev_splice_read()
1437 for (; page_nr < cs.nr_segs; page_nr++) in fuse_dev_splice_read()
1445 struct fuse_copy_state *cs) in fuse_notify_poll() argument
1453 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_poll()
1457 fuse_copy_finish(cs); in fuse_notify_poll()
1461 fuse_copy_finish(cs); in fuse_notify_poll()
1466 struct fuse_copy_state *cs) in fuse_notify_inval_inode() argument
1474 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_inval_inode()
1477 fuse_copy_finish(cs); in fuse_notify_inval_inode()
1489 fuse_copy_finish(cs); in fuse_notify_inval_inode()
1494 struct fuse_copy_state *cs) in fuse_notify_inval_entry() argument
1509 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_inval_entry()
1523 err = fuse_copy_one(cs, buf, outarg.namelen + 1); in fuse_notify_inval_entry()
1526 fuse_copy_finish(cs); in fuse_notify_inval_entry()
1540 fuse_copy_finish(cs); in fuse_notify_inval_entry()
1545 struct fuse_copy_state *cs) in fuse_notify_delete() argument
1560 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_delete()
1574 err = fuse_copy_one(cs, buf, outarg.namelen + 1); in fuse_notify_delete()
1577 fuse_copy_finish(cs); in fuse_notify_delete()
1592 fuse_copy_finish(cs); in fuse_notify_delete()
1597 struct fuse_copy_state *cs) in fuse_notify_store() argument
1614 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_store()
1656 err = fuse_copy_page(cs, &page, offset, this_num, 0); in fuse_notify_store()
1678 fuse_copy_finish(cs); in fuse_notify_store()
1757 struct fuse_copy_state *cs) in fuse_notify_retrieve() argument
1767 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_retrieve()
1771 fuse_copy_finish(cs); in fuse_notify_retrieve()
1789 fuse_copy_finish(cs); in fuse_notify_retrieve()
1794 unsigned int size, struct fuse_copy_state *cs) in fuse_notify() argument
1797 cs->move_pages = 0; in fuse_notify()
1801 return fuse_notify_poll(fc, size, cs); in fuse_notify()
1804 return fuse_notify_inval_inode(fc, size, cs); in fuse_notify()
1807 return fuse_notify_inval_entry(fc, size, cs); in fuse_notify()
1810 return fuse_notify_store(fc, size, cs); in fuse_notify()
1813 return fuse_notify_retrieve(fc, size, cs); in fuse_notify()
1816 return fuse_notify_delete(fc, size, cs); in fuse_notify()
1819 fuse_copy_finish(cs); in fuse_notify()
1836 static int copy_out_args(struct fuse_copy_state *cs, struct fuse_out *out, in copy_out_args() argument
1855 return fuse_copy_args(cs, out->numargs, out->argpages, out->args, in copy_out_args()
1867 struct fuse_copy_state *cs, size_t nbytes) in fuse_dev_do_write() argument
1878 err = fuse_copy_one(cs, &oh, sizeof(oh)); in fuse_dev_do_write()
1891 err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); in fuse_dev_do_write()
1921 fuse_copy_finish(cs); in fuse_dev_do_write()
1930 cs->req = req; in fuse_dev_do_write()
1932 cs->move_pages = 0; in fuse_dev_do_write()
1934 err = copy_out_args(cs, &req->out, nbytes); in fuse_dev_do_write()
1935 fuse_copy_finish(cs); in fuse_dev_do_write()
1954 fuse_copy_finish(cs); in fuse_dev_do_write()
1960 struct fuse_copy_state cs; in fuse_dev_write() local
1969 fuse_copy_init(&cs, 0, from); in fuse_dev_write()
1971 return fuse_dev_do_write(fud, &cs, iov_iter_count(from)); in fuse_dev_write()
1981 struct fuse_copy_state cs; in fuse_dev_splice_write() local
2034 fuse_copy_init(&cs, 0, NULL); in fuse_dev_splice_write()
2035 cs.pipebufs = bufs; in fuse_dev_splice_write()
2036 cs.nr_segs = nbuf; in fuse_dev_splice_write()
2037 cs.pipe = pipe; in fuse_dev_splice_write()
2040 cs.move_pages = 1; in fuse_dev_splice_write()
2042 ret = fuse_dev_do_write(fud, &cs, len); in fuse_dev_splice_write()