@@ -1549,10 +1549,51 @@ static int nfs4_reclaim_locks(struct nfs4_state *state, const struct nfs4_state_
1549
1549
return status ;
1550
1550
}
1551
1551
1552
+ static int __nfs4_reclaim_open_state (struct nfs4_state_owner * sp , struct nfs4_state * state ,
1553
+ const struct nfs4_state_recovery_ops * ops )
1554
+ {
1555
+ struct nfs4_lock_state * lock ;
1556
+ int status ;
1557
+
1558
+ status = ops -> recover_open (sp , state );
1559
+ if (status < 0 )
1560
+ return status ;
1561
+
1562
+ status = nfs4_reclaim_locks (state , ops );
1563
+ if (status < 0 )
1564
+ return status ;
1565
+
1566
+ if (!test_bit (NFS_DELEGATED_STATE , & state -> flags )) {
1567
+ spin_lock (& state -> state_lock );
1568
+ list_for_each_entry (lock , & state -> lock_states , ls_locks ) {
1569
+ if (!test_bit (NFS_LOCK_INITIALIZED , & lock -> ls_flags ))
1570
+ pr_warn_ratelimited ("NFS: %s: Lock reclaim failed!\n" , __func__ );
1571
+ }
1572
+ spin_unlock (& state -> state_lock );
1573
+ }
1574
+
1575
+ #ifdef CONFIG_NFS_V4_2
1576
+ if (test_bit (NFS_CLNT_DST_SSC_COPY_STATE , & state -> flags )) {
1577
+ struct nfs4_copy_state * copy ;
1578
+ spin_lock (& sp -> so_server -> nfs_client -> cl_lock );
1579
+ list_for_each_entry (copy , & sp -> so_server -> ss_copies , copies ) {
1580
+ if (nfs4_stateid_match_other (& state -> stateid , & copy -> parent_state -> stateid ))
1581
+ continue ;
1582
+ copy -> flags = 1 ;
1583
+ complete (& copy -> completion );
1584
+ break ;
1585
+ }
1586
+ spin_unlock (& sp -> so_server -> nfs_client -> cl_lock );
1587
+ }
1588
+ #endif /* CONFIG_NFS_V4_2 */
1589
+
1590
+ clear_bit (NFS_STATE_RECLAIM_NOGRACE , & state -> flags );
1591
+ return status ;
1592
+ }
1593
+
1552
1594
static int nfs4_reclaim_open_state (struct nfs4_state_owner * sp , const struct nfs4_state_recovery_ops * ops )
1553
1595
{
1554
1596
struct nfs4_state * state ;
1555
- struct nfs4_lock_state * lock ;
1556
1597
int status = 0 ;
1557
1598
1558
1599
/* Note: we rely on the sp->so_states list being ordered
@@ -1575,43 +1616,13 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
1575
1616
continue ;
1576
1617
refcount_inc (& state -> count );
1577
1618
spin_unlock (& sp -> so_lock );
1578
- status = ops -> recover_open (sp , state );
1619
+ status = __nfs4_reclaim_open_state (sp , state , ops );
1579
1620
if (status >= 0 ) {
1580
- status = nfs4_reclaim_locks (state , ops );
1581
- if (status >= 0 ) {
1582
- if (!test_bit (NFS_DELEGATED_STATE , & state -> flags )) {
1583
- spin_lock (& state -> state_lock );
1584
- list_for_each_entry (lock , & state -> lock_states , ls_locks ) {
1585
- if (!test_bit (NFS_LOCK_INITIALIZED , & lock -> ls_flags ))
1586
- pr_warn_ratelimited ("NFS: "
1587
- "%s: Lock reclaim "
1588
- "failed!\n" , __func__ );
1589
- }
1590
- spin_unlock (& state -> state_lock );
1591
- }
1592
- clear_bit (NFS_STATE_RECLAIM_NOGRACE ,
1593
- & state -> flags );
1594
- #ifdef CONFIG_NFS_V4_2
1595
- if (test_bit (NFS_CLNT_DST_SSC_COPY_STATE , & state -> flags )) {
1596
- struct nfs4_copy_state * copy ;
1597
-
1598
- spin_lock (& sp -> so_server -> nfs_client -> cl_lock );
1599
- list_for_each_entry (copy , & sp -> so_server -> ss_copies , copies ) {
1600
- if (memcmp (& state -> stateid .other , & copy -> parent_state -> stateid .other , NFS4_STATEID_SIZE ))
1601
- continue ;
1602
- copy -> flags = 1 ;
1603
- complete (& copy -> completion );
1604
- printk ("AGLO: server rebooted waking up the copy\n" );
1605
- break ;
1606
- }
1607
- spin_unlock (& sp -> so_server -> nfs_client -> cl_lock );
1608
- }
1609
- #endif /* CONFIG_NFS_V4_2 */
1610
- nfs4_put_open_state (state );
1611
- spin_lock (& sp -> so_lock );
1612
- goto restart ;
1613
- }
1621
+ nfs4_put_open_state (state );
1622
+ spin_lock (& sp -> so_lock );
1623
+ goto restart ;
1614
1624
}
1625
+
1615
1626
switch (status ) {
1616
1627
default :
1617
1628
printk (KERN_ERR "NFS: %s: unhandled error %d\n" ,
0 commit comments