[Ocfs2-commits] manish commits r982 - in trunk/src: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Jun 2 19:56:06 CDT 2004
Author: manish
Date: 2004-06-02 18:56:04 -0500 (Wed, 02 Jun 2004)
New Revision: 982
Modified:
trunk/src/file.c
trunk/src/inc/ocfs.h
Log:
clean up attribute setting, making 2.4/2.6 differences much less ugly.
>From Christoph Hellwig.
Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c 2004-06-02 23:43:31 UTC (rev 981)
+++ trunk/src/file.c 2004-06-02 23:56:04 UTC (rev 982)
@@ -38,39 +38,21 @@
static int ocfs_change_file_attrib (ocfs_super * osb, __u64 file_off, struct iattr *attr, struct inode *inode);
static int ocfs_truncate_file (ocfs_super * osb, __u64 file_off, __u64 file_size, struct inode *inode);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#define OCFS_FE_SET_ATTRIBUTES(fe, attr) \
-do { \
- if (attr->ia_valid & ATTR_SIZE) \
- fe->file_size = attr->ia_size; \
- if (attr->ia_valid & ATTR_UID) \
- fe->uid = attr->ia_uid; \
- if (attr->ia_valid & ATTR_GID) \
- fe->gid = attr->ia_gid; \
- if (attr->ia_valid & ATTR_MODE) \
- fe->prot_bits = attr->ia_mode & 0007777; \
- if (attr->ia_valid & ATTR_CTIME) \
- fe->create_time = attr->ia_ctime.tv_sec; \
- if (attr->ia_valid & ATTR_MTIME) \
- fe->modify_time = attr->ia_mtime.tv_sec; \
-} while (0)
-#else /* 2.4 kernel */
-#define OCFS_FE_SET_ATTRIBUTES(fe, attr) \
-do { \
- if (attr->ia_valid & ATTR_SIZE) \
- fe->file_size = attr->ia_size; \
- if (attr->ia_valid & ATTR_UID) \
- fe->uid = attr->ia_uid; \
- if (attr->ia_valid & ATTR_GID) \
- fe->gid = attr->ia_gid; \
- if (attr->ia_valid & ATTR_MODE) \
- fe->prot_bits = attr->ia_mode & 0007777; \
- if (attr->ia_valid & ATTR_CTIME) \
- fe->create_time = attr->ia_ctime; \
- if (attr->ia_valid & ATTR_MTIME) \
- fe->modify_time = attr->ia_mtime; \
-} while (0)
-#endif
+static void ocfs_fe_set_attributes(ocfs_file_entry *fe, struct iattr *attr)
+{
+ if (attr->ia_valid & ATTR_SIZE)
+ fe->file_size = attr->ia_size;
+ if (attr->ia_valid & ATTR_UID)
+ fe->uid = attr->ia_uid;
+ if (attr->ia_valid & ATTR_GID)
+ fe->gid = attr->ia_gid;
+ if (attr->ia_valid & ATTR_MODE)
+ fe->prot_bits = attr->ia_mode & 0007777;
+ if (attr->ia_valid & ATTR_CTIME)
+ fe->create_time = ocfs_get_seconds(attr->ia_ctime);
+ if (attr->ia_valid & ATTR_MTIME)
+ fe->modify_time = ocfs_get_seconds(attr->ia_mtime);
+}
static inline int ocfs_sync_inode(struct inode *inode)
{
@@ -656,7 +638,7 @@
fileEntry->modify_time = OCFS_CURRENT_TIME;
DISK_LOCK_SEQNUM (fileEntry) = 0;
- OCFS_FE_SET_ATTRIBUTES(fileEntry, attr);
+ ocfs_fe_set_attributes(fileEntry, attr);
/* Set the valid bit here */
SET_VALID_BIT (fileEntry->sync_flags);
@@ -1284,7 +1266,7 @@
LOG_TRACE_ARGS("fileEntry->alloc_size = %llu\n", fileEntry->alloc_size);
if (attr)
- OCFS_FE_SET_ATTRIBUTES(fileEntry, attr);
+ ocfs_fe_set_attributes(fileEntry, attr);
/* Set the Valid bit and reset the change bit here... TODO */
SET_VALID_BIT (fileEntry->sync_flags);
fileEntry->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h 2004-06-02 23:43:31 UTC (rev 981)
+++ trunk/src/inc/ocfs.h 2004-06-02 23:56:04 UTC (rev 982)
@@ -223,13 +223,14 @@
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#define OCFS_CURRENT_TIME (CURRENT_TIME.tv_sec)
-#define OCFS_SET_INODE_TIME(i, x, y) (i->x.tv_sec = (y))
+#define ocfs_get_seconds(t) ((t).tv_sec)
#else
-#define OCFS_CURRENT_TIME (CURRENT_TIME)
-#define OCFS_SET_INODE_TIME(i, x, y) i->x = (y)
+#define ocfs_get_seconds(t) (t)
#endif
+#define OCFS_CURRENT_TIME ocfs_get_seconds(CURRENT_TIME)
+#define OCFS_SET_INODE_TIME(i, x, y) (ocfs_get_seconds(i->x) = (y))
+
static inline __u64 ocfs_get_publish_time(void)
{
unsigned long ret = jiffies;
More information about the Ocfs2-commits
mailing list