Unix Technical Forum

Re: mountd(8) diff: request for testing

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 ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > lucky.openbsd.tech

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-22-2008, 12:46 PM
Dale Rahn
 
Posts: n/a
Default Re: mountd(8) diff: request for testing

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 10:28 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com