2022-07-22 20:23:43

by Chuck Lever III

[permalink] [raw]
Subject: [PATCH v1 02/11] NFSD: Shrink size of struct nfsd4_copy

struct nfsd4_copy is part of struct nfsd4_op, which resides in an
8-element array.

sizeof(struct nfsd4_op):
Before: /* size: 1696, cachelines: 27, members: 5 */
After: /* size: 672, cachelines: 11, members: 5 */

Signed-off-by: Chuck Lever <[email protected]>
---
fs/nfsd/nfs4proc.c | 6 +++++-
fs/nfsd/nfs4xdr.c | 6 +++++-
fs/nfsd/xdr4.h | 2 +-
3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 22c5ccb83d20..0bcfb9afca03 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -1289,6 +1289,7 @@ void nfs4_put_copy(struct nfsd4_copy *copy)
{
if (!refcount_dec_and_test(&copy->refcount))
return;
+ kfree(copy->cp_src);
kfree(copy);
}

@@ -1761,7 +1762,7 @@ static void dup_copy_fields(struct nfsd4_copy *src, struct nfsd4_copy *dst)
dst->nf_src = nfsd_file_get(src->nf_src);

memcpy(&dst->cp_stateid, &src->cp_stateid, sizeof(src->cp_stateid));
- memcpy(&dst->cp_src, &src->cp_src, sizeof(struct nl4_server));
+ memcpy(dst->cp_src, src->cp_src, sizeof(struct nl4_server));
memcpy(&dst->stateid, &src->stateid, sizeof(src->stateid));
memcpy(&dst->c_fh, &src->c_fh, sizeof(src->c_fh));
dst->ss_mnt = src->ss_mnt;
@@ -1855,6 +1856,9 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
async_copy = kzalloc(sizeof(struct nfsd4_copy), GFP_KERNEL);
if (!async_copy)
goto out_err;
+ async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL);
+ if (!async_copy->cp_src)
+ goto out_err;
if (!nfs4_init_copy_state(nn, copy))
goto out_err;
refcount_set(&async_copy->refcount, 1);
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 335431199077..045301ad6bb5 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1926,8 +1926,12 @@ nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy)
return nfs_ok;
}

+ copy->cp_src = svcxdr_tmpalloc(argp, sizeof(*copy->cp_src));
+ if (copy->cp_src == NULL)
+ return nfserrno(-ENOMEM); /* XXX: jukebox? */
+
/* decode all the supplied server addresses but use only the first */
- status = nfsd4_decode_nl4_server(argp, &copy->cp_src);
+ status = nfsd4_decode_nl4_server(argp, copy->cp_src);
if (status)
return status;

diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
index f253fc3f4708..f5ad2939e6ee 100644
--- a/fs/nfsd/xdr4.h
+++ b/fs/nfsd/xdr4.h
@@ -540,7 +540,7 @@ struct nfsd4_copy {
u64 cp_src_pos;
u64 cp_dst_pos;
u64 cp_count;
- struct nl4_server cp_src;
+ struct nl4_server *cp_src;
bool cp_intra;

/* both */



2022-07-24 06:41:29

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v1 02/11] NFSD: Shrink size of struct nfsd4_copy

Hi Chuck,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.19-rc7 next-20220722]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Chuck-Lever/Put-struct-nfsd4_copy-on-a-diet/20220723-042113
base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 70664fc10c0d722ec79d746d8ac1db8546c94114
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20220724/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/1968aac547167ef15b3634429e0cfac0c5b38419
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Chuck-Lever/Put-struct-nfsd4_copy-on-a-diet/20220723-042113
git checkout 1968aac547167ef15b3634429e0cfac0c5b38419
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash fs/nfsd/

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

All errors (new ones prefixed by >>):

fs/nfsd/nfs4proc.c: In function 'nfsd4_setup_inter_ssc':
>> fs/nfsd/nfs4proc.c:1553:41: error: passing argument 1 of 'nfsd4_interssc_connect' from incompatible pointer type [-Werror=incompatible-pointer-types]
1553 | status = nfsd4_interssc_connect(&copy->cp_src, rqstp, mount);
| ^~~~~~~~~~~~~
| |
| struct nl4_server **
fs/nfsd/nfs4proc.c:1428:43: note: expected 'struct nl4_server *' but argument is of type 'struct nl4_server **'
1428 | nfsd4_interssc_connect(struct nl4_server *nss, struct svc_rqst *rqstp,
| ~~~~~~~~~~~~~~~~~~~^~~
cc1: some warnings being treated as errors


vim +/nfsd4_interssc_connect +1553 fs/nfsd/nfs4proc.c

ce0887ac96d35c Olga Kornievskaia 2019-10-09 1527
f2453978a4f2dd Chuck Lever 2020-04-06 1528 /*
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1529 * Verify COPY destination stateid.
f2453978a4f2dd Chuck Lever 2020-04-06 1530 *
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1531 * Connect to the source server with NFSv4.1.
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1532 * Create the source struct file for nfsd_copy_range.
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1533 * Called with COPY cstate:
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1534 * SAVED_FH: source filehandle
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1535 * CURRENT_FH: destination filehandle
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1536 */
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1537 static __be32
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1538 nfsd4_setup_inter_ssc(struct svc_rqst *rqstp,
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1539 struct nfsd4_compound_state *cstate,
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1540 struct nfsd4_copy *copy, struct vfsmount **mount)
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1541 {
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1542 struct svc_fh *s_fh = NULL;
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1543 stateid_t *s_stid = &copy->cp_src_stateid;
b8290ca250fb77 Olga Kornievskaia 2019-12-04 1544 __be32 status = nfserr_inval;
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1545
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1546 /* Verify the destination stateid and set dst struct file*/
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1547 status = nfs4_preprocess_stateid_op(rqstp, cstate, &cstate->current_fh,
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1548 &copy->cp_dst_stateid,
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1549 WR_STATE, &copy->nf_dst, NULL);
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1550 if (status)
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1551 goto out;
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1552
ce0887ac96d35c Olga Kornievskaia 2019-10-09 @1553 status = nfsd4_interssc_connect(&copy->cp_src, rqstp, mount);
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1554 if (status)
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1555 goto out;
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1556
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1557 s_fh = &cstate->save_fh;
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1558
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1559 copy->c_fh.size = s_fh->fh_handle.fh_size;
d8b26071e65e80 NeilBrown 2021-09-02 1560 memcpy(copy->c_fh.data, &s_fh->fh_handle.fh_raw, copy->c_fh.size);
3f9544ca62bc13 Olga Kornievskaia 2019-12-04 1561 copy->stateid.seqid = cpu_to_be32(s_stid->si_generation);
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1562 memcpy(copy->stateid.other, (void *)&s_stid->si_opaque,
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1563 sizeof(stateid_opaque_t));
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1564
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1565 status = 0;
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1566 out:
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1567 return status;
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1568 }
ce0887ac96d35c Olga Kornievskaia 2019-10-09 1569

--
0-DAY CI Kernel Test Service
https://01.org/lkp