Whamcloud - gitweb
LU-15910 llite: enforce ROOT default on subdir mount
[fs/lustre-release.git] / lustre / llite / dir.c
index f3f9eaa..f6e4779 100644 (file)
@@ -687,10 +687,9 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
        RETURN(rc);
 }
 
-static int ll_dir_get_default_layout(struct inode *inode, void **plmm,
-                                    int *plmm_size,
-                                    struct ptlrpc_request **request, u64 valid,
-                                    enum get_default_layout_type type)
+int ll_dir_get_default_layout(struct inode *inode, void **plmm, int *plmm_size,
+                             struct ptlrpc_request **request, u64 valid,
+                             enum get_default_layout_type type)
 {
        struct ll_sb_info *sbi = ll_i2sbi(inode);
        struct mdt_body   *body;
@@ -1651,33 +1650,51 @@ out:
 
                                lum = (struct lmv_user_md *)lmm;
                                lli = ll_i2info(inode);
-                               if (lum->lum_max_inherit == LMV_INHERIT_NONE ||
-                                   (lum->lum_max_inherit > 0 &&
-                                    lum->lum_max_inherit < lli->lli_dir_depth))
-                                       GOTO(finish_req, rc = -ENODATA);
-
-                               if (lum->lum_max_inherit ==
-                                   lli->lli_dir_depth) {
-                                       lum->lum_max_inherit = LMV_INHERIT_NONE;
-                                       lum->lum_max_inherit_rr =
-                                               LMV_INHERIT_RR_NONE;
-                                       goto out_copy;
-                               }
-                               if (lum->lum_max_inherit > lli->lli_dir_depth &&
-                                   lum->lum_max_inherit <= LMV_INHERIT_MAX)
+                               if (lum->lum_max_inherit !=
+                                   LMV_INHERIT_UNLIMITED) {
+                                       if (lum->lum_max_inherit ==
+                                               LMV_INHERIT_NONE ||
+                                           lum->lum_max_inherit <
+                                               LMV_INHERIT_END ||
+                                           lum->lum_max_inherit >
+                                               LMV_INHERIT_MAX ||
+                                           lum->lum_max_inherit <
+                                               lli->lli_dir_depth)
+                                               GOTO(finish_req, rc = -ENODATA);
+
+                                       if (lum->lum_max_inherit ==
+                                           lli->lli_dir_depth) {
+                                               lum->lum_max_inherit =
+                                                       LMV_INHERIT_NONE;
+                                               lum->lum_max_inherit_rr =
+                                                       LMV_INHERIT_RR_NONE;
+                                               goto out_copy;
+                                       }
+
                                        lum->lum_max_inherit -=
                                                lli->lli_dir_depth;
+                               }
 
-                               if (lum->lum_max_inherit_rr >
-                                       lli->lli_dir_depth &&
-                                   lum->lum_max_inherit_rr <=
-                                       LMV_INHERIT_RR_MAX)
-                                       lum->lum_max_inherit_rr -=
-                                               lli->lli_dir_depth;
-                               else if (lum->lum_max_inherit_rr ==
+                               if (lum->lum_max_inherit_rr !=
+                                       LMV_INHERIT_RR_UNLIMITED) {
+                                       if (lum->lum_max_inherit_rr ==
+                                               LMV_INHERIT_NONE ||
+                                           lum->lum_max_inherit_rr <
+                                               LMV_INHERIT_RR_END ||
+                                           lum->lum_max_inherit_rr >
+                                               LMV_INHERIT_RR_MAX ||
+                                           lum->lum_max_inherit_rr <=
+                                               lli->lli_dir_depth) {
+                                               lum->lum_max_inherit_rr =
+                                                       LMV_INHERIT_RR_NONE;
+                                               goto out_copy;
+                                       }
+
+                                       if (lum->lum_max_inherit_rr >
                                                lli->lli_dir_depth)
-                                       lum->lum_max_inherit_rr =
-                                               LMV_INHERIT_RR_NONE;
+                                               lum->lum_max_inherit_rr -=
+                                                       lli->lli_dir_depth;
+                               }
                        }
 out_copy:
                        if (copy_to_user(ulmv, lmm, lmmsize))