static __be32 * encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat) { struct timespec ts; *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]); *p++ = htonl((u32) (stat->mode & S_IALLUGO)); *p++ = htonl((u32) stat->nlink); *p++ = htonl((u32) from_kuid(&init_user_ns, stat->uid)); *p++ = htonl((u32) from_kgid(&init_user_ns, stat->gid)); if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) { p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN); } else { p = xdr_encode_hyper(p, (u64) stat->size); } p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9); *p++ = htonl((u32) MAJOR(stat->rdev)); *p++ = htonl((u32) MINOR(stat->rdev)); p = encode_fsid(p, fhp); p = xdr_encode_hyper(p, stat->ino); ts = timespec64_to_timespec(stat->atime); p = encode_time3(p, &ts); ts = timespec64_to_timespec(stat->mtime); p = encode_time3(p, &ts); ts = timespec64_to_timespec(stat->ctime); p = encode_time3(p, &ts); return p; }
/* * Enable or disable caching for a file that is being opened as appropriate. * The cookie is allocated when the inode is initialised, but is not enabled at * that time. Enablement is deferred to file-open time to avoid stat() and * access() thrashing the cache. * * For now, with NFS, only regular files that are open read-only will be able * to use the cache. * * We enable the cache for an inode if we open it read-only and it isn't * currently open for writing. We disable the cache if the inode is open * write-only. * * The caller uses the file struct to pin i_writecount on the inode before * calling us when a file is opened for writing, so we can make use of that. * * Note that this may be invoked multiple times in parallel by parallel * nfs_open() functions. */ void nfs_fscache_open_file(struct inode *inode, struct file *filp) { struct nfs_fscache_inode_auxdata auxdata; struct nfs_inode *nfsi = NFS_I(inode); struct fscache_cookie *cookie = nfs_i_fscache(inode); if (!fscache_cookie_valid(cookie)) return; memset(&auxdata, 0, sizeof(auxdata)); auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); if (inode_is_open_for_write(inode)) { dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi); clear_bit(NFS_INO_FSCACHE, &nfsi->flags); fscache_disable_cookie(cookie, &auxdata, true); fscache_uncache_all_inode_pages(cookie, inode); } else { dfprintk(FSCACHE, "NFS: nfsi 0x%p enabling cache\n", nfsi); fscache_enable_cookie(cookie, &auxdata, nfsi->vfs_inode.i_size, nfs_fscache_can_enable, inode); if (fscache_cookie_enabled(cookie)) set_bit(NFS_INO_FSCACHE, &NFS_I(inode)->flags); } }
/* * Release a per-inode cookie. */ void nfs_fscache_clear_inode(struct inode *inode) { struct nfs_fscache_inode_auxdata auxdata; struct nfs_inode *nfsi = NFS_I(inode); struct fscache_cookie *cookie = nfs_i_fscache(inode); dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie); memset(&auxdata, 0, sizeof(auxdata)); auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); fscache_relinquish_cookie(cookie, &auxdata, false); nfsi->fscache = NULL; }
/* * Initialise the per-inode cache cookie pointer for an NFS inode. */ void nfs_fscache_init_inode(struct inode *inode) { struct nfs_fscache_inode_auxdata auxdata; struct nfs_inode *nfsi = NFS_I(inode); nfsi->fscache = NULL; if (!S_ISREG(inode->i_mode)) return; memset(&auxdata, 0, sizeof(auxdata)); auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime); auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime); if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4) auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode); nfsi->fscache = fscache_acquire_cookie(NFS_SB(inode->i_sb)->fscache, &nfs_fscache_inode_object_def, nfsi->fh.data, nfsi->fh.size, &auxdata, sizeof(auxdata), nfsi, nfsi->vfs_inode.i_size, false); }
static int igb_ptp_gettime_i210(struct ptp_clock_info *ptp, struct timespec *ts) { struct timespec64 ts64; int err; err = igb_ptp_gettime64_i210(ptp, &ts64); if (err) return err; *ts = timespec64_to_timespec(ts64); return 0; }
/* * Fill in the pre_op attr for the wcc data */ void fill_pre_wcc(struct svc_fh *fhp) { struct inode *inode; struct kstat stat; __be32 err; if (fhp->fh_pre_saved) return; inode = d_inode(fhp->fh_dentry); err = fh_getattr(fhp, &stat); if (err) { /* Grab the times from inode anyway */ stat.mtime = inode->i_mtime; stat.ctime = inode->i_ctime; stat.size = inode->i_size; } fhp->fh_pre_mtime = timespec64_to_timespec(stat.mtime); fhp->fh_pre_ctime = timespec64_to_timespec(stat.ctime); fhp->fh_pre_size = stat.size; fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode); fhp->fh_pre_saved = true; }
SYSCALL_DEFINE2(clock_gettime, const clockid_t, which_clock, struct timespec __user *,tp) { struct timespec64 kernel_tp64; struct timespec kernel_tp; switch (which_clock) { case CLOCK_REALTIME: ktime_get_real_ts64(&kernel_tp64); break; case CLOCK_MONOTONIC: ktime_get_ts64(&kernel_tp64); break; case CLOCK_BOOTTIME: get_monotonic_boottime64(&kernel_tp64); break; default: return -EINVAL; } kernel_tp = timespec64_to_timespec(kernel_tp64); if (copy_to_user(tp, &kernel_tp, sizeof (kernel_tp))) return -EFAULT; return 0; }