All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] nfsd: Add support for btime
@ 2022-01-10  9:53 Ondrej Valousek
  2022-01-10 15:02 ` Chuck Lever III
  0 siblings, 1 reply; 2+ messages in thread
From: Ondrej Valousek @ 2022-01-10  9:53 UTC (permalink / raw)
  To: Chuck Lever III, Bruce Fields; +Cc: Trond Myklebust, Linux NFS Mailing List

Hi Bruce/kernel maintainers,

Please help to submit the following patch into kernel.
Legal stuff: It is OK for Renesas to submit this code into kernel - and besides, it Bruce's patch in fact as he told me what to do.

Signed-off-by: Ondrej Valousek <ondrej.valousek.xm@renesas.com>
---
Short description:
Adds support for "btime" fattr into nfsd
Long Description:
For filesystems that supports "btime" timestamp (i.e. most modern filesystems do) we share it via kernel nfsd. Btime support for NFS client has already been added by Trond recently

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5a93a5db4fb0..876b317a4cae 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -2865,6 +2865,9 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
        err = vfs_getattr(&path, &stat, STATX_BASIC_STATS, AT_STATX_SYNC_AS_STAT);
        if (err)
                goto out_nfserr;
+       if (!(stat.result_mask & STATX_BTIME))
+               /* underlying FS does not offer btime so we can't share it */
+               bmval1 &= ~FATTR4_WORD1_TIME_CREATE;
        if ((bmval0 & (FATTR4_WORD0_FILES_AVAIL | FATTR4_WORD0_FILES_FREE |
                        FATTR4_WORD0_FILES_TOTAL | FATTR4_WORD0_MAXNAME)) ||
            (bmval1 & (FATTR4_WORD1_SPACE_AVAIL | FATTR4_WORD1_SPACE_FREE |
@@ -3265,6 +3268,14 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
                p = xdr_encode_hyper(p, (s64)stat.mtime.tv_sec);
                *p++ = cpu_to_be32(stat.mtime.tv_nsec);
        }
+       /* support for btime here */
+        if (bmval1 & FATTR4_WORD1_TIME_CREATE) {
+                p = xdr_reserve_space(xdr, 12);
+                if (!p)
+                        goto out_resource;
+                p = xdr_encode_hyper(p, (s64)stat.btime.tv_sec);
+                *p++ = cpu_to_be32(stat.btime.tv_nsec);
+        }
        if (bmval1 & FATTR4_WORD1_MOUNTED_ON_FILEID) {
                struct kstat parent_stat;
                u64 ino = stat.ino;
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 498e5a489826..5ef056ce7591 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -364,7 +364,7 @@ void                nfsd_lockd_shutdown(void);
  | FATTR4_WORD1_OWNER          | FATTR4_WORD1_OWNER_GROUP  | FATTR4_WORD1_RAWDEV           \
  | FATTR4_WORD1_SPACE_AVAIL     | FATTR4_WORD1_SPACE_FREE   | FATTR4_WORD1_SPACE_TOTAL      \
  | FATTR4_WORD1_SPACE_USED      | FATTR4_WORD1_TIME_ACCESS  | FATTR4_WORD1_TIME_ACCESS_SET  \
- | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA    \
+ | FATTR4_WORD1_TIME_DELTA   | FATTR4_WORD1_TIME_METADATA   | FATTR4_WORD1_TIME_CREATE      \
  | FATTR4_WORD1_TIME_MODIFY     | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)

 #define NFSD4_SUPPORTED_ATTRS_WORD2 0
Legal Disclaimer: This e-mail communication (and any attachment/s) is confidential and contains proprietary information, some or all of which may be legally privileged. It is intended solely for the use of the individual or entity to which it is addressed. Access to this email by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful.

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

end of thread, other threads:[~2022-01-10 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-10  9:53 [PATCH 1/1] nfsd: Add support for btime Ondrej Valousek
2022-01-10 15:02 ` Chuck Lever III

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.