since daddr_t is 64-bit these days, simply use nfs directory cookies

as buffer cache indexes.  regress/sys/fs/getdents is now supposed to work.
fix PR/27112.
This commit is contained in:
yamt 2004-10-26 04:34:46 +00:00
parent 0ef90c1bfc
commit a9fa9f0745
3 changed files with 11 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_bio.c,v 1.121 2004/09/17 14:11:25 skrll Exp $ */
/* $NetBSD: nfs_bio.c,v 1.122 2004/10/26 04:34:46 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.121 2004/09/17 14:11:25 skrll Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_bio.c,v 1.122 2004/10/26 04:34:46 yamt Exp $");
#include "opt_nfs.h"
#include "opt_ddb.h"
@ -287,7 +287,7 @@ diragain:
return (0);
}
bp = nfs_getcacheblk(vp, ndp->dc_blkno, NFS_DIRBLKSIZ, p);
bp = nfs_getcacheblk(vp, NFSDC_BLKNO(ndp), NFS_DIRBLKSIZ, p);
if (!bp)
return (EINTR);
if ((bp->b_flags & B_DONE) == 0) {
@ -445,7 +445,7 @@ diragain:
*/
if (nfs_numasync > 0 && nmp->nm_readahead > 0 &&
np->n_direofoffset == 0 && !(np->n_flag & NQNFSNONCACHE)) {
rabp = nfs_getcacheblk(vp, nndp->dc_blkno,
rabp = nfs_getcacheblk(vp, NFSDC_BLKNO(nndp),
NFS_DIRBLKSIZ, p);
if (rabp) {
if ((rabp->b_flags & (B_DONE | B_DELWRI)) == 0) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfs_subs.c,v 1.137 2004/10/03 10:51:28 yamt Exp $ */
/* $NetBSD: nfs_subs.c,v 1.138 2004/10/26 04:34:46 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.137 2004/10/03 10:51:28 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.138 2004/10/26 04:34:46 yamt Exp $");
#include "fs_nfs.h"
#include "opt_nfs.h"
@ -1232,7 +1232,6 @@ nfs_initdircache(vp)
NFSDC_LOCK(np);
if (np->n_dircache == NULL) {
np->n_dircachesize = 0;
np->n_dblkno = 1;
np->n_dircache = dircache;
dircache = NULL;
TAILQ_INIT(&np->n_dirchain);
@ -1374,7 +1373,6 @@ nfs_searchdircache(vp, off, do32, hashent)
*/
if (ndp->dc_flags & NFSDC_INVALID) {
ndp->dc_blkcookie = ndp->dc_cookie;
ndp->dc_blkno = np->n_dblkno++;
ndp->dc_entry = 0;
ndp->dc_flags &= ~NFSDC_INVALID;
}
@ -1471,15 +1469,6 @@ retry:
} else
overwrite = 1;
/*
* If the entry number is 0, we are at the start of a new block, so
* allocate a new blocknumber.
*/
if (en == 0)
ndp->dc_blkno = np->n_dblkno++;
else
ndp->dc_blkno = blkno;
ndp->dc_cookie = off;
ndp->dc_blkcookie = blkoff;
ndp->dc_entry = en;
@ -1545,7 +1534,6 @@ nfs_invaldircache(vp, forcefree)
ndp->dc_flags |= NFSDC_INVALID;
}
np->n_dblkno = 1;
NFSDC_UNLOCK(np);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nfsnode.h,v 1.49 2004/09/15 09:50:56 yamt Exp $ */
/* $NetBSD: nfsnode.h,v 1.50 2004/10/26 04:34:48 yamt Exp $ */
/*
* Copyright (c) 1989, 1993
@ -80,7 +80,6 @@ struct nfsdircache {
off_t dc_blkcookie; /* Offset of block we're in */
LIST_ENTRY(nfsdircache) dc_hash; /* Hash chain */
TAILQ_ENTRY(nfsdircache) dc_chain; /* Least recently entered chn */
daddr_t dc_blkno; /* Number of block we're in */
u_int32_t dc_cookie32; /* Key for 64<->32 xlate case */
int dc_entry; /* Entry number within block */
int dc_refcnt; /* Reference count */
@ -89,6 +88,10 @@ struct nfsdircache {
#define NFSDC_INVALID 1
/*
* NFSDC_BLKNO: get buffer cache index
*/
#define NFSDC_BLKNO(ndp) ((daddr_t)(ndp)->dc_blkcookie)
/*
* The nfsnode is the nfs equivalent to ufs's inode. Any similarity
@ -116,7 +119,6 @@ struct nfsnode_reg {
struct nfsnode_dir {
off_t ndir_direof; /* EOF offset cache */
nfsuint64 ndir_cookieverf; /* Cookie verifier */
daddr_t ndir_dblkno; /* faked dir blkno */
struct nfsdirhashhead *ndir_dircache; /* offset -> cache hash heads */
struct nfsdirchainhead ndir_dirchain; /* Chain of dir cookies */
struct timespec ndir_nctime; /* Last neg cache entry */
@ -146,7 +148,6 @@ struct nfsnode {
#define n_direofoffset n_un1.nu_dir.ndir_direof
#define n_cookieverf n_un1.nu_dir.ndir_cookieverf
#define n_dblkno n_un1.nu_dir.ndir_dblkno
#define n_dircache n_un1.nu_dir.ndir_dircache
#define n_dirchain n_un1.nu_dir.ndir_dirchain
#define n_nctime n_un1.nu_dir.ndir_nctime