[Ocfs2-commits]
manish commits r983 - in branches/format-changes/src: . inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Wed Jun 2 20:04:03 CDT 2004
Author: manish
Date: 2004-06-02 19:04:02 -0500 (Wed, 02 Jun 2004)
New Revision: 983
Modified:
branches/format-changes/src/file.c
branches/format-changes/src/inc/ocfs.h
branches/format-changes/src/inc/ocfs_compat.h
Log:
clean up attribute setting, making 2.4/2.6 differences much less ugly.
>From Christoph Hellwig.
Modified: branches/format-changes/src/file.c
===================================================================
--- branches/format-changes/src/file.c 2004-06-02 23:56:04 UTC (rev 982)
+++ branches/format-changes/src/file.c 2004-06-03 00:04:02 UTC (rev 983)
@@ -45,39 +45,27 @@
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)
+#define ocfs_get_seconds(t) (t).tv_sec
+#else
+#define ocfs_get_seconds(t) (t)
#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)
{
int status;
@@ -662,7 +650,7 @@
fileEntry->modify_time = OCFS_CURRENT_TIME;
DISK_LOCK(fileEntry)->dlock_seq_num = 0;
- OCFS_FE_SET_ATTRIBUTES(fileEntry, attr);
+ ocfs_fe_set_attributes(fileEntry, attr);
/* Set the valid bit here */
SET_VALID_BIT (fileEntry->sync_flags);
@@ -1290,7 +1278,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: branches/format-changes/src/inc/ocfs.h
===================================================================
--- branches/format-changes/src/inc/ocfs.h 2004-06-02 23:56:04 UTC (rev 982)
+++ branches/format-changes/src/inc/ocfs.h 2004-06-03 00:04:02 UTC (rev 983)
@@ -145,7 +145,10 @@
#endif
+#define OCFS_CURRENT_TIME ocfs_get_seconds(CURRENT_TIME)
+#define OCFS_SET_INODE_TIME(i, x, y) (ocfs_get_seconds(i->x) = (y))
+
#define ONE_MEGA_BYTE (1 * 1024 * 1024) /* in bytes */
#define MISS_COUNT_VALUE 30
Modified: branches/format-changes/src/inc/ocfs_compat.h
===================================================================
--- branches/format-changes/src/inc/ocfs_compat.h 2004-06-02 23:56:04 UTC (rev 982)
+++ branches/format-changes/src/inc/ocfs_compat.h 2004-06-03 00:04:02 UTC (rev 983)
@@ -46,15 +46,13 @@
#define OCFS_GENERIC_SB_MEMBER(sb) ((sb)->u.generic_sbp)
-#define OCFS_CURRENT_TIME (CURRENT_TIME)
-#define OCFS_SET_INODE_TIME(i, x, y) i->x = (y)
+#define ocfs_get_seconds(t) (t)
#else /* LINUX_VERSION_CODE < 2.6 */
#define OCFS_GENERIC_SB_MEMBER(sb) ((sb)->s_fs_info)
-#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)
#endif /* LINUX_VERSION_CODE < 2.6 */
More information about the Ocfs2-commits
mailing list