Lines Matching refs:copy

782 	 * If we do a zero copy read, then a client will see read data
786 * To ensure proper ordering, we therefore turn off zero copy if
1108 void nfs4_put_copy(struct nfsd4_copy *copy)
1110 if (!refcount_dec_and_test(&copy->refcount))
1112 kfree(copy);
1116 check_and_set_stop_copy(struct nfsd4_copy *copy)
1120 spin_lock(&copy->cp_clp->async_lock);
1121 value = copy->stopped;
1122 if (!copy->stopped)
1123 copy->stopped = true;
1124 spin_unlock(&copy->cp_clp->async_lock);
1128 static void nfsd4_stop_copy(struct nfsd4_copy *copy)
1130 /* only 1 thread should stop the copy */
1131 if (!check_and_set_stop_copy(copy))
1132 kthread_stop(copy->copy_task);
1133 nfs4_put_copy(copy);
1138 struct nfsd4_copy *copy = NULL;
1142 copy = list_first_entry(&clp->async_copies, struct nfsd4_copy,
1144 refcount_inc(&copy->refcount);
1147 return copy;
1152 struct nfsd4_copy *copy;
1154 while ((copy = nfsd4_get_copy(clp)) != NULL)
1155 nfsd4_stop_copy(copy);
1169 * Support one copy source server for now.
1263 struct nfsd4_copy *copy, struct vfsmount **mount)
1266 stateid_t *s_stid = &copy->cp_src_stateid;
1271 &copy->cp_dst_stateid,
1272 WR_STATE, &copy->nf_dst, NULL);
1276 status = nfsd4_interssc_connect(&copy->cp_src, rqstp, mount);
1282 copy->c_fh.size = s_fh->fh_handle.fh_size;
1283 memcpy(copy->c_fh.data, &s_fh->fh_handle.fh_base, copy->c_fh.size);
1284 copy->stateid.seqid = cpu_to_be32(s_stid->si_generation);
1285 memcpy(copy->stateid.other, (void *)&s_stid->si_opaque,
1308 struct nfsd4_copy *copy,
1332 struct nfsd4_copy *copy)
1334 return nfsd4_verify_copy(rqstp, cstate, &copy->cp_src_stateid,
1335 &copy->nf_src, &copy->cp_dst_stateid,
1336 &copy->nf_dst);
1348 struct nfsd4_copy *copy = container_of(cb, struct nfsd4_copy, cp_cb);
1350 nfs4_put_copy(copy);
1364 static void nfsd4_init_copy_res(struct nfsd4_copy *copy, bool sync)
1366 copy->cp_res.wr_stable_how = NFS_UNSTABLE;
1367 copy->cp_synchronous = sync;
1368 gen_boot_verifier(&copy->cp_res.wr_verifier, copy->cp_clp->net);
1371 static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy)
1373 struct file *dst = copy->nf_dst->nf_file;
1374 struct file *src = copy->nf_src->nf_file;
1376 size_t bytes_total = copy->cp_count;
1377 u64 src_pos = copy->cp_src_pos;
1378 u64 dst_pos = copy->cp_dst_pos;
1388 copy->cp_res.wr_bytes_written += bytes_copied;
1391 } while (bytes_total > 0 && !copy->cp_synchronous);
1395 static __be32 nfsd4_do_copy(struct nfsd4_copy *copy, bool sync)
1400 bytes = _nfsd_copy_file_range(copy);
1401 /* for async copy, we ignore the error, client can always retry
1404 if (bytes < 0 && !copy->cp_res.wr_bytes_written)
1407 nfsd4_init_copy_res(copy, sync);
1411 if (!copy->cp_intra) /* Inter server SSC */
1412 nfsd4_cleanup_inter_ssc(copy->ss_mnt, copy->nf_src,
1413 copy->nf_dst);
1415 nfsd4_cleanup_intra_ssc(copy->nf_src, copy->nf_dst);
1441 static void cleanup_async_copy(struct nfsd4_copy *copy)
1443 nfs4_free_copy_state(copy);
1444 nfsd_file_put(copy->nf_dst);
1445 if (copy->cp_intra)
1446 nfsd_file_put(copy->nf_src);
1447 spin_lock(&copy->cp_clp->async_lock);
1448 list_del(&copy->copies);
1449 spin_unlock(&copy->cp_clp->async_lock);
1450 nfs4_put_copy(copy);
1455 struct nfsd4_copy *copy = (struct nfsd4_copy *)data;
1458 if (!copy->cp_intra) { /* Inter server SSC */
1459 copy->nf_src = kzalloc(sizeof(struct nfsd_file), GFP_KERNEL);
1460 if (!copy->nf_src) {
1461 copy->nfserr = nfserr_serverfault;
1465 copy->nf_src->nf_file = nfs42_ssc_open(copy->ss_mnt, &copy->c_fh,
1466 &copy->stateid);
1467 if (IS_ERR(copy->nf_src->nf_file)) {
1468 copy->nfserr = nfserr_offload_denied;
1474 copy->nfserr = nfsd4_do_copy(copy, 0);
1480 memcpy(&cb_copy->cp_res, &copy->cp_res, sizeof(copy->cp_res));
1481 cb_copy->cp_clp = copy->cp_clp;
1482 cb_copy->nfserr = copy->nfserr;
1483 memcpy(&cb_copy->fh, &copy->fh, sizeof(copy->fh));
1488 if (!copy->cp_intra)
1489 kfree(copy->nf_src);
1490 cleanup_async_copy(copy);
1498 struct nfsd4_copy *copy = &u->copy;
1502 if (!copy->cp_intra) { /* Inter server SSC */
1503 if (!inter_copy_offload_enable || copy->cp_synchronous) {
1507 status = nfsd4_setup_inter_ssc(rqstp, cstate, copy,
1508 &copy->ss_mnt);
1512 status = nfsd4_setup_intra_ssc(rqstp, cstate, copy);
1517 copy->cp_clp = cstate->clp;
1518 memcpy(&copy->fh, &cstate->current_fh.fh_handle,
1520 if (!copy->cp_synchronous) {
1527 if (!nfs4_init_copy_state(nn, copy))
1530 memcpy(&copy->cp_res.cb_stateid, &copy->cp_stateid.stid,
1531 sizeof(copy->cp_res.cb_stateid));
1532 dup_copy_fields(copy, async_copy);
1534 async_copy, "%s", "copy thread");
1544 status = nfsd4_do_copy(copy, 1);
1553 * source's vfsmount of inter-copy will be unmounted
1562 struct nfsd4_copy *copy;
1565 list_for_each_entry(copy, &clp->async_copies, copies) {
1566 if (memcmp(&copy->cp_stateid.stid, stateid, NFS4_STATEID_SIZE))
1568 refcount_inc(&copy->refcount);
1570 return copy;
1582 struct nfsd4_copy *copy;
1585 copy = find_async_copy(clp, &os->stateid);
1586 if (!copy) {
1591 nfsd4_stop_copy(copy);
1669 struct nfsd4_copy *copy;
1672 copy = find_async_copy(clp, &os->stateid);
1673 if (copy) {
1674 os->count = copy->cp_res.wr_bytes_written;
1675 nfs4_put_copy(copy);
2128 * Get the entire list, then copy out only the user attributes
2280 struct nfsd4_copy *copy;
2296 copy = (struct nfsd4_copy *)&op->u;
2302 if (!copy->cp_intra)