Skip to content

Commit b78ef84

Browse files
fllindenTrond Myklebust
authored andcommitted
NFSv4.2: query the server for extended attribute support
Query the server for extended attribute support, and record it as the NFS_CAP_XATTR flag in the server capabilities. Signed-off-by: Frank van der Linden <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent 04a5da6 commit b78ef84

File tree

5 files changed

+32
-1
lines changed

5 files changed

+32
-1
lines changed

fs/nfs/client.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,9 @@ static void nfs_server_set_fsinfo(struct nfs_server *server,
809809
XATTR_SIZE_MAX);
810810
server->lxasize = min_t(unsigned int, raw_max_rpc_payload,
811811
nfs42_listxattr_xdrsize(XATTR_LIST_MAX));
812+
813+
if (fsinfo->xattr_support)
814+
server->caps |= NFS_CAP_XATTR;
812815
#endif
813816
}
814817

fs/nfs/nfs4proc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ const u32 nfs4_fsinfo_bitmap[3] = { FATTR4_WORD0_MAXFILESIZE
256256
| FATTR4_WORD1_FS_LAYOUT_TYPES,
257257
FATTR4_WORD2_LAYOUT_BLKSIZE
258258
| FATTR4_WORD2_CLONE_BLKSIZE
259+
| FATTR4_WORD2_XATTR_SUPPORT
259260
};
260261

261262
const u32 nfs4_fs_locations_bitmap[3] = {
@@ -3740,7 +3741,7 @@ static void nfs4_close_context(struct nfs_open_context *ctx, int is_sync)
37403741

37413742
#define FATTR4_WORD1_NFS40_MASK (2*FATTR4_WORD1_MOUNTED_ON_FILEID - 1UL)
37423743
#define FATTR4_WORD2_NFS41_MASK (2*FATTR4_WORD2_SUPPATTR_EXCLCREAT - 1UL)
3743-
#define FATTR4_WORD2_NFS42_MASK (2*FATTR4_WORD2_MODE_UMASK - 1UL)
3744+
#define FATTR4_WORD2_NFS42_MASK (2*FATTR4_WORD2_XATTR_SUPPORT - 1UL)
37443745

37453746
static int _nfs4_server_capabilities(struct nfs_server *server, struct nfs_fh *fhandle)
37463747
{

fs/nfs/nfs4xdr.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4201,6 +4201,26 @@ static int decode_attr_time_modify(struct xdr_stream *xdr, uint32_t *bitmap, str
42014201
return status;
42024202
}
42034203

4204+
static int decode_attr_xattrsupport(struct xdr_stream *xdr, uint32_t *bitmap,
4205+
uint32_t *res)
4206+
{
4207+
__be32 *p;
4208+
4209+
*res = 0;
4210+
if (unlikely(bitmap[2] & (FATTR4_WORD2_XATTR_SUPPORT - 1U)))
4211+
return -EIO;
4212+
if (likely(bitmap[2] & FATTR4_WORD2_XATTR_SUPPORT)) {
4213+
p = xdr_inline_decode(xdr, 4);
4214+
if (unlikely(!p))
4215+
return -EIO;
4216+
*res = be32_to_cpup(p);
4217+
bitmap[2] &= ~FATTR4_WORD2_XATTR_SUPPORT;
4218+
}
4219+
dprintk("%s: XATTR support=%s\n", __func__,
4220+
*res == 0 ? "false" : "true");
4221+
return 0;
4222+
}
4223+
42044224
static int verify_attr_len(struct xdr_stream *xdr, unsigned int savep, uint32_t attrlen)
42054225
{
42064226
unsigned int attrwords = XDR_QUADLEN(attrlen);
@@ -4855,6 +4875,11 @@ static int decode_fsinfo(struct xdr_stream *xdr, struct nfs_fsinfo *fsinfo)
48554875
if (status)
48564876
goto xdr_error;
48574877

4878+
status = decode_attr_xattrsupport(xdr, bitmap,
4879+
&fsinfo->xattr_support);
4880+
if (status)
4881+
goto xdr_error;
4882+
48584883
status = verify_attr_len(xdr, savep, attrlen);
48594884
xdr_error:
48604885
dprintk("%s: xdr returned %d!\n", __func__, -status);

include/linux/nfs_fs_sb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,6 @@ struct nfs_server {
286286
#define NFS_CAP_OFFLOAD_CANCEL (1U << 25)
287287
#define NFS_CAP_LAYOUTERROR (1U << 26)
288288
#define NFS_CAP_COPY_NOTIFY (1U << 27)
289+
#define NFS_CAP_XATTR (1U << 28)
289290

290291
#endif

include/linux/nfs_xdr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ struct nfs_fsinfo {
150150
__u32 layouttype[NFS_MAX_LAYOUT_TYPES]; /* supported pnfs layout driver */
151151
__u32 blksize; /* preferred pnfs io block size */
152152
__u32 clone_blksize; /* granularity of a CLONE operation */
153+
__u32 xattr_support; /* User xattrs supported */
153154
};
154155

155156
struct nfs_fsstat {

0 commit comments

Comments
 (0)