[lustre-devel] [PATCH 32/50] lustre: llite: LL_IOC_LMV_GETSTRIPE 'default' shows inherit layout

James Simmons jsimmons at infradead.org
Sun Mar 20 06:30:46 PDT 2022


From: Lai Siyao <lai.siyao at whamcloud.com>

Once system-wide default LMV is set, "lfs getdirstripe -D subdir"
should show inherited layout from it.

WC-bug-id: https://jira.whamcloud.com/browse/LU-15200
Lustre-commit: 61b1fad9e3fb21edc ("LU-15200 llite: "lfs getdirstripe -D" shows inherit layout")
Signed-off-by: Lai Siyao <lai.siyao at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/45570
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Jian Yu <yujian at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
 fs/lustre/llite/dir.c | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c
index b4870d9..d3df4d0 100644
--- a/fs/lustre/llite/dir.c
+++ b/fs/lustre/llite/dir.c
@@ -759,7 +759,7 @@ int ll_dir_getstripe_default(struct inode *inode, void **plmm, int *plmm_size,
 	rc = ll_dir_get_default_layout(inode, (void **)&lmm, &lmm_size,
 				       &req, valid, 0);
 	if (rc == -ENODATA && !fid_is_root(ll_inode2fid(inode)) &&
-	    !(valid & (OBD_MD_MEA|OBD_MD_DEFAULT_MEA)) && root_request) {
+	    !(valid & OBD_MD_MEA) && root_request) {
 		int rc2 = ll_dir_get_default_layout(inode, (void **)&lmm,
 						    &lmm_size, &root_req, valid,
 						    GET_DEFAULT_LAYOUT_ROOT);
@@ -1602,6 +1602,43 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 				goto finish_req;
 			}
 
+			if (root_request) {
+				struct lmv_user_md *lum;
+				struct ll_inode_info *lli;
+
+				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)) {
+					rc = -ENODATA;
+					goto finish_req;
+				}
+
+				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)
+					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 ==
+						lli->lli_dir_depth)
+					lum->lum_max_inherit_rr =
+						LMV_INHERIT_RR_NONE;
+			}
+out_copy:
 			if (copy_to_user(ulmv, lmm, lmmsize))
 				rc = -EFAULT;
 
-- 
1.8.3.1



More information about the lustre-devel mailing list