linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] orangefs: remove unused 'diff' function
@ 2016-02-26 12:54 Arnd Bergmann
  2016-02-26 12:54 ` [PATCH 2/2] orangefs: avoid time conversion function Arnd Bergmann
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2016-02-26 12:54 UTC (permalink / raw)
  To: Mike Marshall; +Cc: linux-arm-kernel, Arnd Bergmann, linux-kernel

orangefs contains a helper function to calculate the difference
between two timeval structures. We are trying to remove all
instances of timespec from the kernel, and this one is not
used at all, so let's remove it now.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/orangefs/orangefs-kernel.h | 11 -----------
 1 file changed, 11 deletions(-)

diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index 6290c24d8270..9d92c4fc7dbd 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -675,15 +675,4 @@ static inline void orangefs_i_size_write(struct inode *inode, loff_t i_size)
 #endif
 }
 
-static inline unsigned int diff(struct timeval *end, struct timeval *begin)
-{
-	if (end->tv_usec < begin->tv_usec) {
-		end->tv_usec += 1000000;
-		end->tv_sec--;
-	}
-	end->tv_sec -= begin->tv_sec;
-	end->tv_usec -= begin->tv_usec;
-	return (end->tv_sec * 1000000) + end->tv_usec;
-}
-
 #endif /* __ORANGEFSKERNEL_H */
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] orangefs: avoid time conversion function
  2016-02-26 12:54 [PATCH 1/2] orangefs: remove unused 'diff' function Arnd Bergmann
@ 2016-02-26 12:54 ` Arnd Bergmann
  0 siblings, 0 replies; 2+ messages in thread
From: Arnd Bergmann @ 2016-02-26 12:54 UTC (permalink / raw)
  To: Mike Marshall; +Cc: linux-arm-kernel, Arnd Bergmann, linux-kernel

The new orangefs code uses a helper function to read a time field to
its private structures from struct iattr. This will conflict with the
move to 64-bit timestamps in the kernel and is generally not necessary.

This replaces the conversion with a simple cast to time64_t that shows
what is going on. As the orangefs-internal representation already uses
64-bit timestamps, there should be no ambiguity to negative values,
and the cast ensures that we treat them as times before 1970 on both
32-bit and 64-bit architectures, rather than times after 2038. This
patch keeps that behavior.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/orangefs/orangefs-kernel.h |  5 -----
 fs/orangefs/orangefs-utils.c  | 12 +++++-------
 2 files changed, 5 insertions(+), 12 deletions(-)

diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index 9d92c4fc7dbd..afb8a03b5793 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -564,11 +564,6 @@ int orangefs_unmount_sb(struct super_block *sb);
 
 bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op);
 
-static inline __u64 orangefs_convert_time_field(const struct timespec *ts)
-{
-	return (__u64)ts->tv_sec;
-}
-
 int orangefs_normalize_to_errno(__s32 error_code);
 
 extern struct mutex devreq_mutex;
diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
index 488f3501b09c..8ef9e9646748 100644
--- a/fs/orangefs/orangefs-utils.c
+++ b/fs/orangefs/orangefs-utils.c
@@ -202,9 +202,9 @@ static int copy_attributes_to_inode(struct inode *inode,
 
 	inode->i_uid = make_kuid(&init_user_ns, attrs->owner);
 	inode->i_gid = make_kgid(&init_user_ns, attrs->group);
-	inode->i_atime.tv_sec = (time_t) attrs->atime;
-	inode->i_mtime.tv_sec = (time_t) attrs->mtime;
-	inode->i_ctime.tv_sec = (time_t) attrs->ctime;
+	inode->i_atime.tv_sec = (time64_t) attrs->atime;
+	inode->i_mtime.tv_sec = (time64_t) attrs->mtime;
+	inode->i_ctime.tv_sec = (time64_t) attrs->ctime;
 	inode->i_atime.tv_nsec = 0;
 	inode->i_mtime.tv_nsec = 0;
 	inode->i_ctime.tv_nsec = 0;
@@ -301,16 +301,14 @@ static inline int copy_attributes_from_inode(struct inode *inode,
 	if (iattr->ia_valid & ATTR_ATIME) {
 		attrs->mask |= ORANGEFS_ATTR_SYS_ATIME;
 		if (iattr->ia_valid & ATTR_ATIME_SET) {
-			attrs->atime =
-			    orangefs_convert_time_field(&iattr->ia_atime);
+			attrs->atime = (time64_t)iattr->ia_atime.tv_sec;
 			attrs->mask |= ORANGEFS_ATTR_SYS_ATIME_SET;
 		}
 	}
 	if (iattr->ia_valid & ATTR_MTIME) {
 		attrs->mask |= ORANGEFS_ATTR_SYS_MTIME;
 		if (iattr->ia_valid & ATTR_MTIME_SET) {
-			attrs->mtime =
-			    orangefs_convert_time_field(&iattr->ia_mtime);
+			attrs->mtime = (time64_t)iattr->ia_mtime.tv_sec;
 			attrs->mask |= ORANGEFS_ATTR_SYS_MTIME_SET;
 		}
 	}
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-26 12:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-26 12:54 [PATCH 1/2] orangefs: remove unused 'diff' function Arnd Bergmann
2016-02-26 12:54 ` [PATCH 2/2] orangefs: avoid time conversion function Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).