Whamcloud - gitweb
LU-17000 utils: Pass statx parameter as reference 43/54443/5
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Mon, 18 Mar 2024 08:56:12 +0000 (14:26 +0530)
committerOleg Drokin <green@whamcloud.com>
Tue, 2 Apr 2024 21:04:29 +0000 (21:04 +0000)
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 <arshad.hussain@aeoncomputing.com>
Change-Id: Ic20feff84d7043000ebaa1eaec98d54c73fc1a7e
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54443
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/utils/liblustreapi.c

index 6536ec2..bafd87f 100644 (file)
@@ -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 = &param->fp_lmd->lmd_stx;
+
+               *wrote = printf_format_file_attributes(buffer, size, lstx,
                                                       longopt);
                goto format_done;
        }