Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
[linux-2.6-microblaze.git] / fs / ext4 / namei.c
index 3350926..b17a082 100644 (file)
@@ -182,10 +182,6 @@ static struct buffer_head *__ext4_read_dirblock(struct inode *inode,
        return bh;
 }
 
-#ifndef assert
-#define assert(test) J_ASSERT(test)
-#endif
-
 #ifdef DX_DEBUG
 #define dxtrace(command) command
 #else
@@ -643,13 +639,7 @@ static struct stats dx_show_leaf(struct inode *dir,
 
                                name  = de->name;
                                len = de->name_len;
-                               if (IS_ENCRYPTED(dir))
-                                       res = fscrypt_get_encryption_info(dir);
-                               if (res) {
-                                       printk(KERN_WARNING "Error setting up"
-                                              " fname crypto: %d\n", res);
-                               }
-                               if (!fscrypt_has_encryption_key(dir)) {
+                               if (!IS_ENCRYPTED(dir)) {
                                        /* Directory is not encrypted */
                                        ext4fs_dirhash(dir, de->name,
                                                de->name_len, &h);
@@ -849,7 +839,7 @@ dx_probe(struct ext4_filename *fname, struct inode *dir,
                                        break;
                                }
                        }
-                       assert (at == p - 1);
+                       ASSERT(at == p - 1);
                }
 
                at = p - 1;
@@ -1010,7 +1000,7 @@ static int htree_dirblock_to_tree(struct file *dir_file,
                                           EXT4_DIR_REC_LEN(0));
        /* Check if the directory is encrypted */
        if (IS_ENCRYPTED(dir)) {
-               err = fscrypt_get_encryption_info(dir);
+               err = fscrypt_prepare_readdir(dir);
                if (err < 0) {
                        brelse(bh);
                        return err;
@@ -1265,8 +1255,8 @@ static void dx_insert_block(struct dx_frame *frame, u32 hash, ext4_lblk_t block)
        struct dx_entry *old = frame->at, *new = old + 1;
        int count = dx_get_count(entries);
 
-       assert(count < dx_get_limit(entries));
-       assert(old < entries + count);
+       ASSERT(count < dx_get_limit(entries));
+       ASSERT(old < entries + count);
        memmove(new + 1, new, (char *)(entries + count) - (char *)(new));
        dx_set_hash(new, hash);
        dx_set_block(new, block);
@@ -1614,6 +1604,7 @@ static struct buffer_head *ext4_lookup_entry(struct inode *dir,
        struct buffer_head *bh;
 
        err = ext4_fname_prepare_lookup(dir, dentry, &fname);
+       generic_set_encrypted_ci_d_ops(dentry);
        if (err == -ENOENT)
                return NULL;
        if (err)
@@ -2195,6 +2186,9 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry,
        if (!dentry->d_name.len)
                return -EINVAL;
 
+       if (fscrypt_is_nokey_name(dentry))
+               return -ENOKEY;
+
 #ifdef CONFIG_UNICODE
        if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) &&
            sb->s_encoding && utf8_validate(sb->s_encoding, &dentry->d_name))
@@ -2961,7 +2955,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
         * hold i_mutex, or the inode can not be referenced from outside,
         * so i_nlink should not be bumped due to race
         */
-       J_ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
+       ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
                  S_ISLNK(inode->i_mode)) || inode->i_nlink == 0);
 
        BUFFER_TRACE(sbi->s_sbh, "get_write_access");