Print this page
4827 nfs4: slow file locking
4837 NFSv4 client lock retry delay upper limit should be shorter


1595  * clientid can change if the caller drops mi_recovlock.
1596  */
1597 
1598 clientid4
1599 mi2clientid(mntinfo4_t *mi)
1600 {
1601         nfs4_server_t   *sp;
1602         clientid4       clientid = 0;
1603 
1604         /* this locks down sp if it is found */
1605         sp = find_nfs4_server(mi);
1606         if (sp != NULL) {
1607                 clientid = sp->clientid;
1608                 mutex_exit(&sp->s_lock);
1609                 nfs4_server_rele(sp);
1610         }
1611         return (clientid);
1612 }
1613 
1614 /*
1615  * Return the current lease time for the server associated with the given
1616  * file.  Note that the lease time could change immediately after this
1617  * call.
1618  */
1619 
1620 time_t
1621 r2lease_time(rnode4_t *rp)
1622 {
1623         nfs4_server_t   *sp;
1624         time_t          lease_time;
1625         mntinfo4_t      *mi = VTOMI4(RTOV4(rp));
1626 
1627         (void) nfs_rw_enter_sig(&mi->mi_recovlock, RW_READER, 0);
1628 
1629         /* this locks down sp if it is found */
1630         sp = find_nfs4_server(VTOMI4(RTOV4(rp)));
1631 
1632         if (VTOMI4(RTOV4(rp))->mi_vfsp->vfs_flag & VFS_UNMOUNTED) {
1633                 if (sp != NULL) {
1634                         mutex_exit(&sp->s_lock);
1635                         nfs4_server_rele(sp);
1636                 }
1637                 nfs_rw_exit(&mi->mi_recovlock);
1638                 return (1);             /* 1 second */
1639         }
1640 
1641         ASSERT(sp != NULL);
1642 
1643         lease_time = sp->s_lease_time;
1644 
1645         mutex_exit(&sp->s_lock);
1646         nfs4_server_rele(sp);
1647         nfs_rw_exit(&mi->mi_recovlock);
1648 
1649         return (lease_time);
1650 }
1651 
1652 /*
1653  * Return a list with information about all the known open instances for
1654  * a filesystem. The caller must call r4releopenlist() when done with the
1655  * list.
1656  *
1657  * We are safe at looking at os_valid and os_pending_close across dropping
1658  * the 'os_sync_lock' to count up the number of open streams and then
1659  * allocate memory for the osp list due to:
1660  *      -Looking at os_pending_close is safe since this routine is
1661  *      only called via recovery, and os_pending_close can only be set via
1662  *      a non-recovery operation (which are all blocked when recovery
1663  *      is active).
1664  *
1665  *      -Examining os_valid is safe since non-recovery operations, which
1666  *      could potentially switch os_valid to 0, are blocked (via
1667  *      nfs4_start_fop) and recovery is single-threaded per mntinfo4_t
1668  *      (which means we are the only recovery thread potentially acting
1669  *      on this open stream).
1670  */
1671 
1672 nfs4_opinst_t *




1595  * clientid can change if the caller drops mi_recovlock.
1596  */
1597 
1598 clientid4
1599 mi2clientid(mntinfo4_t *mi)
1600 {
1601         nfs4_server_t   *sp;
1602         clientid4       clientid = 0;
1603 
1604         /* this locks down sp if it is found */
1605         sp = find_nfs4_server(mi);
1606         if (sp != NULL) {
1607                 clientid = sp->clientid;
1608                 mutex_exit(&sp->s_lock);
1609                 nfs4_server_rele(sp);
1610         }
1611         return (clientid);
1612 }
1613 
1614 /*






































1615  * Return a list with information about all the known open instances for
1616  * a filesystem. The caller must call r4releopenlist() when done with the
1617  * list.
1618  *
1619  * We are safe at looking at os_valid and os_pending_close across dropping
1620  * the 'os_sync_lock' to count up the number of open streams and then
1621  * allocate memory for the osp list due to:
1622  *      -Looking at os_pending_close is safe since this routine is
1623  *      only called via recovery, and os_pending_close can only be set via
1624  *      a non-recovery operation (which are all blocked when recovery
1625  *      is active).
1626  *
1627  *      -Examining os_valid is safe since non-recovery operations, which
1628  *      could potentially switch os_valid to 0, are blocked (via
1629  *      nfs4_start_fop) and recovery is single-threaded per mntinfo4_t
1630  *      (which means we are the only recovery thread potentially acting
1631  *      on this open stream).
1632  */
1633 
1634 nfs4_opinst_t *