Allow NFS activity to defer snapshot unmounts

Accessing a snapshot via NFS should cause an auto-unmount of that
snapshot to be deferred until such as time as the snapshot is idle.
This is analogous to the zpl_revalidate logic employed by locally
mounted snapshots.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #3794
This commit is contained in:
Brian Behlendorf 2015-09-23 13:00:28 -07:00
parent 784a7fe5d9
commit d4787d55ad
1 changed files with 13 additions and 2 deletions

View File

@ -1147,8 +1147,19 @@ zfsctl_lookup_objset(struct super_block *sb, uint64_t objsetid, zfs_sb_t **zsbp)
*/
mutex_enter(&zfs_snapshot_lock);
if ((se = zfsctl_snapshot_find_by_objsetid(objsetid)) != NULL) {
*zsbp = ITOZSB(se->se_root_dentry->d_inode);
ASSERT3U(dmu_objset_id((*zsbp)->z_os), ==, objsetid);
zfs_sb_t *zsb;
zsb = ITOZSB(se->se_root_dentry->d_inode);
ASSERT3U(dmu_objset_id(zsb->z_os), ==, objsetid);
if (time_after(jiffies, zsb->z_snap_defer_time +
MAX(zfs_expire_snapshot * HZ / 2, HZ))) {
zsb->z_snap_defer_time = jiffies;
zfsctl_snapshot_unmount_delay(objsetid,
zfs_expire_snapshot);
}
*zsbp = zsb;
zfsctl_snapshot_rele(se);
error = SET_ERROR(0);
} else {