Lines Matching full:copy
58 "Enable inter server to server copy offload. Default: false");
60 static void cleanup_async_copy(struct nfsd4_copy *copy);
413 * field isn't set for some reason, throw warning and just copy
964 * If we do a zero copy read, then a client will see read data
968 * To ensure proper ordering, we therefore turn off zero copy if
1309 * nfsd4_has_active_async_copies - Check for ongoing copy operations
1312 * NFSD maintains state for async COPY operations after they complete,
1318 * %true: At least one active async COPY is ongoing
1319 * %false: No active async COPY operations were found
1323 struct nfsd4_copy *copy;
1327 list_for_each_entry(copy, &clp->async_copies, copies) {
1328 if (!test_bit(NFSD4_COPY_F_COMPLETED, ©->cp_flags) &&
1329 !test_bit(NFSD4_COPY_F_STOPPED, ©->cp_flags)) {
1340 * @nn: Network namespace with possible active copy information
1345 struct nfsd4_copy *copy;
1354 copy = list_entry(pos, struct nfsd4_copy, copies);
1355 if (test_bit(NFSD4_COPY_F_OFFLOAD_DONE, ©->cp_flags)) {
1356 if (--copy->cp_ttl) {
1357 list_del_init(©->copies);
1358 list_add(©->copies, &reaplist);
1367 copy = list_first_entry(&reaplist, struct nfsd4_copy, copies);
1368 list_del_init(©->copies);
1369 cleanup_async_copy(copy);
1373 static void nfs4_put_copy(struct nfsd4_copy *copy)
1375 if (!refcount_dec_and_test(©->refcount))
1377 kfree(copy->cp_src);
1378 kfree(copy);
1381 static void nfsd4_stop_copy(struct nfsd4_copy *copy)
1383 trace_nfsd_copy_async_cancel(copy);
1384 if (!test_and_set_bit(NFSD4_COPY_F_STOPPED, ©->cp_flags)) {
1385 kthread_stop(copy->copy_task);
1386 copy->nfserr = nfs_ok;
1387 set_bit(NFSD4_COPY_F_COMPLETED, ©->cp_flags);
1389 nfs4_put_copy(copy);
1394 struct nfsd4_copy *copy = NULL;
1398 copy = list_first_entry(&clp->async_copies, struct nfsd4_copy,
1400 refcount_inc(©->refcount);
1401 copy->cp_clp = NULL;
1402 if (!list_empty(©->copies))
1403 list_del_init(©->copies);
1406 return copy;
1411 struct nfsd4_copy *copy;
1413 while ((copy = nfsd4_unhash_copy(clp)) != NULL)
1414 nfsd4_stop_copy(copy);
1505 * Support one copy source server for now.
1599 * Verify COPY destination stateid.
1603 * Called with COPY cstate:
1610 struct nfsd4_copy *copy)
1613 stateid_t *s_stid = ©->cp_src_stateid;
1618 ©->cp_dst_stateid,
1619 WR_STATE, ©->nf_dst, NULL);
1623 status = nfsd4_interssc_connect(copy->cp_src, rqstp, ©->ss_nsui);
1629 copy->c_fh.size = s_fh->fh_handle.fh_size;
1630 memcpy(copy->c_fh.data, &s_fh->fh_handle.fh_raw, copy->c_fh.size);
1631 copy->stateid.seqid = cpu_to_be32(s_stid->si_generation);
1632 memcpy(copy->stateid.other, (void *)&s_stid->si_opaque,
1668 struct nfsd4_copy *copy)
1690 struct nfsd4_copy *copy)
1692 return nfsd4_verify_copy(rqstp, cstate, ©->cp_src_stateid,
1693 ©->nf_src, ©->cp_dst_stateid,
1694 ©->nf_dst);
1701 struct nfsd4_copy *copy =
1704 set_bit(NFSD4_COPY_F_OFFLOAD_DONE, ©->cp_flags);
1731 static void nfsd4_init_copy_res(struct nfsd4_copy *copy, bool sync)
1733 copy->cp_res.wr_stable_how =
1734 test_bit(NFSD4_COPY_F_COMMITTED, ©->cp_flags) ?
1736 nfsd4_copy_set_sync(copy, sync);
1739 static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy,
1745 u64 bytes_total = copy->cp_count;
1746 u64 src_pos = copy->cp_src_pos;
1747 u64 dst_pos = copy->cp_dst_pos;
1763 copy->cp_res.wr_bytes_written += bytes_copied;
1766 } while (bytes_total > 0 && nfsd4_copy_is_async(copy));
1767 /* for a non-zero asynchronous copy do a commit of data */
1768 if (nfsd4_copy_is_async(copy) && copy->cp_res.wr_bytes_written > 0) {
1770 end = copy->cp_dst_pos + copy->cp_res.wr_bytes_written - 1;
1771 status = vfs_fsync_range(dst, copy->cp_dst_pos, end, 0);
1775 set_bit(NFSD4_COPY_F_COMMITTED, ©->cp_flags);
1780 static __be32 nfsd4_do_copy(struct nfsd4_copy *copy,
1787 bytes = _nfsd_copy_file_range(copy, dst, src);
1789 /* for async copy, we ignore the error, client can always retry
1792 if (bytes < 0 && !copy->cp_res.wr_bytes_written)
1795 nfsd4_init_copy_res(copy, sync);
1822 static void release_copy_files(struct nfsd4_copy *copy)
1824 if (copy->nf_src)
1825 nfsd_file_put(copy->nf_src);
1826 if (copy->nf_dst)
1827 nfsd_file_put(copy->nf_dst);
1830 static void cleanup_async_copy(struct nfsd4_copy *copy)
1832 nfs4_free_copy_state(copy);
1833 release_copy_files(copy);
1834 if (copy->cp_clp) {
1835 spin_lock(©->cp_clp->async_lock);
1836 if (!list_empty(©->copies))
1837 list_del_init(©->copies);
1838 spin_unlock(©->cp_clp->async_lock);
1840 nfs4_put_copy(copy);
1843 static void nfsd4_send_cb_offload(struct nfsd4_copy *copy)
1845 struct nfsd4_cb_offload *cbo = ©->cp_cb_offload;
1847 memcpy(&cbo->co_res, ©->cp_res, sizeof(copy->cp_res));
1848 memcpy(&cbo->co_fh, ©->fh, sizeof(copy->fh));
1849 cbo->co_nfserr = copy->nfserr;
1852 nfsd4_init_cb(&cbo->co_cb, copy->cp_clp, &nfsd4_cb_offload_ops,
1857 trace_nfsd_cb_offload(copy->cp_clp, &cbo->co_res.cb_stateid,
1858 &cbo->co_fh, copy->cp_count, copy->nfserr);
1863 * nfsd4_do_async_copy - kthread function for background server-side COPY
1864 * @data: arguments for COPY operation
1867 * %0: Copy operation is done.
1871 struct nfsd4_copy *copy = (struct nfsd4_copy *)data;
1873 trace_nfsd_copy_async(copy);
1874 if (nfsd4_ssc_is_inter(copy)) {
1877 filp = nfs42_ssc_open(copy->ss_nsui->nsui_vfsmount,
1878 ©->c_fh, ©->stateid);
1882 copy->nfserr = nfserr_wrong_type;
1885 copy->nfserr = nfserr_offload_denied;
1890 copy->nfserr = nfsd4_do_copy(copy, filp, copy->nf_dst->nf_file,
1892 nfsd4_cleanup_inter_ssc(copy->ss_nsui, filp, copy->nf_dst);
1894 copy->nfserr = nfsd4_do_copy(copy, copy->nf_src->nf_file,
1895 copy->nf_dst->nf_file, false);
1901 set_bit(NFSD4_COPY_F_STOPPED, ©->cp_flags);
1903 set_bit(NFSD4_COPY_F_COMPLETED, ©->cp_flags);
1904 trace_nfsd_copy_async_done(copy);
1905 nfsd4_send_cb_offload(copy);
1906 atomic_dec(©->cp_nn->pending_async_copies);
1916 struct nfsd4_copy *copy = &u->copy;
1920 result = ©->cp_res;
1923 copy->cp_clp = cstate->clp;
1924 if (nfsd4_ssc_is_inter(copy)) {
1925 trace_nfsd_copy_inter(copy);
1926 if (!inter_copy_offload_enable || nfsd4_copy_is_sync(copy)) {
1930 status = nfsd4_setup_inter_ssc(rqstp, cstate, copy);
1932 trace_nfsd_copy_done(copy, status);
1936 trace_nfsd_copy_intra(copy);
1937 status = nfsd4_setup_intra_ssc(rqstp, cstate, copy);
1939 trace_nfsd_copy_done(copy, status);
1944 memcpy(©->fh, &cstate->current_fh.fh_handle,
1946 if (nfsd4_copy_is_async(copy)) {
1954 /* Arbitrary cap on number of pending async copy operations */
1961 if (!nfs4_init_copy_state(nn, copy))
1963 memcpy(&result->cb_stateid, ©->cp_stateid.cs_stid,
1965 dup_copy_fields(copy, async_copy);
1972 async_copy, "%s", "copy thread");
1982 status = nfsd4_do_copy(copy, copy->nf_src->nf_file,
1983 copy->nf_dst->nf_file, true);
1986 trace_nfsd_copy_done(copy, status);
1987 release_copy_files(copy);
1993 if (nfsd4_ssc_is_inter(copy)) {
1995 * Source's vfsmount of inter-copy will be unmounted
1996 * by the laundromat. Use copy instead of async_copy
1999 refcount_dec(©->ss_nsui->nsui_refcnt);
2010 struct nfsd4_copy *copy;
2014 list_for_each_entry(copy, &clp->async_copies, copies) {
2015 if (memcmp(©->cp_stateid.cs_stid, stateid, NFS4_STATEID_SIZE))
2017 return copy;
2025 struct nfsd4_copy *copy;
2028 copy = find_async_copy_locked(clp, stateid);
2029 if (copy)
2030 refcount_inc(©->refcount);
2032 return copy;
2041 struct nfsd4_copy *copy;
2044 copy = find_async_copy(clp, &os->stateid);
2045 if (!copy) {
2050 nfsd4_stop_copy(copy);
2129 struct nfsd4_copy *copy;
2134 copy = find_async_copy_locked(clp, &os->stateid);
2135 if (copy) {
2136 os->count = copy->cp_res.wr_bytes_written;
2137 if (test_bit(NFSD4_COPY_F_COMPLETED, ©->cp_flags)) {
2139 os->status = copy->nfserr;
2618 * Get the entire list, then copy out only the user attributes
2751 struct nfsd4_copy *copy;
2755 /* traverse all operation and if it's a COPY compound, mark the
2767 copy = (struct nfsd4_copy *)&op->u;
2773 if (nfsd4_ssc_is_inter(copy))