From: Arshad Hussain Date: Mon, 18 Mar 2024 08:56:12 +0000 (+0530) Subject: LU-17000 utils: Pass statx parameter as reference X-Git-Tag: 2.15.62~27 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F54443%2F5;p=fs%2Flustre-release.git LU-17000 utils: Pass statx parameter as reference In printf_format_file_attributes() parameter 'struct statx' was passed as value. Since copying large value is inefficient. This function changes passing 'struct statx' to be passed as reference. Test-Parameters: trivial mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 testlist=sanity-sec env=SHARED_KEY=true,ONLY=65 Test-Parameters: trivial mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 testlist=sanity-sec env=SHARED_KEY=true,ONLY=65 Test-Parameters: trivial mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 testlist=sanity-sec env=SHARED_KEY=true,ONLY=65 Test-Parameters: trivial mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 testlist=sanity-sec env=SHARED_KEY=true,ONLY=65 Test-Parameters: trivial mdscount=2 mdtcount=4 osscount=1 ostcount=8 clientcount=2 testlist=sanity-sec env=SHARED_KEY=true,ONLY=65 Fixes: f0ab3ac6d6 ("LU-16760 utils: support 'lfs find --attrs' and '-printf %La'") CoverityID: 399698 ("Big parameter passed by value") Signed-off-by: Arshad Hussain Change-Id: Ic20feff84d7043000ebaa1eaec98d54c73fc1a7e Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54443 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Timothy Day Reviewed-by: Oleg Drokin --- diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 6536ec2..bafd87f 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -5045,13 +5045,15 @@ format_done: * * @param[out] buffer Location where file attributes are written * @param[in] size Size of the available buffer. - * @pararm[in] stx struct statx containing attributes to print + * @pararm[in] lstx Void pointer holding address of struct statx. Which is + * containing attributes to be printed * @return Number of bytes written to output buffer */ static int printf_format_file_attributes(char *buffer, size_t size, - lstatx_t stx, bool longopt) + void *lstx, bool longopt) { - uint64_t attrs = stx.stx_attributes_mask & stx.stx_attributes; + lstatx_t *stx = (lstatx_t *)lstx; + uint64_t attrs = stx->stx_attributes_mask & stx->stx_attributes; int bytes = 0, wrote = 0, first = 1; uint64_t known_attrs = 0; struct attrs_name *ap; @@ -5125,6 +5127,7 @@ static int printf_format_lustre(char *seq, char *buffer, size_t size, int err, bytes, i; bool longopt = true; int rc = 2; /* all current valid sequences are 2 chars */ + void *lstx; *wrote = 0; /* Sanity check. Formats always look like %L{X} */ @@ -5157,8 +5160,9 @@ static int printf_format_lustre(char *seq, char *buffer, size_t size, longopt = false; fallthrough; case 'A': - *wrote = printf_format_file_attributes(buffer, size, - param->fp_lmd->lmd_stx, + lstx = ¶m->fp_lmd->lmd_stx; + + *wrote = printf_format_file_attributes(buffer, size, lstx, longopt); goto format_done; }