kfence: fix is_kfence_address() for addresses below KFENCE_POOL_SIZE
[linux-2.6-microblaze.git] / fs / exfat / namei.c
index d9e8ec6..24b4110 100644 (file)
@@ -340,7 +340,7 @@ static int exfat_find_empty_entry(struct inode *inode,
                exfat_chain_set(&clu, last_clu + 1, 0, p_dir->flags);
 
                /* allocate a cluster */
-               ret = exfat_alloc_cluster(inode, 1, &clu);
+               ret = exfat_alloc_cluster(inode, 1, &clu, IS_DIRSYNC(inode));
                if (ret)
                        return ret;
 
@@ -596,6 +596,8 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
        struct exfat_inode_info *ei = EXFAT_I(dir);
        struct exfat_dentry *ep, *ep2;
        struct exfat_entry_set_cache *es;
+       /* for optimized dir & entry to prevent long traverse of cluster chain */
+       struct exfat_hint hint_opt;
 
        if (qname->len == 0)
                return -ENOENT;
@@ -619,7 +621,7 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
 
        /* search the file name for directories */
        dentry = exfat_find_dir_entry(sb, ei, &cdir, &uni_name,
-                       num_entries, TYPE_ALL);
+                       num_entries, TYPE_ALL, &hint_opt);
 
        if (dentry < 0)
                return dentry; /* -error value */
@@ -628,6 +630,11 @@ static int exfat_find(struct inode *dir, struct qstr *qname,
        info->entry = dentry;
        info->num_subdirs = 0;
 
+       /* adjust cdir to the optimized value */
+       cdir.dir = hint_opt.clu;
+       if (cdir.flags & ALLOC_NO_FAT_CHAIN)
+               cdir.size -= dentry / sbi->dentries_per_clu;
+       dentry = hint_opt.eidx;
        es = exfat_get_dentry_set(sb, &cdir, dentry, ES_2_ENTRIES);
        if (!es)
                return -EIO;