Whamcloud - gitweb
LU-10883 llog: fix backup file name comparison 86/31886/7
authorArtem Blagodarenko <artem.blagodarenko@seagate.com>
Thu, 5 Apr 2018 06:54:40 +0000 (09:54 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 4 Jan 2019 04:45:11 +0000 (04:45 +0000)
Last 3 bytes of key are wrongly compared with ".bak" extention.
4 bytes need to be compared.

Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
Change-Id: I90c1af2e41569780bf81df3975603acdc828edd6
Test-Parameters: testlist=conf-sanity
Reviewed-on: https://review.whamcloud.com/31886
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Vladimir Saveliev <c17830@cray.com>
lustre/mgs/mgs_llog.c

index ffb1e70..5fa816d 100644 (file)
@@ -71,6 +71,7 @@ int class_dentry_readdir(const struct lu_env *env, struct mgs_device *mgs,
        struct mgs_direntry *de;
        char *key;
        int rc, key_sz;
        struct mgs_direntry *de;
        char *key;
        int rc, key_sz;
+       size_t suffix_len = sizeof(".bak") - 1;
 
        INIT_LIST_HEAD(log_list);
 
 
        INIT_LIST_HEAD(log_list);
 
@@ -107,9 +108,8 @@ int class_dentry_readdir(const struct lu_env *env, struct mgs_device *mgs,
                }
 
                /* filter out ".bak" files */
                }
 
                /* filter out ".bak" files */
-               /* sizeof(".bak") - 1 == 3 */
-               if (key_sz >= 3 &&
-                   !memcmp(".bak", key + key_sz - 3, 3)) {
+               if (key_sz >= suffix_len &&
+                   !memcmp(".bak", key + key_sz - suffix_len, suffix_len)) {
                        CDEBUG(D_MGS, "Skipping backup file %.*s\n",
                               key_sz, key);
                        goto next;
                        CDEBUG(D_MGS, "Skipping backup file %.*s\n",
                               key_sz, key);
                        goto next;