#include <lustre_disk.h>
#include <lustre_param.h>
#include <lustre_sec.h>
+#include <lquota.h>
#include "mgs_internal.h"
/********************** Class functions ********************/
name_create(&logname, fsdb->fsdb_name, "-client");
cfs_mutex_lock(&fsdb->fsdb_mutex);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = llog_create(ctxt, &loghandle, NULL, logname);
- if (rc)
- GOTO(out_pop, rc);
+ rc = llog_create(NULL, ctxt, &loghandle, NULL, logname);
+ if (rc)
+ GOTO(out_pop, rc);
- rc = llog_init_handle(loghandle, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_init_handle(NULL, loghandle, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(out_close, rc);
rc = llog_process(NULL, loghandle, mgs_fsdb_handler, (void *) &d,
NULL);
- CDEBUG(D_INFO, "get_db = %d\n", rc);
+ CDEBUG(D_INFO, "get_db = %d\n", rc);
out_close:
- rc2 = llog_close(loghandle);
+ rc2 = llog_close(NULL, loghandle);
if (!rc)
rc = rc2;
out_pop:
cfs_set_bit(mti->mti_stripe_index, imap);
cfs_clear_bit(FSDB_LOG_EMPTY, &fsdb->fsdb_flags);
- server_make_name(mti->mti_flags & ~LDD_F_VIRGIN, mti->mti_stripe_index,
- mti->mti_fsname, mti->mti_svname);
+ server_make_name(mti->mti_flags & ~(LDD_F_VIRGIN | LDD_F_WRITECONF),
+ mti->mti_stripe_index, mti->mti_fsname, mti->mti_svname);
CDEBUG(D_MGS, "Set index for %s to %d\n", mti->mti_svname,
mti->mti_stripe_index);
/* Header and tail are added back to lrh_len in
llog_lvfs_write_rec */
rec->lrh_len = cfg_len;
- rc = llog_write_rec(llh, rec, NULL, 0, (void *)lcfg,
- rec->lrh_index);
+ rc = llog_write_rec(NULL, llh, rec, NULL, 0, (void *)lcfg,
+ rec->lrh_index);
if (!rc)
mml->mml_modified++;
}
ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
- rc = llog_create(ctxt, &loghandle, NULL, logname);
+ rc = llog_create(NULL, ctxt, &loghandle, NULL, logname);
if (rc)
GOTO(out_pop, rc);
- rc = llog_init_handle(loghandle, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_init_handle(NULL, loghandle, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(out_close, rc);
OBD_FREE_PTR(mml);
out_close:
- rc2 = llog_close(loghandle);
+ rc2 = llog_close(NULL, loghandle);
if (!rc)
rc = rc2;
out_pop:
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
/* idx = -1 means append */
- rc = llog_write_rec(llh, &rec, NULL, 0, (void *)lcfg, -1);
+ rc = llog_write_rec(NULL, llh, &rec, NULL, 0, (void *)lcfg, -1);
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
if (rc)
CERROR("failed %d\n", rc);
GOTO(out, rc = -ENODEV);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = llog_create(ctxt, llh, NULL, name);
- if (rc == 0)
- llog_init_handle(*llh, LLOG_F_IS_PLAIN, &cfg_uuid);
- else
- *llh = NULL;
+ rc = llog_create(NULL, ctxt, llh, NULL, name);
+ if (rc == 0)
+ llog_init_handle(NULL, *llh, LLOG_F_IS_PLAIN, &cfg_uuid);
+ else
+ *llh = NULL;
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
llog_ctxt_put(ctxt);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = llog_close(*llh);
+ rc = llog_close(NULL, *llh);
*llh = NULL;
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
ctxt = llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT);
LASSERT(ctxt != NULL);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = llog_create(ctxt, &llh, NULL, name);
+ rc = llog_create(NULL, ctxt, &llh, NULL, name);
if (rc == 0) {
- llog_init_handle(llh, LLOG_F_IS_PLAIN, NULL);
- rc = llog_get_size(llh);
- llog_close(llh);
+ llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_get_size(llh);
+ llog_close(NULL, llh);
}
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
llog_ctxt_put(ctxt);
/* write the lcfg in all logs for the given fs */
int mgs_write_log_direct_all(struct obd_device *obd, struct fs_db *fsdb,
- struct mgs_target_info *mti,
- struct lustre_cfg *lcfg,
- char *devname, char *comment)
+ struct mgs_target_info *mti,
+ struct lustre_cfg *lcfg,
+ char *devname, char *comment,
+ int server_only)
{
struct mgs_obd *mgs = &obd->u.mgs;
cfs_list_t dentry_list;
cfs_list_for_each_entry_safe(dirent, n, &dentry_list, lld_list) {
cfs_list_del(&dirent->lld_list);
/* don't write to sptlrpc rule log */
- if (strncmp(fsname, dirent->lld_name, len) == 0 &&
- strstr(dirent->lld_name, "-sptlrpc") == NULL) {
+ if (strstr(dirent->lld_name, "-sptlrpc") != NULL)
+ goto next;
+
+ /* caller wants write server logs only */
+ if (server_only && strstr(dirent->lld_name, "-client") != NULL)
+ goto next;
+
+ if (strncmp(fsname, dirent->lld_name, len) == 0) {
CDEBUG(D_MGS, "Changing log %s\n", dirent->lld_name);
/* Erase any old settings of this same parameter */
mgs_modify(obd, fsdb, mti, dirent->lld_name, devname,
dirent->lld_name);
}
}
+next:
OBD_FREE(dirent, sizeof(*dirent));
}
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = llog_create(ctxt, &loghandle, NULL, client_name);
+ rc = llog_create(NULL, ctxt, &loghandle, NULL, client_name);
if (rc)
GOTO(out_pop, rc);
- rc = llog_init_handle(loghandle, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_init_handle(NULL, loghandle, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(out_close, rc);
(void *)comp, NULL);
CDEBUG(D_MGS, "steal llog re = %d\n", rc);
out_close:
- rc2 = llog_close(loghandle);
+ rc2 = llog_close(NULL, loghandle);
if (!rc)
rc = rc2;
out_pop:
*ptr = '\0';
/* modify all servers and clients */
rc = mgs_write_log_direct_all(obd, fsdb, mti,
- *tmp == '\0' ? NULL : lcfg,
- mti->mti_fsname, sys);
+ *tmp == '\0' ? NULL : lcfg,
+ mti->mti_fsname, sys, 0);
if (rc == 0 && *tmp != '\0') {
switch (cmd) {
case LCFG_SET_TIMEOUT:
return rc;
}
+/* write quota settings into log */
+static int mgs_write_log_quota(struct obd_device *obd, struct fs_db *fsdb,
+ struct mgs_target_info *mti, char *quota,
+ char *ptr)
+{
+ struct lustre_cfg_bufs bufs;
+ struct lustre_cfg *lcfg;
+ char *tmp;
+ char sep;
+ int cmd = LCFG_PARAM;
+ int rc;
+
+ /* support only 'meta' and 'data' pools so far */
+ if (class_match_param(ptr, QUOTA_METAPOOL_NAME, &tmp) != 0 &&
+ class_match_param(ptr, QUOTA_DATAPOOL_NAME, &tmp) != 0) {
+ CERROR("parameter quota.%s isn't supported (only quota.mdt "
+ "& quota.ost are)\n", ptr);
+ return -EINVAL;
+ }
+
+ if (*tmp == '\0') {
+ CDEBUG(D_MGS, "global '%s' removed\n", quota);
+ } else {
+ CDEBUG(D_MGS, "global '%s'\n", quota);
+
+ if (strchr(tmp, 'u') == NULL && strchr(tmp, 'g') == NULL &&
+ strcmp(tmp, "none") != 0) {
+ CERROR("enable option(%s) isn't supported\n", tmp);
+ return -EINVAL;
+ }
+ }
+
+ lustre_cfg_bufs_reset(&bufs, NULL);
+ lustre_cfg_bufs_set_string(&bufs, 1, quota);
+ lcfg = lustre_cfg_new(cmd, &bufs);
+ /* truncate the comment to the parameter name */
+ ptr = tmp - 1;
+ sep = *ptr;
+ *ptr = '\0';
+
+ /* XXX we duplicated quota enable information in all server
+ * config logs, it should be moved to a separate config
+ * log once we cleanup the config log for global param. */
+ /* modify all servers */
+ rc = mgs_write_log_direct_all(obd, fsdb, mti,
+ *tmp == '\0' ? NULL : lcfg,
+ mti->mti_fsname, quota, 1);
+ *ptr = sep;
+ lustre_cfg_free(lcfg);
+ return rc;
+}
+
static int mgs_srpc_set_param_disk(struct obd_device *obd,
struct fs_db *fsdb,
struct mgs_target_info *mti,
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = llog_create(ctxt, &llh, NULL, logname);
+ rc = llog_create(NULL, ctxt, &llh, NULL, logname);
if (rc)
GOTO(out_pop, rc);
- rc = llog_init_handle(llh, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL);
if (rc)
GOTO(out_close, rc);
NULL);
out_close:
- llog_close(llh);
+ llog_close(NULL, llh);
out_pop:
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
out:
GOTO(end, rc);
}
+ if (class_match_param(ptr, PARAM_QUOTA, &tmp) == 0) {
+ rc = mgs_write_log_quota(obd, fsdb, mti, ptr, tmp);
+ GOTO(end, rc);
+ }
+
if (class_match_param(ptr, PARAM_OSC""PARAM_ACTIVE, &tmp) == 0) {
/* active=0 means off, anything else means on */
int flag = (*tmp == '0') ? CM_EXCLUDE : 0;
LASSERT(ctxt != NULL);
push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
- rc = llog_create(ctxt, &llh, NULL, name);
- if (rc == 0) {
- llog_init_handle(llh, LLOG_F_IS_PLAIN, NULL);
- rc = llog_destroy(llh);
+ rc = llog_create(NULL, ctxt, &llh, NULL, name);
+ if (rc == 0) {
+ llog_init_handle(NULL, llh, LLOG_F_IS_PLAIN, NULL);
+ rc = llog_destroy(NULL, llh);
llog_free_handle(llh);
}
pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);