svn commit: r333940 - in projects/pnfs-planb-server/sys/fs: nfs nfsserver
Rick Macklem
rmacklem at FreeBSD.org
Sun May 20 21:07:31 UTC 2018
Author: rmacklem
Date: Sun May 20 21:07:29 2018
New Revision: 333940
URL: https://svnweb.freebsd.org/changeset/base/333940
Log:
Add code to free layouts in the NFSv4.1 pNFS server when the file is deleted.
Modified:
projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h
projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c
projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c
Modified: projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h Sun May 20 20:48:26 2018 (r333939)
+++ projects/pnfs-planb-server/sys/fs/nfs/nfs_var.h Sun May 20 21:07:29 2018 (r333940)
@@ -155,6 +155,7 @@ int nfsrv_layoutreturn(struct nfsrv_descript *, vnode_
int nfsrv_getdevinfo(char *, int, uint32_t *, uint32_t *, int *, char **);
void nfsrv_freeonedevid(struct nfsdevice *);
void nfsrv_freealllayoutsanddevids(void);
+void nfsrv_freefilelayouts(fhandle_t *);
int nfsrv_deldsserver(char *, NFSPROC_T *);
struct nfsdevice *nfsrv_deldsnmp(struct nfsmount *, NFSPROC_T *);
int nfsrv_createdevids(struct nfsd_nfsd_args *, NFSPROC_T *);
Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c Sun May 20 20:48:26 2018 (r333939)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdport.c Sun May 20 21:07:29 2018 (r333940)
@@ -106,8 +106,9 @@ extern struct nfsdevicehead nfsrv_devidhead;
static void nfsrv_pnfscreate(struct vnode *, struct vattr *, struct ucred *,
NFSPROC_T *);
static void nfsrv_pnfsremovesetup(struct vnode *, NFSPROC_T *, struct vnode **,
- int *, char *);
-static void nfsrv_pnfsremove(struct vnode **, int, char *, NFSPROC_T *);
+ int *, char *, fhandle_t *);
+static void nfsrv_pnfsremove(struct vnode **, int, char *, fhandle_t *,
+ NFSPROC_T *);
static int nfsrv_proxyds(struct nfsrv_descript *, struct vnode *, off_t, int,
struct ucred *, struct thread *, int, struct mbuf **, char *,
struct mbuf **, struct nfsvattr *, struct acl *);
@@ -1209,6 +1210,7 @@ nfsvno_removesub(struct nameidata *ndp, int is_v4, str
struct vnode *vp, *dsdvp[NFSDEV_MAXMIRRORS];
int error = 0, i, mirrorcnt;
char fname[PNFS_FILENAME_LEN + 1];
+ fhandle_t fh;
vp = ndp->ni_vp;
dsdvp[0] = NULL;
@@ -1217,12 +1219,12 @@ nfsvno_removesub(struct nameidata *ndp, int is_v4, str
else if (is_v4)
error = nfsrv_checkremove(vp, 1, p);
if (error == 0)
- nfsrv_pnfsremovesetup(vp, p, dsdvp, &mirrorcnt, fname);
+ nfsrv_pnfsremovesetup(vp, p, dsdvp, &mirrorcnt, fname, &fh);
if (!error)
error = VOP_REMOVE(ndp->ni_dvp, vp, &ndp->ni_cnd);
if (dsdvp[0] != NULL) {
if (error == 0)
- nfsrv_pnfsremove(dsdvp, mirrorcnt, fname, p);
+ nfsrv_pnfsremove(dsdvp, mirrorcnt, fname, &fh, p);
for (i = 0; i < mirrorcnt; i++)
NFSVOPUNLOCK(dsdvp[i], 0);
}
@@ -1288,6 +1290,7 @@ nfsvno_rename(struct nameidata *fromndp, struct nameid
struct vnode *fvp, *tvp, *tdvp, *dsdvp[NFSDEV_MAXMIRRORS];
int error = 0, i, mirrorcnt;
char fname[PNFS_FILENAME_LEN + 1];
+ fhandle_t fh;
dsdvp[0] = NULL;
fvp = fromndp->ni_vp;
@@ -1365,7 +1368,7 @@ nfsvno_rename(struct nameidata *fromndp, struct nameid
nfsd_recalldelegation(fvp, p);
}
if (error == 0 && tvp != NULL) {
- nfsrv_pnfsremovesetup(tvp, p, dsdvp, &mirrorcnt, fname);
+ nfsrv_pnfsremovesetup(tvp, p, dsdvp, &mirrorcnt, fname, &fh);
NFSD_DEBUG(4, "nfsvno_rename: pnfsremovesetup"
" dsdvp=%p\n", dsdvp[0]);
}
@@ -1394,7 +1397,7 @@ out:
*/
if (dsdvp[0] != NULL) {
if (error == 0) {
- nfsrv_pnfsremove(dsdvp, mirrorcnt, fname, p);
+ nfsrv_pnfsremove(dsdvp, mirrorcnt, fname, &fh, p);
NFSD_DEBUG(4, "nfsvno_rename: pnfsremove\n");
}
for (i = 0; i < mirrorcnt; i++)
@@ -3970,7 +3973,7 @@ nfsrv_pnfscreate(struct vnode *vp, struct vattr *vap,
*/
static void
nfsrv_pnfsremovesetup(struct vnode *vp, NFSPROC_T *p, struct vnode **dvpp,
- int *mirrorcntp, char *fname)
+ int *mirrorcntp, char *fname, fhandle_t *fhp)
{
struct vattr va;
struct ucred *tcred;
@@ -3994,6 +3997,12 @@ nfsrv_pnfsremovesetup(struct vnode *vp, NFSPROC_T *p,
if (va.va_nlink > 1)
return;
+ error = nfsvno_getfh(vp, fhp, p);
+ if (error != 0) {
+ printf("pNFS: nfsrv_pnfsremovesetup getfh=%d\n", error);
+ return;
+ }
+
buflen = 1024;
buf = malloc(buflen, M_TEMP, M_WAITOK);
/* Get the directory vnode for the DS mount and the file handle. */
@@ -4073,7 +4082,8 @@ start_dsremove(void *arg, int pending)
* removed to set up the dvp and fill in the FH.
*/
static void
-nfsrv_pnfsremove(struct vnode **dvp, int mirrorcnt, char *fname, NFSPROC_T *p)
+nfsrv_pnfsremove(struct vnode **dvp, int mirrorcnt, char *fname, fhandle_t *fhp,
+ NFSPROC_T *p)
{
struct ucred *tcred;
struct nfsrvdsremove *dsrm, *tdsrm;
@@ -4145,6 +4155,9 @@ nfsrv_pnfsremove(struct vnode **dvp, int mirrorcnt, ch
}
NFSUNLOCKMNT(nmp);
}
+
+ /* Get rid all layouts for the file. */
+ nfsrv_freefilelayouts(fhp);
NFSFREECRED(tcred);
free(dsrm, M_TEMP);
Modified: projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c Sun May 20 20:48:26 2018 (r333939)
+++ projects/pnfs-planb-server/sys/fs/nfsserver/nfs_nfsdstate.c Sun May 20 21:07:29 2018 (r333940)
@@ -7027,6 +7027,27 @@ nfsrv_freelayouts(nfsquad_t *clid, fsid_t *fs, int lay
}
/*
+ * Free all layouts for the argument file.
+ */
+void
+nfsrv_freefilelayouts(fhandle_t *fhp)
+{
+ struct nfslayouthash *lhyp;
+ struct nfslayout *lyp, *nlyp;
+ int i;
+
+ for (i = 0; i < nfsrv_layouthashsize; i++) {
+ lhyp = &nfslayouthash[i];
+ NFSLOCKLAYOUT(lhyp);
+ LIST_FOREACH_SAFE(lyp, &lhyp->list, lay_list, nlyp) {
+ if (NFSBCMP(&lyp->lay_fh, fhp, sizeof(*fhp)) == 0)
+ nfsrv_freelayout(lyp);
+ }
+ NFSUNLOCKLAYOUT(lhyp);
+ }
+}
+
+/*
* Free all layouts.
*/
static void
More information about the svn-src-projects
mailing list