Lines Matching refs:n
14 #define iterate_iovec(i, n, __v, __p, skip, STEP) { \ argument
16 size_t wanted = n; \
18 __v.iov_len = min(n, __p->iov_len - skip); \
24 n -= __v.iov_len; \
28 while (unlikely(!left && n)) { \
30 __v.iov_len = min(n, __p->iov_len); \
37 n -= __v.iov_len; \
39 n = wanted - n; \
42 #define iterate_kvec(i, n, __v, __p, skip, STEP) { \ argument
43 size_t wanted = n; \
45 __v.iov_len = min(n, __p->iov_len - skip); \
50 n -= __v.iov_len; \
52 while (unlikely(n)) { \
54 __v.iov_len = min(n, __p->iov_len); \
60 n -= __v.iov_len; \
62 n = wanted; \
65 #define iterate_bvec(i, n, __v, __bi, skip, STEP) { \ argument
67 __start.bi_size = n; \
77 #define iterate_all_kinds(i, n, v, I, B, K) { \ argument
78 if (likely(n)) { \
83 iterate_bvec(i, n, v, __bi, skip, (B)) \
87 iterate_kvec(i, n, v, kvec, skip, (K)) \
92 iterate_iovec(i, n, v, iov, skip, (I)) \
97 #define iterate_and_advance(i, n, v, I, B, K) { \ argument
98 if (unlikely(i->count < n)) \
99 n = i->count; \
106 iterate_bvec(i, n, v, __bi, skip, (B)) \
113 iterate_kvec(i, n, v, kvec, skip, (K)) \
121 skip += n; \
125 iterate_iovec(i, n, v, iov, skip, (I)) \
133 i->count -= n; \
138 static int copyout(void __user *to, const void *from, size_t n) in copyout() argument
140 if (access_ok(to, n)) { in copyout()
141 kasan_check_read(from, n); in copyout()
142 n = raw_copy_to_user(to, from, n); in copyout()
144 return n; in copyout()
147 static int copyin(void *to, const void __user *from, size_t n) in copyin() argument
149 if (access_ok(from, n)) { in copyin()
150 kasan_check_write(to, n); in copyin()
151 n = raw_copy_from_user(to, from, n); in copyin()
153 return n; in copyin()
544 size_t n, off; in copy_pipe_to_iter() local
550 bytes = n = push_pipe(i, bytes, &idx, &off); in copy_pipe_to_iter()
551 if (unlikely(!n)) in copy_pipe_to_iter()
553 for ( ; n; idx = next_idx(idx, pipe), off = 0) { in copy_pipe_to_iter()
554 size_t chunk = min_t(size_t, n, PAGE_SIZE - off); in copy_pipe_to_iter()
558 n -= chunk; in copy_pipe_to_iter()
576 size_t n, r; in csum_and_copy_to_pipe_iter() local
584 bytes = n = push_pipe(i, bytes, &idx, &r); in csum_and_copy_to_pipe_iter()
585 if (unlikely(!n)) in csum_and_copy_to_pipe_iter()
587 for ( ; n; idx = next_idx(idx, pipe), r = 0) { in csum_and_copy_to_pipe_iter()
588 size_t chunk = min_t(size_t, n, PAGE_SIZE - r); in csum_and_copy_to_pipe_iter()
594 n -= chunk; in csum_and_copy_to_pipe_iter()
622 static int copyout_mcsafe(void __user *to, const void *from, size_t n) in copyout_mcsafe() argument
624 if (access_ok(to, n)) { in copyout_mcsafe()
625 kasan_check_read(from, n); in copyout_mcsafe()
626 n = copy_to_user_mcsafe((__force void *) to, from, n); in copyout_mcsafe()
628 return n; in copyout_mcsafe()
648 size_t n, off, xfer = 0; in copy_pipe_to_iter_mcsafe() local
654 bytes = n = push_pipe(i, bytes, &idx, &off); in copy_pipe_to_iter_mcsafe()
655 if (unlikely(!n)) in copy_pipe_to_iter_mcsafe()
657 for ( ; n; idx = next_idx(idx, pipe), off = 0) { in copy_pipe_to_iter_mcsafe()
658 size_t chunk = min_t(size_t, n, PAGE_SIZE - off); in copy_pipe_to_iter_mcsafe()
668 n -= chunk; in copy_pipe_to_iter_mcsafe()
863 static inline bool page_copy_sane(struct page *page, size_t offset, size_t n) in page_copy_sane() argument
866 size_t v = n + offset; in page_copy_sane()
875 if (n <= v && v <= PAGE_SIZE) in page_copy_sane()
881 if (likely(n <= v && v <= (page_size(head)))) in page_copy_sane()
928 size_t n, off; in pipe_zero() local
934 bytes = n = push_pipe(i, bytes, &idx, &off); in pipe_zero()
935 if (unlikely(!n)) in pipe_zero()
938 for ( ; n; idx = next_idx(idx, pipe), off = 0) { in pipe_zero()
939 size_t chunk = min_t(size_t, n, PAGE_SIZE - off); in pipe_zero()
943 n -= chunk; in pipe_zero()
1059 size_t n = off - pipe->bufs[idx].offset; in iov_iter_revert() local
1060 if (unroll < n) { in iov_iter_revert()
1064 unroll -= n; in iov_iter_revert()
1088 size_t n = (--bvec)->bv_len; in iov_iter_revert() local
1090 if (unroll <= n) { in iov_iter_revert()
1092 i->iov_offset = n - unroll; in iov_iter_revert()
1095 unroll -= n; in iov_iter_revert()
1100 size_t n = (--iov)->iov_len; in iov_iter_revert() local
1102 if (unroll <= n) { in iov_iter_revert()
1104 i->iov_offset = n - unroll; in iov_iter_revert()
1107 unroll -= n; in iov_iter_revert()
1238 ssize_t n = push_pipe(i, maxsize, &idx, start); in __pipe_get_pages() local
1239 if (!n) in __pipe_get_pages()
1242 maxsize = n; in __pipe_get_pages()
1243 n += *start; in __pipe_get_pages()
1244 while (n > 0) { in __pipe_get_pages()
1247 n -= PAGE_SIZE; in __pipe_get_pages()
1290 int n; in iov_iter_get_pages()
1296 n = DIV_ROUND_UP(len, PAGE_SIZE); in iov_iter_get_pages()
1297 res = get_user_pages_fast(addr, n, in iov_iter_get_pages()
1302 return (res == n ? len : res * PAGE_SIZE) - *start; in iov_iter_get_pages()
1316 static struct page **get_pages_array(size_t n) in get_pages_array() argument
1318 return kvmalloc_array(n, sizeof(struct page *), GFP_KERNEL); in get_pages_array()
1326 ssize_t n; in pipe_get_pages_alloc() local
1339 n = npages * PAGE_SIZE - *start; in pipe_get_pages_alloc()
1340 if (maxsize > n) in pipe_get_pages_alloc()
1341 maxsize = n; in pipe_get_pages_alloc()
1347 n = __pipe_get_pages(i, maxsize, p, idx, start); in pipe_get_pages_alloc()
1348 if (n > 0) in pipe_get_pages_alloc()
1352 return n; in pipe_get_pages_alloc()
1372 int n; in iov_iter_get_pages_alloc()
1376 n = DIV_ROUND_UP(len, PAGE_SIZE); in iov_iter_get_pages_alloc()
1377 p = get_pages_array(n); in iov_iter_get_pages_alloc()
1380 res = get_user_pages_fast(addr, n, in iov_iter_get_pages_alloc()
1387 return (res == n ? len : res * PAGE_SIZE) - *start; in iov_iter_get_pages_alloc()
1643 ssize_t n; in import_iovec() local
1645 n = rw_copy_check_uvector(type, uvector, nr_segs, fast_segs, in import_iovec()
1647 if (n < 0) { in import_iovec()
1651 return n; in import_iovec()
1653 iov_iter_init(i, type, p, nr_segs, n); in import_iovec()
1655 return n; in import_iovec()
1667 ssize_t n; in compat_import_iovec() local
1669 n = compat_rw_copy_check_uvector(type, uvector, nr_segs, fast_segs, in compat_import_iovec()
1671 if (n < 0) { in compat_import_iovec()
1675 return n; in compat_import_iovec()
1677 iov_iter_init(i, type, p, nr_segs, n); in compat_import_iovec()
1679 return n; in compat_import_iovec()