Skip to content

Commit 6c5a0d8

Browse files
committed
NFSv4.2: LAYOUTSTATS is optional to implement
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>
1 parent da2e812 commit 6c5a0d8

4 files changed

Lines changed: 14 additions & 3 deletions

File tree

fs/nfs/nfs42proc.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,15 @@ nfs42_layoutstat_done(struct rpc_task *task, void *calldata)
189189
if (!nfs4_sequence_done(task, &data->res.seq_res))
190190
return;
191191

192-
/* well, we don't care about errors at all! */
193-
if (task->tk_status)
192+
switch (task->tk_status) {
193+
case 0:
194+
break;
195+
case -ENOTSUPP:
196+
case -EOPNOTSUPP:
197+
NFS_SERVER(data->inode)->caps &= ~NFS_CAP_LAYOUTSTATS;
198+
default:
194199
dprintk("%s server returns %d\n", __func__, task->tk_status);
200+
}
195201
}
196202

197203
static void

fs/nfs/nfs4proc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8635,7 +8635,8 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
86358635
| NFS_CAP_ATOMIC_OPEN_V1
86368636
| NFS_CAP_ALLOCATE
86378637
| NFS_CAP_DEALLOCATE
8638-
| NFS_CAP_SEEK,
8638+
| NFS_CAP_SEEK
8639+
| NFS_CAP_LAYOUTSTATS,
86398640
.init_client = nfs41_init_client,
86408641
.shutdown_client = nfs41_shutdown_client,
86418642
.match_stateid = nfs41_match_stateid,

fs/nfs/pnfs.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2266,6 +2266,9 @@ pnfs_report_layoutstat(struct inode *inode)
22662266
if (!pnfs_enabled_sb(server) || !ld->prepare_layoutstats)
22672267
goto out;
22682268

2269+
if (!nfs_server_capable(inode, NFS_CAP_LAYOUTSTATS))
2270+
goto out;
2271+
22692272
if (test_and_set_bit(NFS_INO_LAYOUTSTATS, &nfsi->flags))
22702273
goto out;
22712274

include/linux/nfs_fs_sb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,5 +237,6 @@ struct nfs_server {
237237
#define NFS_CAP_SEEK (1U << 19)
238238
#define NFS_CAP_ALLOCATE (1U << 20)
239239
#define NFS_CAP_DEALLOCATE (1U << 21)
240+
#define NFS_CAP_LAYOUTSTATS (1U << 22)
240241

241242
#endif

0 commit comments

Comments
 (0)