This is a discussion on Re: mountd(8) diff: request for testing within the lucky.openbsd.tech forums, part of the OpenBSD category; --> On Fri, Sep 09, 2005 at 09:40:20AM +0200, Otto Moerbeek wrote: > Hi, > > In the last few ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Fri, Sep 09, 2005 at 09:40:20AM +0200, Otto Moerbeek wrote: > Hi, > > In the last few releases NFS has seen a lot of stability and > performance improvements, but there remains an annoying problem, which > this diff should fix. > > NFS clients can get I/O errors if they try to perorm I/O while file > systems are being mounted or unmounted on the NFS server. > > To test, run this diff on your NFS server, and manipulate filesystems > on it while clients are actively doing I/O, e.g. doing a make build > with src on NFS. > > Diff original by Dale Rahn, with fixes by me. > > Thanks in advance for testing, > > -Otto > Found a small error in the diff, corrected version below, the previous version called the mount(...,MNT_UPDATE,...) regardless of presense of MNT_DELEXPORT flag, thus it would be called on other filesystem types including NFS, with this diff it will only call mount if it has something to do. prevents this error from showing up in syslog -- Sep 10 16:54:07 mrquick mountd[1010]: Can't delete exports for /usr/ports/distfiles: Program version wrong -- Index: mountd.c ================================================== ================= RCS file: /cvs/src/sbin/mountd/mountd.c,v retrieving revision 1.63 diff -u -r1.63 mountd.c --- mountd.c 8 Apr 2005 20:09:38 -0000 1.63 +++ mountd.c 10 Sep 2005 23:15:16 -0000 @@ -702,9 +702,20 @@ struct grouplist *grp, *tgrp; struct exportlist **epp; struct dirlist *dirhead; - struct statfs fsb, *fsp; + struct statfs fsb, *ofsp, *fsp; struct hostent *hpe; struct ucred anon; + union { + struct ufs_args ua; + struct iso_args ia; + struct mfs_args ma; + struct msdosfs_args da; + struct adosfs_args aa; + } targs; + struct fsarray { + int exflags; + char *mntonname; + } *fstbl; /* * First, get rid of the old list @@ -731,15 +742,17 @@ * XXX: Should know how to handle all local exportable file systems * instead of just MOUNT_FFS. */ - num = getmntinfo(&fsp, MNT_NOWAIT); + num = getmntinfo(&ofsp, MNT_NOWAIT); + if (num == 0 && errno) + syslog(LOG_ERR, "getmntinfo: %s", strerror(errno)); + + fsp = ofsp; + + fstbl = calloc(num, sizeof (fstbl[0])); + if (fstbl == NULL) + out_of_mem(); + for (i = 0; i < num; i++) { - union { - struct ufs_args ua; - struct iso_args ia; - struct mfs_args ma; - struct msdosfs_args da; - struct adosfs_args aa; - } targs; if (!strncmp(fsp->f_fstypename, MOUNT_MFS, MFSNAMELEN) || !strncmp(fsp->f_fstypename, MOUNT_FFS, MFSNAMELEN) || @@ -747,13 +760,8 @@ !strncmp(fsp->f_fstypename, MOUNT_MSDOS, MFSNAMELEN) || !strncmp(fsp->f_fstypename, MOUNT_ADOSFS, MFSNAMELEN) || !strncmp(fsp->f_fstypename, MOUNT_CD9660, MFSNAMELEN)) { - bzero((char *)&targs, sizeof(targs)); - targs.ua.fspec = NULL; - targs.ua.export_info.ex_flags = MNT_DELEXPORT; - if (mount(fsp->f_fstypename, fsp->f_mntonname, - fsp->f_flags | MNT_UPDATE, &targs) < 0) - syslog(LOG_ERR, "Can't delete exports for %s: %m", - fsp->f_mntonname); + fstbl[i].exflags = MNT_DELEXPORT; + fstbl[i].mntonname = fsp->f_mntonname; } fsp++; } @@ -966,6 +974,26 @@ */ grp = tgrp; do { + + /* + * remove filesystem from unexport list + * add MNT_DELEXPORT to exflags to clean up + * any old addrlist in the kernel + */ + + for (i = 0; i < num; i++) { + if ((fstbl[i].mntonname != NULL) && + (strcmp (dirp, fstbl[i].mntonname) == 0) && + (fstbl[i].exflags & MNT_DELEXPORT)) { + exflags |= MNT_DELEXPORT; + fstbl[i].exflags = 0; + if (debug) + fprintf(stderr, "removing %s %s from unexport list\n", dirp, fstbl[i].mntonname); + } + } + + if (debug) + fprintf(stderr, "exporting %s\n", dirp); /* * Non-zero return indicates an error. Return * val of 1 means line is invalid (not just entry). @@ -1020,6 +1048,21 @@ dirhead = NULL; } } + + fsp = ofsp; + for (i = 0; i < num; i++, fsp++) { + if ((fstbl[i].exflags & MNT_DELEXPORT) == 0) + continue; + if (debug) + fprintf(stderr, "unexporting %s %s\n", + fsp->f_mntonname, fstbl[i].mntonname); + bzero(&targs, sizeof(targs)); + if (mount(fsp->f_fstypename, fsp->f_mntonname, + fsp->f_flags | MNT_UPDATE, &targs) < 0) + syslog(LOG_ERR, "Can't delete exports for %s: %m", + fsp->f_mntonname); + } + free(fstbl); fclose(exp_file); } Dale Rahn drahn@dalerahn.com |