@@ -1293,23 +1293,9 @@ static void nfs4_put_copy(struct nfsd4_copy *copy)
1293
1293
kfree (copy );
1294
1294
}
1295
1295
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
-
1309
1296
static void nfsd4_stop_copy (struct nfsd4_copy * copy )
1310
1297
{
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 ))
1313
1299
kthread_stop (copy -> copy_task );
1314
1300
nfs4_put_copy (copy );
1315
1301
}
@@ -1678,8 +1664,9 @@ static const struct nfsd4_callback_ops nfsd4_cb_offload_ops = {
1678
1664
static void nfsd4_init_copy_res (struct nfsd4_copy * copy , bool sync )
1679
1665
{
1680
1666
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 );
1683
1670
gen_boot_verifier (& copy -> cp_res .wr_verifier , copy -> cp_clp -> net );
1684
1671
}
1685
1672
@@ -1708,16 +1695,16 @@ static ssize_t _nfsd_copy_file_range(struct nfsd4_copy *copy)
1708
1695
copy -> cp_res .wr_bytes_written += bytes_copied ;
1709
1696
src_pos += bytes_copied ;
1710
1697
dst_pos += bytes_copied ;
1711
- } while (bytes_total > 0 && ! copy -> cp_synchronous );
1698
+ } while (bytes_total > 0 && nfsd4_copy_is_async ( copy ) );
1712
1699
/* 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 ) {
1714
1701
since = READ_ONCE (dst -> f_wb_err );
1715
1702
status = vfs_fsync_range (dst , copy -> cp_dst_pos ,
1716
1703
copy -> cp_res .wr_bytes_written , 0 );
1717
1704
if (!status )
1718
1705
status = filemap_check_wb_err (dst -> f_mapping , since );
1719
1706
if (!status )
1720
- copy -> committed = true ;
1707
+ set_bit ( NFSD4_COPY_F_COMMITTED , & copy -> cp_flags ) ;
1721
1708
}
1722
1709
return bytes_copied ;
1723
1710
}
@@ -1738,7 +1725,7 @@ static __be32 nfsd4_do_copy(struct nfsd4_copy *copy, bool sync)
1738
1725
status = nfs_ok ;
1739
1726
}
1740
1727
1741
- if (! copy -> cp_intra ) /* Inter server SSC */
1728
+ if (nfsd4_ssc_is_inter ( copy ))
1742
1729
nfsd4_cleanup_inter_ssc (copy -> ss_mnt , copy -> nf_src ,
1743
1730
copy -> nf_dst );
1744
1731
else
@@ -1752,13 +1739,13 @@ static void dup_copy_fields(struct nfsd4_copy *src, struct nfsd4_copy *dst)
1752
1739
dst -> cp_src_pos = src -> cp_src_pos ;
1753
1740
dst -> cp_dst_pos = src -> cp_dst_pos ;
1754
1741
dst -> cp_count = src -> cp_count ;
1755
- dst -> cp_synchronous = src -> cp_synchronous ;
1742
+ dst -> cp_flags = src -> cp_flags ;
1756
1743
memcpy (& dst -> cp_res , & src -> cp_res , sizeof (src -> cp_res ));
1757
1744
memcpy (& dst -> fh , & src -> fh , sizeof (src -> fh ));
1758
1745
dst -> cp_clp = src -> cp_clp ;
1759
1746
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 ))
1762
1749
dst -> nf_src = nfsd_file_get (src -> nf_src );
1763
1750
1764
1751
memcpy (& dst -> cp_stateid , & src -> cp_stateid , sizeof (src -> cp_stateid ));
@@ -1772,7 +1759,7 @@ static void cleanup_async_copy(struct nfsd4_copy *copy)
1772
1759
{
1773
1760
nfs4_free_copy_state (copy );
1774
1761
nfsd_file_put (copy -> nf_dst );
1775
- if (copy -> cp_intra )
1762
+ if (! nfsd4_ssc_is_inter ( copy ) )
1776
1763
nfsd_file_put (copy -> nf_src );
1777
1764
spin_lock (& copy -> cp_clp -> async_lock );
1778
1765
list_del (& copy -> copies );
@@ -1785,7 +1772,7 @@ static int nfsd4_do_async_copy(void *data)
1785
1772
struct nfsd4_copy * copy = (struct nfsd4_copy * )data ;
1786
1773
struct nfsd4_copy * cb_copy ;
1787
1774
1788
- if (! copy -> cp_intra ) { /* Inter server SSC */
1775
+ if (nfsd4_ssc_is_inter ( copy )) {
1789
1776
copy -> nf_src = kzalloc (sizeof (struct nfsd_file ), GFP_KERNEL );
1790
1777
if (!copy -> nf_src ) {
1791
1778
copy -> nfserr = nfserr_serverfault ;
@@ -1817,7 +1804,7 @@ static int nfsd4_do_async_copy(void *data)
1817
1804
& copy -> fh , copy -> cp_count , copy -> nfserr );
1818
1805
nfsd4_run_cb (& cb_copy -> cp_cb );
1819
1806
out :
1820
- if (! copy -> cp_intra )
1807
+ if (nfsd4_ssc_is_inter ( copy ) )
1821
1808
kfree (copy -> nf_src );
1822
1809
cleanup_async_copy (copy );
1823
1810
return 0 ;
@@ -1831,8 +1818,8 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
1831
1818
__be32 status ;
1832
1819
struct nfsd4_copy * async_copy = NULL ;
1833
1820
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 ) ) {
1836
1823
status = nfserr_notsupp ;
1837
1824
goto out ;
1838
1825
}
@@ -1849,7 +1836,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
1849
1836
copy -> cp_clp = cstate -> clp ;
1850
1837
memcpy (& copy -> fh , & cstate -> current_fh .fh_handle ,
1851
1838
sizeof (struct knfsd_fh ));
1852
- if (! copy -> cp_synchronous ) {
1839
+ if (nfsd4_copy_is_async ( copy ) ) {
1853
1840
struct nfsd_net * nn = net_generic (SVC_NET (rqstp ), nfsd_net_id );
1854
1841
1855
1842
status = nfserrno (- ENOMEM );
@@ -1884,7 +1871,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
1884
1871
if (async_copy )
1885
1872
cleanup_async_copy (async_copy );
1886
1873
status = nfserrno (- ENOMEM );
1887
- if (! copy -> cp_intra )
1874
+ if (nfsd4_ssc_is_inter ( copy ) )
1888
1875
nfsd4_interssc_disconnect (copy -> ss_mnt );
1889
1876
goto out ;
1890
1877
}
@@ -2613,7 +2600,7 @@ check_if_stalefh_allowed(struct nfsd4_compoundargs *args)
2613
2600
return ;
2614
2601
}
2615
2602
putfh = (struct nfsd4_putfh * )& saved_op -> u ;
2616
- if (! copy -> cp_intra )
2603
+ if (nfsd4_ssc_is_inter ( copy ) )
2617
2604
putfh -> no_verify = true;
2618
2605
}
2619
2606
}
0 commit comments