Lines Matching full:cs
664 static void fuse_copy_init(struct fuse_copy_state *cs, int write, in fuse_copy_init() argument
667 memset(cs, 0, sizeof(*cs)); in fuse_copy_init()
668 cs->write = write; in fuse_copy_init()
669 cs->iter = iter; in fuse_copy_init()
673 static void fuse_copy_finish(struct fuse_copy_state *cs) in fuse_copy_finish() argument
675 if (cs->currbuf) { in fuse_copy_finish()
676 struct pipe_buffer *buf = cs->currbuf; in fuse_copy_finish()
678 if (cs->write) in fuse_copy_finish()
679 buf->len = PAGE_SIZE - cs->len; in fuse_copy_finish()
680 cs->currbuf = NULL; in fuse_copy_finish()
681 } else if (cs->pg) { in fuse_copy_finish()
682 if (cs->write) { in fuse_copy_finish()
683 flush_dcache_page(cs->pg); in fuse_copy_finish()
684 set_page_dirty_lock(cs->pg); in fuse_copy_finish()
686 put_page(cs->pg); in fuse_copy_finish()
688 cs->pg = NULL; in fuse_copy_finish()
695 static int fuse_copy_fill(struct fuse_copy_state *cs) in fuse_copy_fill() argument
700 err = unlock_request(cs->req); in fuse_copy_fill()
704 fuse_copy_finish(cs); in fuse_copy_fill()
705 if (cs->pipebufs) { in fuse_copy_fill()
706 struct pipe_buffer *buf = cs->pipebufs; in fuse_copy_fill()
708 if (!cs->write) { in fuse_copy_fill()
709 err = pipe_buf_confirm(cs->pipe, buf); in fuse_copy_fill()
713 BUG_ON(!cs->nr_segs); in fuse_copy_fill()
714 cs->currbuf = buf; in fuse_copy_fill()
715 cs->pg = buf->page; in fuse_copy_fill()
716 cs->offset = buf->offset; in fuse_copy_fill()
717 cs->len = buf->len; in fuse_copy_fill()
718 cs->pipebufs++; in fuse_copy_fill()
719 cs->nr_segs--; in fuse_copy_fill()
721 if (cs->nr_segs >= cs->pipe->max_usage) in fuse_copy_fill()
732 cs->currbuf = buf; in fuse_copy_fill()
733 cs->pg = page; in fuse_copy_fill()
734 cs->offset = 0; in fuse_copy_fill()
735 cs->len = PAGE_SIZE; in fuse_copy_fill()
736 cs->pipebufs++; in fuse_copy_fill()
737 cs->nr_segs++; in fuse_copy_fill()
741 err = iov_iter_get_pages(cs->iter, &page, PAGE_SIZE, 1, &off); in fuse_copy_fill()
745 cs->len = err; in fuse_copy_fill()
746 cs->offset = off; in fuse_copy_fill()
747 cs->pg = page; in fuse_copy_fill()
748 iov_iter_advance(cs->iter, err); in fuse_copy_fill()
751 return lock_request(cs->req); in fuse_copy_fill()
755 static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) in fuse_copy_do() argument
757 unsigned ncpy = min(*size, cs->len); in fuse_copy_do()
759 void *pgaddr = kmap_atomic(cs->pg); in fuse_copy_do()
760 void *buf = pgaddr + cs->offset; in fuse_copy_do()
762 if (cs->write) in fuse_copy_do()
771 cs->len -= ncpy; in fuse_copy_do()
772 cs->offset += ncpy; in fuse_copy_do()
794 static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) in fuse_try_move_page() argument
799 struct pipe_buffer *buf = cs->pipebufs; in fuse_try_move_page()
802 err = unlock_request(cs->req); in fuse_try_move_page()
806 fuse_copy_finish(cs); in fuse_try_move_page()
808 err = pipe_buf_confirm(cs->pipe, buf); in fuse_try_move_page()
812 BUG_ON(!cs->nr_segs); in fuse_try_move_page()
813 cs->currbuf = buf; in fuse_try_move_page()
814 cs->len = buf->len; in fuse_try_move_page()
815 cs->pipebufs++; in fuse_try_move_page()
816 cs->nr_segs--; in fuse_try_move_page()
818 if (cs->len != PAGE_SIZE) in fuse_try_move_page()
821 if (!pipe_buf_try_steal(cs->pipe, buf)) in fuse_try_move_page()
859 spin_lock(&cs->req->waitq.lock); in fuse_try_move_page()
860 if (test_bit(FR_ABORTED, &cs->req->flags)) in fuse_try_move_page()
864 spin_unlock(&cs->req->waitq.lock); in fuse_try_move_page()
875 cs->len = 0; in fuse_try_move_page()
886 cs->pg = buf->page; in fuse_try_move_page()
887 cs->offset = buf->offset; in fuse_try_move_page()
889 err = lock_request(cs->req); in fuse_try_move_page()
896 static int fuse_ref_page(struct fuse_copy_state *cs, struct page *page, in fuse_ref_page() argument
902 if (cs->nr_segs >= cs->pipe->max_usage) in fuse_ref_page()
906 err = unlock_request(cs->req); in fuse_ref_page()
912 fuse_copy_finish(cs); in fuse_ref_page()
914 buf = cs->pipebufs; in fuse_ref_page()
919 cs->pipebufs++; in fuse_ref_page()
920 cs->nr_segs++; in fuse_ref_page()
921 cs->len = 0; in fuse_ref_page()
930 static int fuse_copy_page(struct fuse_copy_state *cs, struct page **pagep, in fuse_copy_page() argument
940 if (cs->write && cs->pipebufs && page) { in fuse_copy_page()
941 return fuse_ref_page(cs, page, offset, count); in fuse_copy_page()
942 } else if (!cs->len) { in fuse_copy_page()
943 if (cs->move_pages && page && in fuse_copy_page()
945 err = fuse_try_move_page(cs, pagep); in fuse_copy_page()
949 err = fuse_copy_fill(cs); in fuse_copy_page()
957 offset += fuse_copy_do(cs, &buf, &count); in fuse_copy_page()
960 offset += fuse_copy_do(cs, NULL, &count); in fuse_copy_page()
962 if (page && !cs->write) in fuse_copy_page()
968 static int fuse_copy_pages(struct fuse_copy_state *cs, unsigned nbytes, in fuse_copy_pages() argument
972 struct fuse_req *req = cs->req; in fuse_copy_pages()
981 err = fuse_copy_page(cs, &ap->pages[i], offset, count, zeroing); in fuse_copy_pages()
991 static int fuse_copy_one(struct fuse_copy_state *cs, void *val, unsigned size) in fuse_copy_one() argument
994 if (!cs->len) { in fuse_copy_one()
995 int err = fuse_copy_fill(cs); in fuse_copy_one()
999 fuse_copy_do(cs, &val, &size); in fuse_copy_one()
1005 static int fuse_copy_args(struct fuse_copy_state *cs, unsigned numargs, in fuse_copy_args() argument
1015 err = fuse_copy_pages(cs, arg->size, zeroing); in fuse_copy_args()
1017 err = fuse_copy_one(cs, arg->value, arg->size); in fuse_copy_args()
1042 struct fuse_copy_state *cs, in fuse_read_interrupt() argument
1063 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_interrupt()
1065 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_interrupt()
1066 fuse_copy_finish(cs); in fuse_read_interrupt()
1095 struct fuse_copy_state *cs, in fuse_read_single_forget() argument
1116 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_single_forget()
1118 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_single_forget()
1119 fuse_copy_finish(cs); in fuse_read_single_forget()
1128 struct fuse_copy_state *cs, size_t nbytes) in fuse_read_batch_forget() argument
1153 err = fuse_copy_one(cs, &ih, sizeof(ih)); in fuse_read_batch_forget()
1155 err = fuse_copy_one(cs, &arg, sizeof(arg)); in fuse_read_batch_forget()
1161 err = fuse_copy_one(cs, &forget->forget_one, in fuse_read_batch_forget()
1168 fuse_copy_finish(cs); in fuse_read_batch_forget()
1177 struct fuse_copy_state *cs, in fuse_read_forget() argument
1182 return fuse_read_single_forget(fiq, cs, nbytes); in fuse_read_forget()
1184 return fuse_read_batch_forget(fiq, cs, nbytes); in fuse_read_forget()
1197 struct fuse_copy_state *cs, size_t nbytes) in fuse_dev_do_read() argument
1249 return fuse_read_interrupt(fiq, cs, nbytes, req); in fuse_dev_do_read()
1254 return fuse_read_forget(fc, fiq, cs, nbytes); in fuse_dev_do_read()
1280 cs->req = req; in fuse_dev_do_read()
1281 err = fuse_copy_one(cs, &req->in.h, sizeof(req->in.h)); in fuse_dev_do_read()
1283 err = fuse_copy_args(cs, args->in_numargs, args->in_pages, in fuse_dev_do_read()
1285 fuse_copy_finish(cs); in fuse_dev_do_read()
1338 struct fuse_copy_state cs; in fuse_dev_read() local
1348 fuse_copy_init(&cs, 1, to); in fuse_dev_read()
1350 return fuse_dev_do_read(fud, file, &cs, iov_iter_count(to)); in fuse_dev_read()
1360 struct fuse_copy_state cs; in fuse_dev_splice_read() local
1371 fuse_copy_init(&cs, 1, NULL); in fuse_dev_splice_read()
1372 cs.pipebufs = bufs; in fuse_dev_splice_read()
1373 cs.pipe = pipe; in fuse_dev_splice_read()
1374 ret = fuse_dev_do_read(fud, in, &cs, len); in fuse_dev_splice_read()
1378 if (pipe_occupancy(pipe->head, pipe->tail) + cs.nr_segs > pipe->max_usage) { in fuse_dev_splice_read()
1383 for (ret = total = 0; page_nr < cs.nr_segs; total += ret) { in fuse_dev_splice_read()
1397 for (; page_nr < cs.nr_segs; page_nr++) in fuse_dev_splice_read()
1405 struct fuse_copy_state *cs) in fuse_notify_poll() argument
1413 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_poll()
1417 fuse_copy_finish(cs); in fuse_notify_poll()
1421 fuse_copy_finish(cs); in fuse_notify_poll()
1426 struct fuse_copy_state *cs) in fuse_notify_inval_inode() argument
1434 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_inval_inode()
1437 fuse_copy_finish(cs); in fuse_notify_inval_inode()
1446 fuse_copy_finish(cs); in fuse_notify_inval_inode()
1451 struct fuse_copy_state *cs) in fuse_notify_inval_entry() argument
1466 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_inval_entry()
1480 err = fuse_copy_one(cs, buf, outarg.namelen + 1); in fuse_notify_inval_entry()
1483 fuse_copy_finish(cs); in fuse_notify_inval_entry()
1494 fuse_copy_finish(cs); in fuse_notify_inval_entry()
1499 struct fuse_copy_state *cs) in fuse_notify_delete() argument
1514 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_delete()
1528 err = fuse_copy_one(cs, buf, outarg.namelen + 1); in fuse_notify_delete()
1531 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()
1603 err = fuse_copy_page(cs, &page, offset, this_num, 0); in fuse_notify_store()
1625 fuse_copy_finish(cs); in fuse_notify_store()
1725 struct fuse_copy_state *cs) in fuse_notify_retrieve() argument
1737 err = fuse_copy_one(cs, &outarg, sizeof(outarg)); in fuse_notify_retrieve()
1741 fuse_copy_finish(cs); in fuse_notify_retrieve()
1757 fuse_copy_finish(cs); in fuse_notify_retrieve()
1762 unsigned int size, struct fuse_copy_state *cs) in fuse_notify() argument
1765 cs->move_pages = 0; in fuse_notify()
1769 return fuse_notify_poll(fc, size, cs); in fuse_notify()
1772 return fuse_notify_inval_inode(fc, size, cs); in fuse_notify()
1775 return fuse_notify_inval_entry(fc, size, cs); in fuse_notify()
1778 return fuse_notify_store(fc, size, cs); in fuse_notify()
1781 return fuse_notify_retrieve(fc, size, cs); in fuse_notify()
1784 return fuse_notify_delete(fc, size, cs); in fuse_notify()
1787 fuse_copy_finish(cs); in fuse_notify()
1805 static int copy_out_args(struct fuse_copy_state *cs, struct fuse_args *args, in copy_out_args() argument
1822 return fuse_copy_args(cs, args->out_numargs, args->out_pages, in copy_out_args()
1834 struct fuse_copy_state *cs, size_t nbytes) in fuse_dev_do_write() argument
1846 err = fuse_copy_one(cs, &oh, sizeof(oh)); in fuse_dev_do_write()
1859 err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), cs); in fuse_dev_do_write()
1901 cs->req = req; in fuse_dev_do_write()
1903 cs->move_pages = 0; in fuse_dev_do_write()
1908 err = copy_out_args(cs, req->args, nbytes); in fuse_dev_do_write()
1909 fuse_copy_finish(cs); in fuse_dev_do_write()
1926 fuse_copy_finish(cs); in fuse_dev_do_write()
1932 struct fuse_copy_state cs; in fuse_dev_write() local
1941 fuse_copy_init(&cs, 0, from); in fuse_dev_write()
1943 return fuse_dev_do_write(fud, &cs, iov_iter_count(from)); in fuse_dev_write()
1954 struct fuse_copy_state cs; in fuse_dev_splice_write() local
2016 fuse_copy_init(&cs, 0, NULL); in fuse_dev_splice_write()
2017 cs.pipebufs = bufs; in fuse_dev_splice_write()
2018 cs.nr_segs = nbuf; in fuse_dev_splice_write()
2019 cs.pipe = pipe; in fuse_dev_splice_write()
2022 cs.move_pages = 1; in fuse_dev_splice_write()
2024 ret = fuse_dev_do_write(fud, &cs, len); in fuse_dev_splice_write()