From 725b8599bbf4c98173cc049d8a73920a31287d5c Mon Sep 17 00:00:00 2001 From: Liu Xuezhao Date: Mon, 9 Jul 2012 16:54:09 +0800 Subject: [PATCH] LU-1337 vfs: kernel 3.3 hides vfsmount guts 3.3 starts hiding vfsmount guts series (move from include/linux/mount.h to fs/mount.h, kernel commit 7d6fec45a5131918b51dcd76da52f2ec86a85be6). Add HAVE_HIDE_VFSMOUNT_GUTS macro to differentiate it. Signed-off-by: Liu Xuezhao Change-Id: If69b4f75e74a64d2c07c082053e639b75585bfc9 Reviewed-on: http://review.whamcloud.com/3399 Tested-by: Hudson Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Yang Sheng --- lustre/autoconf/lustre-core.m4 | 32 +++++++++++++++++++++++--------- lustre/include/linux/lustre_compat25.h | 27 +++++++++++++++++++-------- lustre/mgs/lproc_mgs.c | 11 ++++++----- lustre/obdclass/lprocfs_status.c | 12 ++++++------ lustre/obdclass/obd_mount.c | 18 +++++++++--------- lustre/osd-ldiskfs/osd_lproc.c | 8 ++++---- 6 files changed, 67 insertions(+), 41 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 72f3e09..f67f95f 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1773,20 +1773,34 @@ AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1, # # 2.6.38 vfsmount.mnt_count doesn't use atomic_t # +# 3.3 starts hiding vfsmount guts series (move from include/linux/mount.h to +# fs/mount.h, see kernel commit 7d6fec45a5131918b51dcd76da52f2ec86a85be6) +# AC_DEFUN([LC_ATOMIC_MNT_COUNT], -[AC_MSG_CHECKING([if vfsmount.mnt_count is atomic_t]) +[AC_MSG_CHECKING([if vfsmount guts is hidden, or vfsmount.mnt_count is atomic_t.]) LB_LINUX_TRY_COMPILE([ - #include - #include - #include + #include + #include <../fs/mount.h> ],[ - ((struct vfsmount *)0)->mnt_count = ((atomic_t) { 0 }); + struct mount *mnt = real_mount((struct vfsmount *)0); ],[ - AC_DEFINE(HAVE_ATOMIC_MNT_COUNT, 1, - [vfsmount.mnt_count is atomic_t]) - AC_MSG_RESULT([yes]) + AC_DEFINE(HAVE_HIDE_VFSMOUNT_GUTS, 1, + [hide vfsmount guts in fs/mount.h]) + AC_MSG_RESULT([yes, hide vfsmount guts in fs/mount.h]) ],[ - AC_MSG_RESULT([no]) + LB_LINUX_TRY_COMPILE([ + #include + #include + #include + ],[ + ((struct vfsmount *)0)->mnt_count = ((atomic_t) { 0 }); + ],[ + AC_DEFINE(HAVE_ATOMIC_MNT_COUNT, 1, + [vfsmount.mnt_count is atomic_t]) + AC_MSG_RESULT([yes, vfsmount.mnt_count is atomic_t]) + ],[ + AC_MSG_RESULT([no]) + ]) ]) ]) diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index dcbbda8..b717b90 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -276,24 +276,35 @@ static inline int mapping_has_pages(struct address_space *mapping) #include /* for generic_writepages */ +#ifdef HAVE_HIDE_VFSMOUNT_GUTS +# include <../fs/mount.h> +#else +# define real_mount(mnt) (mnt) +#endif + +static inline const char *mnt_get_devname(struct vfsmount *mnt) +{ + return real_mount(mnt)->mnt_devname; +} + #ifndef HAVE_ATOMIC_MNT_COUNT static inline unsigned int mnt_get_count(struct vfsmount *mnt) { #ifdef CONFIG_SMP - unsigned int count = 0; - int cpu; + unsigned int count = 0; + int cpu; - for_each_possible_cpu(cpu) { - count += per_cpu_ptr(mnt->mnt_pcp, cpu)->mnt_count; - } + for_each_possible_cpu(cpu) { + count += per_cpu_ptr(real_mount(mnt)->mnt_pcp, cpu)->mnt_count; + } - return count; + return count; #else - return mnt->mnt_count; + return real_mount(mnt)->mnt_count; #endif } #else -# define mnt_get_count(mnt) cfs_atomic_read(&mnt->mnt_count) +# define mnt_get_count(mnt) cfs_atomic_read(&(real_mount(mnt)->mnt_count)) #endif #ifdef HAVE_STATFS_DENTRY_PARAM diff --git a/lustre/mgs/lproc_mgs.c b/lustre/mgs/lproc_mgs.c index 5833a13..fad189e 100644 --- a/lustre/mgs/lproc_mgs.c +++ b/lustre/mgs/lproc_mgs.c @@ -48,13 +48,14 @@ static int lprocfs_mgs_rd_mntdev(char *page, char **start, off_t off, int count, int *eof, void *data) { - struct obd_device* obd = (struct obd_device *)data; + struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - LASSERT(obd->u.mgs.mgs_vfsmnt->mnt_devname); - *eof = 1; + LASSERT(obd != NULL); + LASSERT(mnt_get_devname(obd->u.mgs.mgs_vfsmnt)); + *eof = 1; - return snprintf(page, count, "%s\n",obd->u.mgs.mgs_vfsmnt->mnt_devname); + return snprintf(page, count, "%s\n", + mnt_get_devname(obd->u.mgs.mgs_vfsmnt)); } static int mgs_fs_seq_show(struct seq_file *seq, void *v) diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 415b186..cca78bc 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -2522,13 +2522,13 @@ EXPORT_SYMBOL(lprocfs_obd_wr_recovery_time_hard); int lprocfs_obd_rd_mntdev(char *page, char **start, off_t off, int count, int *eof, void *data) { - struct obd_device *obd = (struct obd_device *)data; + struct obd_device *obd = (struct obd_device *)data; - LASSERT(obd != NULL); - LASSERT(obd->u.obt.obt_vfsmnt->mnt_devname); - *eof = 1; - return snprintf(page, count, "%s\n", - obd->u.obt.obt_vfsmnt->mnt_devname); + LASSERT(obd != NULL); + LASSERT(mnt_get_devname(obd->u.obt.obt_vfsmnt)); + *eof = 1; + return snprintf(page, count, "%s\n", + mnt_get_devname(obd->u.obt.obt_vfsmnt)); } EXPORT_SYMBOL(lprocfs_obd_rd_mntdev); diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 56a4492..e26df3c 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1666,15 +1666,15 @@ static void server_wait_finished(struct vfsmount *mnt) (mnt_get_count(mnt) == 1), cfs_time_seconds(3), rc); - cfs_restore_sigs(blocked); - if (rc < 0) { - LCONSOLE_EMERG("Danger: interrupted umount %s with " - "%d refs!\n", mnt->mnt_devname, - mnt_get_count(mnt)); - break; - } - - } + cfs_restore_sigs(blocked); + if (rc < 0) { + LCONSOLE_EMERG("Danger: interrupted umount %s with " + "%d refs!\n", mnt_get_devname(mnt), + mnt_get_count(mnt)); + break; + } + + } } /** Start the shutdown of servers at umount. diff --git a/lustre/osd-ldiskfs/osd_lproc.c b/lustre/osd-ldiskfs/osd_lproc.c index e264c34..d05bac6 100644 --- a/lustre/osd-ldiskfs/osd_lproc.c +++ b/lustre/osd-ldiskfs/osd_lproc.c @@ -328,11 +328,11 @@ static int lprocfs_osd_rd_mntdev(char *page, char **start, off_t off, int count, if (unlikely(osd->od_mount == NULL)) return -EINPROGRESS; - LASSERT(osd->od_mount->lmi_mnt->mnt_devname); - *eof = 1; + LASSERT(mnt_get_devname(osd->od_mount->lmi_mnt)); + *eof = 1; - return snprintf(page, count, "%s\n", - osd->od_mount->lmi_mnt->mnt_devname); + return snprintf(page, count, "%s\n", + mnt_get_devname(osd->od_mount->lmi_mnt)); } #ifdef HAVE_LDISKFS_PDO -- 1.8.3.1