@@ -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);
@@ -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);
@@ -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);
@@ -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;
@@ -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",
@@ -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 | \