Merge tag 'f2fs-for-6.5-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk...
[linux-2.6-microblaze.git] / fs / f2fs / namei.c
index ad597b4..bee0568 100644 (file)
@@ -23,7 +23,7 @@
 #include <trace/events/f2fs.h>
 
 static inline bool is_extension_exist(const unsigned char *s, const char *sub,
-                                               bool tmp_ext)
+                                               bool tmp_ext, bool tmp_dot)
 {
        size_t slen = strlen(s);
        size_t sublen = strlen(sub);
@@ -49,13 +49,27 @@ static inline bool is_extension_exist(const unsigned char *s, const char *sub,
        for (i = 1; i < slen - sublen; i++) {
                if (s[i] != '.')
                        continue;
-               if (!strncasecmp(s + i + 1, sub, sublen))
-                       return true;
+               if (!strncasecmp(s + i + 1, sub, sublen)) {
+                       if (!tmp_dot)
+                               return true;
+                       if (i == slen - sublen - 1 || s[i + 1 + sublen] == '.')
+                               return true;
+               }
        }
 
        return false;
 }
 
+static inline bool is_temperature_extension(const unsigned char *s, const char *sub)
+{
+       return is_extension_exist(s, sub, true, false);
+}
+
+static inline bool is_compress_extension(const unsigned char *s, const char *sub)
+{
+       return is_extension_exist(s, sub, true, true);
+}
+
 int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
                                                        bool hot, bool set)
 {
@@ -148,7 +162,7 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir,
        cold_count = le32_to_cpu(sbi->raw_super->extension_count);
        hot_count = sbi->raw_super->hot_ext_count;
        for (i = cold_count; i < cold_count + hot_count; i++)
-               if (is_extension_exist(name, extlist[i], false))
+               if (is_temperature_extension(name, extlist[i]))
                        break;
        f2fs_up_read(&sbi->sb_lock);
        if (i < (cold_count + hot_count))
@@ -156,12 +170,12 @@ static void set_compress_new_inode(struct f2fs_sb_info *sbi, struct inode *dir,
 
        /* Don't compress unallowed extension. */
        for (i = 0; i < noext_cnt; i++)
-               if (is_extension_exist(name, noext[i], false))
+               if (is_compress_extension(name, noext[i]))
                        return;
 
        /* Compress wanting extension. */
        for (i = 0; i < ext_cnt; i++) {
-               if (is_extension_exist(name, ext[i], false)) {
+               if (is_compress_extension(name, ext[i])) {
                        set_compress_context(inode);
                        return;
                }
@@ -189,7 +203,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode,
        cold_count = le32_to_cpu(sbi->raw_super->extension_count);
        hot_count = sbi->raw_super->hot_ext_count;
        for (i = 0; i < cold_count + hot_count; i++)
-               if (is_extension_exist(name, extlist[i], true))
+               if (is_temperature_extension(name, extlist[i]))
                        break;
        f2fs_up_read(&sbi->sb_lock);
 
@@ -576,8 +590,8 @@ out_splice:
        }
 #endif
        new = d_splice_alias(inode, dentry);
-       err = PTR_ERR_OR_ZERO(new);
-       trace_f2fs_lookup_end(dir, dentry, ino, !new ? -ENOENT : err);
+       trace_f2fs_lookup_end(dir, !IS_ERR_OR_NULL(new) ? new : dentry,
+                               ino, IS_ERR(new) ? PTR_ERR(new) : err);
        return new;
 out_iput:
        iput(inode);