Whamcloud - gitweb
LU-12373 utils: fix llapi_pcc_del_internal() flags
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 22 Apr 2022 23:40:04 +0000 (17:40 -0600)
committerAndreas Dilger <adilger@whamcloud.com>
Fri, 6 May 2022 06:58:42 +0000 (06:58 +0000)
The pch_flags value used by llapi_pcc_del_internal() was declared
as a "bool" but is used to pass a __u32 flags value from the caller.
This coincidentally works in the case where "flags = 1" (which is
the only value currently in use), but would break in confusing ways
in the future.

Change pch_flags to be "enum lu_pcc_cleanup_flags" to make it clear
what possible flag values are being used in this interface.

Fixes: 871da4898405 ("LU-12373 pcc: uncache the pcc copies when remove a PCC backend")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I41a008856af396376303fb156e2a92bce53ebbe5
Reviewed-on: https://review.whamcloud.com/47123
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Feng, Lei <flei@whamcloud.com>
lustre/doc/llapi_pcc_clear.3
lustre/doc/llapi_pcc_del.3
lustre/utils/liblustreapi_pcc.c

index e8ca12e..c30e10b 100644 (file)
@@ -5,7 +5,8 @@ llapi_pcc_clear \- Remove all PCC backends from a client
 .nf
 .B #include <lustre/lustreapi.h>
 .PP
-.BI "int llapi_pcc_clear(const char *" mntpath ", bool " keep_data );
+.BI "int llapi_pcc_clear(const char *" mntpath ,
+.BI "                    enum lu_pcc_cleanup_flags " flags );
 .fi
 .SH DESCRIPTION
 .PP
@@ -16,7 +17,7 @@ deletes all PCC backends on the client with the mount point referenced by
 Reference
 .BR llapi_pcc_del()
 for the usage of the input parameter
-.IR keep_data .
+.IR flags .
 .SH RETURN VALUES
 .PP
 .B llapi_pcc_clear()
index 23cb577..f6a54b2 100644 (file)
@@ -5,8 +5,8 @@ llapi_pcc_del \- Delete a PCC backend from a client
 .nf
 .B #include <lustre/lustreapi.h>
 .PP
-.BI "int llapi_pcc_del(const char *" mntpath ", const char *" pccpath ",
-.BI "                  __u32 " flags );
+.BI "int llapi_pcc_del(const char *" mntpath ", const char *" pccpath ,
+.BI "                  enum lu_pcc_cleanup_flags " flags );
 .fi
 .SH DESCRIPTION
 .PP
@@ -19,10 +19,12 @@ on the client with the mount point of
 By default, when remove a PCC backend from a client, the action is to scan the
 PCC backend fs, uncache (detach and remove) all scanned PCC copies from PCC by
 FIDs. The input parameter
-.IR keep_data
-means that it just removes the PCC backend from the Lustre client, and retains
+.IR flags
+currently only has one value
+.B PCC_CLEANUP_FL_KEEP_DATA
+that means it removes the PCC backend from the Lustre client, but retains
 the data on the cache. In this case, the PCC-RW backend falls back as a
-tranditional HSM storage solution as long as the copytool is still running at
+traditional HSM storage solution as long as the copytool is still running at
 this client.
 .SH RETURN VALUES
 .PP
index bf3c62a..734f3a0 100644 (file)
@@ -645,7 +645,8 @@ static int llapi_pcc_scan_detach(const char *pname, const char *fname,
 }
 
 static int llapi_pcc_del_internal(const char *mntpath, const char *pccpath,
-                                 enum hsmtool_type type, __u32 flags)
+                                 enum hsmtool_type type,
+                                 enum lu_pcc_cleanup_flags flags)
 {
        struct hsm_scan_control hsc = {
                .hsc_type = type,
@@ -694,14 +695,14 @@ enum pcc_cmd_t {
 };
 
 struct pcc_cmd_handler {
-       enum pcc_cmd_t   pch_cmd;
-       enum lu_pcc_type pch_type;
-       bool             pch_iter_cont;
-       bool             pch_flags;
-       const char      *pch_mntpath;
-       const char      *pch_pccpath;
-       pcc_handler_t    pch_cb;
-       __u32            pch_id;
+       enum pcc_cmd_t                   pch_cmd;
+       enum lu_pcc_type                 pch_type;
+       bool                             pch_iter_cont;
+       enum lu_pcc_cleanup_flags        pch_flags;
+       const char                      *pch_mntpath;
+       const char                      *pch_pccpath;
+       pcc_handler_t                    pch_cb;
+       __u32                            pch_id;
 };
 
 static int llapi_pcc_yaml_cb_helper(struct pcc_cmd_handler *pch)
@@ -790,7 +791,8 @@ static int llapi_handle_yaml_pcc_del(struct cYAML *node,
                                      type, pch->pch_flags);
 }
 
-int llapi_pcc_del(const char *mntpath, const char *pccpath, __u32 flags)
+int llapi_pcc_del(const char *mntpath, const char *pccpath,
+                 enum lu_pcc_cleanup_flags flags)
 {
        struct pcc_cmd_handler pch;
 
@@ -824,7 +826,7 @@ static int llapi_handle_yaml_pcc_clear(struct cYAML *node,
                                      type, pch->pch_flags);
 }
 
-int llapi_pcc_clear(const char *mntpath, __u32 flags)
+int llapi_pcc_clear(const char *mntpath, enum lu_pcc_cleanup_flags flags)
 {
        struct pcc_cmd_handler pch;