Linux_5.0: replaced current_kernel_time with ktime_get_coarse_real_ts64
[openafs.git] / src / afs / LINUX / osi_file.c
index 7069297..213d5ef 100644 (file)
 #include "osi_compat.h"
 
 #ifndef CURRENT_TIME
-#define CURRENT_TIME           (current_kernel_time())
+# if defined(HAVE_LINUX_KTIME_GET_COARSE_REAL_TS64)
+#   define AFS_CURRENT_TIME(x) (ktime_get_coarse_real_ts64((x)))
+# else
+#  ifdef IATTR_TAKES_64BIT_TIME
+#    define AFS_CURRENT_TIME(x) do {*(x) = current_kernel_time64();} while (0)
+#  else
+#    define AFS_CURRENT_TIME(x) do {*(x) = current_kernel_time();} while (0)
+#  endif
+# endif
+#else
+# define AFS_CURRENT_TIME(x) do {*(x) = CURRENT_TIME;} while(0)
 #endif
 
 int cache_fh_type = -1;
 int cache_fh_len = -1;
 
-afs_lock_t afs_xosi;           /* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct vfsmount *afs_cacheMnt;
 extern struct super_block *afs_cacheSBp;
@@ -89,7 +98,7 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
        osi_Panic("UFSOpen called for non-UFS cache\n");
     }
     if (!afs_osicred_initialized) {
-       /* valid for alpha_osf, SunOS, Ultrix */
+       /* valid for SunOS, Ultrix */
        memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
        crhold(&afs_osi_cred);  /* don't let it evaporate, since it is static */
        afs_osicred_initialized = 1;
@@ -150,12 +159,10 @@ int
 afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 {
     AFS_STATCNT(osi_Stat);
-    ObtainWriteLock(&afs_xosi, 320);
     astat->size = i_size_read(OSIFILE_INODE(afile));
     astat->mtime = OSIFILE_INODE(afile)->i_mtime.tv_sec;
     astat->atime = OSIFILE_INODE(afile)->i_atime.tv_sec;
 
-    ReleaseWriteLock(&afs_xosi);
     return 0;
 }
 
@@ -188,7 +195,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     code = afs_osi_Stat(afile, &tstat);
     if (code || tstat.size <= asize)
        return code;
-    ObtainWriteLock(&afs_xosi, 321);
     AFS_GUNLOCK();
     afs_linux_lock_inode(inode);
 #ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
@@ -196,7 +202,7 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
 #endif
     newattrs.ia_size = asize;
     newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
-    newattrs.ia_ctime = CURRENT_TIME;
+    AFS_CURRENT_TIME(&newattrs.ia_ctime);
 
     /* avoid notify_change() since it wants to update dentry->d_parent */
 #ifdef HAVE_LINUX_SETATTR_PREPARE
@@ -214,7 +220,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
 #endif
     afs_linux_unlock_inode(inode);
     AFS_GLOCK();
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -295,8 +300,7 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
        afile->offset += code;
     } else {
        if (code == ENOSPC)
-           afs_warnuser
-               ("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
+            afs_WarnENOSPC();
        if (code > 0) {
            code = -code;
        }