Author: rmacklem
Date: Fri Jun 22 00:55:39 2018
New Revision: 335525
URL: https://svnweb.freebsd.org/changeset/base/335525

Log:
  Add a counter to limit the number of disabled DSs for a mirrored pNFS MDS.
  
  This patch adds a counter that limits the number of disabled mirrored DSs
  to mirror level - 1.  It also makes a small change that keeps a Write that
  has failed with EACCES when attempted by a client to a DS from disabling
  the DS.
  This patch only affects the pNFS server.

Modified:
  head/sys/fs/nfsserver/nfs_nfsdstate.c

Modified: head/sys/fs/nfsserver/nfs_nfsdstate.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdstate.c       Fri Jun 22 00:47:18 2018        
(r335524)
+++ head/sys/fs/nfsserver/nfs_nfsdstate.c       Fri Jun 22 00:55:39 2018        
(r335525)
@@ -128,6 +128,7 @@ static int nfsrv_returnoldstateid = 0, nfsrv_clients =
 static int nfsrv_clienthighwater = NFSRV_CLIENTHIGHWATER;
 static int nfsrv_nogsscallback = 0;
 static volatile int nfsrv_writedelegcnt = 0;
+static int nfsrv_faildscnt;
 
 /* local functions */
 static void nfsrv_dumpaclient(struct nfsclient *clp,
@@ -6748,10 +6749,9 @@ nfsrv_flexlayouterr(struct nfsrv_descript *nd, uint32_
                        NFSD_DEBUG(4, "flexlayouterr op=%d stat=%d\n", opnum,
                            stat);
                        /*
-                        * Except for NFSERR_ACCES errors for Reading,
-                        * shut the mirror down.
+                        * Except for NFSERR_ACCES errors, disable the mirror.
                         */
-                       if (opnum != NFSV4OP_READ || stat != NFSERR_ACCES)
+                       if (stat != NFSERR_ACCES)
                                nfsrv_delds(devid, p);
                }
        }
@@ -7514,6 +7514,10 @@ nfsrv_deldsnmp(struct nfsmount *nmp, NFSPROC_T *p)
 
        NFSD_DEBUG(4, "deldsdvp\n");
        NFSDDSLOCK();
+       if (nfsrv_faildscnt <= 0) {
+               NFSDDSUNLOCK();
+               return (NULL);
+       }
        fndds = nfsv4_findmirror(nmp);
        if (fndds != NULL)
                nfsrv_deleteds(fndds);
@@ -7547,6 +7551,10 @@ nfsrv_delds(char *devid, NFSPROC_T *p)
        nmp = NULL;
        fndmirror = 0;
        NFSDDSLOCK();
+       if (nfsrv_faildscnt <= 0) {
+               NFSDDSUNLOCK();
+               return (ENXIO);
+       }
        TAILQ_FOREACH(ds, &nfsrv_devidhead, nfsdev_list) {
                if (NFSBCMP(ds->nfsdev_deviceid, devid, NFSX_V4DEVICEID) == 0 &&
                    ds->nfsdev_nmp != NULL) {
@@ -7593,6 +7601,7 @@ nfsrv_deleteds(struct nfsdevice *fndds)
 
        NFSD_DEBUG(4, "deleteds: deleting a mirror\n");
        fndds->nfsdev_nmp = NULL;
+       nfsrv_faildscnt--;
 }
 
 /*
@@ -7714,6 +7723,8 @@ nfsrv_createdevids(struct nfsd_nfsd_args *args, NFSPRO
                nfsrv_maxpnfsmirror = 1;
                return (ENXIO);
        }
+       /* We can fail at most one less DS than the mirror level. */
+       nfsrv_faildscnt = nfsrv_maxpnfsmirror - 1;
 
        /*
         * Allocate the nfslayout hash table now, since this is a pNFS server.
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to