Skip to content

Commit 82f9c27

Browse files
committed
NFSv4 client tracks opens, and the track records are only dropped when
the vnode is inactivated. This contradicts with the nullfs caching which keeps upper vnode around, as consequence keeping the use reference to lower vnode. Add a filesystem flag to request nullfs to not cache when mounted over that filesystem, and set the flag for nfs v4 mounts. Reported by: asomers Reviewed by: rmacklem Tested by: asomers, rmacklem Sponsored by: The FreeBSD Foundation MFC after: 1 week
1 parent 4343dad commit 82f9c27

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

sys/fs/nfsclient/nfs_clvfsops.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,8 @@ nfs_mount(struct mount *mp)
13201320
MNT_ILOCK(mp);
13211321
mp->mnt_kern_flag |= MNTK_LOOKUP_SHARED | MNTK_NO_IOPF |
13221322
MNTK_USES_BCACHE;
1323+
if ((VFSTONFS(mp)->nm_flag & NFSMNT_NFSV4) != 0)
1324+
mp->mnt_kern_flag |= MNTK_NULL_NOCACHE;
13231325
MNT_IUNLOCK(mp);
13241326
}
13251327
return (error);

sys/fs/nullfs/null_vfsops.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ nullfs_mount(struct mount *mp)
188188
}
189189

190190
xmp->nullm_flags |= NULLM_CACHE;
191-
if (vfs_getopt(mp->mnt_optnew, "nocache", NULL, NULL) == 0)
191+
if (vfs_getopt(mp->mnt_optnew, "nocache", NULL, NULL) == 0 ||
192+
(xmp->nullm_vfs->mnt_kern_flag & MNTK_NULL_NOCACHE) != 0)
192193
xmp->nullm_flags &= ~NULLM_CACHE;
193194

194195
MNT_ILOCK(mp);

sys/sys/mount.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ void __mnt_vnode_markerfree_active(struct vnode **mvp, struct mount *);
370370
#define MNTK_SUSPEND 0x08000000 /* request write suspension */
371371
#define MNTK_SUSPEND2 0x04000000 /* block secondary writes */
372372
#define MNTK_SUSPENDED 0x10000000 /* write operations are suspended */
373-
#define MNTK_UNUSED1 0x20000000
373+
#define MNTK_NULL_NOCACHE 0x20000000 /* auto disable cache for nullfs
374+
mounts over this fs */
374375
#define MNTK_LOOKUP_SHARED 0x40000000 /* FS supports shared lock lookups */
375376
#define MNTK_NOKNOTE 0x80000000 /* Don't send KNOTEs from VOP hooks */
376377

0 commit comments

Comments
 (0)