Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149576246
D3304.id7688.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D3304.id7688.diff
View Options
Index: sys/fs/nfsclient/nfs_clport.c
===================================================================
--- sys/fs/nfsclient/nfs_clport.c
+++ sys/fs/nfsclient/nfs_clport.c
@@ -42,7 +42,9 @@
* generally, I don't like #includes inside .h files, but it seems to
* be the easiest way to handle the port.
*/
+#include <sys/fail.h>
#include <sys/hash.h>
+#include <sys/sysctl.h>
#include <fs/nfs/nfsport.h>
#include <netinet/if_ether.h>
#include <net/if_types.h>
@@ -83,6 +85,16 @@
extern void (*ncl_call_invalcaches)(struct vnode *);
+SYSCTL_DECL(_vfs_nfs);
+static int ncl_fileid_maxwarnings = 10;
+SYSCTL_INT(_vfs_nfs, OID_AUTO, fileid_maxwarnings, CTLFLAG_RWTUN,
+ &ncl_fileid_maxwarnings, 0,
+ "Limit fileid corruption warnings; 0 is off; -1 is unlimited");
+static volatile int ncl_fileid_nwarnings;
+
+static void nfscl_warn_fileid(struct nfsmount *, struct nfsvattr *,
+ struct nfsvattr *);
+
/*
* Comparison function for vfs_hash functions.
*/
@@ -343,6 +355,37 @@
return (EINVAL);
}
+static void
+nfscl_warn_fileid(struct nfsmount *nmp, struct nfsvattr *oldnap,
+ struct nfsvattr *newnap)
+{
+ int off;
+
+ if (ncl_fileid_maxwarnings >= 0 &&
+ ncl_fileid_nwarnings >= ncl_fileid_maxwarnings)
+ return;
+ off = 0;
+ if (ncl_fileid_maxwarnings >= 0) {
+ if (++ncl_fileid_nwarnings >= ncl_fileid_maxwarnings)
+ off = 1;
+ }
+
+ printf("newnfs: server '%s' error: fileid changed. "
+ "fsid %jx:%jx: expected fileid %#jx, got %#jx. "
+ "(Are you using a broken WAN accelerator?)\n",
+ nmp->nm_com.nmcom_hostname,
+ (uintmax_t)nmp->nm_fsid[0],
+ (uintmax_t)nmp->nm_fsid[1],
+ (uintmax_t)oldnap->na_fileid,
+ (uintmax_t)newnap->na_fileid);
+
+ if (off)
+ printf("newnfs: Logged %d times about fileid corruption; "
+ "going quiet to avoid spamming logs excessively. (Limit "
+ "is: %d).\n", ncl_fileid_nwarnings,
+ ncl_fileid_maxwarnings);
+}
+
/*
* Load the attribute cache (that lives in the nfsnode entry) with
* the attributes of the second argument and
@@ -361,7 +404,11 @@
struct nfsmount *nmp;
struct timespec mtime_save;
u_quad_t nsize;
- int setnsize;
+ int setnsize, error, force_fid_err;
+
+ error = 0;
+ setnsize = 0;
+ nsize = 0;
/*
* If v_type == VNON it is a new node, so fill in the v_type,
@@ -389,6 +436,16 @@
np->n_vattr.na_fsid = nap->na_fsid;
np->n_vattr.na_mode = nap->na_mode;
} else {
+ force_fid_err = 0;
+ KFAIL_POINT_ERROR(DEBUG_FP, nfscl_force_fileid_warning,
+ force_fid_err);
+ if ((np->n_vattr.na_fileid != 0 &&
+ np->n_vattr.na_fileid != nap->na_fileid) ||
+ force_fid_err) {
+ nfscl_warn_fileid(nmp, &np->n_vattr, nap);
+ error = EIDRM;
+ goto out;
+ }
NFSBCOPY((caddr_t)nap, (caddr_t)&np->n_vattr,
sizeof (struct nfsvattr));
}
@@ -419,8 +476,6 @@
} else
vap->va_fsid = vp->v_mount->mnt_stat.f_fsid.val[0];
np->n_attrstamp = time_second;
- setnsize = 0;
- nsize = 0;
if (vap->va_size != np->n_size) {
if (vap->va_type == VREG) {
if (dontshrink && vap->va_size < np->n_size) {
@@ -490,14 +545,16 @@
vaper->va_mtime = np->n_mtim;
}
}
+
+out:
#ifdef KDTRACE_HOOKS
if (np->n_attrstamp != 0)
- KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, 0);
+ KDTRACE_NFS_ATTRCACHE_LOAD_DONE(vp, vap, error);
#endif
NFSUNLOCKNODE(np);
if (setnsize)
vnode_pager_setsize(vp, nsize);
- return (0);
+ return (error);
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 26, 8:49 AM (10 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30374938
Default Alt Text
D3304.id7688.diff (3 KB)
Attached To
Mode
D3304: nfsclient: Protest loudly when GETATTR responses are invalid
Attached
Detach File
Event Timeline
Log In to Comment