From: James Simmons <jsimmons@infradead.org>
To: Andreas Dilger <adilger@whamcloud.com>,
Oleg Drokin <green@whamcloud.com>, NeilBrown <neilb@suse.de>
Cc: Lai Siyao <lai.siyao@whamcloud.com>,
Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [lustre-devel] [PATCH 09/32] lustre: llite: enforce ROOT default on subdir mount
Date: Wed, 3 Aug 2022 21:37:54 -0400 [thread overview]
Message-ID: <1659577097-19253-10-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1659577097-19253-1-git-send-email-jsimmons@infradead.org>
From: Lai Siyao <lai.siyao@whamcloud.com>
In subdirectory mount, the filesystem-wide default LMV doesn't take
effect. This fix includes the following changes:
* enforce the filesystem-wide default LMV on subdirectory mount if
it's not set separately.
* "lfs getdirstripe -D <subdir_mount>" should print the
filesystem-wide default LMV.
WC-bug-id: https://jira.whamcloud.com/browse/LU-15910
Lustre-commit: a162e24d2da5e4bd6 ("LU-15910 llite: enforce ROOT default on subdir mount")
Signed-off-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/47518
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jian Yu <yujian@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
fs/lustre/llite/dir.c | 75 ++++++++++++++++++++++++----------------
fs/lustre/llite/llite_internal.h | 3 ++
fs/lustre/llite/llite_lib.c | 46 ++++++++++++++++++++++--
3 files changed, 93 insertions(+), 31 deletions(-)
diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c
index 6eaac9a..2b63c48 100644
--- a/fs/lustre/llite/dir.c
+++ b/fs/lustre/llite/dir.c
@@ -655,10 +655,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;
@@ -1627,35 +1626,53 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
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 !=
+ 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) {
+ 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_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;
+ 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 -=
+ lli->lli_dir_depth;
+ }
}
out_copy:
if (copy_to_user(ulmv, lmm, lmmsize))
diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h
index 70a42d4..c350440 100644
--- a/fs/lustre/llite/llite_internal.h
+++ b/fs/lustre/llite/llite_internal.h
@@ -1155,6 +1155,9 @@ int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
struct ptlrpc_request **request);
int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
int set_default);
+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_getstripe_default(struct inode *inode, void **lmmp,
int *lmm_size, struct ptlrpc_request **request,
struct ptlrpc_request **root_request, u64 valid);
diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c
index b55a30f..5b80722 100644
--- a/fs/lustre/llite/llite_lib.c
+++ b/fs/lustre/llite/llite_lib.c
@@ -2972,6 +2972,39 @@ void ll_open_cleanup(struct super_block *sb, struct req_capsule *pill)
ll_finish_md_op_data(op_data);
}
+/* set filesystem-wide default LMV for subdir mount if it's enabled on ROOT. */
+static int ll_fileset_default_lmv_fixup(struct inode *inode,
+ struct lustre_md *md)
+{
+ struct ll_sb_info *sbi = ll_i2sbi(inode);
+ struct ptlrpc_request *req = NULL;
+ union lmv_mds_md *lmm = NULL;
+ int size = 0;
+ int rc;
+
+ LASSERT(is_root_inode(inode));
+ LASSERT(!fid_is_root(&sbi->ll_root_fid));
+ LASSERT(!md->default_lmv);
+
+ rc = ll_dir_get_default_layout(inode, (void **)&lmm, &size, &req,
+ OBD_MD_DEFAULT_MEA,
+ GET_DEFAULT_LAYOUT_ROOT);
+ if (rc && rc != -ENODATA)
+ goto out;
+
+ rc = 0;
+ if (lmm && size) {
+ rc = md_unpackmd(sbi->ll_md_exp, &md->default_lmv, lmm, size);
+ if (rc < 0)
+ goto out;
+ rc = 0;
+ }
+out:
+ if (req)
+ ptlrpc_req_finished(req);
+ return rc;
+}
+
int ll_prep_inode(struct inode **inode, struct req_capsule *pill,
struct super_block *sb, struct lookup_intent *it)
{
@@ -2993,8 +3026,17 @@ int ll_prep_inode(struct inode **inode, struct req_capsule *pill,
* ll_update_lsm_md() may change md.
*/
if (it && (it->it_op & (IT_LOOKUP | IT_GETATTR)) &&
- S_ISDIR(md.body->mbo_mode) && !md.default_lmv)
- default_lmv_deleted = true;
+ S_ISDIR(md.body->mbo_mode) && !md.default_lmv) {
+ if (unlikely(*inode && is_root_inode(*inode) &&
+ !fid_is_root(&sbi->ll_root_fid))) {
+ rc = ll_fileset_default_lmv_fixup(*inode, &md);
+ if (rc)
+ goto out;
+ }
+
+ if (!md.default_lmv)
+ default_lmv_deleted = true;
+ }
if (*inode) {
rc = ll_update_inode(*inode, &md);
--
1.8.3.1
_______________________________________________
lustre-devel mailing list
lustre-devel@lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
next prev parent reply other threads:[~2022-08-04 1:38 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-04 1:37 [lustre-devel] [PATCH 00/32] lustre: Update to OpenSFS as of Aug 3 2022 James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 01/32] lustre: mdc: Remove entry from list before freeing James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 02/32] lustre: flr: Don't assume RDONLY implies SOM James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 03/32] lustre: echo: remove client operations from echo objects James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 04/32] lustre: clio: remove cl_page_export() and cl_page_is_vmlocked() James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 05/32] lustre: clio: remove cpo_own and cpo_disown James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 06/32] lustre: clio: remove cpo_assume, cpo_unassume, cpo_fini James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 07/32] lustre: enc: enc-unaware clients get ENOKEY if file not found James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 08/32] lnet: socklnd: Duplicate ksock_conn_cb James Simmons
2022-08-04 1:37 ` James Simmons [this message]
2022-08-04 1:37 ` [lustre-devel] [PATCH 10/32] lnet: Replace msg_rdma_force with a new md_flag LNET_MD_FLAG_GPU James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 11/32] lustre: som: disabling xattr cache for LSOM on client James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 12/32] lnet: discard some peer_ni lookup functions James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 13/32] lnet: change lnet_*_peer_ni to take struct lnet_nid James Simmons
2022-08-04 1:37 ` [lustre-devel] [PATCH 14/32] lnet: Ensure round robin across nets James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 15/32] lustre: llite: dont restart directIO with IOCB_NOWAIT James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 16/32] lustre: sec: handle read-only flag James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 17/32] lustre: llog: Add LLOG_SKIP_PLAIN to skip llog plain James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 18/32] lustre: llite: add projid to debug logs James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 19/32] lnet: asym route inconsistency warning James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 20/32] lnet: libcfs: debugfs file_operation should have an owner James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 21/32] lustre: client: able to cleanup devices manually James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 22/32] lustre: lmv: support striped LMVs James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 23/32] lnet: o2iblnd: add debug messages for IB James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 24/32] lnet: o2iblnd: debug message is missing a newline James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 25/32] lustre: quota: skip non-exist or inact tgt for lfs_quota James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 26/32] lustre: mdc: pack default LMV in open reply James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 27/32] lnet: Define KFILND network type James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 28/32] lnet: Adjust niov checks for large MD James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 29/32] lustre: ec: code to add support for M to N parity James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 30/32] lustre: llite: use max default EA size to get default LMV James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 31/32] lustre: llite: pass dmv inherit depth instead of dir depth James Simmons
2022-08-04 1:38 ` [lustre-devel] [PATCH 32/32] lustre: ldlm: Prioritize blocking callbacks James Simmons
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1659577097-19253-10-git-send-email-jsimmons@infradead.org \
--to=jsimmons@infradead.org \
--cc=adilger@whamcloud.com \
--cc=green@whamcloud.com \
--cc=lai.siyao@whamcloud.com \
--cc=lustre-devel@lists.lustre.org \
--cc=neilb@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).