@@ -1293,23 +1293,9 @@ static void nfs4_put_copy(struct nfsd4_copy *copy)
12931293 kfree (copy );
12941294}
12951295
1296- static bool
1297- check_and_set_stop_copy (struct nfsd4_copy * copy )
1298- {
1299- bool value ;
1300-
1301- spin_lock (& copy -> cp_clp -> async_lock );
1302- value = copy -> stopped ;
1303- if (!copy -> stopped )
1304- copy -> stopped = true;
1305- spin_unlock (& copy -> cp_clp -> async_lock );
1306- return value ;
1307- }
1308-
13091296static void nfsd4_stop_copy (struct nfsd4_copy * copy )
13101297{
1311- /* only 1 thread should stop the copy */
1312- if (!check_and_set_stop_copy (copy ))
1298+ if (!test_and_set_bit (NFSD4_COPY_F_STOPPED , & copy -> cp_flags ))
13131299 kthread_stop (copy -> copy_task );
13141300 nfs4_put_copy (copy );
13151301}
@@ -1678,8 +1664,9 @@ static const struct nfsd4_callback_ops nfsd4_cb_offload_ops = {
16781664static void nfsd4_init_copy_res (struct nfsd4_copy * copy , bool sync )
16791665{
16801666 copy -> cp_res .wr_stable_how =
1681- copy -> committed ? NFS_FILE_SYNC : NFS_UNSTABLE ;
1682- copy -> cp_synchronous = sync ;
1667+ test_bit (NFSD4_COPY_F_COMMITTED , & copy -> cp_flags ) ?
1668+ NFS_FILE_SYNC : NFS_UNSTABLE ;
1669+ nfsd4_copy_set_sync (copy , sync );
16831670 gen_boot_verifier (& copy -> cp_res .wr_verifier , copy -> cp_clp -> net );
16841671}
16851672
@@ -1708,16 +1695,16 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy)
17081695 copy -> cp_res .wr_bytes_written += bytes_copied ;
17091696 src_pos += bytes_copied ;
17101697 dst_pos += bytes_copied ;
1711- } while (bytes_total > 0 && ! copy -> cp_synchronous );
1698+ } while (bytes_total > 0 && nfsd4_copy_is_async ( copy ) );
17121699 /* for a non-zero asynchronous copy do a commit of data */
1713- if (! copy -> cp_synchronous && copy -> cp_res .wr_bytes_written > 0 ) {
1700+ if (nfsd4_copy_is_async ( copy ) && copy -> cp_res .wr_bytes_written > 0 ) {
17141701 since = READ_ONCE (dst -> f_wb_err );
17151702 status = vfs_fsync_range (dst , copy -> cp_dst_pos ,
17161703 copy -> cp_res .wr_bytes_written , 0 );
17171704 if (!status )
17181705 status = filemap_check_wb_err (dst -> f_mapping , since );
17191706 if (!status )
1720- copy -> committed = true ;
1707+ set_bit ( NFSD4_COPY_F_COMMITTED , & copy -> cp_flags ) ;
17211708 }
17221709 return bytes_copied ;
17231710}
@@ -1738,7 +1725,7 @@ static __be32 nfsd4_do_copy(struct nfsd4_copy *copy, bool sync)
17381725 status = nfs_ok ;
17391726 }
17401727
1741- if (! copy -> cp_intra ) /* Inter server SSC */
1728+ if (nfsd4_ssc_is_inter ( copy ))
17421729 nfsd4_cleanup_inter_ssc (copy -> ss_mnt , copy -> nf_src ,
17431730 copy -> nf_dst );
17441731 else
@@ -1752,13 +1739,13 @@ static void dup_copy_fields(struct nfsd4_copy *src, struct nfsd4_copy *dst)
17521739 dst -> cp_src_pos = src -> cp_src_pos ;
17531740 dst -> cp_dst_pos = src -> cp_dst_pos ;
17541741 dst -> cp_count = src -> cp_count ;
1755- dst -> cp_synchronous = src -> cp_synchronous ;
1742+ dst -> cp_flags = src -> cp_flags ;
17561743 memcpy (& dst -> cp_res , & src -> cp_res , sizeof (src -> cp_res ));
17571744 memcpy (& dst -> fh , & src -> fh , sizeof (src -> fh ));
17581745 dst -> cp_clp = src -> cp_clp ;
17591746 dst -> nf_dst = nfsd_file_get (src -> nf_dst );
1760- dst -> cp_intra = src -> cp_intra ;
1761- if (src -> cp_intra ) /* for inter, file_src doesn't exist yet */
1747+ /* for inter, nf_src doesn't exist yet */
1748+ if (! nfsd4_ssc_is_inter ( src ))
17621749 dst -> nf_src = nfsd_file_get (src -> nf_src );
17631750
17641751 memcpy (& dst -> cp_stateid , & src -> cp_stateid , sizeof (src -> cp_stateid ));
@@ -1772,7 +1759,7 @@ static void cleanup_async_copy(struct nfsd4_copy *copy)
17721759{
17731760 nfs4_free_copy_state (copy );
17741761 nfsd_file_put (copy -> nf_dst );
1775- if (copy -> cp_intra )
1762+ if (! nfsd4_ssc_is_inter ( copy ) )
17761763 nfsd_file_put (copy -> nf_src );
17771764 spin_lock (& copy -> cp_clp -> async_lock );
17781765 list_del (& copy -> copies );
@@ -1785,7 +1772,7 @@ static int nfsd4_do_async_copy(void *data)
17851772 struct nfsd4_copy * copy = (struct nfsd4_copy * )data ;
17861773 struct nfsd4_copy * cb_copy ;
17871774
1788- if (! copy -> cp_intra ) { /* Inter server SSC */
1775+ if (nfsd4_ssc_is_inter ( copy )) {
17891776 copy -> nf_src = kzalloc (sizeof (struct nfsd_file ), GFP_KERNEL );
17901777 if (!copy -> nf_src ) {
17911778 copy -> nfserr = nfserr_serverfault ;
@@ -1817,7 +1804,7 @@ static int nfsd4_do_async_copy(void *data)
18171804 & copy -> fh , copy -> cp_count , copy -> nfserr );
18181805 nfsd4_run_cb (& cb_copy -> cp_cb );
18191806out :
1820- if (! copy -> cp_intra )
1807+ if (nfsd4_ssc_is_inter ( copy ) )
18211808 kfree (copy -> nf_src );
18221809 cleanup_async_copy (copy );
18231810 return 0 ;
@@ -1831,8 +1818,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18311818 __be32 status ;
18321819 struct nfsd4_copy * async_copy = NULL ;
18331820
1834- if (! copy -> cp_intra ) { /* Inter server SSC */
1835- if (!inter_copy_offload_enable || copy -> cp_synchronous ) {
1821+ if (nfsd4_ssc_is_inter ( copy )) {
1822+ if (!inter_copy_offload_enable || nfsd4_copy_is_sync ( copy ) ) {
18361823 status = nfserr_notsupp ;
18371824 goto out ;
18381825 }
@@ -1849,7 +1836,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18491836 copy -> cp_clp = cstate -> clp ;
18501837 memcpy (& copy -> fh , & cstate -> current_fh .fh_handle ,
18511838 sizeof (struct knfsd_fh ));
1852- if (! copy -> cp_synchronous ) {
1839+ if (nfsd4_copy_is_async ( copy ) ) {
18531840 struct nfsd_net * nn = net_generic (SVC_NET (rqstp ), nfsd_net_id );
18541841
18551842 status = nfserrno (- ENOMEM );
@@ -1884,7 +1871,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18841871 if (async_copy )
18851872 cleanup_async_copy (async_copy );
18861873 status = nfserrno (- ENOMEM );
1887- if (! copy -> cp_intra )
1874+ if (nfsd4_ssc_is_inter ( copy ) )
18881875 nfsd4_interssc_disconnect (copy -> ss_mnt );
18891876 goto out ;
18901877}
@@ -2613,7 +2600,7 @@ check_if_stalefh_allowed(struct nfsd4_compoundargs *args)
26132600 return ;
26142601 }
26152602 putfh = (struct nfsd4_putfh * )& saved_op -> u ;
2616- if (! copy -> cp_intra )
2603+ if (nfsd4_ssc_is_inter ( copy ) )
26172604 putfh -> no_verify = true;
26182605 }
26192606 }
0 commit comments