From d7756663bc659044b3a63a3236d6d5fec264add2 Mon Sep 17 00:00:00 2001 From: Swapnil Pimpale Date: Fri, 21 Mar 2014 15:26:36 -0400 Subject: [PATCH] LU-4795 obd: Remove server_{get,put}_mount_2() functions This patch fixes server_put_mount() to call server_deregister_mount() only if the caller is never going to need the mount again. The only caller of server_get_mount_2(), lustre_find_lwp_by_index(), is changed to now call server_get_mount() and server_put_mount() without calling server_deregister_mount(). Signed-off-by: Swapnil Pimpale Change-Id: I37fd00bd477f946ac1bd8375da4899c2a1fe9e22 Reviewed-on: http://review.whamcloud.com/9749 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Mike Pershin --- lustre/include/lustre_disk.h | 4 +-- lustre/mdt/mdt_handler.c | 4 +-- lustre/mgs/mgs_handler.c | 4 +-- lustre/obdclass/obd_mount.c | 14 +++++----- lustre/obdclass/obd_mount_server.c | 53 ++++++++++++++------------------------ lustre/ofd/ofd_dev.c | 2 +- 6 files changed, 33 insertions(+), 48 deletions(-) diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index a61f7be..567e194 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -548,9 +548,7 @@ int lustre_common_put_super(struct super_block *sb); /* obd_mount_server.c */ int server_fill_super(struct super_block *sb); struct lustre_mount_info *server_get_mount(const char *name); -struct lustre_mount_info *server_get_mount_2(const char *name); -int server_put_mount(const char *name); -int server_put_mount_2(const char *name, struct vfsmount *mnt); +int server_put_mount(const char *name, bool dereg_mnt); struct mgs_target_info; int server_mti_print(const char *title, struct mgs_target_info *mti); void server_calc_timeout(struct lustre_sb_info *lsi, struct obd_device *obd); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index a0b8b55..9f84d08 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -4389,7 +4389,7 @@ static void mdt_fini(const struct lu_env *env, struct mdt_device *m) LASSERT(atomic_read(&d->ld_ref) == 0); - server_put_mount(mdt_obd_name(m)); + server_put_mount(mdt_obd_name(m), true); EXIT; } @@ -4645,7 +4645,7 @@ err_fini_stack: mdt_stack_fini(env, m, md2lu_dev(m->mdt_child)); err_lmi: if (lmi) - server_put_mount(dev); + server_put_mount(dev, true); return(rc); } diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 48209ac..b0c5be7 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -1232,7 +1232,7 @@ err_ops: obd_disconnect(mgs->mgs_bottom_exp); err_lmi: if (lmi) - server_put_mount(lustre_cfg_string(lcfg, 0)); + server_put_mount(lustre_cfg_string(lcfg, 0), true); RETURN(rc); } @@ -1404,7 +1404,7 @@ static struct lu_device *mgs_device_fini(const struct lu_env *env, LASSERT(mgs->mgs_bottom_exp); obd_disconnect(mgs->mgs_bottom_exp); - server_put_mount(obd->obd_name); + server_put_mount(obd->obd_name, true); RETURN(NULL); } diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index f6e4690..2289b8d 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -645,10 +645,10 @@ static int lustre_free_lsi(struct super_block *sb) e.g. MDT, MGS, and potentially MGC */ int lustre_put_lsi(struct super_block *sb) { - struct lustre_sb_info *lsi = s2lsi(sb); - ENTRY; + struct lustre_sb_info *lsi = s2lsi(sb); + ENTRY; - LASSERT(lsi != NULL); + LASSERT(lsi != NULL); CDEBUG(D_MOUNT, "put %p %d\n", sb, atomic_read(&lsi->lsi_mounts)); if (atomic_dec_and_test(&lsi->lsi_mounts)) { @@ -660,10 +660,10 @@ int lustre_put_lsi(struct super_block *sb) /* wait till OSD is gone */ obd_zombie_barrier(); } - lustre_free_lsi(sb); - RETURN(1); - } - RETURN(0); + lustre_free_lsi(sb); + RETURN(1); + } + RETURN(0); } /*** SERVER NAME *** diff --git a/lustre/obdclass/obd_mount_server.c b/lustre/obdclass/obd_mount_server.c index d67963b..02d2cb0 100644 --- a/lustre/obdclass/obd_mount_server.c +++ b/lustre/obdclass/obd_mount_server.c @@ -173,28 +173,19 @@ struct lustre_mount_info *server_get_mount(const char *name) } EXPORT_SYMBOL(server_get_mount); -/* - * Used by mdt to get mount_info from obdname. - * There are no blocking when using the mount_info. - * Do not use server_get_mount for this purpose. +/** + * server_put_mount: to be called from obd_cleanup methods + * @name: obd name + * @dereg_mnt: 0 or 1 depending on whether the mount is to be deregistered or + * not + * + * The caller decides whether server_deregister_mount() needs to be called or + * not. Calling of server_deregister_mount() does not depend on refcounting on + * lsi because we could have say the mgs and mds on the same node and we + * unmount the mds, then the ref on the lsi would still be non-zero but we + * would still want to deregister the mds mount. */ -struct lustre_mount_info *server_get_mount_2(const char *name) -{ - struct lustre_mount_info *lmi; - ENTRY; - - mutex_lock(&lustre_mount_info_lock); - lmi = server_find_mount(name); - mutex_unlock(&lustre_mount_info_lock); - if (!lmi) - CERROR("Can't find mount for %s\n", name); - - RETURN(lmi); -} -EXPORT_SYMBOL(server_get_mount_2); - -/* to be called from obd_cleanup methods */ -int server_put_mount(const char *name) +int server_put_mount(const char *name, bool dereg_mnt) { struct lustre_mount_info *lmi; struct lustre_sb_info *lsi; @@ -216,21 +207,14 @@ int server_put_mount(const char *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); + if (dereg_mnt) + /* this obd should never need the mount again */ + server_deregister_mount(name); RETURN(0); } EXPORT_SYMBOL(server_put_mount); -/* Corresponding to server_get_mount_2 */ -int server_put_mount_2(const char *name, struct vfsmount *mnt) -{ - ENTRY; - RETURN(0); -} -EXPORT_SYMBOL(server_put_mount_2); - /* Set up a MGS to serve startup logs */ static int server_start_mgs(struct super_block *sb) { @@ -468,7 +452,7 @@ struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx) char lwp_name[24]; int rc; - lmi = server_get_mount_2(dev); + lmi = server_get_mount(dev); if (lmi == NULL) return NULL; @@ -477,7 +461,7 @@ struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx) if (rc != 0) { CERROR("%s: failed to get fsname: rc = %d\n", lsi->lsi_svname, rc); - return NULL; + goto err_lmi; } snprintf(lwp_name, sizeof(lwp_name), "%s-MDT%04x", fsname, idx); @@ -492,6 +476,9 @@ struct obd_export *lustre_find_lwp_by_index(const char *dev, __u32 idx) } spin_unlock(&lsi->lsi_lwp_lock); +err_lmi: + server_put_mount(dev, false); + return exp; } EXPORT_SYMBOL(lustre_find_lwp_by_index); diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 4e4fd1c..7f24f32 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -2293,7 +2293,7 @@ static void ofd_fini(const struct lu_env *env, struct ofd_device *m) ofd_stack_fini(env, m, &m->ofd_dt_dev.dd_lu_dev); ofd_procfs_fini(m); LASSERT(atomic_read(&d->ld_ref) == 0); - server_put_mount(obd->obd_name); + server_put_mount(obd->obd_name, true); EXIT; } -- 1.8.3.1