From: NeilBrown From: "J. Bruce Fields" Slightly better behavior on failed mapping (which may happen either because idmapd is not running, or because there it has told us it doesn't know the mapping.): on name->id (setattr), return BADNAME. (I used ESRCH to communicate BADNAME, just because it was the first error in include/asm-generic/errno-base.h that had something to do with nonexistance of something, and that we weren't already using.) id->name (getattr), return a string representation of the numerical id. This is probably useless to the client, especially since we're unlikely to accept such a string on a setattr, but perhaps some client will find it mildly helpful. --- 25-akpm/fs/nfsd/nfs4idmap.c | 4 ++++ 25-akpm/fs/nfsd/nfsproc.c | 1 + 25-akpm/include/linux/nfsd/nfsd.h | 1 + 3 files changed, 6 insertions(+) diff -puN fs/nfsd/nfs4idmap.c~knfsd-7-of-10-improve-idmapper-behaviour-on-failure fs/nfsd/nfs4idmap.c --- 25/fs/nfsd/nfs4idmap.c~knfsd-7-of-10-improve-idmapper-behaviour-on-failure Tue May 18 15:27:49 2004 +++ 25-akpm/fs/nfsd/nfs4idmap.c Tue May 18 15:27:49 2004 @@ -543,6 +543,8 @@ idmap_name_to_id(struct svc_rqst *rqstp, key.name[namelen] = '\0'; strlcpy(key.authname, rqstp->rq_client->name, sizeof(key.authname)); ret = idmap_lookup(rqstp, nametoid_lookup, &key, &nametoid_cache, &item); + if (ret == -ENOENT) + ret = -ESRCH; /* nfserr_badname */ if (ret) return ret; *id = item->id; @@ -561,6 +563,8 @@ idmap_id_to_name(struct svc_rqst *rqstp, strlcpy(key.authname, rqstp->rq_client->name, sizeof(key.authname)); ret = idmap_lookup(rqstp, idtoname_lookup, &key, &idtoname_cache, &item); + if (ret == -ENOENT) + return sprintf(name, "%u", id); if (ret) return ret; ret = strlen(item->name); diff -puN fs/nfsd/nfsproc.c~knfsd-7-of-10-improve-idmapper-behaviour-on-failure fs/nfsd/nfsproc.c --- 25/fs/nfsd/nfsproc.c~knfsd-7-of-10-improve-idmapper-behaviour-on-failure Tue May 18 15:27:49 2004 +++ 25-akpm/fs/nfsd/nfsproc.c Tue May 18 15:27:49 2004 @@ -589,6 +589,7 @@ nfserrno (int errno) { nfserr_jukebox, -ETIMEDOUT }, { nfserr_dropit, -EAGAIN }, { nfserr_dropit, -ENOMEM }, + { nfserr_badname, -ESRCH }, { -1, -EIO } }; int i; diff -puN include/linux/nfsd/nfsd.h~knfsd-7-of-10-improve-idmapper-behaviour-on-failure include/linux/nfsd/nfsd.h --- 25/include/linux/nfsd/nfsd.h~knfsd-7-of-10-improve-idmapper-behaviour-on-failure Tue May 18 15:27:49 2004 +++ 25-akpm/include/linux/nfsd/nfsd.h Tue May 18 15:27:49 2004 @@ -199,6 +199,7 @@ void nfsd_lockd_shutdown(void); #define nfserr_grace __constant_htonl(NFSERR_GRACE) #define nfserr_no_grace __constant_htonl(NFSERR_NO_GRACE) #define nfserr_reclaim_bad __constant_htonl(NFSERR_RECLAIM_BAD) +#define nfserr_badname __constant_htonl(NFSERR_BADNAME) /* error codes for internal use */ /* if a request fails due to kmalloc failure, it gets dropped. _