X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Fobd_mount_server.c;h=b617d4c50f010bda0a3f5decae4fa068037a874d;hb=fee90a75e11d68f348decd00f698849d085069f2;hp=01fd9e00cba1f15bec391576986d422063358422;hpb=10cf5e4ec079fed1fa339240e00c027232f7971e;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/obdclass/obd_mount_server.c index 01fd9e0..b617d4c 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) 2011, 2012, Intel Corporation. + * Copyright (c) 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -47,8 +47,6 @@ #define PRINT_MASK (D_SUPER | D_CONFIG) #include -#include -#include #include #include #include @@ -58,6 +56,9 @@ #ifdef HAVE_KERNEL_LOCKED #include #endif +#ifdef HAVE_SELINUX_IS_ENABLED +#include +#endif /*********** mount lookup *********/ @@ -82,8 +83,7 @@ static struct lustre_mount_info *server_find_mount(const char *name) /* 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; @@ -112,12 +112,11 @@ static int server_register_mount(const char *name, struct super_block *sb, } 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); } @@ -136,7 +135,7 @@ static int server_deregister_mount(const char *name) 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); @@ -166,7 +165,7 @@ struct lustre_mount_info *server_get_mount(const char *name) cfs_atomic_inc(&lsi->lsi_mounts); - CDEBUG(D_MOUNT, "get_mnt %p from %s, refs=%d\n", lmi->lmi_mnt, + CDEBUG(D_MOUNT, "get mount %p from %s, refs=%d\n", lmi->lmi_sb, name, cfs_atomic_read(&lsi->lsi_mounts)); RETURN(lmi); @@ -194,7 +193,7 @@ struct lustre_mount_info *server_get_mount_2(const char *name) 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; @@ -209,12 +208,12 @@ int server_put_mount(const char *name, struct vfsmount *mnt) } 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, cfs_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); @@ -235,7 +234,6 @@ EXPORT_SYMBOL(server_put_mount_2); 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; @@ -252,15 +250,20 @@ static int server_start_mgs(struct super_block *sb) 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, LUSTRE_MGS_OBDNAME, 0, 0, lsi->lsi_osd_obdname, 0); - /* Do NOT call server_deregister_mount() here. This leads to - * inability cleanup cleanly and free lsi and other stuff when - * mgs calls server_put_mount() in error handling case. -umka */ + /* server_deregister_mount() is not called previously, for lsi + * and other stuff can't be freed cleanly when mgs calls + * server_put_mount() in error handling case (see b=17758), + * this problem is caused by a bug in mgs_init0, which forgot + * calling server_put_mount in error case. */ + + if (rc) + server_deregister_mount(LUSTRE_MGS_OBDNAME); } if (rc) @@ -508,7 +511,7 @@ static int lustre_lwp_connect(struct obd_device *lwp) 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; @@ -560,7 +563,6 @@ out: **/ static int lustre_lwp_setup(struct lustre_cfg *lcfg, struct lustre_sb_info *lsi) { - struct obd_connect_data *data = NULL; struct obd_device *obd; char *lwpname = NULL; char *lwpuuid = NULL; @@ -605,8 +607,6 @@ static int lustre_lwp_setup(struct lustre_cfg *lcfg, struct lustre_sb_info *lsi) if (rc != 0) CERROR("%s: connect failed: rc = %d\n", lwpname, rc); out: - if (data != NULL) - OBD_FREE_PTR(data); if (lwpname != NULL) OBD_FREE(lwpname, MTI_NAME_MAXLEN); if (lwpuuid != NULL) @@ -978,13 +978,9 @@ static int server_stop_servers(int lsiflags) } if (obd != NULL && (type == NULL || type->typ_refcnt == 0)) { - int err; - obd->obd_force = 1; /* obd_fail doesn't mean much on a server obd */ - err = class_manual_cleanup(obd); - if (rc != 0) - rc = err; + rc = class_manual_cleanup(obd); } mutex_unlock(&server_start_lock); @@ -1180,7 +1176,7 @@ out: /** 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); @@ -1231,11 +1227,9 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) /* 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); @@ -1244,7 +1238,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) /* 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); @@ -1291,7 +1285,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) 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; @@ -1314,8 +1308,7 @@ static int server_start_targets(struct super_block *sb, struct vfsmount *mnt) 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) @@ -1355,7 +1348,7 @@ static int lsi_prepare(struct lustre_sb_info *lsi) 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"); @@ -1553,6 +1546,35 @@ static struct super_operations server_ops = { .statfs = server_statfs, }; +/* + * Xattr support for Lustre servers + */ +static ssize_t lustre_getxattr(struct dentry *dentry, const char *name, + void *buffer, size_t size) +{ + if (!selinux_is_enabled()) + return -EOPNOTSUPP; + return -ENODATA; +} + +static int lustre_setxattr(struct dentry *dentry, const char *name, + const void *value, size_t size, int flags) +{ + return -EOPNOTSUPP; +} + +static ssize_t lustre_listxattr(struct dentry *d_entry, char *name, + size_t size) +{ + return -EOPNOTSUPP; +} + +const struct inode_operations server_inode_operations = { + .setxattr = lustre_setxattr, + .getxattr = lustre_getxattr, + .listxattr = lustre_listxattr, +}; + #define log2(n) ffz(~(n)) #define LUSTRE_SUPER_MAGIC 0x0BD00BD1 @@ -1580,7 +1602,7 @@ static int server_fill_super_common(struct super_block *sb) /* make_bad_inode(root); -- badness - can't umount */ /* apparently we need to be a directory for the mount to finish */ root->i_mode = S_IFDIR; - + root->i_op = &server_inode_operations; sb->s_root = d_make_root(root); if (!sb->s_root) { CERROR("%s: can't make root dentry\n", sb->s_id); @@ -1627,18 +1649,19 @@ static int osd_start(struct lustre_sb_info *lsi, unsigned long mflags) obd->obd_force = 1; class_manual_cleanup(obd); lsi->lsi_dt_dev = NULL; + RETURN(rc); } - /* XXX: to keep support old components relying on lsi_srv_mnt - * we get this info from OSD just started */ LASSERT(obd->obd_lu_dev); + lu_device_get(obd->obd_lu_dev); lsi->lsi_dt_dev = lu2dt_dev(obd->obd_lu_dev); LASSERT(lsi->lsi_dt_dev); - dt_conf_get(NULL, lsi->lsi_dt_dev, &p); - - lsi->lsi_srv_mnt = p.ddp_mnt; + /* set disk context for llog usage */ + OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt); + obd->obd_lvfs_ctxt.dt = lsi->lsi_dt_dev; + dt_conf_get(NULL, lsi->lsi_dt_dev, &p); out: RETURN(rc); } @@ -1694,7 +1717,7 @@ int server_fill_super(struct super_block *sb) /* 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);