Lines Matching refs:fs

117  * Flush cached data for an fserver (or for all, if fs==NULL)
120 flush_srvr_nfs_cache(fserver *fs)
125 if (fs == NULL || fs == fs2) {
187 fserver *fs = 0;
192 ITER(fs, fserver, &nfs_srvr_list)
193 if (fs == fs2)
196 if (fs == fs2) {
199 nfs_private *np = (nfs_private *) fs->fs_private;
202 dlog("got port (%d) for mountd on %s", (int) port, fs->fs_host);
213 dlog("Error fetching port for mountd on %s", fs->fs_host);
221 if (fs->fs_flags & FSF_WANT)
222 wakeup_srvr(fs);
235 call_portmap(fserver *fs, AUTH *auth, u_long prog, u_long vers, u_long prot)
258 sin = *fs->fs_ip;
261 &sin, &sin, (voidp) fs, got_portmap);
271 recompute_portmap(fserver *fs)
279 if (fs->fs_flags & FSF_WEBNFS)
288 nfs_private *np = (nfs_private *) fs->fs_private;
293 if (fs->fs_version == 0)
297 (int) fs->fs_version, fs->fs_host);
299 if (fs->fs_version == NFS_VERSION3)
306 call_portmap(fs, nfs_auth, MOUNTPROG, mnt_version, (u_long) IPPROTO_UDP);
311 get_mountd_port(fserver *fs, u_short *port, wchan_t wchan)
314 if (FSRV_ISDOWN(fs))
317 if (FSRV_ISUP(fs)) {
318 nfs_private *np = (nfs_private *) fs->fs_private;
333 recompute_portmap(fs);
337 if (error < 0 && wchan && !(fs->fs_flags & FSF_WANT)) {
342 * whenever a wakeup is done on this fs node.
343 * Wakeup's are done on the fs node whenever
347 fs->fs_flags |= FSF_WANT;
348 sched_task(wakeup_task, wchan, (wchan_t) fs);
363 fserver *fs;
372 ITER(fs, fserver, &nfs_srvr_list) {
373 nfs_private *np = (nfs_private *) fs->fs_private;
374 if (np->np_xid == xid && (fs->fs_flags & FSF_PINGING)) {
380 if (fs->fs_flags & FSF_DOWN) {
381 fs->fs_flags &= ~FSF_DOWN;
382 if (fs->fs_flags & FSF_VALID) {
383 srvrlog(fs, "is up");
386 srvrlog(fs, "ok");
388 srvrlog(fs, "starts up");
389 fs->fs_flags |= FSF_VALID;
392 map_flush_srvr(fs);
394 if (fs->fs_flags & FSF_VALID) {
395 dlog("file server %s type nfs is still up", fs->fs_host);
398 srvrlog(fs, "ok");
399 fs->fs_flags |= FSF_VALID;
406 untimeout(fs->fs_cid);
407 fs->fs_cid = timeout(fs->fs_pinger, nfs_keepalive, (voidp) fs);
413 (MAX_ALLOWED_PINGS - 1) * FAST_NFS_PING + fs->fs_pinger - 1;
429 recompute_portmap(fs);
442 check_fs_addr_change(fserver *fs)
448 hp = gethostbyname(fs->fs_host);
451 !STREQ((char *) hp->h_name, fs->fs_host) ||
452 memcmp((voidp) &fs->fs_ip->sin_addr,
454 sizeof(fs->fs_ip->sin_addr)) == 0)
457 old_ipaddr = strdup(inet_ntoa(fs->fs_ip->sin_addr));
461 fs->fs_host, old_ipaddr, new_ipaddr);
464 memmove((voidp) &fs->fs_ip->sin_addr,
466 sizeof(fs->fs_ip->sin_addr));
468 fs->fs_flags &= ~FSF_DOWN;
469 fs->fs_flags |= FSF_VALID | FSF_WANT;
470 map_flush_srvr(fs); /* XXX: a race with flush_srvr_nfs_cache? */
471 flush_srvr_nfs_cache(fs);
472 fs->fs_flags |= FSF_FORCE_UNMOUNT;
475 flush_nfs_fhandle_cache(fs); /* done in caller: nfs_keepalive_timeout */
487 fserver *fs = v;
488 nfs_private *np = (nfs_private *) fs->fs_private;
495 srvrlog(fs, "not responding");
500 if (FSRV_ISUP(fs))
501 fs->fs_flags &= ~FSF_VALID;
507 int oflags = fs->fs_flags;
509 if ((fs->fs_flags & FSF_DOWN) == 0) {
513 srvrlog(fs, "is down");
514 fs->fs_flags |= FSF_DOWN | FSF_VALID;
520 flush_nfs_fhandle_cache(fs);
522 check_fs_addr_change(fs); /* check if IP addr of fserver changed */
527 if ((fs->fs_flags & FSF_VALID) == 0)
528 srvrlog(fs, "starts down");
529 fs->fs_flags |= FSF_VALID;
531 if (oflags != fs->fs_flags && (fs->fs_flags & FSF_WANT))
532 wakeup_srvr(fs);
539 dlog("%d pings to %s failed - at most %d allowed", np->np_ping, fs->fs_host, MAX_ALLOWED_PINGS);
551 nfs_keepalive(fs);
561 fserver *fs = v;
563 nfs_private *np = (nfs_private *) fs->fs_private;
570 if (ping_len[fs->fs_version - NFS_VERSION] == 0)
571 create_ping_payload(fs->fs_version);
577 ping_buf[fs->fs_version - NFS_VERSION],
578 ping_len[fs->fs_version - NFS_VERSION],
579 fs->fs_ip,
603 dlog("Sent NFS ping to %s", fs->fs_host);
611 switch (fs->fs_flags & (FSF_DOWN | FSF_VALID)) {
618 fstimeo = fs->fs_pinger;
628 fs->fs_cid = timeout(fstimeo, nfs_keepalive_timeout, (voidp) fs);
633 start_nfs_pings(fserver *fs, int pingval)
638 if (fs->fs_flags & FSF_PING_UNINIT) {
639 fs->fs_flags &= ~FSF_PING_UNINIT;
640 plog(XLOG_INFO, "initializing %s's pinger to %d sec", fs->fs_host, pingval);
644 if ((fs->fs_flags & FSF_PINGING) && fs->fs_pinger == pingval) {
645 dlog("already running pings to %s", fs->fs_host);
651 fs->fs_host,
652 fs->fs_pinger, (fs->fs_pinger < 0 ? " (off)" : ""),
655 fs->fs_pinger = pingval;
657 if (fs->fs_cid)
658 untimeout(fs->fs_cid);
660 srvrlog(fs, "wired up (pings disabled)");
661 fs->fs_flags |= FSF_VALID;
662 fs->fs_flags &= ~FSF_DOWN;
664 fs->fs_flags |= FSF_PINGING;
665 nfs_keepalive(fs);
677 fserver *fs;
793 ITER(fs, fserver, &nfs_srvr_list) {
794 if (FSRV_ISDOWN(fs) &&
795 STREQ(host, fs->fs_host)) {
797 fs->fs_refc++;
800 return fs;
917 * Try to find an existing fs server structure for this host.
922 ITER(fs, fserver, &nfs_srvr_list) {
923 if (STREQ(host, fs->fs_host) &&
924 nfs_version == fs->fs_version &&
925 STREQ(nfs_proto, fs->fs_proto)) {
932 if (hp && fs->fs_ip &&
933 memcmp((voidp) &fs->fs_ip->sin_addr,
935 sizeof(fs->fs_ip->sin_addr)) != 0) {
938 old_ipaddr = strdup(inet_ntoa(fs->fs_ip->sin_addr));
942 fs->fs_host, old_ipaddr, new_ipaddr);
944 flush_nfs_fhandle_cache(fs);
945 memmove((voidp) &fs->fs_ip->sin_addr, (voidp) hp->h_addr, sizeof(fs->fs_ip->sin_addr));
953 fs->fs_flags &= ~FSF_WEBNFS;
956 start_nfs_pings(fs, pingval);
963 if (!(fs->fs_flags & FSF_PINGING)) {
964 np = (nfs_private *) fs->fs_private;
975 start_nfs_pings(fs, pingval);
977 fs->fs_flags |= FSF_VALID | FSF_DOWN;
980 fs->fs_refc++;
983 return fs;
994 fs = ALLOC(struct fserver);
995 fs->fs_refc = 1;
996 fs->fs_host = strdup(hp ? hp->h_name : "unknown_hostname");
998 host_normalize(&fs->fs_host);
999 fs->fs_ip = ip;
1000 fs->fs_cid = 0;
1002 fs->fs_flags = FSF_DOWN; /* Starts off down */
1004 fs->fs_flags = FSF_ERROR | FSF_VALID;
1009 fs->fs_flags |= FSF_WEBNFS;
1010 fs->fs_version = nfs_version;
1011 fs->fs_proto = nfs_proto;
1012 fs->fs_type = MNTTAB_TYPE_NFS;
1013 fs->fs_pinger = AM_PINGER;
1014 fs->fs_flags |= FSF_PING_UNINIT; /* pinger hasn't been initialized */
1026 fs->fs_private = (voidp) np;
1027 fs->fs_prfree = (void (*)(voidp)) free;
1029 if (!FSRV_ERROR(fs)) {
1031 start_nfs_pings(fs, pingval);
1033 fs->fs_flags |= FSF_VALID | FSF_DOWN;
1039 ins_que(&fs->fs_q, &nfs_srvr_list);
1041 return fs;