Skip to content
Snippets Groups Projects
Commit 71950ce9 authored by komaln's avatar komaln
Browse files

b=11694

r=Nathan, Adilger
This patch changes the default stripe policy, when changed on root of the
filesystem using 'lfs setstripe' command.
parent 2137e7e0
No related branches found
No related tags found
No related merge requests found
...@@ -1110,10 +1110,18 @@ typedef enum { ...@@ -1110,10 +1110,18 @@ typedef enum {
MGS_EXCEPTION, /* node died, etc. */ MGS_EXCEPTION, /* node died, etc. */
MGS_TARGET_REG, /* whenever target starts up */ MGS_TARGET_REG, /* whenever target starts up */
MGS_TARGET_DEL, MGS_TARGET_DEL,
MGS_SET_INFO,
MGS_LAST_OPC MGS_LAST_OPC
} mgs_cmd_t; } mgs_cmd_t;
#define MGS_FIRST_OPC MGS_CONNECT #define MGS_FIRST_OPC MGS_CONNECT
#define MGS_PARAM_MAXLEN 1024
#define KEY_SET_INFO "set_info"
struct mgs_send_param {
char mgs_param[MGS_PARAM_MAXLEN];
};
/* We pass this info to the MGS so it can write config logs */ /* We pass this info to the MGS so it can write config logs */
#define MTI_NAME_MAXLEN 64 #define MTI_NAME_MAXLEN 64
#define MTI_PARAM_MAXLEN 4096 #define MTI_PARAM_MAXLEN 4096
......
...@@ -453,11 +453,51 @@ do { \ ...@@ -453,11 +453,51 @@ do { \
Q_COPY(out, in, qc_dqblk); \ Q_COPY(out, in, qc_dqblk); \
} while (0) } while (0)
int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump) int ll_send_mgc_param(struct obd_export *mgc, char *string)
{
struct mgs_send_param *msp;
int rc = 0;
OBD_ALLOC_PTR(msp);
if (!msp)
return -ENOMEM;
strncpy(msp->mgs_param, string, MGS_PARAM_MAXLEN);
rc = obd_set_info_async(mgc, strlen(KEY_SET_INFO), KEY_SET_INFO,
sizeof(struct mgs_send_param), msp, NULL);
if (rc)
CERROR("Failed to set parameter: %d\n", rc);
OBD_FREE_PTR(msp);
return rc;
}
char *ll_get_fsname(struct inode *inode)
{
struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
char *ptr, *fsname;
int len;
OBD_ALLOC(fsname, MGS_PARAM_MAXLEN);
len = strlen(lsi->lsi_lmd->lmd_profile);
ptr = strrchr(lsi->lsi_lmd->lmd_profile, '-');
if (ptr && (strcmp(ptr, "-client") == 0))
len -= 7;
strncpy(fsname, lsi->lsi_lmd->lmd_profile, len);
fsname[len] = '\0';
return fsname;
}
int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
int set_default)
{ {
struct ll_sb_info *sbi = ll_i2sbi(inode); struct ll_sb_info *sbi = ll_i2sbi(inode);
struct mdc_op_data data; struct mdc_op_data data;
struct ptlrpc_request *req = NULL; struct ptlrpc_request *req = NULL;
struct lustre_sb_info *lsi = s2lsi(inode->i_sb);
struct obd_device *mgc = lsi->lsi_mgc;
char *fsname = NULL, *param = NULL;
struct iattr attr = { 0 }; struct iattr attr = { 0 };
int rc = 0; int rc = 0;
...@@ -486,8 +526,38 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump) ...@@ -486,8 +526,38 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump)
} }
ptlrpc_req_finished(req); ptlrpc_req_finished(req);
return rc; if (set_default && mgc->u.cli.cl_mgc_mgsexp) {
OBD_ALLOC(param, MGS_PARAM_MAXLEN);
/* Get fsname and assume devname to be -MDT0000. */
fsname = ll_get_fsname(inode);
/* Set root stripesize */
sprintf(param, "%s-MDT0000.lov.stripesize=%u", fsname,
lump->lmm_stripe_size);
rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
if (rc)
goto end;
/* Set root stripecount */
sprintf(param, "%s-MDT0000.lov.stripecount=%u", fsname,
lump->lmm_stripe_count);
rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
if (rc)
goto end;
/* Set root stripeoffset */
sprintf(param, "%s-MDT0000.lov.stripeoffset=%u", fsname,
lump->lmm_stripe_offset);
rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
if (rc)
goto end;
end:
if (fsname)
OBD_FREE(fsname, MGS_PARAM_MAXLEN);
if (param)
OBD_FREE(param, MGS_PARAM_MAXLEN);
}
return rc;
} }
int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp, int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmmp,
...@@ -614,6 +684,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, ...@@ -614,6 +684,7 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
case LL_IOC_LOV_SETSTRIPE: { case LL_IOC_LOV_SETSTRIPE: {
struct lov_user_md lum, *lump = (struct lov_user_md *)arg; struct lov_user_md lum, *lump = (struct lov_user_md *)arg;
int rc = 0; int rc = 0;
int set_default = 0;
LASSERT(sizeof(lum) == sizeof(*lump)); LASSERT(sizeof(lum) == sizeof(*lump));
LASSERT(sizeof(lum.lmm_objects[0]) == LASSERT(sizeof(lum.lmm_objects[0]) ==
...@@ -622,7 +693,10 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file, ...@@ -622,7 +693,10 @@ static int ll_dir_ioctl(struct inode *inode, struct file *file,
if (rc) if (rc)
return(-EFAULT); return(-EFAULT);
rc = ll_dir_setstripe(inode, &lum); if (inode->i_sb->s_root == file->f_dentry)
set_default = 1;
rc = ll_dir_setstripe(inode, &lum, set_default);
return rc; return rc;
} }
......
...@@ -575,7 +575,8 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file, ...@@ -575,7 +575,8 @@ int ll_lov_setstripe_ea_info(struct inode *inode, struct file *file,
int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename, int ll_lov_getstripe_ea_info(struct inode *inode, const char *filename,
struct lov_mds_md **lmm, int *lmm_size, struct lov_mds_md **lmm, int *lmm_size,
struct ptlrpc_request **request); struct ptlrpc_request **request);
int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump); int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
int set_default);
int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmm, int ll_dir_getstripe(struct inode *inode, struct lov_mds_md **lmm,
int *lmm_size, struct ptlrpc_request **request); int *lmm_size, struct ptlrpc_request **request);
......
...@@ -175,7 +175,7 @@ int ll_setxattr(struct dentry *dentry, const char *name, ...@@ -175,7 +175,7 @@ int ll_setxattr(struct dentry *dentry, const char *name,
/* b10667: rc always be 0 here for now */ /* b10667: rc always be 0 here for now */
rc = 0; rc = 0;
} else if (S_ISDIR(inode->i_mode)) { } else if (S_ISDIR(inode->i_mode)) {
rc = ll_dir_setstripe(inode, lump); rc = ll_dir_setstripe(inode, lump, 0);
} }
return rc; return rc;
......
...@@ -733,6 +733,39 @@ static int mgc_target_register(struct obd_export *exp, ...@@ -733,6 +733,39 @@ static int mgc_target_register(struct obd_export *exp,
RETURN(rc); RETURN(rc);
} }
/* Send parameter to MGS*/
static int mgc_set_mgs_param(struct obd_export *exp,
struct mgs_send_param *msp)
{
struct ptlrpc_request *req;
struct mgs_send_param *req_msp, *rep_msp;
int size[] = { sizeof(struct ptlrpc_body), sizeof(*req_msp) };
int rep_size[] = { sizeof(struct ptlrpc_body), sizeof(*msp) };
int rc;
ENTRY;
req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MGS_VERSION,
MGS_SET_INFO, 2, size, NULL);
if (!req)
RETURN(-ENOMEM);
req_msp = lustre_msg_buf(req->rq_reqmsg, REQ_REC_OFF, sizeof(*req_msp));
if (!req_msp)
RETURN(-ENOMEM);
memcpy(req_msp, msp, sizeof(*req_msp));
ptlrpc_req_set_repsize(req, 2, rep_size);
rc = ptlrpc_queue_wait(req);
if (!rc) {
rep_msp = lustre_swab_repbuf(req, REPLY_REC_OFF,
sizeof(*rep_msp), NULL);
memcpy(msp, rep_msp, sizeof(*rep_msp));
}
ptlrpc_req_finished(req);
RETURN(rc);
}
int mgc_reconnect_import(struct obd_import *imp) int mgc_reconnect_import(struct obd_import *imp)
{ {
...@@ -834,6 +867,13 @@ int mgc_set_info_async(struct obd_export *exp, obd_count keylen, ...@@ -834,6 +867,13 @@ int mgc_set_info_async(struct obd_export *exp, obd_count keylen,
} }
RETURN(rc); RETURN(rc);
} }
if (KEY_IS(KEY_SET_INFO)) {
struct mgs_send_param *msp;
msp = (struct mgs_send_param *)val;
rc = mgc_set_mgs_param(exp, msp);
RETURN(rc);
}
RETURN(rc); RETURN(rc);
} }
......
...@@ -450,6 +450,54 @@ out_nolock: ...@@ -450,6 +450,54 @@ out_nolock:
RETURN(rc); RETURN(rc);
} }
static int mgs_set_info_rpc(struct ptlrpc_request *req)
{
struct obd_device *obd = req->rq_export->exp_obd;
struct mgs_send_param *msp, *rep_msp;
struct lustre_handle lockh;
int rep_size[] = { sizeof(struct ptlrpc_body), sizeof(*msp) };
int lockrc, rc;
struct lustre_cfg_bufs bufs;
struct lustre_cfg *lcfg;
char fsname[MTI_NAME_MAXLEN];
ENTRY;
msp = lustre_swab_reqbuf(req, REQ_REC_OFF, sizeof(*msp), NULL);
/* Construct lustre_cfg structure to pass to function mgs_setparam */
lustre_cfg_bufs_reset(&bufs, NULL);
lustre_cfg_bufs_set_string(&bufs, 1, msp->mgs_param);
lcfg = lustre_cfg_new(LCFG_PARAM, &bufs);
rc = mgs_setparam(obd, lcfg, fsname);
if (rc) {
CERROR("Error %d in setting the parameter %s for fs %s\n",
rc, msp->mgs_param, fsname);
RETURN(rc);
}
/* Revoke lock so everyone updates. Should be alright if
* someone was already reading while we were updating the logs,
* so we don't really need to hold the lock while we're
* writing.
*/
if (fsname[0]) {
lockrc = mgs_get_cfg_lock(obd, fsname, &lockh);
if (lockrc != ELDLM_OK)
CERROR("lock error %d for fs %s\n", lockrc,
fsname);
else
mgs_put_cfg_lock(&lockh);
}
lustre_cfg_free(lcfg);
lustre_pack_reply(req, 2, rep_size, NULL);
rep_msp = lustre_msg_buf(req->rq_repmsg, REPLY_REC_OFF,
sizeof(*rep_msp));
memcpy(rep_msp, msp, sizeof(*rep_msp));
RETURN(rc);
}
int mgs_handle(struct ptlrpc_request *req) int mgs_handle(struct ptlrpc_request *req)
{ {
int fail = OBD_FAIL_MGS_ALL_REPLY_NET; int fail = OBD_FAIL_MGS_ALL_REPLY_NET;
...@@ -493,6 +541,9 @@ int mgs_handle(struct ptlrpc_request *req) ...@@ -493,6 +541,9 @@ int mgs_handle(struct ptlrpc_request *req)
DEBUG_REQ(D_MGS, req, "target del"); DEBUG_REQ(D_MGS, req, "target del");
//rc = mgs_handle_target_del(req); //rc = mgs_handle_target_del(req);
break; break;
case MGS_SET_INFO:
rc = mgs_set_info_rpc(req);
break;
case LDLM_ENQUEUE: case LDLM_ENQUEUE:
DEBUG_REQ(D_MGS, req, "enqueue"); DEBUG_REQ(D_MGS, req, "enqueue");
......
...@@ -90,6 +90,7 @@ struct ll_rpc_opcode { ...@@ -90,6 +90,7 @@ struct ll_rpc_opcode {
{ MGS_EXCEPTION, "mgs_exception" }, { MGS_EXCEPTION, "mgs_exception" },
{ MGS_TARGET_REG, "mgs_target_reg" }, { MGS_TARGET_REG, "mgs_target_reg" },
{ MGS_TARGET_DEL, "mgs_target_del" }, { MGS_TARGET_DEL, "mgs_target_del" },
{ MGS_SET_INFO, "mgs_set_info" },
{ OBD_PING, "obd_ping" }, { OBD_PING, "obd_ping" },
{ OBD_LOG_CANCEL, "llog_origin_handle_cancel" }, { OBD_LOG_CANCEL, "llog_origin_handle_cancel" },
{ OBD_QC_CALLBACK, "obd_quota_callback" }, { OBD_QC_CALLBACK, "obd_quota_callback" },
......
...@@ -139,6 +139,8 @@ void lustre_assert_wire_constants(void) ...@@ -139,6 +139,8 @@ void lustre_assert_wire_constants(void)
(long long)MGS_TARGET_REG); (long long)MGS_TARGET_REG);
LASSERTF(MGS_TARGET_DEL == 254, " found %lld\n", LASSERTF(MGS_TARGET_DEL == 254, " found %lld\n",
(long long)MGS_TARGET_DEL); (long long)MGS_TARGET_DEL);
LASSERTF(MGS_SET_INFO == 255, " found %lld\n",
(long long)MGS_SET_INFO);
LASSERTF(DISP_IT_EXECD == 1, " found %lld\n", LASSERTF(DISP_IT_EXECD == 1, " found %lld\n",
(long long)DISP_IT_EXECD); (long long)DISP_IT_EXECD);
LASSERTF(DISP_LOOKUP_EXECD == 2, " found %lld\n", LASSERTF(DISP_LOOKUP_EXECD == 2, " found %lld\n",
...@@ -211,6 +213,8 @@ void lustre_assert_wire_constants(void) ...@@ -211,6 +213,8 @@ void lustre_assert_wire_constants(void)
(long long)MGS_TARGET_REG); (long long)MGS_TARGET_REG);
LASSERTF(MGS_TARGET_DEL == 254, " found %lld\n", LASSERTF(MGS_TARGET_DEL == 254, " found %lld\n",
(long long)MGS_TARGET_DEL); (long long)MGS_TARGET_DEL);
LASSERTF(MGS_SET_INFO == 255, " found %lld\n",
(long long)MGS_SET_INFO);
/* Sizes and Offsets */ /* Sizes and Offsets */
/* Checks for struct obd_uuid */ /* Checks for struct obd_uuid */
......
...@@ -1129,6 +1129,7 @@ main(int argc, char **argv) ...@@ -1129,6 +1129,7 @@ main(int argc, char **argv)
CHECK_VALUE(MGS_EXCEPTION); CHECK_VALUE(MGS_EXCEPTION);
CHECK_VALUE(MGS_TARGET_REG); CHECK_VALUE(MGS_TARGET_REG);
CHECK_VALUE(MGS_TARGET_DEL); CHECK_VALUE(MGS_TARGET_DEL);
CHECK_VALUE(MGS_SET_INFO);
CHECK_VALUE(DISP_IT_EXECD); CHECK_VALUE(DISP_IT_EXECD);
CHECK_VALUE(DISP_LOOKUP_EXECD); CHECK_VALUE(DISP_LOOKUP_EXECD);
...@@ -1175,6 +1176,7 @@ main(int argc, char **argv) ...@@ -1175,6 +1176,7 @@ main(int argc, char **argv)
CHECK_VALUE(MGS_EXCEPTION); CHECK_VALUE(MGS_EXCEPTION);
CHECK_VALUE(MGS_TARGET_REG); CHECK_VALUE(MGS_TARGET_REG);
CHECK_VALUE(MGS_TARGET_DEL); CHECK_VALUE(MGS_TARGET_DEL);
CHECK_VALUE(MGS_SET_INFO);
COMMENT("Sizes and Offsets"); COMMENT("Sizes and Offsets");
BLANK_LINE(); BLANK_LINE();
......
...@@ -155,6 +155,8 @@ void lustre_assert_wire_constants(void) ...@@ -155,6 +155,8 @@ void lustre_assert_wire_constants(void)
(long long)MGS_TARGET_REG); (long long)MGS_TARGET_REG);
LASSERTF(MGS_TARGET_DEL == 254, " found %lld\n", LASSERTF(MGS_TARGET_DEL == 254, " found %lld\n",
(long long)MGS_TARGET_DEL); (long long)MGS_TARGET_DEL);
LASSERTF(MGS_SET_INFO == 255, " found %lld\n",
(long long)MGS_SET_INFO);
LASSERTF(DISP_IT_EXECD == 1, " found %lld\n", LASSERTF(DISP_IT_EXECD == 1, " found %lld\n",
(long long)DISP_IT_EXECD); (long long)DISP_IT_EXECD);
LASSERTF(DISP_LOOKUP_EXECD == 2, " found %lld\n", LASSERTF(DISP_LOOKUP_EXECD == 2, " found %lld\n",
...@@ -227,6 +229,8 @@ void lustre_assert_wire_constants(void) ...@@ -227,6 +229,8 @@ void lustre_assert_wire_constants(void)
(long long)MGS_TARGET_REG); (long long)MGS_TARGET_REG);
LASSERTF(MGS_TARGET_DEL == 254, " found %lld\n", LASSERTF(MGS_TARGET_DEL == 254, " found %lld\n",
(long long)MGS_TARGET_DEL); (long long)MGS_TARGET_DEL);
LASSERTF(MGS_SET_INFO == 255, " found %lld\n",
(long long)MGS_SET_INFO);
/* Sizes and Offsets */ /* Sizes and Offsets */
/* Checks for struct obd_uuid */ /* Checks for struct obd_uuid */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment