2021-12-17 20:55:03

by trondmy

[permalink] [raw]
Subject: [PATCH 0/8] Support btime and other NFSv4 specific attributes

From: Trond Myklebust <[email protected]>

NFSv4 has support for a number of extra attributes that are of interest
to Samba when it is used to re-export a filesystem to Windows clients.
Aside from the btime, which is of interest in statx(), Windows clients
have an interest in determining the status of the 'hidden', and 'system'
flags.
Backup programs want to read the 'archive' flags and the 'time backup'
attribute.
Finally, the 'offline' flag can tell whether or not a file needs to be
staged by an HSM system before it can be read or written to.

The patch series also adds an ioctl() to allow userspace retrieval and
setting of these attributes where appropriate. It also adds an ioctl()
to allow retrieval of the raw NFSv4 ACCESS information, to allow more
fine grained determination of the user's access rights to a file or
directory. All of this information is of use for Samba.

Anne Marie Merritt (3):
nfs: Add timecreate to nfs inode
nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
nfs: Add 'time backup' to nfs inode

Richard Sharpe (1):
NFS: Support statx_get and statx_set ioctls

Trond Myklebust (4):
NFS: Expand the type of nfs_fattr->valid
NFS: Return the file btime in the statx results when appropriate
NFSv4: Support the offline bit
NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask

fs/nfs/dir.c | 71 ++---
fs/nfs/getroot.c | 3 +-
fs/nfs/inode.c | 147 +++++++++-
fs/nfs/internal.h | 10 +
fs/nfs/nfs3proc.c | 1 +
fs/nfs/nfs4_fs.h | 31 +++
fs/nfs/nfs4file.c | 550 ++++++++++++++++++++++++++++++++++++++
fs/nfs/nfs4proc.c | 175 +++++++++++-
fs/nfs/nfs4trace.h | 8 +-
fs/nfs/nfs4xdr.c | 240 +++++++++++++++--
fs/nfs/nfstrace.c | 5 +
fs/nfs/nfstrace.h | 9 +-
fs/nfs/proc.c | 1 +
include/linux/nfs4.h | 1 +
include/linux/nfs_fs.h | 15 ++
include/linux/nfs_fs_sb.h | 2 +-
include/linux/nfs_xdr.h | 80 ++++--
include/uapi/linux/nfs.h | 101 +++++++
18 files changed, 1356 insertions(+), 94 deletions(-)

--
2.33.1



2021-12-17 20:55:04

by trondmy

[permalink] [raw]
Subject: [PATCH 1/8] NFS: Expand the type of nfs_fattr->valid

From: Trond Myklebust <[email protected]>

We need to be able to track more than 32 attributes per inode.

Signed-off-by: Trond Myklebust <[email protected]>
Signed-off-by: Lance Shelton <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/inode.c | 5 ++--
include/linux/nfs_fs_sb.h | 2 +-
include/linux/nfs_xdr.h | 54 +++++++++++++++++++--------------------
3 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index fda530d5e764..897dec07cf4b 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -2001,10 +2001,11 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
bool attr_changed = false;
bool have_delegation;

- dfprintk(VFS, "NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%x)\n",
+ dfprintk(VFS, "NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%lx)\n",
__func__, inode->i_sb->s_id, inode->i_ino,
nfs_display_fhandle_hash(NFS_FH(inode)),
- atomic_read(&inode->i_count), fattr->valid);
+ atomic_read(&inode->i_count),
+ (unsigned long)fattr->valid);

if (!(fattr->valid & NFS_ATTR_FATTR_FILEID)) {
/* Only a mounted-on-fileid? Just exit */
diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h
index 2a9acbfe00f0..8468206fb535 100644
--- a/include/linux/nfs_fs_sb.h
+++ b/include/linux/nfs_fs_sb.h
@@ -157,8 +157,8 @@ struct nfs_server {
#define NFS_MOUNT_WRITE_EAGER 0x01000000
#define NFS_MOUNT_WRITE_WAIT 0x02000000

- unsigned int fattr_valid; /* Valid attributes */
unsigned int caps; /* server capabilities */
+ __u64 fattr_valid; /* Valid attributes */
unsigned int rsize; /* read size */
unsigned int rpages; /* read size (in pages) */
unsigned int wsize; /* write size */
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 967a0098f0a9..d0722269b392 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -45,7 +45,7 @@ struct nfs4_threshold {
};

struct nfs_fattr {
- unsigned int valid; /* which fields are valid */
+ __u64 valid; /* which fields are valid */
umode_t mode;
__u32 nlink;
kuid_t uid;
@@ -80,32 +80,32 @@ struct nfs_fattr {
struct nfs4_label *label;
};

-#define NFS_ATTR_FATTR_TYPE (1U << 0)
-#define NFS_ATTR_FATTR_MODE (1U << 1)
-#define NFS_ATTR_FATTR_NLINK (1U << 2)
-#define NFS_ATTR_FATTR_OWNER (1U << 3)
-#define NFS_ATTR_FATTR_GROUP (1U << 4)
-#define NFS_ATTR_FATTR_RDEV (1U << 5)
-#define NFS_ATTR_FATTR_SIZE (1U << 6)
-#define NFS_ATTR_FATTR_PRESIZE (1U << 7)
-#define NFS_ATTR_FATTR_BLOCKS_USED (1U << 8)
-#define NFS_ATTR_FATTR_SPACE_USED (1U << 9)
-#define NFS_ATTR_FATTR_FSID (1U << 10)
-#define NFS_ATTR_FATTR_FILEID (1U << 11)
-#define NFS_ATTR_FATTR_ATIME (1U << 12)
-#define NFS_ATTR_FATTR_MTIME (1U << 13)
-#define NFS_ATTR_FATTR_CTIME (1U << 14)
-#define NFS_ATTR_FATTR_PREMTIME (1U << 15)
-#define NFS_ATTR_FATTR_PRECTIME (1U << 16)
-#define NFS_ATTR_FATTR_CHANGE (1U << 17)
-#define NFS_ATTR_FATTR_PRECHANGE (1U << 18)
-#define NFS_ATTR_FATTR_V4_LOCATIONS (1U << 19)
-#define NFS_ATTR_FATTR_V4_REFERRAL (1U << 20)
-#define NFS_ATTR_FATTR_MOUNTPOINT (1U << 21)
-#define NFS_ATTR_FATTR_MOUNTED_ON_FILEID (1U << 22)
-#define NFS_ATTR_FATTR_OWNER_NAME (1U << 23)
-#define NFS_ATTR_FATTR_GROUP_NAME (1U << 24)
-#define NFS_ATTR_FATTR_V4_SECURITY_LABEL (1U << 25)
+#define NFS_ATTR_FATTR_TYPE BIT_ULL(0)
+#define NFS_ATTR_FATTR_MODE BIT_ULL(1)
+#define NFS_ATTR_FATTR_NLINK BIT_ULL(2)
+#define NFS_ATTR_FATTR_OWNER BIT_ULL(3)
+#define NFS_ATTR_FATTR_GROUP BIT_ULL(4)
+#define NFS_ATTR_FATTR_RDEV BIT_ULL(5)
+#define NFS_ATTR_FATTR_SIZE BIT_ULL(6)
+#define NFS_ATTR_FATTR_PRESIZE BIT_ULL(7)
+#define NFS_ATTR_FATTR_BLOCKS_USED BIT_ULL(8)
+#define NFS_ATTR_FATTR_SPACE_USED BIT_ULL(9)
+#define NFS_ATTR_FATTR_FSID BIT_ULL(10)
+#define NFS_ATTR_FATTR_FILEID BIT_ULL(11)
+#define NFS_ATTR_FATTR_ATIME BIT_ULL(12)
+#define NFS_ATTR_FATTR_MTIME BIT_ULL(13)
+#define NFS_ATTR_FATTR_CTIME BIT_ULL(14)
+#define NFS_ATTR_FATTR_PREMTIME BIT_ULL(15)
+#define NFS_ATTR_FATTR_PRECTIME BIT_ULL(16)
+#define NFS_ATTR_FATTR_CHANGE BIT_ULL(17)
+#define NFS_ATTR_FATTR_PRECHANGE BIT_ULL(18)
+#define NFS_ATTR_FATTR_V4_LOCATIONS BIT_ULL(19)
+#define NFS_ATTR_FATTR_V4_REFERRAL BIT_ULL(20)
+#define NFS_ATTR_FATTR_MOUNTPOINT BIT_ULL(21)
+#define NFS_ATTR_FATTR_MOUNTED_ON_FILEID BIT_ULL(22)
+#define NFS_ATTR_FATTR_OWNER_NAME BIT_ULL(23)
+#define NFS_ATTR_FATTR_GROUP_NAME BIT_ULL(24)
+#define NFS_ATTR_FATTR_V4_SECURITY_LABEL BIT_ULL(25)

#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
| NFS_ATTR_FATTR_MODE \
--
2.33.1


2021-12-17 20:55:07

by trondmy

[permalink] [raw]
Subject: [PATCH 2/8] nfs: Add timecreate to nfs inode

From: Anne Marie Merritt <[email protected]>

Add tracking of the create time (a.k.a. btime) along with corresponding
bitfields, request, and decode xdr routines.

Signed-off-by: Anne Marie Merritt <[email protected]>
Signed-off-by: Lance Shelton <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/inode.c | 28 ++++++++++++++++++++++------
fs/nfs/nfs4proc.c | 15 +++++++++++++--
fs/nfs/nfs4xdr.c | 24 ++++++++++++++++++++++++
fs/nfs/nfstrace.h | 3 ++-
include/linux/nfs_fs.h | 7 +++++++
include/linux/nfs_xdr.h | 3 +++
6 files changed, 71 insertions(+), 9 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 897dec07cf4b..908a62d6a29c 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -201,6 +201,7 @@ void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
if (!(flags & NFS_INO_REVAL_FORCED))
flags &= ~(NFS_INO_INVALID_MODE |
NFS_INO_INVALID_OTHER |
+ NFS_INO_INVALID_BTIME |
NFS_INO_INVALID_XATTR);
flags &= ~(NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_SIZE);
} else if (flags & NFS_INO_REVAL_PAGECACHE)
@@ -521,6 +522,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
memset(&inode->i_atime, 0, sizeof(inode->i_atime));
memset(&inode->i_mtime, 0, sizeof(inode->i_mtime));
memset(&inode->i_ctime, 0, sizeof(inode->i_ctime));
+ memset(&nfsi->btime, 0, sizeof(nfsi->btime));
inode_set_iversion_raw(inode, 0);
inode->i_size = 0;
clear_nlink(inode);
@@ -544,6 +546,10 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr)
inode->i_ctime = fattr->ctime;
else if (fattr_supported & NFS_ATTR_FATTR_CTIME)
nfs_set_cache_invalid(inode, NFS_INO_INVALID_CTIME);
+ if (fattr->valid & NFS_ATTR_FATTR_BTIME)
+ nfsi->btime = fattr->btime;
+ else if (fattr_supported & NFS_ATTR_FATTR_BTIME)
+ nfs_set_cache_invalid(inode, NFS_INO_INVALID_BTIME);
if (fattr->valid & NFS_ATTR_FATTR_CHANGE)
inode_set_iversion_raw(inode, fattr->change_attr);
else
@@ -1801,7 +1807,7 @@ static int nfs_inode_finish_partial_attr_update(const struct nfs_fattr *fattr,
NFS_INO_INVALID_ATIME | NFS_INO_INVALID_CTIME |
NFS_INO_INVALID_MTIME | NFS_INO_INVALID_SIZE |
NFS_INO_INVALID_BLOCKS | NFS_INO_INVALID_OTHER |
- NFS_INO_INVALID_NLINK;
+ NFS_INO_INVALID_NLINK | NFS_INO_INVALID_BTIME;
unsigned long cache_validity = NFS_I(inode)->cache_validity;
enum nfs4_change_attr_type ctype = NFS_SERVER(inode)->change_attr_type;

@@ -2052,10 +2058,13 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
nfsi->read_cache_jiffies = fattr->time_start;

save_cache_validity = nfsi->cache_validity;
- nfsi->cache_validity &= ~(NFS_INO_INVALID_ATTR
- | NFS_INO_INVALID_ATIME
- | NFS_INO_REVAL_FORCED
- | NFS_INO_INVALID_BLOCKS);
+ nfsi->cache_validity &=
+ ~(NFS_INO_INVALID_ATIME | NFS_INO_REVAL_FORCED |
+ NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME |
+ NFS_INO_INVALID_MTIME | NFS_INO_INVALID_SIZE |
+ NFS_INO_INVALID_OTHER | NFS_INO_INVALID_BLOCKS |
+ NFS_INO_INVALID_NLINK | NFS_INO_INVALID_MODE |
+ NFS_INO_INVALID_BTIME);

/* Do atomic weak cache consistency updates */
nfs_wcc_update_inode(inode, fattr);
@@ -2085,7 +2094,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
| NFS_INO_INVALID_BLOCKS
| NFS_INO_INVALID_NLINK
| NFS_INO_INVALID_MODE
- | NFS_INO_INVALID_OTHER;
+ | NFS_INO_INVALID_OTHER
+ | NFS_INO_INVALID_BTIME;
if (S_ISDIR(inode->i_mode))
nfs_force_lookup_revalidate(inode);
attr_changed = true;
@@ -2116,6 +2126,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
nfsi->cache_validity |=
save_cache_validity & NFS_INO_INVALID_CTIME;

+ if (fattr->valid & NFS_ATTR_FATTR_BTIME)
+ nfsi->btime = fattr->btime;
+ else if (fattr_supported & NFS_ATTR_FATTR_BTIME)
+ nfsi->cache_validity |=
+ save_cache_validity & NFS_INO_INVALID_BTIME;
+
/* Check if our cached file size is stale */
if (fattr->valid & NFS_ATTR_FATTR_SIZE) {
new_isize = nfs_size_to_loff_t(fattr->size);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 535436dbdc9a..aabf14e5f8c8 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -207,6 +207,7 @@ const u32 nfs4_fattr_bitmap[3] = {
| FATTR4_WORD1_RAWDEV
| FATTR4_WORD1_SPACE_USED
| FATTR4_WORD1_TIME_ACCESS
+ | FATTR4_WORD1_TIME_CREATE
| FATTR4_WORD1_TIME_METADATA
| FATTR4_WORD1_TIME_MODIFY
| FATTR4_WORD1_MOUNTED_ON_FILEID,
@@ -228,6 +229,7 @@ static const u32 nfs4_pnfs_open_bitmap[3] = {
| FATTR4_WORD1_RAWDEV
| FATTR4_WORD1_SPACE_USED
| FATTR4_WORD1_TIME_ACCESS
+ | FATTR4_WORD1_TIME_CREATE
| FATTR4_WORD1_TIME_METADATA
| FATTR4_WORD1_TIME_MODIFY,
FATTR4_WORD2_MDSTHRESHOLD
@@ -307,6 +309,9 @@ static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,
dst[1] &= ~FATTR4_WORD1_MODE;
if (!(cache_validity & NFS_INO_INVALID_OTHER))
dst[1] &= ~(FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP);
+
+ if (!(cache_validity & NFS_INO_INVALID_BTIME))
+ dst[1] &= ~FATTR4_WORD1_TIME_CREATE;
}

static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry,
@@ -1232,8 +1237,8 @@ nfs4_update_changeattr_locked(struct inode *inode,
NFS_INO_INVALID_ACCESS | NFS_INO_INVALID_ACL |
NFS_INO_INVALID_SIZE | NFS_INO_INVALID_OTHER |
NFS_INO_INVALID_BLOCKS | NFS_INO_INVALID_NLINK |
- NFS_INO_INVALID_MODE | NFS_INO_INVALID_XATTR |
- NFS_INO_REVAL_PAGECACHE;
+ NFS_INO_INVALID_MODE | NFS_INO_INVALID_BTIME |
+ NFS_INO_INVALID_XATTR | NFS_INO_REVAL_PAGECACHE;
nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
}
nfsi->attrtimeo_timestamp = jiffies;
@@ -3893,6 +3898,10 @@ static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *f
server->fattr_valid &= ~NFS_ATTR_FATTR_CTIME;
if (!(res.attr_bitmask[1] & FATTR4_WORD1_TIME_MODIFY))
server->fattr_valid &= ~NFS_ATTR_FATTR_MTIME;
+ if (!(res.attr_bitmask[1] & FATTR4_WORD1_TIME_MODIFY))
+ server->fattr_valid &= ~NFS_ATTR_FATTR_MTIME;
+ if (!(res.attr_bitmask[1] & FATTR4_WORD1_TIME_CREATE))
+ server->fattr_valid &= ~NFS_ATTR_FATTR_BTIME;
memcpy(server->attr_bitmask_nl, res.attr_bitmask,
sizeof(server->attr_bitmask));
server->attr_bitmask_nl[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
@@ -5448,6 +5457,8 @@ static void nfs4_bitmask_set(__u32 bitmask[NFS4_BITMASK_SZ], const __u32 *src,
bitmask[1] |= FATTR4_WORD1_TIME_MODIFY;
if (cache_validity & NFS_INO_INVALID_BLOCKS)
bitmask[1] |= FATTR4_WORD1_SPACE_USED;
+ if (cache_validity & NFS_INO_INVALID_BTIME)
+ bitmask[1] |= FATTR4_WORD1_TIME_CREATE;

if (cache_validity & NFS_INO_INVALID_SIZE)
bitmask[0] |= FATTR4_WORD0_SIZE;
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 69862bf6db00..b60b6b8f83ad 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1616,6 +1616,7 @@ static void encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
attrs[1] |= FATTR4_WORD1_MODE|FATTR4_WORD1_NUMLINKS|FATTR4_WORD1_OWNER|
FATTR4_WORD1_OWNER_GROUP|FATTR4_WORD1_RAWDEV|
FATTR4_WORD1_SPACE_USED|FATTR4_WORD1_TIME_ACCESS|
+ FATTR4_WORD1_TIME_CREATE |
FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY;
attrs[2] |= FATTR4_WORD2_SECURITY_LABEL;
dircount >>= 1;
@@ -4121,6 +4122,24 @@ static int decode_attr_time_access(struct xdr_stream *xdr, uint32_t *bitmap, str
return status;
}

+static int decode_attr_time_create(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time)
+{
+ int status = 0;
+
+ time->tv_sec = 0;
+ time->tv_nsec = 0;
+ if (unlikely(bitmap[1] & (FATTR4_WORD1_TIME_CREATE - 1U)))
+ return -EIO;
+ if (likely(bitmap[1] & FATTR4_WORD1_TIME_CREATE)) {
+ status = decode_attr_time(xdr, time);
+ if (status == 0)
+ status = NFS_ATTR_FATTR_BTIME;
+ bitmap[1] &= ~FATTR4_WORD1_TIME_CREATE;
+ }
+ dprintk("%s: btime=%lld\n", __func__, time->tv_sec);
+ return status;
+}
+
static int decode_attr_time_metadata(struct xdr_stream *xdr, uint32_t *bitmap, struct timespec64 *time)
{
int status = 0;
@@ -4677,6 +4696,11 @@ static int decode_getfattr_attrs(struct xdr_stream *xdr, uint32_t *bitmap,
goto xdr_error;
fattr->valid |= status;

+ status = decode_attr_time_create(xdr, bitmap, &fattr->btime);
+ if (status < 0)
+ goto xdr_error;
+ fattr->valid |= status;
+
status = decode_attr_time_metadata(xdr, bitmap, &fattr->ctime);
if (status < 0)
goto xdr_error;
diff --git a/fs/nfs/nfstrace.h b/fs/nfs/nfstrace.h
index b3aee261801e..cba86d167c38 100644
--- a/fs/nfs/nfstrace.h
+++ b/fs/nfs/nfstrace.h
@@ -33,7 +33,8 @@
{ NFS_INO_INVALID_BLOCKS, "INVALID_BLOCKS" }, \
{ NFS_INO_INVALID_XATTR, "INVALID_XATTR" }, \
{ NFS_INO_INVALID_NLINK, "INVALID_NLINK" }, \
- { NFS_INO_INVALID_MODE, "INVALID_MODE" })
+ { NFS_INO_INVALID_MODE, "INVALID_MODE" }, \
+ { NFS_INO_INVALID_BTIME, "INVALID_BTIME" })

#define nfs_show_nfsi_flags(v) \
__print_flags(v, "|", \
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 05f249f20f55..18f027ce5b4b 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -136,6 +136,12 @@ struct nfs_inode {
unsigned long flags; /* atomic bit ops */
unsigned long cache_validity; /* bit mask */

+ /*
+ * NFS Attributes not included in struct inode
+ */
+
+ struct timespec64 btime;
+
/*
* read_cache_jiffies is when we started read-caching this inode.
* attrtimeo is for how long the cached information is assumed
@@ -258,6 +264,7 @@ struct nfs4_copy_state {
#define NFS_INO_INVALID_XATTR BIT(15) /* xattrs are invalid */
#define NFS_INO_INVALID_NLINK BIT(16) /* cached nlinks is invalid */
#define NFS_INO_INVALID_MODE BIT(17) /* cached mode is invalid */
+#define NFS_INO_INVALID_BTIME BIT(18) /* cached btime is invalid */

#define NFS_INO_INVALID_ATTR (NFS_INO_INVALID_CHANGE \
| NFS_INO_INVALID_CTIME \
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index d0722269b392..6b9e802ddac0 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -67,6 +67,7 @@ struct nfs_fattr {
struct timespec64 atime;
struct timespec64 mtime;
struct timespec64 ctime;
+ struct timespec64 btime;
__u64 change_attr; /* NFSv4 change attribute */
__u64 pre_change_attr;/* pre-op NFSv4 change attribute */
__u64 pre_size; /* pre_op_attr.size */
@@ -106,6 +107,7 @@ struct nfs_fattr {
#define NFS_ATTR_FATTR_OWNER_NAME BIT_ULL(23)
#define NFS_ATTR_FATTR_GROUP_NAME BIT_ULL(24)
#define NFS_ATTR_FATTR_V4_SECURITY_LABEL BIT_ULL(25)
+#define NFS_ATTR_FATTR_BTIME BIT_ULL(26)

#define NFS_ATTR_FATTR (NFS_ATTR_FATTR_TYPE \
| NFS_ATTR_FATTR_MODE \
@@ -126,6 +128,7 @@ struct nfs_fattr {
| NFS_ATTR_FATTR_SPACE_USED)
#define NFS_ATTR_FATTR_V4 (NFS_ATTR_FATTR \
| NFS_ATTR_FATTR_SPACE_USED \
+ | NFS_ATTR_FATTR_BTIME \
| NFS_ATTR_FATTR_V4_SECURITY_LABEL)

/*
--
2.33.1


2022-01-03 20:51:05

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Fri, Dec 17, 2021 at 03:48:46PM -0500, [email protected] wrote:
> From: Trond Myklebust <[email protected]>
>
> NFSv4 has support for a number of extra attributes that are of interest
> to Samba when it is used to re-export a filesystem to Windows clients.
> Aside from the btime, which is of interest in statx(), Windows clients
> have an interest in determining the status of the 'hidden', and 'system'
> flags.
> Backup programs want to read the 'archive' flags and the 'time backup'
> attribute.
> Finally, the 'offline' flag can tell whether or not a file needs to be
> staged by an HSM system before it can be read or written to.
>
> The patch series also adds an ioctl() to allow userspace retrieval and
> setting of these attributes where appropriate. It also adds an ioctl()
> to allow retrieval of the raw NFSv4 ACCESS information, to allow more
> fine grained determination of the user's access rights to a file or
> directory. All of this information is of use for Samba.

Same question, what filesystem and server are you testing against?

--b.

>
> Anne Marie Merritt (3):
> nfs: Add timecreate to nfs inode
> nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
> nfs: Add 'time backup' to nfs inode
>
> Richard Sharpe (1):
> NFS: Support statx_get and statx_set ioctls
>
> Trond Myklebust (4):
> NFS: Expand the type of nfs_fattr->valid
> NFS: Return the file btime in the statx results when appropriate
> NFSv4: Support the offline bit
> NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask
>
> fs/nfs/dir.c | 71 ++---
> fs/nfs/getroot.c | 3 +-
> fs/nfs/inode.c | 147 +++++++++-
> fs/nfs/internal.h | 10 +
> fs/nfs/nfs3proc.c | 1 +
> fs/nfs/nfs4_fs.h | 31 +++
> fs/nfs/nfs4file.c | 550 ++++++++++++++++++++++++++++++++++++++
> fs/nfs/nfs4proc.c | 175 +++++++++++-
> fs/nfs/nfs4trace.h | 8 +-
> fs/nfs/nfs4xdr.c | 240 +++++++++++++++--
> fs/nfs/nfstrace.c | 5 +
> fs/nfs/nfstrace.h | 9 +-
> fs/nfs/proc.c | 1 +
> include/linux/nfs4.h | 1 +
> include/linux/nfs_fs.h | 15 ++
> include/linux/nfs_fs_sb.h | 2 +-
> include/linux/nfs_xdr.h | 80 ++++--
> include/uapi/linux/nfs.h | 101 +++++++
> 18 files changed, 1356 insertions(+), 94 deletions(-)
>
> --
> 2.33.1

2022-01-03 20:51:47

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Mon, 2022-01-03 at 15:51 -0500, J. Bruce Fields wrote:
> On Fri, Dec 17, 2021 at 03:48:46PM -0500, [email protected] wrote:
> > From: Trond Myklebust <[email protected]>
> >
> > NFSv4 has support for a number of extra attributes that are of
> > interest
> > to Samba when it is used to re-export a filesystem to Windows
> > clients.
> > Aside from the btime, which is of interest in statx(), Windows
> > clients
> > have an interest in determining the status of the 'hidden', and
> > 'system'
> > flags.
> > Backup programs want to read the 'archive' flags and the 'time
> > backup'
> > attribute.
> > Finally, the 'offline' flag can tell whether or not a file needs to
> > be
> > staged by an HSM system before it can be read or written to.
> >
> > The patch series also adds an ioctl() to allow userspace retrieval
> > and
> > setting of these attributes where appropriate. It also adds an
> > ioctl()
> > to allow retrieval of the raw NFSv4 ACCESS information, to allow
> > more
> > fine grained determination of the user's access rights to a file or
> > directory. All of this information is of use for Samba.
>
> Same question, what filesystem and server are you testing against?
>

Same answer.

> --b.
>
> >
> > Anne Marie Merritt (3):
> >   nfs: Add timecreate to nfs inode
> >   nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
> >   nfs: Add 'time backup' to nfs inode
> >
> > Richard Sharpe (1):
> >   NFS: Support statx_get and statx_set ioctls
> >
> > Trond Myklebust (4):
> >   NFS: Expand the type of nfs_fattr->valid
> >   NFS: Return the file btime in the statx results when appropriate
> >   NFSv4: Support the offline bit
> >   NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask
> >
> >  fs/nfs/dir.c              |  71 ++---
> >  fs/nfs/getroot.c          |   3 +-
> >  fs/nfs/inode.c            | 147 +++++++++-
> >  fs/nfs/internal.h         |  10 +
> >  fs/nfs/nfs3proc.c         |   1 +
> >  fs/nfs/nfs4_fs.h          |  31 +++
> >  fs/nfs/nfs4file.c         | 550
> > ++++++++++++++++++++++++++++++++++++++
> >  fs/nfs/nfs4proc.c         | 175 +++++++++++-
> >  fs/nfs/nfs4trace.h        |   8 +-
> >  fs/nfs/nfs4xdr.c          | 240 +++++++++++++++--
> >  fs/nfs/nfstrace.c         |   5 +
> >  fs/nfs/nfstrace.h         |   9 +-
> >  fs/nfs/proc.c             |   1 +
> >  include/linux/nfs4.h      |   1 +
> >  include/linux/nfs_fs.h    |  15 ++
> >  include/linux/nfs_fs_sb.h |   2 +-
> >  include/linux/nfs_xdr.h   |  80 ++++--
> >  include/uapi/linux/nfs.h  | 101 +++++++
> >  18 files changed, 1356 insertions(+), 94 deletions(-)
> >
> > --
> > 2.33.1

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]


2022-01-05 15:06:00

by Ondrej Valousek

[permalink] [raw]
Subject: RE: [PATCH 0/8] Support btime and other NFSv4 specific attributes

Hi all,
Sorry for confusion and maybe dumb questions:
- The aim is to transfer these attributes via RFC8276 (File System Extended attributes in NFSv4)?
- AFAIK support for RFC8276 in NFS (only version 4.2) server is since kernel 5.9, right? NFS client supports these as well?
- The patches below implements the feature in both, nfs client AND server, right?

I am bit confused as "btime" does not seem to be stored as extended attribute in most local filesystems (checked ext4) but is in standard inode structure.
Thanks,
Ondrej


-----Original Message-----
From: Trond Myklebust <[email protected]>
Sent: pondělí 3. ledna 2022 21:52
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Mon, 2022-01-03 at 15:51 -0500, J. Bruce Fields wrote:
> On Fri, Dec 17, 2021 at 03:48:46PM -0500, [email protected] wrote:
> > From: Trond Myklebust <[email protected]>
> >
> > NFSv4 has support for a number of extra attributes that are of
> > interest to Samba when it is used to re-export a filesystem to
> > Windows clients.
> > Aside from the btime, which is of interest in statx(), Windows
> > clients have an interest in determining the status of the 'hidden',
> > and 'system'
> > flags.
> > Backup programs want to read the 'archive' flags and the 'time
> > backup'
> > attribute.
> > Finally, the 'offline' flag can tell whether or not a file needs to
> > be staged by an HSM system before it can be read or written to.
> >
> > The patch series also adds an ioctl() to allow userspace retrieval
> > and setting of these attributes where appropriate. It also adds an
> > ioctl()
> > to allow retrieval of the raw NFSv4 ACCESS information, to allow
> > more fine grained determination of the user's access rights to a
> > file or directory. All of this information is of use for Samba.
>
> Same question, what filesystem and server are you testing against?
>

Same answer.

> --b.
>
> >
> > Anne Marie Merritt (3):
> > nfs: Add timecreate to nfs inode
> > nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
> > nfs: Add 'time backup' to nfs inode
> >
> > Richard Sharpe (1):
> > NFS: Support statx_get and statx_set ioctls
> >
> > Trond Myklebust (4):
> > NFS: Expand the type of nfs_fattr->valid
> > NFS: Return the file btime in the statx results when appropriate
> > NFSv4: Support the offline bit
> > NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask
> >
> > fs/nfs/dir.c | 71 ++---
> > fs/nfs/getroot.c | 3 +-
> > fs/nfs/inode.c | 147 +++++++++-
> > fs/nfs/internal.h | 10 +
> > fs/nfs/nfs3proc.c | 1 +
> > fs/nfs/nfs4_fs.h | 31 +++
> > fs/nfs/nfs4file.c | 550
> > ++++++++++++++++++++++++++++++++++++++
> > fs/nfs/nfs4proc.c | 175 +++++++++++-
> > fs/nfs/nfs4trace.h | 8 +-
> > fs/nfs/nfs4xdr.c | 240 +++++++++++++++--
> > fs/nfs/nfstrace.c | 5 +
> > fs/nfs/nfstrace.h | 9 +-
> > fs/nfs/proc.c | 1 +
> > include/linux/nfs4.h | 1 +
> > include/linux/nfs_fs.h | 15 ++
> > include/linux/nfs_fs_sb.h | 2 +-
> > include/linux/nfs_xdr.h | 80 ++++--
> > include/uapi/linux/nfs.h | 101 +++++++
> > 18 files changed, 1356 insertions(+), 94 deletions(-)
> >
> > --
> > 2.33.1

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace [email protected]


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.

2022-01-05 15:10:11

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Wed, Jan 05, 2022 at 03:05:17PM +0000, Ondrej Valousek wrote:
> Sorry for confusion and maybe dumb questions:
> - The aim is to transfer these attributes via RFC8276 (File System Extended attributes in NFSv4)?

No, NFSv4 defines attributes for all of these.

RFC8276 attributes are purely for user-defined attribues, not for
anything that the server or filesystem gives specific meaning.

> - AFAIK support for RFC8276 in NFS (only version 4.2) server is since kernel 5.9, right? NFS client supports these as well?
> - The patches below implements the feature in both, nfs client AND server, right?

Client only.

These would probably be quite easy to support on the server side when
the filesystem supports them, but nobody's volunteered to implement
that yet; patches welcome.

--b.

2022-01-05 15:10:12

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Wed, 2022-01-05 at 15:05 +0000, Ondrej Valousek wrote:
> Hi all,
> Sorry for confusion and maybe dumb questions:
> - The aim is to transfer these attributes via RFC8276 (File System
> Extended attributes in NFSv4)?

No.

> - AFAIK support for RFC8276 in NFS (only version 4.2) server is since
> kernel 5.9, right? NFS client supports these as well?
> - The patches below implements the feature in both, nfs client AND
> server, right?
>
> I am bit confused as "btime" does not seem to be stored as extended
> attribute in most local filesystems (checked ext4) but is in standard
> inode structure.

All these attributes are defined as regular attributes in rfc7530. All
this code does is add the standard NFSv4 encoders/decoders for these
attributes and adds the ioctl() to set/retrieve them all.

There is no need to hack the NFS protocol to retrieve or set them using
the xattr stuff.

> Thanks,
> Ondrej
>
>
> -----Original Message-----
> From: Trond Myklebust <[email protected]>
> Sent: pondělí 3. ledna 2022 21:52
> To: [email protected]; [email protected]
> Cc: [email protected]; [email protected]
> Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific
> attributes
>
> On Mon, 2022-01-03 at 15:51 -0500, J. Bruce Fields wrote:
> > On Fri, Dec 17, 2021 at 03:48:46PM -0500, [email protected] wrote:
> > > From: Trond Myklebust <[email protected]>
> > >
> > > NFSv4 has support for a number of extra attributes that are of
> > > interest to Samba when it is used to re-export a filesystem to
> > > Windows clients.
> > > Aside from the btime, which is of interest in statx(), Windows
> > > clients have an interest in determining the status of the
> > > 'hidden',
> > > and 'system'
> > > flags.
> > > Backup programs want to read the 'archive' flags and the 'time
> > > backup'
> > > attribute.
> > > Finally, the 'offline' flag can tell whether or not a file needs
> > > to
> > > be staged by an HSM system before it can be read or written to.
> > >
> > > The patch series also adds an ioctl() to allow userspace
> > > retrieval
> > > and setting of these attributes where appropriate. It also adds
> > > an
> > > ioctl()
> > > to allow retrieval of the raw NFSv4 ACCESS information, to allow
> > > more fine grained determination of the user's access rights to a
> > > file or directory. All of this information is of use for Samba.
> >
> > Same question, what filesystem and server are you testing against?
> >
>
> Same answer.
>
> > --b.
> >
> > >
> > > Anne Marie Merritt (3):
> > >   nfs: Add timecreate to nfs inode
> > >   nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
> > >   nfs: Add 'time backup' to nfs inode
> > >
> > > Richard Sharpe (1):
> > >   NFS: Support statx_get and statx_set ioctls
> > >
> > > Trond Myklebust (4):
> > >   NFS: Expand the type of nfs_fattr->valid
> > >   NFS: Return the file btime in the statx results when
> > > appropriate
> > >   NFSv4: Support the offline bit
> > >   NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS
> > > mask
> > >
> > >  fs/nfs/dir.c              |  71 ++---
> > >  fs/nfs/getroot.c          |   3 +-
> > >  fs/nfs/inode.c            | 147 +++++++++-
> > >  fs/nfs/internal.h         |  10 +
> > >  fs/nfs/nfs3proc.c         |   1 +
> > >  fs/nfs/nfs4_fs.h          |  31 +++
> > >  fs/nfs/nfs4file.c         | 550
> > > ++++++++++++++++++++++++++++++++++++++
> > >  fs/nfs/nfs4proc.c         | 175 +++++++++++-
> > >  fs/nfs/nfs4trace.h        |   8 +-
> > >  fs/nfs/nfs4xdr.c          | 240 +++++++++++++++--
> > >  fs/nfs/nfstrace.c         |   5 +
> > >  fs/nfs/nfstrace.h         |   9 +-
> > >  fs/nfs/proc.c             |   1 +
> > >  include/linux/nfs4.h      |   1 +
> > >  include/linux/nfs_fs.h    |  15 ++
> > >  include/linux/nfs_fs_sb.h |   2 +-
> > >  include/linux/nfs_xdr.h   |  80 ++++--
> > >  include/uapi/linux/nfs.h  | 101 +++++++
> > >  18 files changed, 1356 insertions(+), 94 deletions(-)
> > >
> > > --
> > > 2.33.1
>
> --
> Trond Myklebust
> Linux NFS client maintainer, Hammerspace
> [email protected]
>
>
> 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.

--
Trond Myklebust
CTO, Hammerspace Inc
4984 El Camino Real, Suite 208
Los Altos, CA 94022

http://www.hammer.space

2022-01-05 15:40:26

by Ondrej Valousek

[permalink] [raw]
Subject: RE: [PATCH 0/8] Support btime and other NFSv4 specific attributes


>> - AFAIK support for RFC8276 in NFS (only version 4.2) server is since kernel 5.9, right? NFS client supports these as well?
>> - The patches below implements the feature in both, nfs client AND server, right?

> Client only.

Right, but then it will be only useful if we use non-linux based NFS server right?

I mean simply:
1. $ stat /tmp/foo.txt --> shows birth date
2. # exportfs \*/tmp
3. # mount 127.0.0.1:/tmp /mnt
4. $ stat /mnt/foo.txt --> no birth date shown
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.

2022-01-05 15:55:01

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Wed, Jan 05, 2022 at 03:40:19PM +0000, Ondrej Valousek wrote:
>
> >> - AFAIK support for RFC8276 in NFS (only version 4.2) server is since kernel 5.9, right? NFS client supports these as well?
> >> - The patches below implements the feature in both, nfs client AND server, right?
>
> > Client only.
>
> Right, but then it will be only useful if we use non-linux based NFS server right?
>
> I mean simply:
> 1. $ stat /tmp/foo.txt --> shows birth date
> 2. # exportfs \*/tmp
> 3. # mount 127.0.0.1:/tmp /mnt
> 4. $ stat /mnt/foo.txt --> no birth date shown

Right.

Fixing that's likely just a few lines of code added to
fs/nfsd/nfs4xdr.c:nfsd4_encode_fattr(). Patches welcome.

--b.

2022-01-06 09:31:24

by Ondrej Valousek

[permalink] [raw]
Subject: RE: [PATCH 0/8] Support btime and other NFSv4 specific attributes

Looks like this should do I guess...

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5a93a5db4fb0..be47e1dd6da5 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3265,6 +3265,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;



-----Original Message-----
From: [email protected] <[email protected]>
Sent: st?eda 5. ledna 2022 16:55
To: Ondrej Valousek <[email protected]>
Cc: Trond Myklebust <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Wed, Jan 05, 2022 at 03:40:19PM +0000, Ondrej Valousek wrote:
>
> >> - AFAIK support for RFC8276 in NFS (only version 4.2) server is since kernel 5.9, right? NFS client supports these as well?
> >> - The patches below implements the feature in both, nfs client AND server, right?
>
> > Client only.
>
> Right, but then it will be only useful if we use non-linux based NFS server right?
>
> I mean simply:
> 1. $ stat /tmp/foo.txt --> shows birth date
> 2. # exportfs \*/tmp
> 3. # mount 127.0.0.1:/tmp /mnt
> 4. $ stat /mnt/foo.txt --> no birth date shown

Right.

Fixing that's likely just a few lines of code added to fs/nfsd/nfs4xdr.c:nfsd4_encode_fattr(). Patches welcome.

--b.
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.

2022-01-06 14:15:28

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Thu, 2022-01-06 at 09:31 +0000, Ondrej Valousek wrote:
> Looks like this should do I guess...
>
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 5a93a5db4fb0..be47e1dd6da5 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -3265,6 +3265,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;
>

You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to
reflect the new support for FATTR4_WORD1_TIME_CREATE.


--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]


2022-01-06 14:19:32

by Ondrej Valousek

[permalink] [raw]
Subject: RE: [PATCH 0/8] Support btime and other NFSv4 specific attributes

> You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to reflect the new support for FATTR4_WORD1_TIME_CREATE.

Yes, I realized that one shortly after I sent the mail.
Just going to try this patch:

[[email protected] /opt/kernel/linux-git/fs/nfsd]$ git diff
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5a93a5db4fb0..be47e1dd6da5 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3265,6 +3265,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


... will see

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.

2022-01-06 14:28:14

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Thu, Jan 06, 2022 at 02:19:22PM +0000, Ondrej Valousek wrote:
> > You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to reflect the new support for FATTR4_WORD1_TIME_CREATE.
>
> Yes, I realized that one shortly after I sent the mail.
> Just going to try this patch:

Thanks!

Don't we want to vary support depending on the filesystem, though? Is
there a way to query that?

--b.

>
> [[email protected] /opt/kernel/linux-git/fs/nfsd]$ git diff
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 5a93a5db4fb0..be47e1dd6da5 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -3265,6 +3265,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
>
>
> ... will see
>
> 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.

2022-01-06 14:36:08

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Thu, Jan 06, 2022 at 09:28:12AM -0500, [email protected] wrote:
> On Thu, Jan 06, 2022 at 02:19:22PM +0000, Ondrej Valousek wrote:
> > > You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to reflect the new support for FATTR4_WORD1_TIME_CREATE.
> >
> > Yes, I realized that one shortly after I sent the mail.
> > Just going to try this patch:
>
> Thanks!
>
> Don't we want to vary support depending on the filesystem, though? Is
> there a way to query that?

Poking around a bit... looks like we need to check stat->result_mask &
STATX_BTIME. And use that to adjust the value of bmval0 at the top of
encode_fattr, and make the below encoding conditional on it.

?

--b.

>
> --b.
>
> >
> > [[email protected] /opt/kernel/linux-git/fs/nfsd]$ git diff
> > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> > index 5a93a5db4fb0..be47e1dd6da5 100644
> > --- a/fs/nfsd/nfs4xdr.c
> > +++ b/fs/nfsd/nfs4xdr.c
> > @@ -3265,6 +3265,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
> >
> >
> > ... will see
> >
> > 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.

2022-01-06 14:52:45

by Ondrej Valousek

[permalink] [raw]
Subject: RE: [PATCH 0/8] Support btime and other NFSv4 specific attributes

You rather mean bmval1 not bmval0, right?

-----Original Message-----
From: [email protected] <[email protected]>
Sent: ?tvrtek 6. ledna 2022 15:36
To: Ondrej Valousek <[email protected]>
Cc: Trond Myklebust <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Thu, Jan 06, 2022 at 09:28:12AM -0500, [email protected] wrote:
> On Thu, Jan 06, 2022 at 02:19:22PM +0000, Ondrej Valousek wrote:
> > > You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to reflect the new support for FATTR4_WORD1_TIME_CREATE.
> >
> > Yes, I realized that one shortly after I sent the mail.
> > Just going to try this patch:
>
> Thanks!
>
> Don't we want to vary support depending on the filesystem, though? Is
> there a way to query that?

Poking around a bit... looks like we need to check stat->result_mask & STATX_BTIME. And use that to adjust the value of bmval0 at the top of encode_fattr, and make the below encoding conditional on it.

?

--b.

>
> --b.
>
> >
> > [[email protected] /opt/kernel/linux-git/fs/nfsd]$ git diff diff
> > --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index
> > 5a93a5db4fb0..be47e1dd6da5 100644
> > --- a/fs/nfsd/nfs4xdr.c
> > +++ b/fs/nfsd/nfs4xdr.c
> > @@ -3265,6 +3265,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
> >
> >
> > ... will see
> >
> > 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.
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.

2022-01-06 14:55:49

by J. Bruce Fields

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Thu, Jan 06, 2022 at 02:52:36PM +0000, Ondrej Valousek wrote:
> You rather mean bmval1 not bmval0, right?

Oops, right.--b.

>
> -----Original Message-----
> From: [email protected] <[email protected]>
> Sent: čtvrtek 6. ledna 2022 15:36
> To: Ondrej Valousek <[email protected]>
> Cc: Trond Myklebust <[email protected]>; [email protected]; [email protected]; [email protected]
> Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes
>
> On Thu, Jan 06, 2022 at 09:28:12AM -0500, [email protected] wrote:
> > On Thu, Jan 06, 2022 at 02:19:22PM +0000, Ondrej Valousek wrote:
> > > > You also need to update the value of NFSD4_SUPPORTED_ATTRS_WORD1 to reflect the new support for FATTR4_WORD1_TIME_CREATE.
> > >
> > > Yes, I realized that one shortly after I sent the mail.
> > > Just going to try this patch:
> >
> > Thanks!
> >
> > Don't we want to vary support depending on the filesystem, though? Is
> > there a way to query that?
>
> Poking around a bit... looks like we need to check stat->result_mask & STATX_BTIME. And use that to adjust the value of bmval0 at the top of encode_fattr, and make the below encoding conditional on it.
>
> ?
>
> --b.
>
> >
> > --b.
> >
> > >
> > > [[email protected] /opt/kernel/linux-git/fs/nfsd]$ git diff diff
> > > --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index
> > > 5a93a5db4fb0..be47e1dd6da5 100644
> > > --- a/fs/nfsd/nfs4xdr.c
> > > +++ b/fs/nfsd/nfs4xdr.c
> > > @@ -3265,6 +3265,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
> > >
> > >
> > > ... will see
> > >
> > > 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.
> 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.

2022-01-06 16:13:33

by Ondrej Valousek

[permalink] [raw]
Subject: RE: [PATCH 0/8] Support btime and other NFSv4 specific attributes

So I think this is what we eventually need (thanks for the pointers you gave me!):

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 5a93a5db4fb0..e88ae4ce5263 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.

2022-01-06 16:59:23

by Chuck Lever III

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes



> On Jan 6, 2022, at 11:13 AM, Ondrej Valousek <[email protected]> wrote:
>
> So I think this is what we eventually need (thanks for the pointers you gave me!):
>
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index 5a93a5db4fb0..e88ae4ce5263 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.

Thanks, Ondrej.

This looks like an interesting new feature, however it's a little
late for the v5.17 merge window, IMO. (On the plus side, that gives
us a month or two for further review and deeper testing).

Also, the change needs to be submitted as a real patch. See the

Documentation/process/submitting-patches.rst

file in the Linux kernel tree for information on the p's and q's.
In particular:

-- you need a short and full patch description. The "Describe
your changes" section explains the details.

-- you need to ensure your employer permits you to contribute
to the Linux kernel under GPLv2. The "Sign your work - the
Developer's Certificate of Origin" section explains this.

I'm a little concerned about your Legal Disclaimer which suggests
that anything you have sent in e-mail is already owned by Renesas
and is therefore constrained for submission to the kernel. Before
submitting again, can you ask your legal team for clarification?

--
Chuck Lever




2022-01-06 18:47:40

by Olga Kornievskaia

[permalink] [raw]
Subject: Re: [PATCH 0/8] Support btime and other NFSv4 specific attributes

On Mon, Jan 3, 2022 at 4:34 PM J. Bruce Fields <[email protected]> wrote:
>
> On Fri, Dec 17, 2021 at 03:48:46PM -0500, [email protected] wrote:
> > From: Trond Myklebust <[email protected]>
> >
> > NFSv4 has support for a number of extra attributes that are of interest
> > to Samba when it is used to re-export a filesystem to Windows clients.
> > Aside from the btime, which is of interest in statx(), Windows clients
> > have an interest in determining the status of the 'hidden', and 'system'
> > flags.
> > Backup programs want to read the 'archive' flags and the 'time backup'
> > attribute.
> > Finally, the 'offline' flag can tell whether or not a file needs to be
> > staged by an HSM system before it can be read or written to.
> >
> > The patch series also adds an ioctl() to allow userspace retrieval and
> > setting of these attributes where appropriate. It also adds an ioctl()
> > to allow retrieval of the raw NFSv4 ACCESS information, to allow more
> > fine grained determination of the user's access rights to a file or
> > directory. All of this information is of use for Samba.
>
> Same question, what filesystem and server are you testing against?

I have tested the patch set against the Netapp filer. generic/528
tests the btime attribute. I'm not sure if xfstests has any other
tests for archive, offline, hidden attributes.

>
> --b.
>
> >
> > Anne Marie Merritt (3):
> > nfs: Add timecreate to nfs inode
> > nfs: Add 'archive', 'hidden' and 'system' fields to nfs inode
> > nfs: Add 'time backup' to nfs inode
> >
> > Richard Sharpe (1):
> > NFS: Support statx_get and statx_set ioctls
> >
> > Trond Myklebust (4):
> > NFS: Expand the type of nfs_fattr->valid
> > NFS: Return the file btime in the statx results when appropriate
> > NFSv4: Support the offline bit
> > NFSv4: Add an ioctl to allow retrieval of the NFS raw ACCESS mask
> >
> > fs/nfs/dir.c | 71 ++---
> > fs/nfs/getroot.c | 3 +-
> > fs/nfs/inode.c | 147 +++++++++-
> > fs/nfs/internal.h | 10 +
> > fs/nfs/nfs3proc.c | 1 +
> > fs/nfs/nfs4_fs.h | 31 +++
> > fs/nfs/nfs4file.c | 550 ++++++++++++++++++++++++++++++++++++++
> > fs/nfs/nfs4proc.c | 175 +++++++++++-
> > fs/nfs/nfs4trace.h | 8 +-
> > fs/nfs/nfs4xdr.c | 240 +++++++++++++++--
> > fs/nfs/nfstrace.c | 5 +
> > fs/nfs/nfstrace.h | 9 +-
> > fs/nfs/proc.c | 1 +
> > include/linux/nfs4.h | 1 +
> > include/linux/nfs_fs.h | 15 ++
> > include/linux/nfs_fs_sb.h | 2 +-
> > include/linux/nfs_xdr.h | 80 ++++--
> > include/uapi/linux/nfs.h | 101 +++++++
> > 18 files changed, 1356 insertions(+), 94 deletions(-)
> >
> > --
> > 2.33.1