Commit 74d88830 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] kNFSd: Improve idmapper behaviour on failure.

From: NeilBrown <neilb@cse.unsw.edu.au>

From: "J. Bruce Fields" <bfields@fieldses.org>

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.
parent 63b60615
...@@ -543,6 +543,8 @@ idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen ...@@ -543,6 +543,8 @@ idmap_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen
key.name[namelen] = '\0'; key.name[namelen] = '\0';
strlcpy(key.authname, rqstp->rq_client->name, sizeof(key.authname)); strlcpy(key.authname, rqstp->rq_client->name, sizeof(key.authname));
ret = idmap_lookup(rqstp, nametoid_lookup, &key, &nametoid_cache, &item); ret = idmap_lookup(rqstp, nametoid_lookup, &key, &nametoid_cache, &item);
if (ret == -ENOENT)
ret = -ESRCH; /* nfserr_badname */
if (ret) if (ret)
return ret; return ret;
*id = item->id; *id = item->id;
...@@ -561,6 +563,8 @@ idmap_id_to_name(struct svc_rqst *rqstp, int type, uid_t id, char *name) ...@@ -561,6 +563,8 @@ idmap_id_to_name(struct svc_rqst *rqstp, int type, uid_t id, char *name)
strlcpy(key.authname, rqstp->rq_client->name, sizeof(key.authname)); strlcpy(key.authname, rqstp->rq_client->name, sizeof(key.authname));
ret = idmap_lookup(rqstp, idtoname_lookup, &key, &idtoname_cache, &item); ret = idmap_lookup(rqstp, idtoname_lookup, &key, &idtoname_cache, &item);
if (ret == -ENOENT)
return sprintf(name, "%u", id);
if (ret) if (ret)
return ret; return ret;
ret = strlen(item->name); ret = strlen(item->name);
......
...@@ -589,6 +589,7 @@ nfserrno (int errno) ...@@ -589,6 +589,7 @@ nfserrno (int errno)
{ nfserr_jukebox, -ETIMEDOUT }, { nfserr_jukebox, -ETIMEDOUT },
{ nfserr_dropit, -EAGAIN }, { nfserr_dropit, -EAGAIN },
{ nfserr_dropit, -ENOMEM }, { nfserr_dropit, -ENOMEM },
{ nfserr_badname, -ESRCH },
{ -1, -EIO } { -1, -EIO }
}; };
int i; int i;
......
...@@ -199,6 +199,7 @@ void nfsd_lockd_shutdown(void); ...@@ -199,6 +199,7 @@ void nfsd_lockd_shutdown(void);
#define nfserr_grace __constant_htonl(NFSERR_GRACE) #define nfserr_grace __constant_htonl(NFSERR_GRACE)
#define nfserr_no_grace __constant_htonl(NFSERR_NO_GRACE) #define nfserr_no_grace __constant_htonl(NFSERR_NO_GRACE)
#define nfserr_reclaim_bad __constant_htonl(NFSERR_RECLAIM_BAD) #define nfserr_reclaim_bad __constant_htonl(NFSERR_RECLAIM_BAD)
#define nfserr_badname __constant_htonl(NFSERR_BADNAME)
/* error codes for internal use */ /* error codes for internal use */
/* if a request fails due to kmalloc failure, it gets dropped. /* if a request fails due to kmalloc failure, it gets dropped.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment