From decec51b97b8517f9a524aeaf8b3660a2fc97d4b Mon Sep 17 00:00:00 2001
From: kalpak <kalpak>
Date: Tue, 15 May 2007 10:12:14 +0000
Subject: [PATCH] b=10768 i=adilger i=green

Lustre methods to set/get the inode version. Only sles10 and 2.6.18 have inode version support and older kernels may not need this support. Hence added a HAVE_DISK_INODE_VERSION in ext3_fs_i.h, so that lustre can decide whether to compile inode-version code or not without requiring a cnfigure time check.
---
 lustre/include/linux/lustre_fsfilt.h | 18 ++++++++++++++++++
 lustre/lvfs/fsfilt_ext3.c            | 26 ++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/lustre/include/linux/lustre_fsfilt.h b/lustre/include/linux/lustre_fsfilt.h
index 70a4bc890a..121b588edc 100644
--- a/lustre/include/linux/lustre_fsfilt.h
+++ b/lustre/include/linux/lustre_fsfilt.h
@@ -101,6 +101,10 @@ struct fsfilt_operations {
         int     (* fs_get_op_len)(int, struct fsfilt_objinfo *, int);
         int     (* fs_quotacheck)(struct super_block *sb,
                                   struct obd_quotactl *oqctl);
+#ifdef HAVE_DISK_INODE_VERSION
+        __u64   (* fs_get_version) (struct inode *inode);
+        __u64   (* fs_set_version) (struct inode *inode, __u64 new_version);
+#endif
         int     (* fs_quotactl)(struct super_block *sb,
                                 struct obd_quotactl *oqctl);
         int     (* fs_quotainfo)(struct lustre_quota_info *lqi, int type,
@@ -457,6 +461,20 @@ static inline int fsfilt_setup(struct obd_device *obd, struct super_block *fs)
         return 0;
 }
 
+#ifdef HAVE_DISK_INODE_VERSION
+static inline void fsfilt_set_version(struct obd_device *obd,
+				      struct inode *inode, __u64 new_version)
+{
+	obd->obd_fsops->fs_set_version(inode, new_version);
+}
+
+static inline __u64 fsfilt_get_version(struct obd_device *obd,
+				       struct inode *inode)
+{
+	return obd->obd_fsops->fs_get_version(inode);
+}
+#endif
+
 #endif /* __KERNEL__ */
 
 #endif
diff --git a/lustre/lvfs/fsfilt_ext3.c b/lustre/lvfs/fsfilt_ext3.c
index f1e80d96d0..ee5a81c36f 100644
--- a/lustre/lvfs/fsfilt_ext3.c
+++ b/lustre/lvfs/fsfilt_ext3.c
@@ -125,6 +125,28 @@ static char *fsfilt_ext3_uuid(struct super_block *sb)
         return EXT3_SB(sb)->s_es->s_uuid;
 }
 
+#ifdef HAVE_DISK_INODE_VERSION
+/*
+ * Get the 64-bit version for an inode.
+ */
+static __u64 fsfilt_ext3_get_version(struct inode *inode)
+{
+        return EXT3_I(inode)->i_fs_version;
+}
+
+/*
+ * Set the 64-bit version and return the old version.
+ */
+static __u64 fsfilt_ext3_set_version(struct inode *inode, __u64 new_version)
+{
+        __u64 old_version = EXT3_I(inode)->i_fs_version;
+
+        (EXT3_I(inode))->i_fs_version = new_version;
+        return old_version;
+}
+
+#endif
+
 /*
  * We don't currently need any additional blocks for rmdir and
  * unlink transactions because we are storing the OST oa_id inside
@@ -2074,6 +2096,10 @@ static struct fsfilt_operations fsfilt_ext3_ops = {
         .fs_get_op_len          = fsfilt_ext3_get_op_len,
         .fs_quotactl            = fsfilt_ext3_quotactl,
         .fs_quotacheck          = fsfilt_ext3_quotacheck,
+#ifdef HAVE_DISK_INODE_VERSION
+        .fs_get_version         = fsfilt_ext3_get_version,
+        .fs_set_version         = fsfilt_ext3_set_version,
+#endif
 #ifdef HAVE_QUOTA_SUPPORT
         .fs_quotainfo           = fsfilt_ext3_quotainfo,
         .fs_qids                = fsfilt_ext3_qids,
-- 
GitLab