From: Vitaly Fertman Date: Thu, 4 Nov 2010 20:53:32 +0000 (+0300) Subject: b=23064 Adopt for new backing_dev_info interface. X-Git-Tag: 2.0.55.0~1 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=e218d06f97d0c3bb8ddba68060320a1ff45984b8 b=23064 Adopt for new backing_dev_info interface. o=yangsheng i=dmitry --- diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 07d339e..bb9bf6e 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -1899,6 +1899,33 @@ 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 wb_cnt field]) +LB_LINUX_TRY_COMPILE([ + #include +],[ + struct backing_dev_info bdi; + bdi.wb_cnt = 0; +],[ + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_NEW_BACKING_DEV_INFO, 1, + [backing_dev_info has a wb_cnt field]) +],[ + AC_MSG_RESULT(no) +]) +]) + +# 2.6.24 has bdi_init()/bdi_destroy() functions. +AC_DEFUN([LC_EXPORT_BDI_INIT], +[LB_CHECK_SYMBOL_EXPORT([bdi_init], +[mm/backing-dev.c],[ + AC_DEFINE(HAVE_BDI_INIT, 1, + [bdi_init/bdi_destroy functions are present]) +],[ +]) +]) + # # LC_PROG_LINUX # @@ -2011,6 +2038,7 @@ AC_DEFUN([LC_PROG_LINUX], LC_STRUCT_HASH_DESC LC_STRUCT_BLKCIPHER_DESC LC_FS_RENAME_DOES_D_MOVE + # 2.6.23 LC_UNREGISTER_BLKDEV_RETURN_INT LC_KERNEL_SPLICE_READ @@ -2024,6 +2052,7 @@ AC_DEFUN([LC_PROG_LINUX], LC_BIO_ENDIO_2ARG LC_FH_TO_DENTRY LC_PROCFS_DELETED + LC_EXPORT_BDI_INIT #2.6.25 LC_MAPPING_CAP_WRITEBACK_DIRTY @@ -2055,6 +2084,7 @@ AC_DEFUN([LC_PROG_LINUX], # 2.6.32 LC_DQUOT_INIT LC_REQUEST_QUEUE_LIMITS + LC_NEW_BACKING_DEV_INFO # if test x$enable_server = xyes ; then diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index d2b3f80..05af255 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -805,5 +805,19 @@ static inline int ll_quota_off(struct super_block *sb, int off, int remount) # define ll_vfs_dq_drop vfs_dq_drop #endif +#ifdef HAVE_BDI_INIT +#define ll_bdi_init(bdi) bdi_init(bdi) +#define ll_bdi_destroy(bdi) bdi_destroy(bdi) +#else +#define ll_bdi_init(bdi) 0 +#define ll_bdi_destroy(bdi) do { } while(0) +#endif + +#ifdef HAVE_NEW_BACKING_DEV_INFO +#define ll_bdi_wb_cnt(bdi) ((bdi).wb_cnt) +#else +#define ll_bdi_wb_cnt(bdi) 1 +#endif + #endif /* __KERNEL__ */ #endif /* _COMPAT25_H */ diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index 0915d80..8c3e8c8 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -436,6 +436,7 @@ struct lustre_sb_info { struct ll_sb_info *lsi_llsbi; /* add'l client sbi info */ struct vfsmount *lsi_srv_mnt; /* the one server mount */ cfs_atomic_t lsi_mounts; /* references to the srv_mnt */ + struct backing_dev_info bdi; /* Each client mountpoint needs own backing_dev_info */ }; #define LSI_SERVER 0x00000001 diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 5c98d39..c3e66ba 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -817,6 +817,10 @@ void ll_lli_init(struct ll_inode_info *lli) cfs_spin_lock_init(&lli->lli_sa_lock); } +#ifdef HAVE_NEW_BACKING_DEV_INFO +static atomic_t ll_bdi_num = ATOMIC_INIT(0); +#endif + int ll_fill_super(struct super_block *sb) { struct lustre_profile *lprof; @@ -844,6 +848,18 @@ int ll_fill_super(struct super_block *sb) if (err) GOTO(out_free, err); + err = ll_bdi_init(&lsi->bdi); + if (err) + GOTO(out_free, err); + +#ifdef HAVE_NEW_BACKING_DEV_INFO + lsi->bdi.name = "lustre"; + lsi->bdi.capabilities = BDI_CAP_MAP_COPY; + err = bdi_register(&lsi->bdi, NULL, "lustre-%d", + atomic_inc_return(&ll_bdi_num)); + sb->s_bdi = &lsi->bdi; +#endif + /* Generate a string unique to this super, in case some joker tries to mount the same fs at two mount points. Use the address of the super itself.*/ @@ -948,6 +964,9 @@ void ll_put_super(struct super_block *sb) if (profilenm) class_del_profile(profilenm); + if (ll_bdi_wb_cnt(lsi->bdi) > 0) + ll_bdi_destroy(&lsi->bdi); + ll_free_sbi(sb); lsi->lsi_llsbi = NULL; @@ -1613,15 +1632,6 @@ void ll_update_inode(struct inode *inode, struct lustre_md *md) } } -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; @@ -1647,6 +1657,10 @@ void ll_read_inode2(struct inode *inode, void *opaque) /* OIDEBUG(inode); */ + /* initializing backing dev info. */ + inode->i_mapping->backing_dev_info = &(s2lsi(inode->i_sb)->bdi); + + if (S_ISREG(inode->i_mode)) { struct ll_sb_info *sbi = ll_i2sbi(inode); inode->i_op = &ll_file_inode_operations; @@ -1667,9 +1681,6 @@ 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. */ - inode->i_mapping->backing_dev_info = &ll_backing_dev_info; - EXIT; } }