From 0f818352ca6872810197c2f263728d41967679ea Mon Sep 17 00:00:00 2001 From: Peng Tao Date: Tue, 15 May 2012 14:43:58 +0800 Subject: [PATCH] LU-709 build: clean up LC_NR_PAGECACHE/LC_STATFS_DENTRY_PARAM 1. nr_pagecache is not exported from 2.6.18 to latest 2. super_operations->statfs takes dentry instead of superblock as first parameter since v2.6.18 Signed-off-by: Peng Tao Change-Id: I93fd5cdd81b83f0896a1305f5b625fa0c82ef515 Reviewed-on: http://review.whamcloud.com/2319 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 43 ---------------------- lustre/include/linux/lustre_compat25.h | 6 ---- lustre/include/linux/lustre_patchless_compat.h | 3 -- lustre/llite/llite_internal.h | 4 --- lustre/llite/llite_lib.c | 11 ++---- lustre/lvfs/fsfilt_ext3.c | 12 +++---- lustre/obdclass/obd_mount.c | 49 +++++++++++--------------- lustre/osd-ldiskfs/osd_handler.c | 18 +++++----- 8 files changed, 38 insertions(+), 108 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index 6f6fd31..0ee0a91 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -484,47 +484,6 @@ EXTRA_KCFLAGS="$tmp_flags" # 2.6.18 -# LC_NR_PAGECACHE -# 2.6.18 don't export nr_pagecahe -AC_DEFUN([LC_NR_PAGECACHE], -[AC_MSG_CHECKING([kernel export nr_pagecache]) -LB_LINUX_TRY_COMPILE([ - #include -],[ - return atomic_read(&nr_pagecache); -],[ - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_NR_PAGECACHE, 1, - [is kernel export nr_pagecache]) -],[ - AC_MSG_RESULT(no) -]) -]) - -# -# LC_STATFS_DENTRY_PARAM -# starting from 2.6.18 linux kernel uses dentry instead of super_block -# for the first parameter of the super_operations->statfs() callback. -# -# -AC_DEFUN([LC_STATFS_DENTRY_PARAM], -[AC_MSG_CHECKING([if super_ops.statfs() first parameter is dentry]) -tmp_flags="$EXTRA_KCFLAGS" -EXTRA_KCFLAGS="-Werror" -LB_LINUX_TRY_COMPILE([ - #include -],[ - ((struct super_operations *)0)->statfs((struct dentry *)0, (struct kstatfs*)0); -],[ - AC_DEFINE(HAVE_STATFS_DENTRY_PARAM, 1, - [super_ops.statfs() first parameter is dentry]) - AC_MSG_RESULT([yes]) -],[ - AC_MSG_RESULT([no]) -]) -EXTRA_KCFLAGS="$tmp_flags" -]) - # LC_UMOUNTBEGIN_HAS_VFSMOUNT # 2.6.18~2.6.25 umount_begin has different parameters AC_DEFUN([LC_UMOUNTBEGIN_HAS_VFSMOUNT], @@ -1921,8 +1880,6 @@ AC_DEFUN([LC_PROG_LINUX], LC_RW_TREE_LOCK # 2.6.18 - LC_NR_PAGECACHE - LC_STATFS_DENTRY_PARAM LC_UMOUNTBEGIN_HAS_VFSMOUNT LC_FLUSH_OWNER_ID if test x$enable_server = xyes ; then diff --git a/lustre/include/linux/lustre_compat25.h b/lustre/include/linux/lustre_compat25.h index b717b90..28ca758 100644 --- a/lustre/include/linux/lustre_compat25.h +++ b/lustre/include/linux/lustre_compat25.h @@ -307,12 +307,6 @@ static inline unsigned int mnt_get_count(struct vfsmount *mnt) # define mnt_get_count(mnt) cfs_atomic_read(&(real_mount(mnt)->mnt_count)) #endif -#ifdef HAVE_STATFS_DENTRY_PARAM -#define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb)->s_root, (sfs)) -#else -#define ll_do_statfs(sb, sfs) (sb)->s_op->statfs((sb), (sfs)) -#endif - #ifdef HAVE_RW_TREE_LOCK #define TREE_READ_LOCK_IRQ(mapping) read_lock_irq(&(mapping)->tree_lock) #define TREE_READ_UNLOCK_IRQ(mapping) read_unlock_irq(&(mapping)->tree_lock) diff --git a/lustre/include/linux/lustre_patchless_compat.h b/lustre/include/linux/lustre_patchless_compat.h index d79d1c8..9af47ef 100644 --- a/lustre/include/linux/lustre_patchless_compat.h +++ b/lustre/include/linux/lustre_patchless_compat.h @@ -50,9 +50,6 @@ #ifndef HAVE_DELETE_FROM_PAGE_CACHE /* 2.6.39 */ #ifndef HAVE_REMOVE_FROM_PAGE_CACHE /* 2.6.35 - 2.6.38 */ -#ifdef HAVE_NR_PAGECACHE /* 2.6.18 */ -#define __dec_zone_page_state(page, flag) atomic_add(-1, &nr_pagecache); -#endif /* HAVE_NR_PAGECACHE */ /* XXX copy & paste from 2.6.15 kernel */ static inline void ll_remove_from_page_cache(struct page *page) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 510a9b9..02f80bf 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -803,11 +803,7 @@ struct inode *ll_inode_from_lock(struct ldlm_lock *lock); void ll_clear_inode(struct inode *inode); int ll_setattr_raw(struct dentry *dentry, struct iattr *attr); int ll_setattr(struct dentry *de, struct iattr *attr); -#ifndef HAVE_STATFS_DENTRY_PARAM -int ll_statfs(struct super_block *sb, struct kstatfs *sfs); -#else int ll_statfs(struct dentry *de, struct kstatfs *sfs); -#endif int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, __u64 max_age, __u32 flags); void ll_update_inode(struct inode *inode, struct lustre_md *md); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 1a24d72..cc747c8 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -1539,16 +1539,11 @@ int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, RETURN(rc); } -#ifndef HAVE_STATFS_DENTRY_PARAM -int ll_statfs(struct super_block *sb, struct kstatfs *sfs) -{ -#else int ll_statfs(struct dentry *de, struct kstatfs *sfs) { - struct super_block *sb = de->d_sb; -#endif - struct obd_statfs osfs; - int rc; + struct super_block *sb = de->d_sb; + struct obd_statfs osfs; + int rc; CDEBUG(D_VFSTRACE, "VFS Op: at "LPU64" jiffies\n", get_jiffies_64()); ll_stats_ops_tally(ll_s2sbi(sb), LPROC_LL_STAFS, 1); diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c index 406e744..b341502 100644 --- a/lustre/lvfs/fsfilt_ext3.c +++ b/lustre/lvfs/fsfilt_ext3.c @@ -799,13 +799,13 @@ static int fsfilt_ext3_add_journal_cb(struct obd_device *obd, __u64 last_rcvd, static int fsfilt_ext3_statfs(struct super_block *sb, struct obd_statfs *osfs) { - struct kstatfs sfs; - int rc; + struct kstatfs sfs; + int rc; - memset(&sfs, 0, sizeof(sfs)); - rc = ll_do_statfs(sb, &sfs); - statfs_pack(osfs, &sfs); - return rc; + memset(&sfs, 0, sizeof(sfs)); + rc = sb->s_op->statfs(sb->s_root, &sfs); + statfs_pack(osfs, &sfs); + return rc; } static int fsfilt_ext3_sync(struct super_block *sb) diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index e26df3c..f712c4a 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1800,39 +1800,30 @@ static void server_umount_begin(struct super_block *sb) EXIT; } -#ifndef HAVE_STATFS_DENTRY_PARAM -static int server_statfs (struct super_block *sb, cfs_kstatfs_t *buf) -{ -#else static int server_statfs (struct dentry *dentry, cfs_kstatfs_t *buf) { - struct super_block *sb = dentry->d_sb; -#endif - struct vfsmount *mnt = s2lsi(sb)->lsi_srv_mnt; - ENTRY; + struct super_block *sb = dentry->d_sb; + struct vfsmount *mnt = s2lsi(sb)->lsi_srv_mnt; + ENTRY; - if (mnt && mnt->mnt_sb && mnt->mnt_sb->s_op->statfs) { -#ifdef HAVE_STATFS_DENTRY_PARAM - int rc = mnt->mnt_sb->s_op->statfs(mnt->mnt_root, buf); -#else - int rc = mnt->mnt_sb->s_op->statfs(mnt->mnt_sb, buf); -#endif - if (!rc) { - buf->f_type = sb->s_magic; - RETURN(0); - } - } + if (mnt && mnt->mnt_sb && mnt->mnt_sb->s_op->statfs) { + int rc = mnt->mnt_sb->s_op->statfs(mnt->mnt_root, buf); + if (!rc) { + buf->f_type = sb->s_magic; + RETURN(0); + } + } - /* just return 0 */ - buf->f_type = sb->s_magic; - buf->f_bsize = sb->s_blocksize; - buf->f_blocks = 1; - buf->f_bfree = 0; - buf->f_bavail = 0; - buf->f_files = 1; - buf->f_ffree = 0; - buf->f_namelen = NAME_MAX; - RETURN(0); + /* just return 0 */ + buf->f_type = sb->s_magic; + buf->f_bsize = sb->s_blocksize; + buf->f_blocks = 1; + buf->f_bfree = 0; + buf->f_bavail = 0; + buf->f_files = 1; + buf->f_ffree = 0; + buf->f_namelen = NAME_MAX; + RETURN(0); } /** The operations we support directly on the superblock: diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 2474f69..2db0ff2 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -1007,15 +1007,15 @@ int osd_statfs(const struct lu_env *env, struct dt_device *d, ksfs = &osd_oti_get(env)->oti_ksfs; } - cfs_spin_lock(&osd->od_osfs_lock); - /* cache 1 second */ - if (cfs_time_before_64(osd->od_osfs_age, cfs_time_shift_64(-1))) { - result = ll_do_statfs(sb, ksfs); - if (likely(result == 0)) { /* N.B. statfs can't really fail */ - osd->od_osfs_age = cfs_time_current_64(); - statfs_pack(&osd->od_statfs, ksfs); - } - } + cfs_spin_lock(&osd->od_osfs_lock); + /* cache 1 second */ + if (cfs_time_before_64(osd->od_osfs_age, cfs_time_shift_64(-1))) { + result = sb->s_op->statfs(sb->s_root, ksfs); + if (likely(result == 0)) { /* N.B. statfs can't really fail */ + osd->od_osfs_age = cfs_time_current_64(); + statfs_pack(&osd->od_statfs, ksfs); + } + } if (likely(result == 0)) *sfs = osd->od_statfs; -- 1.8.3.1