#define PRINT_MASK (D_SUPER | D_CONFIG)
#include <obd.h>
-#include <lvfs.h>
#include <obd_class.h>
#include <lustre/lustre_user.h>
#include <linux/version.h>
/* we must register an obd for a mount before we call the setup routine.
*_setup will call lustre_get_mount to get the mnt struct
by obd_name, since we can't pass the pointer to setup. */
-static int server_register_mount(const char *name, struct super_block *sb,
- struct vfsmount *mnt)
+static int server_register_mount(const char *name, struct super_block *sb)
{
struct lustre_mount_info *lmi;
char *name_cp;
}
lmi->lmi_name = name_cp;
lmi->lmi_sb = sb;
- lmi->lmi_mnt = mnt;
cfs_list_add(&lmi->lmi_list_chain, &server_mount_info_list);
mutex_unlock(&lustre_mount_info_lock);
- CDEBUG(D_MOUNT, "reg_mnt %p from %s\n", lmi->lmi_mnt, name);
+ CDEBUG(D_MOUNT, "register mount %p from %s\n", sb, name);
RETURN(0);
}
RETURN(-ENOENT);
}
- CDEBUG(D_MOUNT, "dereg_mnt %p from %s\n", lmi->lmi_mnt, name);
+ CDEBUG(D_MOUNT, "deregister mount %p from %s\n", lmi->lmi_sb, name);
OBD_FREE(lmi->lmi_name, strlen(lmi->lmi_name) + 1);
cfs_list_del(&lmi->lmi_list_chain);
}
lsi = s2lsi(lmi->lmi_sb);
- cfs_atomic_inc(&lsi->lsi_mounts);
+ atomic_inc(&lsi->lsi_mounts);
- CDEBUG(D_MOUNT, "get_mnt %p from %s, refs=%d\n", lmi->lmi_mnt,
- name, cfs_atomic_read(&lsi->lsi_mounts));
+ CDEBUG(D_MOUNT, "get mount %p from %s, refs=%d\n", lmi->lmi_sb,
+ name, atomic_read(&lsi->lsi_mounts));
RETURN(lmi);
}
EXPORT_SYMBOL(server_get_mount_2);
/* to be called from obd_cleanup methods */
-int server_put_mount(const char *name, struct vfsmount *mnt)
+int server_put_mount(const char *name)
{
struct lustre_mount_info *lmi;
struct lustre_sb_info *lsi;
}
lsi = s2lsi(lmi->lmi_sb);
- CDEBUG(D_MOUNT, "put_mnt %p from %s, refs=%d\n",
- lmi->lmi_mnt, name, cfs_atomic_read(&lsi->lsi_mounts));
+ CDEBUG(D_MOUNT, "put mount %p from %s, refs=%d\n",
+ lmi->lmi_sb, name, atomic_read(&lsi->lsi_mounts));
if (lustre_put_lsi(lmi->lmi_sb))
- CDEBUG(D_MOUNT, "Last put of mnt %p from %s\n",
- lmi->lmi_mnt, name);
+ CDEBUG(D_MOUNT, "Last put of mount %p from %s\n",
+ lmi->lmi_sb, name);
/* this obd should never need the mount again */
server_deregister_mount(name);
static int server_start_mgs(struct super_block *sb)
{
struct lustre_sb_info *lsi = s2lsi(sb);
- struct vfsmount *mnt = lsi->lsi_srv_mnt;
struct lustre_mount_info *lmi;
int rc = 0;
ENTRY;
CDEBUG(D_CONFIG, "Start MGS service %s\n", LUSTRE_MGS_OBDNAME);
- rc = server_register_mount(LUSTRE_MGS_OBDNAME, sb, mnt);
+ rc = server_register_mount(LUSTRE_MGS_OBDNAME, sb);
if (!rc) {
rc = lustre_start_simple(LUSTRE_MGS_OBDNAME, LUSTRE_MGS_NAME,
RETURN(rc);
}
-static int is_mdc_device(const char *devname)
+static inline bool is_mdc_device(const char *devname)
{
char *ptr;
ptr = strrchr(devname, '-');
- if (ptr != NULL && strcmp(ptr, "-mdc") == 0)
- return 1;
-
- return 0;
+ return ptr != NULL && strcmp(ptr, "-mdc") == 0;
}
-static inline int tgt_is_mdt0(const char *tgtname)
+static inline bool tgt_is_mdt(const char *tgtname, __u32 *idx)
{
- __u32 idx;
- int type;
-
- type = server_name2index(tgtname, &idx, NULL);
- if (type != LDD_F_SV_TYPE_MDT)
- return 0;
-
- return idx == 0;
-}
+ int type;
-static inline int is_mdc_for_mdt0(const char *devname)
-{
- char *ptr;
-
- if (!is_mdc_device(devname))
- return 0;
-
- ptr = strrchr(devname, '-');
- if (ptr == NULL)
- return 0;
+ type = server_name2index(tgtname, idx, NULL);
- *ptr = 0;
- if (tgt_is_mdt0(devname)) {
- *ptr = '-';
- return 1;
- }
- *ptr = '-';
- return 0;
+ return type == LDD_F_SV_TYPE_MDT;
}
/**
- * Convert OST/MDT name(fsname-OSTxxxx) to a lwp name
- * (fsname-MDT0000-lwp-OSTxxxx)
+ * Convert OST/MDT name(fsname-{MDT,OST}xxxx) to a lwp name with the @idx:yyyy
+ * (fsname-MDTyyyy-lwp-{MDT,OST}xxxx)
**/
-int tgt_name2lwpname(const char *svname, char *lwpname)
+int tgt_name2lwp_name(const char *tgt_name, char *lwp_name, int len, __u32 idx)
{
char *fsname;
const char *tgt;
if (fsname == NULL)
RETURN(-ENOMEM);
- rc = server_name2fsname(svname, fsname, &tgt);
+ rc = server_name2fsname(tgt_name, fsname, &tgt);
if (rc != 0) {
- CERROR("%s: failed to get fsname from svname. %d\n",
- svname, rc);
+ CERROR("%s: failed to get fsname from tgt_name: rc = %d\n",
+ tgt_name, rc);
GOTO(cleanup, rc);
}
if (*tgt != '-' && *tgt != ':') {
- CERROR("%s: invalid svname name!\n", svname);
+ CERROR("%s: invalid tgt_name name!\n", tgt_name);
GOTO(cleanup, rc = -EINVAL);
}
tgt++;
if (strncmp(tgt, "OST", 3) != 0 && strncmp(tgt, "MDT", 3) != 0) {
- CERROR("%s is not an OST or MDT target!\n", svname);
+ CERROR("%s is not an OST or MDT target!\n", tgt_name);
GOTO(cleanup, rc = -EINVAL);
}
- sprintf(lwpname, "%s-MDT0000-%s-%s", fsname, LUSTRE_LWP_NAME, tgt);
+ snprintf(lwp_name, len, "%s-MDT%04x-%s-%s",
+ fsname, idx, LUSTRE_LWP_NAME, tgt);
+
+ GOTO(cleanup, rc = 0);
+
cleanup:
if (fsname != NULL)
OBD_FREE(fsname, MTI_NAME_MAXLEN);
- RETURN(rc);
+
+ return rc;
}
-EXPORT_SYMBOL(tgt_name2lwpname);
+EXPORT_SYMBOL(tgt_name2lwp_name);
static CFS_LIST_HEAD(lwp_register_list);
DEFINE_MUTEX(lwp_register_list_lock);
}
EXPORT_SYMBOL(lustre_deregister_lwp_item);
+struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx)
+{
+ struct lustre_mount_info *lmi;
+ struct lustre_sb_info *lsi;
+ struct obd_device *lwp;
+ struct obd_export *exp = NULL;
+ char fsname[16];
+ char lwp_name[24];
+ int rc;
+
+ lmi = server_get_mount_2(dev);
+ if (lmi == NULL)
+ return NULL;
+
+ lsi = s2lsi(lmi->lmi_sb);
+ rc = server_name2fsname(lsi->lsi_svname, fsname, NULL);
+ if (rc != 0) {
+ CERROR("%s: failed to get fsname: rc = %d\n",
+ lsi->lsi_svname, rc);
+ return NULL;
+ }
+
+ snprintf(lwp_name, sizeof(lwp_name), "%s-MDT%04x", fsname, idx);
+ spin_lock(&lsi->lsi_lwp_lock);
+ list_for_each_entry(lwp, &lsi->lsi_lwp_list, obd_lwp_list) {
+ char *ptr = strstr(lwp->obd_name, lwp_name);
+
+ if (ptr != NULL) {
+ exp = class_export_get(lwp->obd_lwp_export);
+ break;
+ }
+ }
+ spin_unlock(&lsi->lsi_lwp_lock);
+
+ return exp;
+}
+EXPORT_SYMBOL(lustre_find_lwp_by_index);
+
static void lustre_notify_lwp_list(struct obd_export *exp)
{
struct lwp_register_item *lri, *tmp;
if (rc != 0)
RETURN(rc);
- lu_context_init(&session_ctx, LCT_SESSION);
+ lu_context_init(&session_ctx, LCT_SERVER_SESSION);
session_ctx.lc_thread = NULL;
lu_context_enter(&session_ctx);
env.le_ses = &session_ctx;
data->ocd_connect_flags |= OBD_CONNECT_MDS_MDS | OBD_CONNECT_FID |
OBD_CONNECT_AT | OBD_CONNECT_LRU_RESIZE |
OBD_CONNECT_FULL20 | OBD_CONNECT_LVB_TYPE |
- OBD_CONNECT_LIGHTWEIGHT;
+ OBD_CONNECT_LIGHTWEIGHT | OBD_CONNECT_LFSCK;
OBD_ALLOC_PTR(uuid);
if (uuid == NULL)
GOTO(out, rc = -ENOMEM);
/* Use lwp name as the uuid, so we find the export by lwp name later */
memcpy(uuid->uuid, lwp->obd_name, strlen(lwp->obd_name));
rc = obd_connect(&env, &exp, lwp, uuid, data, NULL);
- if (rc != 0)
+ if (rc != 0) {
CERROR("%s: connect failed: rc = %d\n", lwp->obd_name, rc);
- else
+ } else {
+ if (unlikely(lwp->obd_lwp_export != NULL))
+ class_export_put(lwp->obd_lwp_export);
+ lwp->obd_lwp_export = class_export_get(exp);
lustre_notify_lwp_list(exp);
+ }
+
+ GOTO(out, rc);
out:
if (data != NULL)
lu_context_exit(&session_ctx);
lu_context_fini(&session_ctx);
- RETURN(rc);
+ return rc;
}
/**
- * lwp is used by slaves (Non-MDT0 targets) to manage the connection
- * to MDT0.
+ * lwp is used by slaves (Non-MDT0 targets) to manage the connection to MDT0,
+ * or from the OSTx to MDTy.
**/
-static int lustre_lwp_setup(struct lustre_cfg *lcfg, struct lustre_sb_info *lsi)
+static int lustre_lwp_setup(struct lustre_cfg *lcfg, struct lustre_sb_info *lsi,
+ __u32 idx)
{
struct obd_device *obd;
char *lwpname = NULL;
rc = class_add_uuid(lustre_cfg_string(lcfg, 1),
lcfg->lcfg_nid);
- if (rc) {
+ if (rc != 0) {
CERROR("%s: Can't add uuid: rc =%d\n", lsi->lsi_svname, rc);
- GOTO(out, rc);
+ RETURN(rc);
}
OBD_ALLOC(lwpname, MTI_NAME_MAXLEN);
if (lwpname == NULL)
GOTO(out, rc = -ENOMEM);
- rc = tgt_name2lwpname(lsi->lsi_svname, lwpname);
+ rc = tgt_name2lwp_name(lsi->lsi_svname, lwpname, MTI_NAME_MAXLEN, idx);
if (rc != 0) {
- CERROR("%s: failed to generate lwp name. %d\n",
+ CERROR("%s: failed to generate lwp name: rc = %d\n",
lsi->lsi_svname, rc);
GOTO(out, rc);
}
LASSERT(obd != NULL);
rc = lustre_lwp_connect(obd);
- if (rc != 0)
+ if (rc == 0) {
+ obd->u.cli.cl_max_mds_easize = MAX_MD_SIZE;
+ spin_lock(&lsi->lsi_lwp_lock);
+ list_add_tail(&obd->obd_lwp_list, &lsi->lsi_lwp_list);
+ spin_unlock(&lsi->lsi_lwp_lock);
+ } else {
CERROR("%s: connect failed: rc = %d\n", lwpname, rc);
+ }
+
+ GOTO(out, rc);
+
out:
if (lwpname != NULL)
OBD_FREE(lwpname, MTI_NAME_MAXLEN);
if (lwpuuid != NULL)
OBD_FREE(lwpuuid, MTI_NAME_MAXLEN);
- RETURN(rc);
+ return rc;
}
/* the caller is responsible for memory free */
static struct obd_device *lustre_find_lwp(struct lustre_sb_info *lsi,
- char **lwpname, char **logname)
+ char **lwpname, __u32 idx)
{
struct obd_device *lwp;
int rc = 0;
if (*lwpname == NULL)
RETURN(ERR_PTR(-ENOMEM));
- if (logname != NULL) {
- OBD_ALLOC(*logname, MTI_NAME_MAXLEN);
- if (*logname == NULL)
- GOTO(out, rc = -ENOMEM);
- rc = server_name2fsname(lsi->lsi_svname, *lwpname, NULL);
- if (rc != 0) {
- CERROR("%s: failed to get fsname from svname. %d\n",
- lsi->lsi_svname, rc);
- GOTO(out, rc = -EINVAL);
- }
- sprintf(*logname, "%s-client", *lwpname);
- }
-
- rc = tgt_name2lwpname(lsi->lsi_svname, *lwpname);
+ rc = tgt_name2lwp_name(lsi->lsi_svname, *lwpname, MTI_NAME_MAXLEN, idx);
if (rc != 0) {
- CERROR("%s: failed to generate lwp name. %d\n",
+ CERROR("%s: failed to generate lwp name: rc = %d\n",
lsi->lsi_svname, rc);
GOTO(out, rc = -EINVAL);
}
OBD_FREE(*lwpname, MTI_NAME_MAXLEN);
*lwpname = NULL;
}
- if (logname != NULL && *logname != NULL) {
- OBD_FREE(*logname, MTI_NAME_MAXLEN);
- *logname = NULL;
- }
lwp = ERR_PTR(rc);
}
}
static int lustre_lwp_add_conn(struct lustre_cfg *cfg,
- struct lustre_sb_info *lsi)
+ struct lustre_sb_info *lsi, __u32 idx)
{
struct lustre_cfg_bufs *bufs = NULL;
struct lustre_cfg *lcfg = NULL;
int rc;
ENTRY;
- lwp = lustre_find_lwp(lsi, &lwpname, NULL);
+ lwp = lustre_find_lwp(lsi, &lwpname, idx);
if (IS_ERR(lwp)) {
CERROR("%s: can't find lwp device.\n", lsi->lsi_svname);
GOTO(out, rc = PTR_ERR(lwp));
* Retrieve MDT nids from the client log, then start the lwp device.
* there are only two scenarios which would include mdt nid.
* 1.
- * marker 5 (flags=0x01, v2.1.54.0) lustre-MDT0000 'add mdc' xxx-
+ * marker 5 (flags=0x01, v2.1.54.0) lustre-MDTyyyy 'add mdc' xxx-
* add_uuid nid=192.168.122.162@tcp(0x20000c0a87aa2) 0: 1:192.168.122.162@tcp
- * attach 0:lustre-MDT0000-mdc 1:mdc 2:lustre-clilmv_UUID
- * setup 0:lustre-MDT0000-mdc 1:lustre-MDT0000_UUID 2:192.168.122.162@tcp
+ * attach 0:lustre-MDTyyyy-mdc 1:mdc 2:lustre-clilmv_UUID
+ * setup 0:lustre-MDTyyyy-mdc 1:lustre-MDTyyyy_UUID 2:192.168.122.162@tcp
* add_uuid nid=192.168.172.1@tcp(0x20000c0a8ac01) 0: 1:192.168.172.1@tcp
- * add_conn 0:lustre-MDT0000-mdc 1:192.168.172.1@tcp
- * modify_mdc_tgts add 0:lustre-clilmv 1:lustre-MDT0000_UUID xxxx
- * marker 5 (flags=0x02, v2.1.54.0) lustre-MDT0000 'add mdc' xxxx-
+ * add_conn 0:lustre-MDTyyyy-mdc 1:192.168.172.1@tcp
+ * modify_mdc_tgts add 0:lustre-clilmv 1:lustre-MDTyyyy_UUID xxxx
+ * marker 5 (flags=0x02, v2.1.54.0) lustre-MDTyyyy 'add mdc' xxxx-
* 2.
- * marker 7 (flags=0x01, v2.1.54.0) lustre-MDT0000 'add failnid' xxxx-
+ * marker 7 (flags=0x01, v2.1.54.0) lustre-MDTyyyy 'add failnid' xxxx-
* add_uuid nid=192.168.122.2@tcp(0x20000c0a87a02) 0: 1:192.168.122.2@tcp
- * add_conn 0:lustre-MDT0000-mdc 1:192.168.122.2@tcp
- * marker 7 (flags=0x02, v2.1.54.0) lustre-MDT0000 'add failnid' xxxx-
+ * add_conn 0:lustre-MDTyyyy-mdc 1:192.168.122.2@tcp
+ * marker 7 (flags=0x02, v2.1.54.0) lustre-MDTyyyy 'add failnid' xxxx-
**/
static int client_lwp_config_process(const struct lu_env *env,
struct llog_handle *handle,
marker->cm_flags & CM_EXCLUDE)
GOTO(out, rc = 0);
- if (!tgt_is_mdt0(marker->cm_tgtname))
+ if (!tgt_is_mdt(marker->cm_tgtname, &clli->cfg_lwp_idx))
+ GOTO(out, rc = 0);
+
+ if (IS_MDT(lsi) && clli->cfg_lwp_idx != 0)
GOTO(out, rc = 0);
if (!strncmp(marker->cm_comment, "add mdc", 7) ||
}
case LCFG_ADD_UUID: {
if (clli->cfg_flags == CFG_F_MARKER) {
- rc = lustre_lwp_setup(lcfg, lsi);
+ rc = lustre_lwp_setup(lcfg, lsi, clli->cfg_lwp_idx);
/* XXX: process only the first nid as
* we don't need another instance of lwp */
clli->cfg_flags |= CFG_F_SKIP;
break;
}
case LCFG_ADD_CONN: {
- if (is_mdc_for_mdt0(lustre_cfg_string(lcfg, 0)))
- rc = lustre_lwp_add_conn(lcfg, lsi);
+ char *devname = lustre_cfg_string(lcfg, 0);
+ char *ptr;
+ __u32 idx = 0;
+
+ if (!is_mdc_device(devname))
+ break;
+
+ ptr = strrchr(devname, '-');
+ if (ptr == NULL)
+ break;
+
+ *ptr = 0;
+ if (!tgt_is_mdt(devname, &idx)) {
+ *ptr = '-';
+ break;
+ }
+
+ *ptr = '-';
+ rc = lustre_lwp_add_conn(lcfg, lsi, idx);
break;
}
default:
static int lustre_disconnect_lwp(struct super_block *sb)
{
- struct lustre_sb_info *lsi = s2lsi(sb);
+ struct lustre_sb_info *lsi = s2lsi(sb);
struct obd_device *lwp;
- char *lwpname = NULL;
char *logname = NULL;
- struct lustre_cfg *lcfg = NULL;
- struct lustre_cfg_bufs *bufs = NULL;
- struct config_llog_instance *cfg = NULL;
- int rc;
+ struct lustre_cfg_bufs *bufs = NULL;
+ struct config_llog_instance *cfg = NULL;
+ int rc = 0;
+ int rc1 = 0;
ENTRY;
- lwp = lustre_find_lwp(lsi, &lwpname, &logname);
- if (IS_ERR(lwp) && PTR_ERR(lwp) != -ENOENT)
- GOTO(out, rc = PTR_ERR(lwp));
+ if (likely(lsi->lsi_lwp_started)) {
+ OBD_ALLOC(logname, MTI_NAME_MAXLEN);
+ if (logname == NULL)
+ RETURN(-ENOMEM);
- LASSERT(lwpname != NULL);
- LASSERT(logname != NULL);
+ rc = server_name2fsname(lsi->lsi_svname, logname, NULL);
+ if (rc != 0) {
+ CERROR("%s: failed to get fsname from svname: "
+ "rc = %d\n", lsi->lsi_svname, rc);
+ GOTO(out, rc = -EINVAL);
+ }
- OBD_ALLOC_PTR(cfg);
- if (cfg == NULL)
- GOTO(out, rc = -ENOMEM);
+ strcat(logname, "-client");
+ OBD_ALLOC_PTR(cfg);
+ if (cfg == NULL)
+ GOTO(out, rc = -ENOMEM);
- /* end log first */
- cfg->cfg_instance = sb;
- rc = lustre_end_log(sb, logname, cfg);
- if (rc != 0) {
- CERROR("%s: Can't end config log %s.\n", lwpname, logname);
- GOTO(out, rc);
- }
+ /* end log first */
+ cfg->cfg_instance = sb;
+ rc = lustre_end_log(sb, logname, cfg);
+ if (rc != 0)
+ GOTO(out, rc);
- if (PTR_ERR(lwp) == -ENOENT) {
- CDEBUG(D_CONFIG, "%s: lwp device wasn't started.\n",
- lsi->lsi_svname);
- GOTO(out, rc = 0);
+ lsi->lsi_lwp_started = 0;
}
OBD_ALLOC_PTR(bufs);
if (bufs == NULL)
GOTO(out, rc = -ENOMEM);
- lustre_cfg_bufs_reset(bufs, lwp->obd_name);
- lustre_cfg_bufs_set_string(bufs, 1, NULL);
- lcfg = lustre_cfg_new(LCFG_CLEANUP, bufs);
- if (!lcfg)
- GOTO(out, rc = -ENOMEM);
+ list_for_each_entry(lwp, &lsi->lsi_lwp_list, obd_lwp_list) {
+ struct lustre_cfg *lcfg;
- /* Disconnect import first. NULL is passed for the '@env', since
- * it will not be used. */
- rc = lwp->obd_lu_dev->ld_ops->ldo_process_config(NULL, lwp->obd_lu_dev,
- lcfg);
-out:
- if (lcfg)
+ if (likely(lwp->obd_lwp_export != NULL)) {
+ class_export_put(lwp->obd_lwp_export);
+ lwp->obd_lwp_export = NULL;
+ }
+
+ lustre_cfg_bufs_reset(bufs, lwp->obd_name);
+ lustre_cfg_bufs_set_string(bufs, 1, NULL);
+ lcfg = lustre_cfg_new(LCFG_CLEANUP, bufs);
+ if (lcfg == NULL)
+ GOTO(out, rc = -ENOMEM);
+
+ /* Disconnect import first. NULL is passed for the '@env',
+ * since it will not be used. */
+ rc = lwp->obd_lu_dev->ld_ops->ldo_process_config(NULL,
+ lwp->obd_lu_dev, lcfg);
lustre_cfg_free(lcfg);
- if (bufs)
+ if (rc != 0 && rc != -ETIMEDOUT) {
+ CERROR("%s: fail to disconnect LWP: rc = %d\n",
+ lwp->obd_name, rc);
+ rc1 = rc;
+ }
+ }
+
+ GOTO(out, rc);
+
+out:
+ if (bufs != NULL)
OBD_FREE_PTR(bufs);
- if (cfg)
+ if (cfg != NULL)
OBD_FREE_PTR(cfg);
- if (lwpname)
- OBD_FREE(lwpname, MTI_NAME_MAXLEN);
- if (logname)
+ if (logname != NULL)
OBD_FREE(logname, MTI_NAME_MAXLEN);
- RETURN(rc);
+
+ return rc1 != 0 ? rc1 : rc;
}
/**
static int lustre_stop_lwp(struct super_block *sb)
{
struct lustre_sb_info *lsi = s2lsi(sb);
- struct obd_device *lwp = NULL;
- char *lwpname = NULL;
- int rc = 0;
+ struct obd_device *lwp;
+ int rc = 0;
+ int rc1 = 0;
ENTRY;
- lwp = lustre_find_lwp(lsi, &lwpname, NULL);
- if (IS_ERR(lwp)) {
- CDEBUG(PTR_ERR(lwp) == -ENOENT ? D_CONFIG : D_ERROR,
- "%s: lwp wasn't started.\n", lsi->lsi_svname);
- GOTO(out, rc = 0);
+ while (!list_empty(&lsi->lsi_lwp_list)) {
+ lwp = list_entry(lsi->lsi_lwp_list.next, struct obd_device,
+ obd_lwp_list);
+ list_del_init(&lwp->obd_lwp_list);
+ lwp->obd_force = 1;
+ rc = class_manual_cleanup(lwp);
+ if (rc != 0) {
+ CERROR("%s: fail to stop LWP: rc = %d\n",
+ lwp->obd_name, rc);
+ rc1 = rc;
+ }
}
- lwp->obd_force = 1;
- rc = class_manual_cleanup(lwp);
-
-out:
- if (lwpname != NULL)
- OBD_FREE(lwpname, MTI_NAME_MAXLEN);
- RETURN(rc);
+ RETURN(rc1 != 0 ? rc1 : rc);
}
/**
- * Start the lwp(fsname-MDT0000-lwp-OSTxxxx) for an OST or MDT target,
- * which would be used to establish connection from OST to MDT0.
+ * Start the lwp(fsname-MDTyyyy-lwp-{MDT,OST}xxxx) for a MDT/OST or MDT target.
**/
static int lustre_start_lwp(struct super_block *sb)
{
struct lustre_sb_info *lsi = s2lsi(sb);
struct config_llog_instance *cfg = NULL;
- struct obd_device *lwp;
- char *lwpname = NULL;
- char *logname = NULL;
+ char *logname;
int rc;
ENTRY;
- lwp = lustre_find_lwp(lsi, &lwpname, &logname);
+ if (unlikely(lsi->lsi_lwp_started))
+ RETURN(0);
- /* the lwp device already stared */
- if (lwp && !IS_ERR(lwp))
- GOTO(out, rc = 0);
-
- if (PTR_ERR(lwp) != -ENOENT)
- GOTO(out, rc = PTR_ERR(lwp));
+ OBD_ALLOC(logname, MTI_NAME_MAXLEN);
+ if (logname == NULL)
+ RETURN(-ENOMEM);
- LASSERT(lwpname != NULL);
- LASSERT(logname != NULL);
+ rc = server_name2fsname(lsi->lsi_svname, logname, NULL);
+ if (rc != 0) {
+ CERROR("%s: failed to get fsname from svname: rc = %d\n",
+ lsi->lsi_svname, rc);
+ GOTO(out, rc = -EINVAL);
+ }
+ strcat(logname, "-client");
OBD_ALLOC_PTR(cfg);
if (cfg == NULL)
GOTO(out, rc = -ENOMEM);
cfg->cfg_callback = client_lwp_config_process;
cfg->cfg_instance = sb;
-
rc = lustre_process_log(sb, logname, cfg);
+ if (rc == 0)
+ lsi->lsi_lwp_started = 1;
+
+ GOTO(out, rc);
+
out:
- if (lwpname != NULL)
- OBD_FREE(lwpname, MTI_NAME_MAXLEN);
- if (logname != NULL)
- OBD_FREE(logname, MTI_NAME_MAXLEN);
+ OBD_FREE(logname, MTI_NAME_MAXLEN);
if (cfg != NULL)
OBD_FREE_PTR(cfg);
- RETURN(rc);
+
+ return rc;
}
DEFINE_MUTEX(server_start_lock);
/** Start server targets: MDTs and OSTs
*/
-static int server_start_targets(struct super_block *sb, struct vfsmount *mnt)
+static int server_start_targets(struct super_block *sb)
{
struct obd_device *obd;
struct lustre_sb_info *lsi = s2lsi(sb);
/* Set the mgc fs to our server disk. This allows the MGC to
* read and write configs locally, in case it can't talk to the MGS. */
- if (lsi->lsi_srv_mnt) {
- rc = server_mgc_set_fs(lsi->lsi_mgc, sb);
- if (rc)
- GOTO(out_stop_service, rc);
- }
+ rc = server_mgc_set_fs(lsi->lsi_mgc, sb);
+ if (rc)
+ GOTO(out_stop_service, rc);
/* Register with MGS */
rc = server_register_target(lsi);
/* Let the target look up the mount using the target's name
(we can't pass the sb or mnt through class_process_config.) */
- rc = server_register_mount(lsi->lsi_svname, sb, mnt);
+ rc = server_register_mount(lsi->lsi_svname, sb);
if (rc)
GOTO(out_mgc, rc);
if (rc == 0) {
struct lu_context session_ctx;
- lu_context_init(&session_ctx, LCT_SESSION);
+ lu_context_init(&session_ctx, LCT_SERVER_SESSION);
session_ctx.lc_thread = NULL;
lu_context_enter(&session_ctx);
env.le_ses = &session_ctx;
out_mgc:
/* Release the mgc fs for others to use */
- if (lsi->lsi_srv_mnt)
- server_mgc_clear_fs(lsi->lsi_mgc);
+ server_mgc_clear_fs(lsi->lsi_mgc);
out_stop_service:
if (rc != 0)
strcpy(lsi->lsi_osd_type, LUSTRE_OSD_LDISKFS_NAME);
}
- /* XXX: a temp. solution for components using fsfilt
+ /* XXX: a temp. solution for components using ldiskfs
* to be removed in one of the subsequent patches */
if (!strcmp(lsi->lsi_lmd->lmd_osd_type, "osd-ldiskfs"))
strcpy(lsi->lsi_fstype, "ldiskfs");
int rc;
rc = lustre_disconnect_lwp(sb);
- if (rc && rc != ETIMEDOUT)
- CERROR("%s: failed to disconnect lwp. (rc=%d)\n",
- tmpname, rc);
+ if (rc != 0 && rc != -ETIMEDOUT &&
+ rc != -ENOTCONN && rc != -ESHUTDOWN)
+ CWARN("%s: failed to disconnect lwp: rc= %d\n",
+ tmpname, rc);
}
/* Stop the target */
obd->obd_lvfs_ctxt.dt = lsi->lsi_dt_dev;
dt_conf_get(NULL, lsi->lsi_dt_dev, &p);
-
- lsi->lsi_srv_mnt = p.ddp_mnt;
-
out:
RETURN(rc);
}
/* Set up all obd devices for service */
if (!(lsi->lsi_lmd->lmd_flags & LMD_FLG_NOSVC) &&
(IS_OST(lsi) || IS_MDT(lsi))) {
- rc = server_start_targets(sb, lsi->lsi_srv_mnt);
+ rc = server_start_targets(sb);
if (rc < 0) {
CERROR("Unable to start targets: %d\n", rc);
GOTO(out_mnt, rc);