Whamcloud - gitweb
LU-15850 llite: pass dmv inherit depth instead of dir depth
[fs/lustre-release.git] / lustre / llite / namei.c
index 3b0267e..fc6b20d 100644 (file)
@@ -383,8 +383,9 @@ static void ll_lock_cancel_bits(struct ldlm_lock *lock, __u64 to_cancel)
                }
        }
 
+       /* at umount s_root becomes NULL */
        if ((bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM)) &&
-           !is_root_inode(inode))
+           inode->i_sb->s_root && !is_root_inode(inode))
                ll_prune_aliases(inode);
 
        if (bits & (MDS_INODELOCK_LOOKUP | MDS_INODELOCK_PERM))
@@ -423,13 +424,13 @@ int ll_md_need_convert(struct ldlm_lock *lock)
        switch (lock->l_req_mode) {
        case LCK_PR:
                mode = LCK_PR;
-               /* fallthrough */
+               fallthrough;
        case LCK_PW:
                mode |= LCK_CR;
                break;
        case LCK_CW:
                mode = LCK_CW;
-               /* fallthrough */
+               fallthrough;
        case LCK_CR:
                mode |= LCK_CR;
                break;
@@ -688,7 +689,7 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
                                       "server returned encryption ctx for "DFID"\n",
                                       PFID(ll_inode2fid(inode)));
                                rc = ll_xattr_cache_insert(inode,
-                                              LL_XATTR_NAME_ENCRYPTION_CONTEXT,
+                                                          xattr_for_enc(inode),
                                                           encctx, encctxlen);
                                if (rc)
                                        CWARN("%s: cannot set enc ctx for "DFID": rc = %d\n",
@@ -783,14 +784,17 @@ static int ll_lookup_it_finish(struct ptlrpc_request *request,
                struct lookup_intent parent_it = {
                                        .it_op = IT_GETATTR,
                                        .it_lock_handle = 0 };
-               struct lu_fid   fid = ll_i2info(parent)->lli_fid;
+               struct ll_inode_info *lli = ll_i2info(parent);
+               struct lu_fid fid = lli->lli_fid;
 
                /* If it is striped directory, get the real stripe parent */
                if (unlikely(ll_dir_striped(parent))) {
+                       down_read(&lli->lli_lsm_sem);
                        rc = md_get_fid_from_lsm(ll_i2mdexp(parent),
-                                                ll_i2info(parent)->lli_lsm_md,
+                                                lli->lli_lsm_md,
                                                 (*de)->d_name.name,
                                                 (*de)->d_name.len, &fid);
+                       up_read(&lli->lli_lsm_sem);
                        if (rc != 0)
                                GOTO(out, rc);
                }
@@ -875,7 +879,7 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
        rc = ll_setup_filename(parent, &dentry->d_name, 1, &fname, &fid);
        if ((!rc || rc == -ENOENT) && fname.is_ciphertext_name) {
                spin_lock(&dentry->d_lock);
-               dentry->d_flags |= DCACHE_ENCRYPTED_NAME;
+               dentry->d_flags |= DCACHE_NOKEY_NAME;
                spin_unlock(&dentry->d_lock);
        }
        if (rc == -ENOENT)
@@ -1511,7 +1515,7 @@ static void ll_qos_mkdir_prep(struct md_op_data *op_data, struct inode *dir)
        struct ll_inode_info *lli = ll_i2info(dir);
        struct lmv_stripe_md *lsm;
 
-       op_data->op_dir_depth = lli->lli_dir_depth;
+       op_data->op_dir_depth = lli->lli_inherit_depth ?: lli->lli_dir_depth;
 
        /* parent directory is striped */
        if (unlikely(lli->lli_lsm_md))
@@ -1594,7 +1598,8 @@ again:
        if (ll_sbi_has_encrypt(sbi) &&
            ((IS_ENCRYPTED(dir) &&
            (S_ISREG(mode) || S_ISDIR(mode) || S_ISLNK(mode))) ||
-           (unlikely(llcrypt_dummy_context_enabled(dir)) && S_ISDIR(mode)))) {
+            (unlikely(ll_sb_has_test_dummy_encryption(dir->i_sb)) &&
+             S_ISDIR(mode)))) {
                err = llcrypt_get_encryption_info(dir);
                if (err)
                        GOTO(err_exit, err);
@@ -1646,7 +1651,7 @@ again:
                        from_kuid(&init_user_ns, current_fsuid()),
                        from_kgid(&init_user_ns, current_fsgid()),
                        current_cap(), rdev, &request);
-#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 14, 58, 0)
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 15, 58, 0)
        /*
         * server < 2.12.58 doesn't pack default LMV in intent_getattr reply,
         * fetch default LMV here.
@@ -1659,11 +1664,11 @@ again:
 
                ptlrpc_req_finished(request);
                request = NULL;
+               ll_finish_md_op_data(op_data);
+               op_data = NULL;
 
                err2 = ll_dir_getstripe(dir, (void **)&lum, &lumsize, &request,
                                        OBD_MD_DEFAULT_MEA);
-               ll_finish_md_op_data(op_data);
-               op_data = NULL;
                if (err2 == 0) {
                        struct lustre_md md = { NULL };
 
@@ -1795,7 +1800,7 @@ static int ll_mknod(struct user_namespace *mnt_userns, struct inode *dir,
        switch (mode & S_IFMT) {
        case 0:
                mode |= S_IFREG;
-               /* fallthrough */
+               fallthrough;
        case S_IFREG:
        case S_IFCHR:
        case S_IFBLK:
@@ -2147,6 +2152,15 @@ static int ll_rename(struct user_namespace *mnt_userns,
        if (IS_ERR(op_data))
                RETURN(PTR_ERR(op_data));
 
+       /* If the client is using a subdir mount and does a rename to what it
+        * sees as /.fscrypt, interpret it as the .fscrypt dir at fs root.
+        */
+       if (unlikely(is_root_inode(tgt) && !fid_is_root(ll_inode2fid(tgt)) &&
+                    tgt_dchild->d_name.len == strlen(dot_fscrypt_name) &&
+                    strncmp(tgt_dchild->d_name.name, dot_fscrypt_name,
+                            tgt_dchild->d_name.len) == 0))
+               lu_root_fid(&op_data->op_fid2);
+
        if (src_dchild->d_inode)
                op_data->op_fid3 = *ll_inode2fid(src_dchild->d_inode);