Skip to content

Commit 044cfb7

Browse files
author
Prakash Surya
committed
Update "fs/nfsd" based on "upstream/master"
1 parent b283920 commit 044cfb7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5381
-3713
lines changed

fs/nfsd/Kconfig

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ config NFSD
88
select SUNRPC
99
select EXPORTFS
1010
select NFS_ACL_SUPPORT if NFSD_V2_ACL
11+
select NFS_ACL_SUPPORT if NFSD_V3_ACL
1112
depends on MULTIUSER
1213
help
1314
Choose Y here if you want to allow other computers to access
@@ -26,28 +27,29 @@ config NFSD
2627

2728
Below you can choose which versions of the NFS protocol are
2829
available to clients mounting the NFS server on this system.
29-
Support for NFS version 2 (RFC 1094) is always available when
30+
Support for NFS version 3 (RFC 1813) is always available when
3031
CONFIG_NFSD is selected.
3132

3233
If unsure, say N.
3334

34-
config NFSD_V2_ACL
35-
bool
36-
depends on NFSD
37-
38-
config NFSD_V3
39-
bool "NFS server support for NFS version 3"
35+
config NFSD_V2
36+
bool "NFS server support for NFS version 2 (DEPRECATED)"
4037
depends on NFSD
38+
default n
4139
help
42-
This option enables support in your system's NFS server for
43-
version 3 of the NFS protocol (RFC 1813).
40+
NFSv2 (RFC 1094) was the first publicly-released version of NFS.
41+
Unless you are hosting ancient (1990's era) NFS clients, you don't
42+
need this.
4443

45-
If unsure, say Y.
44+
If unsure, say N.
45+
46+
config NFSD_V2_ACL
47+
bool "NFS server support for the NFSv2 ACL protocol extension"
48+
depends on NFSD_V2
4649

4750
config NFSD_V3_ACL
4851
bool "NFS server support for the NFSv3 ACL protocol extension"
49-
depends on NFSD_V3
50-
select NFSD_V2_ACL
52+
depends on NFSD
5153
help
5254
Solaris NFS servers support an auxiliary NFSv3 ACL protocol that
5355
never became an official part of the NFS version 3 protocol.
@@ -70,9 +72,8 @@ config NFSD_V3_ACL
7072
config NFSD_V4
7173
bool "NFS server support for NFS version 4"
7274
depends on NFSD && PROC_FS
73-
select NFSD_V3
7475
select FS_POSIX_ACL
75-
select SUNRPC_GSS
76+
select RPCSEC_GSS_KRB5
7677
select CRYPTO
7778
select CRYPTO_MD5
7879
select CRYPTO_SHA256
@@ -109,7 +110,6 @@ config NFSD_SCSILAYOUT
109110
depends on NFSD_V4 && BLOCK
110111
select NFSD_PNFS
111112
select EXPORTFS_BLOCK_OPS
112-
select SCSI_COMMON
113113
help
114114
This option enables support for the exporting pNFS SCSI layouts
115115
in the kernel's NFS server. The pNFS SCSI layout enables NFS

fs/nfsd/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ obj-$(CONFIG_NFSD) += nfsd.o
1010
# this one should be compiled first, as the tracing macros can easily blow up
1111
nfsd-y += trace.o
1212

13-
nfsd-y += nfssvc.o nfsctl.o nfsproc.o nfsfh.o vfs.o \
14-
export.o auth.o lockd.o nfscache.o nfsxdr.o \
15-
stats.o filecache.o
13+
nfsd-y += nfssvc.o nfsctl.o nfsfh.o vfs.o \
14+
export.o auth.o lockd.o nfscache.o \
15+
stats.o filecache.o nfs3proc.o nfs3xdr.o
16+
nfsd-$(CONFIG_NFSD_V2) += nfsproc.o nfsxdr.o
1617
nfsd-$(CONFIG_NFSD_V2_ACL) += nfs2acl.o
17-
nfsd-$(CONFIG_NFSD_V3) += nfs3proc.o nfs3xdr.o
1818
nfsd-$(CONFIG_NFSD_V3_ACL) += nfs3acl.o
1919
nfsd-$(CONFIG_NFSD_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4idmap.o \
2020
nfs4acl.o nfs4callback.o nfs4recover.o

fs/nfsd/acl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,16 @@
3838
struct nfs4_acl;
3939
struct svc_fh;
4040
struct svc_rqst;
41+
struct nfsd_attrs;
42+
enum nfs_ftype4;
4143

4244
int nfs4_acl_bytes(int entries);
4345
int nfs4_acl_get_whotype(char *, u32);
4446
__be32 nfs4_acl_write_who(struct xdr_stream *xdr, int who);
4547

4648
int nfsd4_get_nfs4_acl(struct svc_rqst *rqstp, struct dentry *dentry,
4749
struct nfs4_acl **acl);
48-
__be32 nfsd4_set_nfs4_acl(struct svc_rqst *rqstp, struct svc_fh *fhp,
49-
struct nfs4_acl *acl);
50+
__be32 nfsd4_acl_to_attr(enum nfs_ftype4 type, struct nfs4_acl *acl,
51+
struct nfsd_attrs *attr);
5052

5153
#endif /* LINUX_NFS4_ACL_H */

fs/nfsd/blocklayout.c

Lines changed: 43 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@
44
*/
55
#include <linux/exportfs.h>
66
#include <linux/iomap.h>
7-
#include <linux/genhd.h>
87
#include <linux/slab.h>
98
#include <linux/pr.h>
109

1110
#include <linux/nfsd/debug.h>
12-
#include <scsi/scsi_proto.h>
13-
#include <scsi/scsi_common.h>
14-
#include <scsi/scsi_request.h>
1511

1612
#include "blocklayoutxdr.h"
1713
#include "pnfs.h"
1814
#include "filecache.h"
15+
#include "vfs.h"
1916

2017
#define NFSDDBG_FACILITY NFSDDBG_PNFS
2118

@@ -211,109 +208,6 @@ const struct nfsd4_layout_ops bl_layout_ops = {
211208
#endif /* CONFIG_NFSD_BLOCKLAYOUT */
212209

213210
#ifdef CONFIG_NFSD_SCSILAYOUT
214-
static int nfsd4_scsi_identify_device(struct block_device *bdev,
215-
struct pnfs_block_volume *b)
216-
{
217-
struct request_queue *q = bdev->bd_disk->queue;
218-
struct request *rq;
219-
struct scsi_request *req;
220-
/*
221-
* The allocation length (passed in bytes 3 and 4 of the INQUIRY
222-
* command descriptor block) specifies the number of bytes that have
223-
* been allocated for the data-in buffer.
224-
* 252 is the highest one-byte value that is a multiple of 4.
225-
* 65532 is the highest two-byte value that is a multiple of 4.
226-
*/
227-
size_t bufflen = 252, maxlen = 65532, len, id_len;
228-
u8 *buf, *d, type, assoc;
229-
int retries = 1, error;
230-
231-
if (WARN_ON_ONCE(!blk_queue_scsi_passthrough(q)))
232-
return -EINVAL;
233-
234-
again:
235-
buf = kzalloc(bufflen, GFP_KERNEL);
236-
if (!buf)
237-
return -ENOMEM;
238-
239-
rq = blk_get_request(q, REQ_OP_DRV_IN, 0);
240-
if (IS_ERR(rq)) {
241-
error = -ENOMEM;
242-
goto out_free_buf;
243-
}
244-
req = scsi_req(rq);
245-
246-
error = blk_rq_map_kern(q, rq, buf, bufflen, GFP_KERNEL);
247-
if (error)
248-
goto out_put_request;
249-
250-
req->cmd[0] = INQUIRY;
251-
req->cmd[1] = 1;
252-
req->cmd[2] = 0x83;
253-
req->cmd[3] = bufflen >> 8;
254-
req->cmd[4] = bufflen & 0xff;
255-
req->cmd_len = COMMAND_SIZE(INQUIRY);
256-
257-
blk_execute_rq(NULL, rq, 1);
258-
if (req->result) {
259-
pr_err("pNFS: INQUIRY 0x83 failed with: %x\n",
260-
req->result);
261-
error = -EIO;
262-
goto out_put_request;
263-
}
264-
265-
len = (buf[2] << 8) + buf[3] + 4;
266-
if (len > bufflen) {
267-
if (len <= maxlen && retries--) {
268-
blk_put_request(rq);
269-
kfree(buf);
270-
bufflen = len;
271-
goto again;
272-
}
273-
pr_err("pNFS: INQUIRY 0x83 response invalid (len = %zd)\n",
274-
len);
275-
goto out_put_request;
276-
}
277-
278-
d = buf + 4;
279-
for (d = buf + 4; d < buf + len; d += id_len + 4) {
280-
id_len = d[3];
281-
type = d[1] & 0xf;
282-
assoc = (d[1] >> 4) & 0x3;
283-
284-
/*
285-
* We only care about a EUI-64 and NAA designator types
286-
* with LU association.
287-
*/
288-
if (assoc != 0x00)
289-
continue;
290-
if (type != 0x02 && type != 0x03)
291-
continue;
292-
if (id_len != 8 && id_len != 12 && id_len != 16)
293-
continue;
294-
295-
b->scsi.code_set = PS_CODE_SET_BINARY;
296-
b->scsi.designator_type = type == 0x02 ?
297-
PS_DESIGNATOR_EUI64 : PS_DESIGNATOR_NAA;
298-
b->scsi.designator_len = id_len;
299-
memcpy(b->scsi.designator, d + 4, id_len);
300-
301-
/*
302-
* If we found a 8 or 12 byte descriptor continue on to
303-
* see if a 16 byte one is available. If we find a
304-
* 16 byte descriptor we're done.
305-
*/
306-
if (id_len == 16)
307-
break;
308-
}
309-
310-
out_put_request:
311-
blk_put_request(rq);
312-
out_free_buf:
313-
kfree(buf);
314-
return error;
315-
}
316-
317211
#define NFSD_MDS_PR_KEY 0x0100000000000000ULL
318212

319213
/*
@@ -325,6 +219,31 @@ static u64 nfsd4_scsi_pr_key(struct nfs4_client *clp)
325219
return ((u64)clp->cl_clientid.cl_boot << 32) | clp->cl_clientid.cl_id;
326220
}
327221

222+
static const u8 designator_types[] = {
223+
PS_DESIGNATOR_EUI64,
224+
PS_DESIGNATOR_NAA,
225+
};
226+
227+
static int
228+
nfsd4_block_get_unique_id(struct gendisk *disk, struct pnfs_block_volume *b)
229+
{
230+
int ret, i;
231+
232+
for (i = 0; i < ARRAY_SIZE(designator_types); i++) {
233+
u8 type = designator_types[i];
234+
235+
ret = disk->fops->get_unique_id(disk, b->scsi.designator, type);
236+
if (ret > 0) {
237+
b->scsi.code_set = PS_CODE_SET_BINARY;
238+
b->scsi.designator_type = type;
239+
b->scsi.designator_len = ret;
240+
return 0;
241+
}
242+
}
243+
244+
return -EINVAL;
245+
}
246+
328247
static int
329248
nfsd4_block_get_device_info_scsi(struct super_block *sb,
330249
struct nfs4_client *clp,
@@ -333,7 +252,7 @@ nfsd4_block_get_device_info_scsi(struct super_block *sb,
333252
struct pnfs_block_deviceaddr *dev;
334253
struct pnfs_block_volume *b;
335254
const struct pr_ops *ops;
336-
int error;
255+
int ret;
337256

338257
dev = kzalloc(sizeof(struct pnfs_block_deviceaddr) +
339258
sizeof(struct pnfs_block_volume), GFP_KERNEL);
@@ -347,33 +266,39 @@ nfsd4_block_get_device_info_scsi(struct super_block *sb,
347266
b->type = PNFS_BLOCK_VOLUME_SCSI;
348267
b->scsi.pr_key = nfsd4_scsi_pr_key(clp);
349268

350-
error = nfsd4_scsi_identify_device(sb->s_bdev, b);
351-
if (error)
352-
return error;
269+
ret = nfsd4_block_get_unique_id(sb->s_bdev->bd_disk, b);
270+
if (ret < 0)
271+
goto out_free_dev;
353272

273+
ret = -EINVAL;
354274
ops = sb->s_bdev->bd_disk->fops->pr_ops;
355275
if (!ops) {
356276
pr_err("pNFS: device %s does not support PRs.\n",
357277
sb->s_id);
358-
return -EINVAL;
278+
goto out_free_dev;
359279
}
360280

361-
error = ops->pr_register(sb->s_bdev, 0, NFSD_MDS_PR_KEY, true);
362-
if (error) {
281+
ret = ops->pr_register(sb->s_bdev, 0, NFSD_MDS_PR_KEY, true);
282+
if (ret) {
363283
pr_err("pNFS: failed to register key for device %s.\n",
364284
sb->s_id);
365-
return -EINVAL;
285+
goto out_free_dev;
366286
}
367287

368-
error = ops->pr_reserve(sb->s_bdev, NFSD_MDS_PR_KEY,
288+
ret = ops->pr_reserve(sb->s_bdev, NFSD_MDS_PR_KEY,
369289
PR_EXCLUSIVE_ACCESS_REG_ONLY, 0);
370-
if (error) {
290+
if (ret) {
371291
pr_err("pNFS: failed to reserve device %s.\n",
372292
sb->s_id);
373-
return -EINVAL;
293+
goto out_free_dev;
374294
}
375295

376296
return 0;
297+
298+
out_free_dev:
299+
kfree(dev);
300+
gdp->gd_device = NULL;
301+
return ret;
377302
}
378303

379304
static __be32

fs/nfsd/blocklayoutxdr.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "nfsd.h"
1111
#include "blocklayoutxdr.h"
12+
#include "vfs.h"
1213

1314
#define NFSDDBG_FACILITY NFSDDBG_PNFS
1415

fs/nfsd/cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,6 @@ int nfsd_reply_cache_init(struct nfsd_net *);
8484
void nfsd_reply_cache_shutdown(struct nfsd_net *);
8585
int nfsd_cache_lookup(struct svc_rqst *);
8686
void nfsd_cache_update(struct svc_rqst *, int, __be32 *);
87-
int nfsd_reply_cache_stats_open(struct inode *, struct file *);
87+
int nfsd_reply_cache_stats_show(struct seq_file *m, void *v);
8888

8989
#endif /* NFSCACHE_H */

0 commit comments

Comments
 (0)