Whamcloud - gitweb
b=23118 Change for new backing_dev_info interface.
authoryangsheng <Sheng.Yang@Sun.COM>
Thu, 24 Jun 2010 13:34:12 +0000 (21:34 +0800)
committerJohann Lombardi <johann@sun.com>
Thu, 24 Jun 2010 15:19:26 +0000 (17:19 +0200)
i=kalpak
i=johann

lustre/autoconf/lustre-core.m4
lustre/include/lustre_disk.h
lustre/llite/llite_lib.c

index c63e6b4..3689184 100644 (file)
@@ -1723,6 +1723,23 @@ LB_LINUX_TRY_COMPILE([
 ])
 ])
 
+# 2.6.32 has new BDI interface.
+AC_DEFUN([LC_NEW_BACKING_DEV_INFO],
+[AC_MSG_CHECKING([if backing_dev_info has a bdi_list field])
+LB_LINUX_TRY_COMPILE([
+        #include <linux/backing-dev.h>
+],[
+        struct backing_dev_info bdi;
+        memset(&bdi.bdi_list, 0x00, sizeof(bdi.bdi_list));
+],[
+        AC_MSG_RESULT(yes)
+        AC_DEFINE(HAVE_NEW_BACKING_DEV_INFO, 1,
+                  [backing_dev_info has a bdi_list field])
+],[
+        AC_MSG_RESULT(no)
+])
+])
+
 #
 # LC_PROG_LINUX
 #
@@ -1878,6 +1895,9 @@ AC_DEFUN([LC_PROG_LINUX],
 
           # 2.6.31
           LC_BLK_QUEUE_LOG_BLK_SIZE
+        
+          # 2.6.32
+          LC_NEW_BACKING_DEV_INFO
 ])
 
 #
index e902569..b14eb82 100644 (file)
@@ -296,6 +296,9 @@ struct lustre_sb_info {
         struct ll_sb_info        *lsi_llsbi;   /* add'l client sbi info */
         struct vfsmount          *lsi_srv_mnt; /* the one server mount */
         atomic_t                  lsi_mounts;  /* references to the srv_mnt */
+#ifdef HAVE_NEW_BACKING_DEV_INFO
+        struct backing_dev_info   bdi;         /* Each client mountpoint needs own backing_dev_info */
+#endif
 };
 
 #define LSI_SERVER                       0x00000001
index c28ee0a..8e07388 100644 (file)
@@ -995,6 +995,20 @@ out:
 }
 /* end COMPAT_146 */
 
+static struct backing_dev_info ll_backing_dev_info = {
+        .ra_pages       = 0,    /* No readahead */
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12))
+        .capabilities   = 0,    /* Does contribute to dirty memory */
+#else
+        .memory_backed  = 0,    /* Does contribute to dirty memory */
+#endif
+#ifdef HAVE_NEW_BACKING_DEV_INFO
+        .wb_cnt = 0,
+#endif
+};
+
+static atomic_t ll_bdi_num = ATOMIC_INIT(0);
+
 int ll_fill_super(struct super_block *sb)
 {
         struct lustre_profile *lprof = NULL;
@@ -1123,6 +1137,22 @@ int ll_fill_super(struct super_block *sb)
 
         /* connections, registrations, sb setup */
         err = client_common_fill_super(sb, mdc, osc);
+        if (err)
+                GOTO(out_free, err);
+
+#ifdef HAVE_NEW_BACKING_DEV_INFO
+        lsi->bdi = ll_backing_dev_info;
+        err = bdi_init(&lsi->bdi);
+        if (err)
+                GOTO(out_free, err);
+
+        err = bdi_register(&lsi->bdi, NULL, "lustre-%d",
+                                atomic_inc_return(&ll_bdi_num));
+        if (err) {
+                bdi_destroy(&lsi->bdi);
+                GOTO(out_free, err);
+        }
+#endif
 
 out_free:
         if (save && lprof)
@@ -1186,6 +1216,11 @@ void ll_put_super(struct super_block *sb)
         if (profilenm)
                 class_del_profile(profilenm);
 
+#ifdef HAVE_NEW_BACKING_DEV_INFO
+        if (lsi->bdi.wb_cnt > 0)
+                bdi_destroy(&lsi->bdi);
+#endif
+
         ll_free_sbi(sb);
         lsi->lsi_llsbi = NULL;
 
@@ -1955,15 +1990,6 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md)
         EXIT;
 }
 
-static struct backing_dev_info ll_backing_dev_info = {
-        .ra_pages       = 0,    /* No readahead */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12))
-        .capabilities   = 0,    /* Does contribute to dirty memory */
-#else
-        .memory_backed  = 0,    /* Does contribute to dirty memory */
-#endif
-};
-
 void ll_read_inode2(struct inode *inode, void *opaque)
 {
         struct lustre_md *md = opaque;
@@ -2008,7 +2034,11 @@ void ll_read_inode2(struct inode *inode, void *opaque)
                 init_special_inode(inode, inode->i_mode,
                                    kdev_t_to_nr(inode->i_rdev));
                 /* initializing backing dev info. */
+#ifdef HAVE_NEW_BACKING_DEV_INFO
+                inode->i_mapping->backing_dev_info = &(s2lsi(inode->i_sb)->bdi);
+#else
                 inode->i_mapping->backing_dev_info = &ll_backing_dev_info;
+#endif
                 EXIT;
         }
 }