Skip to content

Commit 6184514

Browse files
committed
Merge branch 'for-3.20' of git://linux-nfs.org/~bfields/linux
Pull nfsd updates from Bruce Fields: "The main change is the pNFS block server support from Christoph, which allows an NFS client connected to shared disk to do block IO to the shared disk in place of NFS reads and writes. This also requires xfs patches, which should arrive soon through the xfs tree, barring unexpected problems. Support for other filesystems is also possible if there's interest. Thanks also to Chuck Lever for continuing work to get NFS/RDMA into shape" * 'for-3.20' of git://linux-nfs.org/~bfields/linux: (32 commits) nfsd: default NFSv4.2 to on nfsd: pNFS block layout driver exportfs: add methods for block layout exports nfsd: add trace events nfsd: update documentation for pNFS support nfsd: implement pNFS layout recalls nfsd: implement pNFS operations nfsd: make find_any_file available outside nfs4state.c nfsd: make find/get/put file available outside nfs4state.c nfsd: make lookup/alloc/unhash_stid available outside nfs4state.c nfsd: add fh_fsid_match helper nfsd: move nfsd_fh_match to nfsfh.h fs: add FL_LAYOUT lease type fs: track fl_owner for leases nfs: add LAYOUT_TYPE_MAX enum value nfsd: factor out a helper to decode nfstime4 values sunrpc/lockd: fix references to the BKL nfsd: fix year-2038 nfs4 state problem svcrdma: Handle additional inline content svcrdma: Move read list XDR round-up logic ...
2 parents a26be14 + c23ae60 commit 6184514

40 files changed

+2562
-254
lines changed

Documentation/filesystems/nfs/nfs41-server.txt

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ focuses on the mandatory-to-implement NFSv4.1 Sessions, providing
2424
"exactly once" semantics and better control and throttling of the
2525
resources allocated for each client.
2626

27-
Other NFSv4.1 features, Parallel NFS operations in particular,
28-
are still under development out of tree.
29-
See http://wiki.linux-nfs.org/wiki/index.php/PNFS_prototype_design
30-
for more information.
31-
3227
The table below, taken from the NFSv4.1 document, lists
3328
the operations that are mandatory to implement (REQ), optional
3429
(OPT), and NFSv4.0 operations that are required not to implement (MNI)
@@ -43,9 +38,7 @@ The OPTIONAL features identified and their abbreviations are as follows:
4338
The following abbreviations indicate the linux server implementation status.
4439
I Implemented NFSv4.1 operations.
4540
NS Not Supported.
46-
NS* unimplemented optional feature.
47-
P pNFS features implemented out of tree.
48-
PNS pNFS features that are not supported yet (out of tree).
41+
NS* Unimplemented optional feature.
4942

5043
Operations
5144

@@ -70,13 +63,13 @@ I | DESTROY_SESSION | REQ | | Section 18.37 |
7063
I | EXCHANGE_ID | REQ | | Section 18.35 |
7164
I | FREE_STATEID | REQ | | Section 18.38 |
7265
| GETATTR | REQ | | Section 18.7 |
73-
P | GETDEVICEINFO | OPT | pNFS (REQ) | Section 18.40 |
74-
P | GETDEVICELIST | OPT | pNFS (OPT) | Section 18.41 |
66+
I | GETDEVICEINFO | OPT | pNFS (REQ) | Section 18.40 |
67+
NS*| GETDEVICELIST | OPT | pNFS (OPT) | Section 18.41 |
7568
| GETFH | REQ | | Section 18.8 |
7669
NS*| GET_DIR_DELEGATION | OPT | DDELG (REQ) | Section 18.39 |
77-
P | LAYOUTCOMMIT | OPT | pNFS (REQ) | Section 18.42 |
78-
P | LAYOUTGET | OPT | pNFS (REQ) | Section 18.43 |
79-
P | LAYOUTRETURN | OPT | pNFS (REQ) | Section 18.44 |
70+
I | LAYOUTCOMMIT | OPT | pNFS (REQ) | Section 18.42 |
71+
I | LAYOUTGET | OPT | pNFS (REQ) | Section 18.43 |
72+
I | LAYOUTRETURN | OPT | pNFS (REQ) | Section 18.44 |
8073
| LINK | OPT | | Section 18.9 |
8174
| LOCK | REQ | | Section 18.10 |
8275
| LOCKT | REQ | | Section 18.11 |
@@ -122,9 +115,9 @@ Callback Operations
122115
| | MNI | or OPT) | |
123116
+-------------------------+-----------+-------------+---------------+
124117
| CB_GETATTR | OPT | FDELG (REQ) | Section 20.1 |
125-
P | CB_LAYOUTRECALL | OPT | pNFS (REQ) | Section 20.3 |
118+
I | CB_LAYOUTRECALL | OPT | pNFS (REQ) | Section 20.3 |
126119
NS*| CB_NOTIFY | OPT | DDELG (REQ) | Section 20.4 |
127-
P | CB_NOTIFY_DEVICEID | OPT | pNFS (OPT) | Section 20.12 |
120+
NS*| CB_NOTIFY_DEVICEID | OPT | pNFS (OPT) | Section 20.12 |
128121
NS*| CB_NOTIFY_LOCK | OPT | | Section 20.11 |
129122
NS*| CB_PUSH_DELEG | OPT | FDELG (OPT) | Section 20.5 |
130123
| CB_RECALL | OPT | FDELG, | Section 20.2 |
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
pNFS block layout server user guide
2+
3+
The Linux NFS server now supports the pNFS block layout extension. In this
4+
case the NFS server acts as Metadata Server (MDS) for pNFS, which in addition
5+
to handling all the metadata access to the NFS export also hands out layouts
6+
to the clients to directly access the underlying block devices that are
7+
shared with the client.
8+
9+
To use pNFS block layouts with with the Linux NFS server the exported file
10+
system needs to support the pNFS block layouts (currently just XFS), and the
11+
file system must sit on shared storage (typically iSCSI) that is accessible
12+
to the clients in addition to the MDS. As of now the file system needs to
13+
sit directly on the exported volume, striping or concatenation of
14+
volumes on the MDS and clients is not supported yet.
15+
16+
On the server, pNFS block volume support is automatically if the file system
17+
support it. On the client make sure the kernel has the CONFIG_PNFS_BLOCK
18+
option enabled, the blkmapd daemon from nfs-utils is running, and the
19+
file system is mounted using the NFSv4.1 protocol version (mount -o vers=4.1).
20+
21+
If the nfsd server needs to fence a non-responding client it calls
22+
/sbin/nfsd-recall-failed with the first argument set to the IP address of
23+
the client, and the second argument set to the device node without the /dev
24+
prefix for the file system to be fenced. Below is an example file that shows
25+
how to translate the device into a serial number from SCSI EVPD 0x80:
26+
27+
cat > /sbin/nfsd-recall-failed << EOF
28+
#!/bin/sh
29+
30+
CLIENT="$1"
31+
DEV="/dev/$2"
32+
EVPD=`sg_inq --page=0x80 ${DEV} | \
33+
grep "Unit serial number:" | \
34+
awk -F ': ' '{print $2}'`
35+
36+
echo "fencing client ${CLIENT} serial ${EVPD}" >> /var/log/pnfsd-fence.log
37+
EOF

fs/lockd/svclock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ static DEFINE_SPINLOCK(nlm_blocked_lock);
5757
static const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie)
5858
{
5959
/*
60-
* We can get away with a static buffer because we're only
61-
* called with BKL held.
60+
* We can get away with a static buffer because this is only called
61+
* from lockd, which is single-threaded.
6262
*/
6363
static char buf[2*NLM_MAXCOOKIELEN+1];
6464
unsigned int i, len = sizeof(buf);

fs/lockd/xdr.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,6 @@ nlm_decode_fh(__be32 *p, struct nfs_fh *f)
9595
return p + XDR_QUADLEN(NFS2_FHSIZE);
9696
}
9797

98-
static inline __be32 *
99-
nlm_encode_fh(__be32 *p, struct nfs_fh *f)
100-
{
101-
*p++ = htonl(NFS2_FHSIZE);
102-
memcpy(p, f->data, NFS2_FHSIZE);
103-
return p + XDR_QUADLEN(NFS2_FHSIZE);
104-
}
105-
10698
/*
10799
* Encode and decode owner handle
108100
*/

fs/locks.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137

138138
#define IS_POSIX(fl) (fl->fl_flags & FL_POSIX)
139139
#define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK)
140-
#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG))
140+
#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG|FL_LAYOUT))
141141
#define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK)
142142

143143
static bool lease_breaking(struct file_lock *fl)
@@ -1371,6 +1371,8 @@ static void time_out_leases(struct inode *inode, struct list_head *dispose)
13711371

13721372
static bool leases_conflict(struct file_lock *lease, struct file_lock *breaker)
13731373
{
1374+
if ((breaker->fl_flags & FL_LAYOUT) != (lease->fl_flags & FL_LAYOUT))
1375+
return false;
13741376
if ((breaker->fl_flags & FL_DELEG) && (lease->fl_flags & FL_LEASE))
13751377
return false;
13761378
return locks_conflict(breaker, lease);
@@ -1594,11 +1596,14 @@ int fcntl_getlease(struct file *filp)
15941596
* conflict with the lease we're trying to set.
15951597
*/
15961598
static int
1597-
check_conflicting_open(const struct dentry *dentry, const long arg)
1599+
check_conflicting_open(const struct dentry *dentry, const long arg, int flags)
15981600
{
15991601
int ret = 0;
16001602
struct inode *inode = dentry->d_inode;
16011603

1604+
if (flags & FL_LAYOUT)
1605+
return 0;
1606+
16021607
if ((arg == F_RDLCK) && (atomic_read(&inode->i_writecount) > 0))
16031608
return -EAGAIN;
16041609

@@ -1647,7 +1652,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
16471652

16481653
spin_lock(&ctx->flc_lock);
16491654
time_out_leases(inode, &dispose);
1650-
error = check_conflicting_open(dentry, arg);
1655+
error = check_conflicting_open(dentry, arg, lease->fl_flags);
16511656
if (error)
16521657
goto out;
16531658

@@ -1661,7 +1666,8 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
16611666
*/
16621667
error = -EAGAIN;
16631668
list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
1664-
if (fl->fl_file == filp) {
1669+
if (fl->fl_file == filp &&
1670+
fl->fl_owner == lease->fl_owner) {
16651671
my_fl = fl;
16661672
continue;
16671673
}
@@ -1702,7 +1708,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
17021708
* precedes these checks.
17031709
*/
17041710
smp_mb();
1705-
error = check_conflicting_open(dentry, arg);
1711+
error = check_conflicting_open(dentry, arg, lease->fl_flags);
17061712
if (error) {
17071713
locks_unlink_lock_ctx(lease, &ctx->flc_lease_cnt);
17081714
goto out;
@@ -1721,7 +1727,7 @@ generic_add_lease(struct file *filp, long arg, struct file_lock **flp, void **pr
17211727
return error;
17221728
}
17231729

1724-
static int generic_delete_lease(struct file *filp)
1730+
static int generic_delete_lease(struct file *filp, void *owner)
17251731
{
17261732
int error = -EAGAIN;
17271733
struct file_lock *fl, *victim = NULL;
@@ -1737,7 +1743,8 @@ static int generic_delete_lease(struct file *filp)
17371743

17381744
spin_lock(&ctx->flc_lock);
17391745
list_for_each_entry(fl, &ctx->flc_lease, fl_list) {
1740-
if (fl->fl_file == filp) {
1746+
if (fl->fl_file == filp &&
1747+
fl->fl_owner == owner) {
17411748
victim = fl;
17421749
break;
17431750
}
@@ -1778,13 +1785,14 @@ int generic_setlease(struct file *filp, long arg, struct file_lock **flp,
17781785

17791786
switch (arg) {
17801787
case F_UNLCK:
1781-
return generic_delete_lease(filp);
1788+
return generic_delete_lease(filp, *priv);
17821789
case F_RDLCK:
17831790
case F_WRLCK:
17841791
if (!(*flp)->fl_lmops->lm_break) {
17851792
WARN_ON_ONCE(1);
17861793
return -ENOLCK;
17871794
}
1795+
17881796
return generic_add_lease(filp, arg, flp, priv);
17891797
default:
17901798
return -EINVAL;
@@ -1857,7 +1865,7 @@ static int do_fcntl_add_lease(unsigned int fd, struct file *filp, long arg)
18571865
int fcntl_setlease(unsigned int fd, struct file *filp, long arg)
18581866
{
18591867
if (arg == F_UNLCK)
1860-
return vfs_setlease(filp, F_UNLCK, NULL, NULL);
1868+
return vfs_setlease(filp, F_UNLCK, NULL, (void **)&filp);
18611869
return do_fcntl_add_lease(fd, filp, arg);
18621870
}
18631871

fs/nfsd/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,16 @@ config NFSD_V4
8282

8383
If unsure, say N.
8484

85+
config NFSD_PNFS
86+
bool "NFSv4.1 server support for Parallel NFS (pNFS)"
87+
depends on NFSD_V4
88+
help
89+
This option enables support for the parallel NFS features of the
90+
minor version 1 of the NFSv4 protocol (RFC5661) in the kernel's NFS
91+
server.
92+
93+
If unsure, say N.
94+
8595
config NFSD_V4_SECURITY_LABEL
8696
bool "Provide Security Label support for NFSv4 server"
8797
depends on NFSD_V4 && SECURITY

fs/nfsd/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,19 @@
22
# Makefile for the Linux nfs server
33
#
44

5+
ccflags-y += -I$(src) # needed for trace events
6+
57
obj-$(CONFIG_NFSD) += nfsd.o
68

7-
nfsd-y := nfssvc.o nfsctl.o nfsproc.o nfsfh.o vfs.o \
9+
# this one should be compiled first, as the tracing macros can easily blow up
10+
nfsd-y += trace.o
11+
12+
nfsd-y += nfssvc.o nfsctl.o nfsproc.o nfsfh.o vfs.o \
813
export.o auth.o lockd.o nfscache.o nfsxdr.o stats.o
914
nfsd-$(CONFIG_NFSD_FAULT_INJECTION) += fault_inject.o
1015
nfsd-$(CONFIG_NFSD_V2_ACL) += nfs2acl.o
1116
nfsd-$(CONFIG_NFSD_V3) += nfs3proc.o nfs3xdr.o
1217
nfsd-$(CONFIG_NFSD_V3_ACL) += nfs3acl.o
1318
nfsd-$(CONFIG_NFSD_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4idmap.o \
1419
nfs4acl.o nfs4callback.o nfs4recover.o
20+
nfsd-$(CONFIG_NFSD_PNFS) += nfs4layouts.o blocklayout.o blocklayoutxdr.o

0 commit comments

Comments
 (0)