@@ -1637,6 +1637,14 @@ static void nfs_state_set_delegation(struct nfs4_state *state,
1637
1637
write_sequnlock (& state -> seqlock );
1638
1638
}
1639
1639
1640
+ static void nfs_state_clear_delegation (struct nfs4_state * state )
1641
+ {
1642
+ write_seqlock (& state -> seqlock );
1643
+ nfs4_stateid_copy (& state -> stateid , & state -> open_stateid );
1644
+ clear_bit (NFS_DELEGATED_STATE , & state -> flags );
1645
+ write_sequnlock (& state -> seqlock );
1646
+ }
1647
+
1640
1648
static int update_open_stateid (struct nfs4_state * state ,
1641
1649
const nfs4_stateid * open_stateid ,
1642
1650
const nfs4_stateid * delegation ,
@@ -2145,10 +2153,7 @@ int nfs4_open_delegation_recall(struct nfs_open_context *ctx,
2145
2153
if (IS_ERR (opendata ))
2146
2154
return PTR_ERR (opendata );
2147
2155
nfs4_stateid_copy (& opendata -> o_arg .u .delegation , stateid );
2148
- write_seqlock (& state -> seqlock );
2149
- nfs4_stateid_copy (& state -> stateid , & state -> open_stateid );
2150
- write_sequnlock (& state -> seqlock );
2151
- clear_bit (NFS_DELEGATED_STATE , & state -> flags );
2156
+ nfs_state_clear_delegation (state );
2152
2157
switch (type & (FMODE_READ |FMODE_WRITE )) {
2153
2158
case FMODE_READ |FMODE_WRITE :
2154
2159
case FMODE_WRITE :
@@ -2601,10 +2606,7 @@ static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state,
2601
2606
const nfs4_stateid * stateid )
2602
2607
{
2603
2608
nfs_remove_bad_delegation (state -> inode , stateid );
2604
- write_seqlock (& state -> seqlock );
2605
- nfs4_stateid_copy (& state -> stateid , & state -> open_stateid );
2606
- write_sequnlock (& state -> seqlock );
2607
- clear_bit (NFS_DELEGATED_STATE , & state -> flags );
2609
+ nfs_state_clear_delegation (state );
2608
2610
}
2609
2611
2610
2612
static void nfs40_clear_delegation_stateid (struct nfs4_state * state )
@@ -2672,13 +2674,14 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state)
2672
2674
delegation = rcu_dereference (NFS_I (state -> inode )-> delegation );
2673
2675
if (delegation == NULL ) {
2674
2676
rcu_read_unlock ();
2677
+ nfs_state_clear_delegation (state );
2675
2678
return ;
2676
2679
}
2677
2680
2678
2681
nfs4_stateid_copy (& stateid , & delegation -> stateid );
2679
2682
if (test_bit (NFS_DELEGATION_REVOKED , & delegation -> flags )) {
2680
2683
rcu_read_unlock ();
2681
- nfs_finish_clear_delegation_stateid (state , & stateid );
2684
+ nfs_state_clear_delegation (state );
2682
2685
return ;
2683
2686
}
2684
2687
0 commit comments