* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2013, Intel Corporation.
+ * Copyright (c) 2013, 2014, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#define PRINT_CMD CDEBUG
#define PRINT_MASK (D_SUPER | D_CONFIG)
+#include <linux/statfs.h>
#include <obd.h>
#include <obd_class.h>
#include <lustre/lustre_user.h>
/*********** mount lookup *********/
-DEFINE_MUTEX(lustre_mount_info_lock);
+static DEFINE_MUTEX(lustre_mount_info_lock);
static struct list_head server_mount_info_list =
LIST_HEAD_INIT(server_mount_info_list);
static struct list_head lwp_register_list =
LIST_HEAD_INIT(lwp_register_list);
-DEFINE_MUTEX(lwp_register_list_lock);
+static DEFINE_MUTEX(lwp_register_list_lock);
int lustre_register_lwp_item(const char *lwpname, struct obd_export **exp,
register_lwp_cb cb_func, void *cb_data)
return rc;
}
-DEFINE_MUTEX(server_start_lock);
+static DEFINE_MUTEX(server_start_lock);
/* Stop MDS/OSS if nobody is using them */
static int server_stop_servers(int lsiflags)
static int lsi_prepare(struct lustre_sb_info *lsi)
{
+ const char *osd_type;
+ const char *fstype;
__u32 index;
int rc;
ENTRY;
RETURN(-EINVAL);
}
- if (strlen(lsi->lsi_lmd->lmd_profile) >= sizeof(lsi->lsi_svname))
- RETURN(-ENAMETOOLONG);
-
- strcpy(lsi->lsi_svname, lsi->lsi_lmd->lmd_profile);
-
/* Determine osd type */
- if (lsi->lsi_lmd->lmd_osd_type != NULL) {
- if (strlen(lsi->lsi_lmd->lmd_osd_type) >=
- sizeof(lsi->lsi_osd_type))
- RETURN(-ENAMETOOLONG);
-
- strcpy(lsi->lsi_osd_type, lsi->lsi_lmd->lmd_osd_type);
+ if (lsi->lsi_lmd->lmd_osd_type == NULL) {
+ osd_type = LUSTRE_OSD_LDISKFS_NAME;
+ fstype = "ldiskfs";
} else {
- strcpy(lsi->lsi_osd_type, LUSTRE_OSD_LDISKFS_NAME);
+ osd_type = lsi->lsi_lmd->lmd_osd_type;
+ fstype = lsi->lsi_lmd->lmd_osd_type;
}
+ if (strlen(lsi->lsi_lmd->lmd_profile) >= sizeof(lsi->lsi_svname) ||
+ strlen(osd_type) >= sizeof(lsi->lsi_osd_type) ||
+ strlen(fstype) >= sizeof(lsi->lsi_fstype))
+ RETURN(-ENAMETOOLONG);
+
+ strlcpy(lsi->lsi_svname, lsi->lsi_lmd->lmd_profile,
+ sizeof(lsi->lsi_svname));
+ strlcpy(lsi->lsi_osd_type, osd_type, sizeof(lsi->lsi_osd_type));
/* 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");
- else
- strcpy(lsi->lsi_fstype, lsi->lsi_lmd->lmd_osd_type);
+ strlcpy(lsi->lsi_fstype, fstype, sizeof(lsi->lsi_fstype));
/* Determine server type */
rc = server_name2index(lsi->lsi_svname, &index, NULL);
return -EOPNOTSUPP;
}
-const struct inode_operations server_inode_operations = {
+static const struct inode_operations server_inode_operations = {
.setxattr = lustre_setxattr,
.getxattr = lustre_getxattr,
.listxattr = lustre_listxattr,
struct dt_device_param p;
char flagstr[16];
int rc;
- bool already_started = 0;
ENTRY;
CDEBUG(D_MOUNT,
LASSERT(obd);
} else {
CDEBUG(D_MOUNT, "%s already started\n", lsi->lsi_osd_obdname);
- already_started = 1;
/* but continue setup to allow special case of MDT and internal
- * MGT being started separately, that will be identified in
- * caller server_fill_super().
- */
+ * MGT being started separately. */
+ if (!((IS_MGS(lsi) && (lsi->lsi_lmd->lmd_flags &
+ LMD_FLG_NOMGS)) ||
+ (IS_MDT(lsi) && (lsi->lsi_lmd->lmd_flags &
+ LMD_FLG_NOSVC))))
+ RETURN(-EALREADY);
}
rc = obd_connect(NULL, &lsi->lsi_osd_exp,
OBD_FAIL_TIMEOUT(OBD_FAIL_TGT_DELAY_CONNECT, 10);
if (rc) {
- if (!already_started) {
- obd->obd_force = 1;
- class_manual_cleanup(obd);
- lsi->lsi_dt_dev = NULL;
- }
- GOTO(out, rc);
+ obd->obd_force = 1;
+ class_manual_cleanup(obd);
+ lsi->lsi_dt_dev = NULL;
+ RETURN(rc);
}
LASSERT(obd->obd_lu_dev);
dt_conf_get(NULL, lsi->lsi_dt_dev, &p);
out:
- RETURN(already_started ? -EALREADY : rc);
+ RETURN(rc);
}
/** Fill in the superblock info for a Lustre server.
/* Start low level OSD */
rc = osd_start(lsi, sb->s_flags);
- /* Handle separate nosvc and nomgs case */
- if (rc && ((rc != -EALREADY) || !(lsi->lsi_lmd->lmd_flags &
- (LMD_FLG_NOSVC|LMD_FLG_NOMGS)))) {
+ if (rc) {
CERROR("Unable to start osd on %s: %d\n",
lsi->lsi_lmd->lmd_dev, rc);
lustre_put_lsi(sb);