Whamcloud - gitweb
LU-1337 vfs: kernel 3.3 hides vfsmount guts
authorLiu Xuezhao <xuezhao.liu@emc.com>
Mon, 9 Jul 2012 08:54:09 +0000 (16:54 +0800)
committerOleg Drokin <green@whamcloud.com>
Tue, 24 Jul 2012 04:57:02 +0000 (00:57 -0400)
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 <xuezhao.liu@emc.com>
Change-Id: If69b4f75e74a64d2c07c082053e639b75585bfc9
Reviewed-on: http://review.whamcloud.com/3399
Tested-by: Hudson
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
lustre/autoconf/lustre-core.m4
lustre/include/linux/lustre_compat25.h
lustre/mgs/lproc_mgs.c
lustre/obdclass/lprocfs_status.c
lustre/obdclass/obd_mount.c
lustre/osd-ldiskfs/osd_lproc.c

index 72f3e09..f67f95f 100644 (file)
@@ -1773,20 +1773,34 @@ AC_DEFINE(HAVE_BLKDEV_GET_BY_DEV, 1,
 #
 # 2.6.38 vfsmount.mnt_count doesn't use atomic_t
 #
 #
 # 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_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([
 LB_LINUX_TRY_COMPILE([
-        #include <asm/atomic.h>
-        #include <linux/fs.h>
-        #include <linux/mount.h>
+       #include <linux/fs.h>
+       #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 <asm/atomic.h>
+               #include <linux/fs.h>
+               #include <linux/mount.h>
+       ],[
+               ((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])
+       ])
 ])
 ])
 
 ])
 ])
 
index dcbbda8..b717b90 100644 (file)
@@ -276,24 +276,35 @@ static inline int mapping_has_pages(struct address_space *mapping)
 
 #include <linux/mpage.h>        /* for generic_writepages */
 
 
 #include <linux/mpage.h>        /* 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
 #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
 #else
-        return mnt->mnt_count;
+       return real_mount(mnt)->mnt_count;
 #endif
 }
 #else
 #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
 #endif
 
 #ifdef HAVE_STATFS_DENTRY_PARAM
index 5833a13..fad189e 100644 (file)
 static int lprocfs_mgs_rd_mntdev(char *page, char **start, off_t off, int count,
                                  int *eof, void *data)
 {
 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)
 }
 
 static int mgs_fs_seq_show(struct seq_file *seq, void *v)
index 415b186..cca78bc 100644 (file)
@@ -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)
 {
 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);
 
 }
 EXPORT_SYMBOL(lprocfs_obd_rd_mntdev);
 
index 56a4492..e26df3c 100644 (file)
@@ -1666,15 +1666,15 @@ static void server_wait_finished(struct vfsmount *mnt)
                        (mnt_get_count(mnt) == 1),
                        cfs_time_seconds(3),
                        rc);
                        (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.
 }
 
 /** Start the shutdown of servers at umount.
index e264c34..d05bac6 100644 (file)
@@ -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;
 
         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
 }
 
 #ifdef HAVE_LDISKFS_PDO