Whamcloud - gitweb
LU-15850 llite: pass dmv inherit depth instead of dir depth
[fs/lustre-release.git] / lustre / llite / llite_lib.c
index d6da421..94dc136 100644 (file)
@@ -183,6 +183,7 @@ static struct ll_sb_info *ll_init_sbi(void)
        set_bit(LL_SBI_TINY_WRITE, sbi->ll_flags);
        set_bit(LL_SBI_PARALLEL_DIO, sbi->ll_flags);
        ll_sbi_set_encrypt(sbi, true);
+       ll_sbi_set_name_encrypt(sbi, true);
 
        /* root squash */
        sbi->ll_squash.rsi_uid = 0;
@@ -373,8 +374,10 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
                data->ocd_connect_flags &= ~OBD_CONNECT_PINGLESS;
 
        obd_connect_set_secctx(data);
-       if (ll_sbi_has_encrypt(sbi))
+       if (ll_sbi_has_encrypt(sbi)) {
+               obd_connect_set_name_enc(data);
                obd_connect_set_enc(data);
+       }
 
 #if defined(CONFIG_SECURITY)
        data->ocd_connect_flags2 |= OBD_CONNECT2_SELINUX_POLICY;
@@ -494,6 +497,17 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
                ll_sbi_set_encrypt(sbi, false);
        }
 
+       if (ll_sbi_has_name_encrypt(sbi) && !obd_connect_has_name_enc(data)) {
+               struct  lustre_sb_info *lsi = s2lsi(sb);
+
+               if (ll_sb_has_test_dummy_encryption(sb))
+                       LCONSOLE_WARN("%s: server %s does not support name encryption, not using it.\n",
+                                     sbi->ll_fsname,
+                                     sbi->ll_md_exp->exp_obd->obd_name);
+               lsi->lsi_flags &= ~LSI_FILENAME_ENC;
+               ll_sbi_set_name_encrypt(sbi, false);
+       }
+
        if (data->ocd_ibits_known & MDS_INODELOCK_XATTR) {
                if (!(data->ocd_connect_flags & OBD_CONNECT_MAX_EASIZE)) {
                        LCONSOLE_INFO("%s: disabling xattr cache due to "
@@ -955,6 +969,7 @@ static const match_table_t ll_sbi_flags_name = {
        {LL_SBI_TINY_WRITE,             "tiny_write"},
        {LL_SBI_FILE_HEAT,              "file_heat"},
        {LL_SBI_PARALLEL_DIO,           "parallel_dio"},
+       {LL_SBI_ENCRYPT_NAME,           "name_encrypt"},
 };
 
 int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
@@ -1288,6 +1303,13 @@ int ll_fill_super(struct super_block *sb)
        if (err)
                GOTO(out_free_cfg, err);
 
+       if (ll_sb_has_test_dummy_encryption(sb))
+               /* enable filename encryption by default for dummy enc mode */
+               lsi->lsi_flags |= LSI_FILENAME_ENC;
+       else
+               /* filename encryption is disabled by default */
+               lsi->lsi_flags &= ~LSI_FILENAME_ENC;
+
        /* kernel >= 2.6.38 store dentry operations in sb->s_d_op. */
        sb->s_d_op = &ll_d_ops;
 
@@ -1460,10 +1482,15 @@ void ll_put_super(struct super_block *sb)
                client_common_put_super(sb);
        }
 
+       /* imitate failed cleanup */
+       if (OBD_FAIL_CHECK(OBD_FAIL_OBD_CLEANUP))
+               goto skip_cleanup;
+
        next = 0;
        while ((obd = class_devices_in_group(&sbi->ll_sb_uuid, &next)))
                class_manual_cleanup(obd);
 
+skip_cleanup:
        if (test_bit(LL_SBI_VERBOSE, sbi->ll_flags))
                LCONSOLE_WARN("Unmounted %s\n", profilenm ? profilenm : "");
 
@@ -1652,6 +1679,7 @@ static void ll_update_default_lsm_md(struct inode *inode, struct lustre_md *md)
                                lmv_free_memmd(lli->lli_default_lsm_md);
                                lli->lli_default_lsm_md = NULL;
                        }
+                       lli->lli_inherit_depth = 0;
                        up_write(&lli->lli_lsm_sem);
                }
                RETURN_EXIT;
@@ -2043,7 +2071,7 @@ int ll_io_zero_page(struct inode *inode, pgoff_t index, pgoff_t offset,
                anchor = &vvp_env_info(env)->vti_anchor;
                cl_sync_io_init(anchor, 1);
                clpage->cp_sync_io = anchor;
-               cl_2queue_add(queue, clpage, true);
+               cl_page_list_add(&queue->c2_qin, clpage, true);
                rc = cl_io_submit_rw(env, io, CRT_WRITE, queue);
                if (rc)
                        GOTO(queuefini1, rc);
@@ -2731,9 +2759,34 @@ int ll_update_inode(struct inode *inode, struct lustre_md *md)
        return 0;
 }
 
+/* child default LMV is inherited from parent */
+static inline bool ll_default_lmv_inherited(struct lmv_stripe_md *pdmv,
+                                           struct lmv_stripe_md *cdmv)
+{
+       if (!pdmv || !cdmv)
+               return false;
+
+       if (pdmv->lsm_md_magic != cdmv->lsm_md_magic ||
+           pdmv->lsm_md_stripe_count != cdmv->lsm_md_stripe_count ||
+           pdmv->lsm_md_master_mdt_index != cdmv->lsm_md_master_mdt_index ||
+           pdmv->lsm_md_hash_type != cdmv->lsm_md_hash_type)
+               return false;
+
+       if (cdmv->lsm_md_max_inherit !=
+           lmv_inherit_next(pdmv->lsm_md_max_inherit))
+               return false;
+
+       if (cdmv->lsm_md_max_inherit_rr !=
+           lmv_inherit_rr_next(pdmv->lsm_md_max_inherit_rr))
+               return false;
+
+       return true;
+}
+
 /* update directory depth to ROOT, called after LOOKUP lock is fetched. */
 void ll_update_dir_depth(struct inode *dir, struct inode *inode)
 {
+       struct ll_inode_info *plli;
        struct ll_inode_info *lli;
 
        if (!S_ISDIR(inode->i_mode))
@@ -2742,10 +2795,26 @@ void ll_update_dir_depth(struct inode *dir, struct inode *inode)
        if (inode == dir)
                return;
 
+       plli = ll_i2info(dir);
        lli = ll_i2info(inode);
-       lli->lli_dir_depth = ll_i2info(dir)->lli_dir_depth + 1;
-       CDEBUG(D_INODE, DFID" depth %hu\n",
-              PFID(&lli->lli_fid), lli->lli_dir_depth);
+       lli->lli_dir_depth = plli->lli_dir_depth + 1;
+       if (plli->lli_default_lsm_md && lli->lli_default_lsm_md) {
+               down_read(&plli->lli_lsm_sem);
+               down_read(&lli->lli_lsm_sem);
+               if (ll_default_lmv_inherited(plli->lli_default_lsm_md,
+                                            lli->lli_default_lsm_md))
+                       lli->lli_inherit_depth =
+                               plli->lli_inherit_depth + 1;
+               else
+                       lli->lli_inherit_depth = 0;
+               up_read(&lli->lli_lsm_sem);
+               up_read(&plli->lli_lsm_sem);
+       } else {
+               lli->lli_inherit_depth = 0;
+       }
+
+       CDEBUG(D_INODE, DFID" depth %hu default LMV depth %hu\n",
+              PFID(&lli->lli_fid), lli->lli_dir_depth, lli->lli_inherit_depth);
 }
 
 void ll_truncate_inode_pages_final(struct inode *inode)