NFSv4.2: LAYOUTSTATS is optional to implement
authorTrond Myklebust <trond.myklebust@primarydata.com>
Sat, 27 Jun 2015 15:45:46 +0000 (11:45 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Sat, 27 Jun 2015 15:48:58 +0000 (11:48 -0400)
Make it so, by checking the return value for NFS4ERR_MOTSUPP and
caching the information as a server capability.

Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/nfs42proc.c
fs/nfs/nfs4proc.c
fs/nfs/pnfs.c
include/linux/nfs_fs_sb.h

index 06c74cd9387566ff57c2b8a23109b7895d215755..f486b80f927ab7204159852a9740900a6c73aec6 100644 (file)
@@ -189,9 +189,15 @@ nfs42_layoutstat_done(struct rpc_task *task, void *calldata)
        if (!nfs4_sequence_done(task, &data->res.seq_res))
                return;
 
-       /* well, we don't care about errors at all! */
-       if (task->tk_status)
+       switch (task->tk_status) {
+       case 0:
+               break;
+       case -ENOTSUPP:
+       case -EOPNOTSUPP:
+               NFS_SERVER(data->inode)->caps &= ~NFS_CAP_LAYOUTSTATS;
+       default:
                dprintk("%s server returns %d\n", __func__, task->tk_status);
+       }
 }
 
 static void
index 643ce3a91b2299c197292a4c5f6956320464a7f8..8eab42407d39d9c8b2e9c6a9b333f2aac2260af2 100644 (file)
@@ -8635,7 +8635,8 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
                | NFS_CAP_ATOMIC_OPEN_V1
                | NFS_CAP_ALLOCATE
                | NFS_CAP_DEALLOCATE
-               | NFS_CAP_SEEK,
+               | NFS_CAP_SEEK
+               | NFS_CAP_LAYOUTSTATS,
        .init_client = nfs41_init_client,
        .shutdown_client = nfs41_shutdown_client,
        .match_stateid = nfs41_match_stateid,
index 40bacebb5b97deda58036d78e06ead361dc7c128..0ba9a02c95664960f8c0f46ea97249bd8653fe16 100644 (file)
@@ -2266,6 +2266,9 @@ pnfs_report_layoutstat(struct inode *inode)
        if (!pnfs_enabled_sb(server) || !ld->prepare_layoutstats)
                goto out;
 
+       if (!nfs_server_capable(inode, NFS_CAP_LAYOUTSTATS))
+               goto out;
+
        if (test_and_set_bit(NFS_INO_LAYOUTSTATS, &nfsi->flags))
                goto out;
 
index 5e1273d4de14064198489a7aaccb73a88f36e7b8..a2ea1491d3dfc487611445490fb10adf9972d777 100644 (file)
@@ -237,5 +237,6 @@ struct nfs_server {
 #define NFS_CAP_SEEK           (1U << 19)
 #define NFS_CAP_ALLOCATE       (1U << 20)
 #define NFS_CAP_DEALLOCATE     (1U << 21)
+#define NFS_CAP_LAYOUTSTATS    (1U << 22)
 
 #endif