From 985248165e53a67e7cb6a18ec2813aba8b26da33 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 14 Jun 2023 16:49:37 -0400 Subject: [RFC] NFS: Add debugging printk()s to trace the xdr->scratch buffer I'm trying to figure out at what point the xdr->scratch buffer is allocated, freed, set, and reset to figure out why READ_PLUS suddenly thinks it's a NULL pointer with length 16. Signed-off-by: Anna Schumaker --- fs/nfs/nfs42xdr.c | 7 +++++++ fs/nfs/read.c | 8 +++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 20aa5e746497..6f63c816b0a5 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -1351,21 +1351,28 @@ static int nfs4_xdr_dec_read_plus(struct rpc_rqst *rqstp, struct compound_hdr hdr; int status; + printk(KERN_INFO "%s(hdr=%px, scratch=%px)\n", __func__, + container_of(res, struct nfs_pgio_header, res), res->scratch); xdr_set_scratch_buffer(xdr, res->scratch, READ_PLUS_SCRATCH_SIZE); + printk(KERN_INFO " buf = {%px, %zd}\n", xdr->scratch.iov_base, xdr->scratch.iov_len); status = decode_compound_hdr(xdr, &hdr); if (status) goto out; + printk(KERN_INFO " buf = {%px, %zd}\n", xdr->scratch.iov_base, xdr->scratch.iov_len); status = decode_sequence(xdr, &res->seq_res, rqstp); if (status) goto out; + printk(KERN_INFO " buf = {%px, %zd}\n", xdr->scratch.iov_base, xdr->scratch.iov_len); status = decode_putfh(xdr); if (status) goto out; + printk(KERN_INFO " buf = {%px, %zd}\n", xdr->scratch.iov_base, xdr->scratch.iov_len); status = decode_read_plus(xdr, res); if (!status) status = res->count; out: + printk(KERN_INFO " buf = {%px, %zd}\n", xdr->scratch.iov_base, xdr->scratch.iov_len); return status; } diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 7dc21a48e3e7..7b93316a52de 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -47,8 +47,11 @@ static struct nfs_pgio_header *nfs_readhdr_alloc(void) static void nfs_readhdr_free(struct nfs_pgio_header *rhdr) { - if (rhdr->res.scratch != NULL) + if (rhdr->res.scratch != NULL) { + printk(KERN_INFO "%s(hdr=%px, scratch=%px)\n", + __func__, rhdr, rhdr->res.scratch); kfree(rhdr->res.scratch); + } kmem_cache_free(nfs_rdata_cachep, rhdr); } @@ -114,6 +117,9 @@ bool nfs_read_alloc_scratch(struct nfs_pgio_header *hdr, size_t size) { WARN_ON(hdr->res.scratch != NULL); hdr->res.scratch = kmalloc(size, GFP_KERNEL); + printk(KERN_INFO "\n"); + printk(KERN_INFO "%s(hdr=%px, size=%zd) = %px\n", + __func__, hdr, size, hdr->res.scratch); return hdr->res.scratch != NULL; } EXPORT_SYMBOL_GPL(nfs_read_alloc_scratch); -- 2.41.0