aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2012-03-01 17:00:31 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-03-02 15:36:26 -0500
commit02a2976c9180a7dcc43bc46cf69bd3687a9d7ea6 (patch)
tree0cf276340b9a6013b33e54092f35ab9196c8f095 /fs
parent88b8e133c46792d264c991065c2c395d0b3b5482 (diff)
NFS: Clean up debugging in decode_pathname()
I noticed recently that decode_attr_fs_locations() is not generating very pretty debugging output. The pathname components each appear on a separate line of output, though that does not appear to be the intended display behavior. The preferred way to generate continued lines of output on the console is to use pr_cont(). Note that incoming pathname4 components contain a string that is not necessarily NUL-terminated. I did actually see some trailing garbage on the console. In addition to correcting the line continuation problem, add a string precision format specifier to ensure that each component string is displayed properly, and that vsnprintf() does not Oops. Someone pointed out that allowing incoming network data to possibly generate a console line of unbounded length may not be such a good idea. Since this output will rarely be enabled, and there is a hard upper bound (NFS4_PATHNAME_MAXCOMPONENTS) in our implementation, this is probably not a major concern. It might be useful to additionally sanity-check the length of each incoming component, however. RFC 3530bis15 does not suggest a maximum number of UTF-8 characters per component for either the pathname4 or component4 types. However, we could invent one that is appropriate for our implementation. Another possibility is to scrap all of this and print these pathnames in upper layers after a reasonable amount of sanity checking in the XDR layer. This would give us an opportunity to allocate a full buffer so that the whole pathname would be output via a single dprintk. Introduced by commit 7aaa0b3b: "NFSv4: convert fs-locations-components to conform to RFC3530," (June 9, 2006). Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/nfs4xdr.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index b7c04339fdc1..b5c5212cd184 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -3555,16 +3555,17 @@ static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
3555 n = be32_to_cpup(p); 3555 n = be32_to_cpup(p);
3556 if (n == 0) 3556 if (n == 0)
3557 goto root_path; 3557 goto root_path;
3558 dprintk("path "); 3558 dprintk("pathname4: ");
3559 path->ncomponents = 0; 3559 path->ncomponents = 0;
3560 while (path->ncomponents < n) { 3560 while (path->ncomponents < n) {
3561 struct nfs4_string *component = &path->components[path->ncomponents]; 3561 struct nfs4_string *component = &path->components[path->ncomponents];
3562 status = decode_opaque_inline(xdr, &component->len, &component->data); 3562 status = decode_opaque_inline(xdr, &component->len, &component->data);
3563 if (unlikely(status != 0)) 3563 if (unlikely(status != 0))
3564 goto out_eio; 3564 goto out_eio;
3565 if (path->ncomponents != n) 3565 if (unlikely(nfs_debug & NFSDBG_XDR))
3566 dprintk("/"); 3566 pr_cont("%s%.*s ",
3567 dprintk("%s", component->data); 3567 (path->ncomponents != n ? "/ " : ""),
3568 component->len, component->data);
3568 if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS) 3569 if (path->ncomponents < NFS4_PATHNAME_MAXCOMPONENTS)
3569 path->ncomponents++; 3570 path->ncomponents++;
3570 else { 3571 else {
@@ -3573,14 +3574,13 @@ static int decode_pathname(struct xdr_stream *xdr, struct nfs4_pathname *path)
3573 } 3574 }
3574 } 3575 }
3575out: 3576out:
3576 dprintk("\n");
3577 return status; 3577 return status;
3578root_path: 3578root_path:
3579/* a root pathname is sent as a zero component4 */ 3579/* a root pathname is sent as a zero component4 */
3580 path->ncomponents = 1; 3580 path->ncomponents = 1;
3581 path->components[0].len=0; 3581 path->components[0].len=0;
3582 path->components[0].data=NULL; 3582 path->components[0].data=NULL;
3583 dprintk("path /\n"); 3583 dprintk("pathname4: /\n");
3584 goto out; 3584 goto out;
3585out_eio: 3585out_eio:
3586 dprintk(" status %d", status); 3586 dprintk(" status %d", status);
@@ -3606,7 +3606,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st
3606 /* Ignore borken servers that return unrequested attrs */ 3606 /* Ignore borken servers that return unrequested attrs */
3607 if (unlikely(res == NULL)) 3607 if (unlikely(res == NULL))
3608 goto out; 3608 goto out;
3609 dprintk("%s: fsroot ", __func__); 3609 dprintk("%s: fsroot:\n", __func__);
3610 status = decode_pathname(xdr, &res->fs_path); 3610 status = decode_pathname(xdr, &res->fs_path);
3611 if (unlikely(status != 0)) 3611 if (unlikely(status != 0))
3612 goto out; 3612 goto out;
@@ -3627,7 +3627,7 @@ static int decode_attr_fs_locations(struct xdr_stream *xdr, uint32_t *bitmap, st
3627 m = be32_to_cpup(p); 3627 m = be32_to_cpup(p);
3628 3628
3629 loc->nservers = 0; 3629 loc->nservers = 0;
3630 dprintk("%s: servers ", __func__); 3630 dprintk("%s: servers:\n", __func__);
3631 while (loc->nservers < m) { 3631 while (loc->nservers < m) {
3632 struct nfs4_string *server = &loc->servers[loc->nservers]; 3632 struct nfs4_string *server = &loc->servers[loc->nservers];
3633 status = decode_opaque_inline(xdr, &server->len, &server->data); 3633 status = decode_opaque_inline(xdr, &server->len, &server->data);