Lines Matching full:cs

709 static void fuse_copy_init(struct fuse_copy_state *cs, int write,  in fuse_copy_init()  argument
712 memset(cs, 0, sizeof(*cs)); in fuse_copy_init()
713 cs->write = write; in fuse_copy_init()
714 cs->iter = iter; in fuse_copy_init()
718 static void fuse_copy_finish(struct fuse_copy_state *cs) in fuse_copy_finish() argument
720 if (cs->currbuf) { in fuse_copy_finish()
721 struct pipe_buffer *buf = cs->currbuf; in fuse_copy_finish()
723 if (cs->write) in fuse_copy_finish()
724 buf->len = PAGE_SIZE - cs->len; in fuse_copy_finish()
725 cs->currbuf = NULL; in fuse_copy_finish()
726 } else if (cs->pg) { in fuse_copy_finish()
727 if (cs->write) { in fuse_copy_finish()
728 flush_dcache_page(cs->pg); in fuse_copy_finish()
729 set_page_dirty_lock(cs->pg); in fuse_copy_finish()
731 put_page(cs->pg); in fuse_copy_finish()
733 cs->pg = NULL; in fuse_copy_finish()
740 static int fuse_copy_fill(struct fuse_copy_state *cs) in fuse_copy_fill() argument
745 err = unlock_request(cs->req); in fuse_copy_fill()
749 fuse_copy_finish(cs); in fuse_copy_fill()
750 if (cs->pipebufs) { in fuse_copy_fill()
751 struct pipe_buffer *buf = cs->pipebufs; in fuse_copy_fill()
753 if (!cs->write) { in fuse_copy_fill()
754 err = pipe_buf_confirm(cs->pipe, buf); in fuse_copy_fill()
758 BUG_ON(!cs->nr_segs); in fuse_copy_fill()
759 cs->currbuf = buf; in fuse_copy_fill()
760 cs->pg = buf->page; in fuse_copy_fill()
761 cs->offset = buf->offset; in fuse_copy_fill()
762 cs->len = buf->len; in fuse_copy_fill()
763 cs->pipebufs++; in fuse_copy_fill()
764 cs->nr_segs--; in fuse_copy_fill()
766 if (cs->nr_segs >= cs->pipe->max_usage) in fuse_copy_fill()
777 cs->currbuf = buf; in fuse_copy_fill()
778 cs->pg = page; in fuse_copy_fill()
779 cs->offset = 0; in fuse_copy_fill()
780 cs->len = PAGE_SIZE; in fuse_copy_fill()
781 cs->pipebufs++; in fuse_copy_fill()
782 cs->nr_segs++; in fuse_copy_fill()
786 err = iov_iter_get_pages2(cs->iter, &page, PAGE_SIZE, 1, &off); in fuse_copy_fill()
790 cs->len = err; in fuse_copy_fill()
791 cs->offset = off; in fuse_copy_fill()
792 cs->pg = page; in fuse_copy_fill()
795 return lock_request(cs->req); in fuse_copy_fill()
799 static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) in fuse_copy_do() argument
801 unsigned ncpy = min(*size, cs->len); in fuse_copy_do()
803 void *pgaddr = kmap_local_page(cs->pg); in fuse_copy_do()
804 void *buf = pgaddr + cs->offset; in fuse_copy_do()
806 if (cs->write) in fuse_copy_do()
815 cs->len -= ncpy; in fuse_copy_do()
816 cs->offset += ncpy; in fuse_copy_do()
839 static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) in fuse_try_move_page() argument
844 struct pipe_buffer *buf = cs->pipebufs; in fuse_try_move_page()
847 err = unlock_request(cs->req); in fuse_try_move_page()
851 fuse_copy_finish(cs); in fuse_try_move_page()
853 err = pipe_buf_confirm(cs->pipe, buf); in fuse_try_move_page()
857 BUG_ON(!cs->nr_segs); in fuse_try_move_page()
858 cs->currbuf = buf; in fuse_try_move_page()
859 cs->len = buf->len; in fuse_try_move_page()
860 cs->pipebufs++; in fuse_try_move_page()
861 cs->nr_segs--; in fuse_try_move_page()
863 if (cs->len != PAGE_SIZE) in fuse_try_move_page()
866 if (!pipe_buf_try_steal(cs->pipe, buf)) in fuse_try_move_page()
902 pipe_buf_release(cs->pipe, buf); in fuse_try_move_page()
905 spin_lock(&cs->req->waitq.lock); in fuse_try_move_page()
906 if (test_bit(FR_ABORTED, &cs->req->flags)) in fuse_try_move_page()
910 spin_unlock(&cs->req->waitq.lock); in fuse_try_move_page()
921 cs->len = 0; in fuse_try_move_page()
932 cs->pg = buf->page; in fuse_try_move_page()
933 cs->offset = buf->offset; in fuse_try_move_page()
935 err = lock_request(cs->req); in fuse_try_move_page()
942 static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page, in fuse_ref_page() argument
948 if (cs->nr_segs >= cs->pipe->max_usage) in fuse_ref_page()
952 err = unlock_request(cs->req); in fuse_ref_page()
958 fuse_copy_finish(cs); in fuse_ref_page()
960 buf = cs->pipebufs; in fuse_ref_page()
965 cs->pipebufs++; in fuse_ref_page()
966 cs->nr_segs++; in fuse_ref_page()
967 cs->len = 0; in fuse_ref_page()
976 static int fuse_copy_page(struct fuse_copy_state *cs, struct page **pagep, in fuse_copy_page() argument
986 if (cs->write && cs->pipebufs && page) { in fuse_copy_page()
991 if (cs->req->args->user_pages) { in fuse_copy_page()
992 err = fuse_copy_fill(cs); in fuse_copy_page()
996 return fuse_ref_page(cs, page, offset, count); in fuse_copy_page()
998 } else if (!cs->len) { in fuse_copy_page()
999 if (cs->move_pages && page && in fuse_copy_page()
1001 err = fuse_try_move_page(cs, pagep); in fuse_copy_page()
1005 err = fuse_copy_fill(cs); in fuse_copy_page()
1013 offset += fuse_copy_do(cs, &buf, &count); in fuse_copy_page()
1016 offset += fuse_copy_do(cs, NULL, &count); in fuse_copy_page()
1018 if (page && !cs->write) in fuse_copy_page()
1024 static int fuse_copy_pages(struct fuse_copy_state *cs, unsigned nbytes, in fuse_copy_pages() argument
1028 struct fuse_req *req = cs->req; in fuse_copy_pages()
1037 err = fuse_copy_page(cs, &ap->pages[i], offset, count, zeroing); in fuse_copy_pages()
1047 static int fuse_copy_one(struct fuse_copy_state *cs, void *val, unsigned size) in fuse_copy_one() argument
1050 if (!cs->len) { in fuse_copy_one()
1051 int err = fuse_copy_fill(cs); in fuse_copy_one()
1055 fuse_copy_do(cs, &val, &size); in fuse_copy_one()
1061 static int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, in fuse_copy_args() argument
1071 err = fuse_copy_pages(cs, arg->size, zeroing); in fuse_copy_args()
1073 err = fuse_copy_one(cs, arg->value, arg->size); in fuse_copy_args()
1098 struct fuse_copy_state *cs, in fuse_read_interrupt() argument
1119 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_interrupt()
1121 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_interrupt()
1122 fuse_copy_finish(cs); in fuse_read_interrupt()
1150 struct fuse_copy_state *cs, in fuse_read_single_forget() argument
1171 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_single_forget()
1173 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_single_forget()
1174 fuse_copy_finish(cs); in fuse_read_single_forget()
1183 struct fuse_copy_state *cs, size_t nbytes) in fuse_read_batch_forget() argument
1208 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_batch_forget()
1210 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_batch_forget()
1216 err = fuse_copy_one(cs, &forget->forget_one, in fuse_read_batch_forget()
1223 fuse_copy_finish(cs); in fuse_read_batch_forget()
1232 struct fuse_copy_state *cs, in fuse_read_forget() argument
1237 return fuse_read_single_forget(fiq, cs, nbytes); in fuse_read_forget()
1239 return fuse_read_batch_forget(fiq, cs, nbytes); in fuse_read_forget()
1252 struct fuse_copy_state *cs, size_t nbytes) in fuse_dev_do_read() argument
1304 return fuse_read_interrupt(fiq, cs, nbytes, req); in fuse_dev_do_read()
1309 return fuse_read_forget(fc, fiq, cs, nbytes); in fuse_dev_do_read()
1344 cs->req = req; in fuse_dev_do_read()
1345 err = fuse_copy_one(cs, &req->in.h, sizeof(req->in.h)); in fuse_dev_do_read()
1347 err = fuse_copy_args(cs, args->in_numargs, args->in_pages, in fuse_dev_do_read()
1349 fuse_copy_finish(cs); in fuse_dev_do_read()
1402 struct fuse_copy_state cs; in fuse_dev_read() local
1412 fuse_copy_init(&cs, 1, to); in fuse_dev_read()
1414 return fuse_dev_do_read(fud, file, &cs, iov_iter_count(to)); in fuse_dev_read()
1424 struct fuse_copy_state cs; in fuse_dev_splice_read() local
1435 fuse_copy_init(&cs, 1, NULL); in fuse_dev_splice_read()
1436 cs.pipebufs = bufs; in fuse_dev_splice_read()
1437 cs.pipe = pipe; in fuse_dev_splice_read()
1438 ret = fuse_dev_do_read(fud, in, &cs, len); in fuse_dev_splice_read()
1442 if (pipe_occupancy(pipe->head, pipe->tail) + cs.nr_segs > pipe->max_usage) { in fuse_dev_splice_read()
1447 for (ret = total = 0; page_nr < cs.nr_segs; total += ret) { in fuse_dev_splice_read()
1461 for (; page_nr < cs.nr_segs; page_nr++) in fuse_dev_splice_read()
1469 struct fuse_copy_state *cs) in fuse_notify_poll() argument
1477 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_poll()
1481 fuse_copy_finish(cs); in fuse_notify_poll()
1485 fuse_copy_finish(cs); in fuse_notify_poll()
1490 struct fuse_copy_state *cs) in fuse_notify_inval_inode() argument
1498 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_inval_inode()
1501 fuse_copy_finish(cs); in fuse_notify_inval_inode()
1510 fuse_copy_finish(cs); in fuse_notify_inval_inode()
1515 struct fuse_copy_state *cs) in fuse_notify_inval_entry() argument
1530 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_inval_entry()
1544 err = fuse_copy_one(cs, buf, outarg.namelen + 1); in fuse_notify_inval_entry()
1547 fuse_copy_finish(cs); in fuse_notify_inval_entry()
1558 fuse_copy_finish(cs); in fuse_notify_inval_entry()
1563 struct fuse_copy_state *cs) in fuse_notify_delete() argument
1578 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_delete()
1592 err = fuse_copy_one(cs, buf, outarg.namelen + 1); in fuse_notify_delete()
1595 fuse_copy_finish(cs); in fuse_notify_delete()
1606 fuse_copy_finish(cs); in fuse_notify_delete()
1611 struct fuse_copy_state *cs) in fuse_notify_store() argument
1628 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_store()
1667 err = fuse_copy_page(cs, &page, offset, this_num, 0); in fuse_notify_store()
1691 fuse_copy_finish(cs); in fuse_notify_store()
1791 struct fuse_copy_state *cs) in fuse_notify_retrieve() argument
1803 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_retrieve()
1807 fuse_copy_finish(cs); in fuse_notify_retrieve()
1823 fuse_copy_finish(cs); in fuse_notify_retrieve()
1891 unsigned int size, struct fuse_copy_state *cs) in fuse_notify() argument
1894 cs->move_pages = 0; in fuse_notify()
1898 return fuse_notify_poll(fc, size, cs); in fuse_notify()
1901 return fuse_notify_inval_inode(fc, size, cs); in fuse_notify()
1904 return fuse_notify_inval_entry(fc, size, cs); in fuse_notify()
1907 return fuse_notify_store(fc, size, cs); in fuse_notify()
1910 return fuse_notify_retrieve(fc, size, cs); in fuse_notify()
1913 return fuse_notify_delete(fc, size, cs); in fuse_notify()
1919 fuse_copy_finish(cs); in fuse_notify()
1937 static int copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, in copy_out_args() argument
1954 return fuse_copy_args(cs, args->out_numargs, args->out_pages, in copy_out_args()
1966 struct fuse_copy_state *cs, size_t nbytes) in fuse_dev_do_write() argument
1978 err = fuse_copy_one(cs, &oh, sizeof(oh)); in fuse_dev_do_write()
1991 err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); in fuse_dev_do_write()
2033 cs->req = req; in fuse_dev_do_write()
2035 cs->move_pages = 0; in fuse_dev_do_write()
2040 err = copy_out_args(cs, req->args, nbytes); in fuse_dev_do_write()
2041 fuse_copy_finish(cs); in fuse_dev_do_write()
2058 fuse_copy_finish(cs); in fuse_dev_do_write()
2064 struct fuse_copy_state cs; in fuse_dev_write() local
2073 fuse_copy_init(&cs, 0, from); in fuse_dev_write()
2075 return fuse_dev_do_write(fud, &cs, iov_iter_count(from)); in fuse_dev_write()
2086 struct fuse_copy_state cs; in fuse_dev_splice_write() local
2148 fuse_copy_init(&cs, 0, NULL); in fuse_dev_splice_write()
2149 cs.pipebufs = bufs; in fuse_dev_splice_write()
2150 cs.nr_segs = nbuf; in fuse_dev_splice_write()
2151 cs.pipe = pipe; in fuse_dev_splice_write()
2154 cs.move_pages = 1; in fuse_dev_splice_write()
2156 ret = fuse_dev_do_write(fud, &cs, len); in fuse_dev_splice_write()