X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=sidebyside;f=lustre%2Fobdclass%2Fobd_mount_server.c;h=148cbf3899c2daa695e12a4e952c8b35e5a5799c;hb=2b294992edce5af7b79d4300ed3aa1ea6a8db850;hp=f0b169e4d08e7819044c35383e12ec1f7dccf322;hpb=166c5ba95cb2a4771317e030a3649e4480c8cbad;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/obdclass/obd_mount_server.c index f0b169e..148cbf3 100644 --- a/lustre/obdclass/obd_mount_server.c +++ b/lustre/obdclass/obd_mount_server.c @@ -27,7 +27,7 @@ * 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/ @@ -46,6 +46,7 @@ #define PRINT_CMD CDEBUG #define PRINT_MASK (D_SUPER | D_CONFIG) +#include #include #include #include @@ -63,7 +64,7 @@ /*********** 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); @@ -377,7 +378,7 @@ EXPORT_SYMBOL(tgt_name2lwp_name); 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) @@ -998,7 +999,7 @@ out: 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) @@ -1367,6 +1368,8 @@ out_stop_service: static int lsi_prepare(struct lustre_sb_info *lsi) { + const char *osd_type; + const char *fstype; __u32 index; int rc; ENTRY; @@ -1380,28 +1383,26 @@ static int lsi_prepare(struct lustre_sb_info *lsi) 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); @@ -1618,7 +1619,7 @@ static ssize_t lustre_listxattr(struct dentry *d_entry, char *name, 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, @@ -1668,7 +1669,6 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags) struct dt_device_param p; char flagstr[16]; int rc; - bool already_started = 0; ENTRY; CDEBUG(D_MOUNT, @@ -1693,11 +1693,13 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags) 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, @@ -1706,12 +1708,10 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags) 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); @@ -1725,7 +1725,7 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags) 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. @@ -1745,9 +1745,7 @@ int server_fill_super(struct super_block *sb) /* 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);