[lustre-devel] [PATCH 05/13] lustre: dne: dir migration in non-recursive mode
James Simmons
jsimmons at infradead.org
Wed Dec 29 06:51:19 PST 2021
From: Lai Siyao <lai.siyao at whamcloud.com>
Add an option "-d|--directory" option for LL_IOC_MIGRATE to
migrate specified directory only, which is similar to "ls -d".
WC-bug-id: https://jira.whamcloud.com/browse/LU-14975
Lustre-commit: 5604a6d270b8be13a ("LU-14975 dne: dir migration in non-recursive mode")
Signed-off-by: Lai Siyao <lai.siyao at whamcloud.com>
Reviewed-on: https://review.whamcloud.com/44802
Reviewed-by: Andreas Dilger <adilger at whamcloud.com>
Reviewed-by: Yingjin Qian <qian at ddn.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
fs/lustre/llite/dir.c | 5 ++++-
fs/lustre/llite/file.c | 7 ++++++-
fs/lustre/llite/llite_internal.h | 2 +-
fs/lustre/lmv/lmv_obd.c | 5 +++++
fs/lustre/ptlrpc/wiretest.c | 6 ++++++
include/uapi/linux/lustre/lustre_idl.h | 2 ++
6 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/fs/lustre/llite/dir.c b/fs/lustre/llite/dir.c
index 23d3fba..40e83e7 100644
--- a/fs/lustre/llite/dir.c
+++ b/fs/lustre/llite/dir.c
@@ -2102,6 +2102,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
struct lmv_user_md *lum;
char *filename;
int namelen = 0;
+ u32 flags;
int len;
int rc;
@@ -2117,6 +2118,8 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
filename = data->ioc_inlbuf1;
namelen = data->ioc_inllen1;
+ flags = data->ioc_type;
+
if (namelen < 1 || namelen != strlen(filename) + 1) {
CDEBUG(D_INFO, "IOC_MDC_LOOKUP missing filename\n");
rc = -EINVAL;
@@ -2132,7 +2135,7 @@ static long ll_dir_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
goto migrate_free;
}
- rc = ll_migrate(inode, file, lum, filename);
+ rc = ll_migrate(inode, file, lum, filename, flags);
migrate_free:
kvfree(data);
diff --git a/fs/lustre/llite/file.c b/fs/lustre/llite/file.c
index 20571c9..0dd1bae 100644
--- a/fs/lustre/llite/file.c
+++ b/fs/lustre/llite/file.c
@@ -4682,7 +4682,7 @@ int ll_get_fid_by_name(struct inode *parent, const char *name,
}
int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum,
- const char *name)
+ const char *name, u32 flags)
{
struct ptlrpc_request *request = NULL;
struct obd_client_handle *och = NULL;
@@ -4779,6 +4779,11 @@ int ll_migrate(struct inode *parent, struct file *file, struct lmv_user_md *lum,
op_data->op_data = lum;
op_data->op_data_size = lumlen;
+ /* migrate dirent only for subdirs if MDS_MIGRATE_NSONLY set */
+ if (S_ISDIR(child_inode->i_mode) && (flags & MDS_MIGRATE_NSONLY) &&
+ lmv_dir_layout_changing(ll_i2info(parent)->lli_lsm_md))
+ op_data->op_bias |= MDS_MIGRATE_NSONLY;
+
again:
if (S_ISREG(child_inode->i_mode)) {
och = ll_lease_open(child_inode, NULL, FMODE_WRITE, 0);
diff --git a/fs/lustre/llite/llite_internal.h b/fs/lustre/llite/llite_internal.h
index 6e212c9..12d47e8 100644
--- a/fs/lustre/llite/llite_internal.h
+++ b/fs/lustre/llite/llite_internal.h
@@ -1130,7 +1130,7 @@ static inline int ll_inode_flags_to_xflags(int inode_flags)
}
int ll_migrate(struct inode *parent, struct file *file,
- struct lmv_user_md *lum, const char *name);
+ struct lmv_user_md *lum, const char *name, u32 flags);
int ll_get_fid_by_name(struct inode *parent, const char *name,
int namelen, struct lu_fid *fid, struct inode **inode);
int ll_inode_permission(struct inode *inode, int mask);
diff --git a/fs/lustre/lmv/lmv_obd.c b/fs/lustre/lmv/lmv_obd.c
index b31f943..c87f37f 100644
--- a/fs/lustre/lmv/lmv_obd.c
+++ b/fs/lustre/lmv/lmv_obd.c
@@ -2227,6 +2227,11 @@ static int lmv_migrate(struct obd_export *exp, struct md_op_data *op_data,
tp_tgt = lmv_tgt(lmv, oinfo->lmo_mds);
if (!tp_tgt)
return -ENODEV;
+
+ /* parent unchanged and update namespace only */
+ if (lu_fid_eq(&op_data->op_fid4, &op_data->op_fid2) &&
+ op_data->op_bias & MDS_MIGRATE_NSONLY)
+ return -EALREADY;
}
} else {
sp_tgt = parent_tgt;
diff --git a/fs/lustre/ptlrpc/wiretest.c b/fs/lustre/ptlrpc/wiretest.c
index a381af4..687a54d 100644
--- a/fs/lustre/ptlrpc/wiretest.c
+++ b/fs/lustre/ptlrpc/wiretest.c
@@ -2119,6 +2119,12 @@ void lustre_assert_wire_constants(void)
(unsigned int)MDS_PCC_ATTACH);
LASSERTF(MDS_CLOSE_UPDATE_TIMES == 0x00100000UL, "found 0x%.8xUL\n",
(unsigned int)MDS_CLOSE_UPDATE_TIMES);
+ LASSERTF(MDS_SETSTRIPE_CREATE == 0x00200000UL, "found 0x%.8xUL\n",
+ (unsigned int)MDS_SETSTRIPE_CREATE);
+ LASSERTF(MDS_FID_OP == 0x00400000UL, "found 0x%.8xUL\n",
+ (unsigned int)MDS_FID_OP);
+ LASSERTF(MDS_MIGRATE_NSONLY == 0x00800000UL, "found 0x%.8xUL\n",
+ (unsigned int)MDS_MIGRATE_NSONLY);
/* Checks for struct mdt_body */
LASSERTF((int)sizeof(struct mdt_body) == 216, "found %lld\n",
diff --git a/include/uapi/linux/lustre/lustre_idl.h b/include/uapi/linux/lustre/lustre_idl.h
index debd0c1..35d3ed2 100644
--- a/include/uapi/linux/lustre/lustre_idl.h
+++ b/include/uapi/linux/lustre/lustre_idl.h
@@ -1710,6 +1710,8 @@ enum mds_op_bias {
/* setstripe create only, don't restripe if target exists */
MDS_SETSTRIPE_CREATE = 1 << 21,
MDS_FID_OP = 1 << 22,
+ /* migrate dirent only */
+ MDS_MIGRATE_NSONLY = 1 << 23,
};
#define MDS_CLOSE_INTENT (MDS_HSM_RELEASE | MDS_CLOSE_LAYOUT_SWAP | \
--
1.8.3.1
More information about the lustre-devel
mailing list